Best Python code snippet using ATX
asprestrdialog.py
Source:asprestrdialog.py
1#!/usr/bin/env python2# -*- coding: utf-8 -*-3"""4New/edit aspects restrictions.5"""6import sys7import os.path8from PyQt4.QtCore import *9from PyQt4.QtGui import *10from oroboros.core import cfg11from oroboros.core import db12from oroboros.core.aspectsrestrictions import AspectsRestrictions13from oroboros.gui import app14from oroboros.gui import names15__all__ = ['AspectsRestrictionsDialog']16_baseDir = os.path.dirname(os.path.abspath(__file__))17class AspectsRestrictionsDialog(QDialog):18 19 def __init__(self, parent=None, filt=None):20 QDialog.__init__(self, parent)21 self._parent = parent22 tr = self.tr23 if isinstance(filt, AspectsRestrictions):24 self._filt = filt25 title = unicode(tr('Edit Aspects Restrictions \xab %(filter)s \xbb')) % {26 'filter': filt._name}27 else:28 self._filt = AspectsRestrictions(cfg.dft_filter._asprestr._idx_)29 self._filt._idx_ = None # copy dft filter and set idx to None30 title = tr('New Aspects Restrictions')31 self.setWindowTitle(title)32 # size33 self.setMinimumWidth(350)34 self.setMinimumHeight(350)35 self.setSizeGripEnabled(True)36 # layout37 grid = QGridLayout(self)38 self.setLayout(grid)39 # filter name40 grid.addWidget(QLabel(tr('Filter name')), 0, 0)41 self.nameEdit = QLineEdit(self)42 grid.addWidget(self.nameEdit, 0, 1)43 # tab widget44 tabs = QTabWidget(self)45 grid.addWidget(tabs, 1, 0, 1, 2)46 self._cb = dict() ## holds the checkboxes47 48 # ### main planets ###49 mainWidget = QWidget()50 tabs.addTab(mainWidget, tr('Main', 'Main planets'))51 mainGrid = QGridLayout()52 mainWidget.setLayout(mainGrid)53 # sun54 self._cb['Sun'] = QCheckBox(names.planets['Sun'], self)55 mainGrid.addWidget(self._cb['Sun'], 0, 0)56 # moon57 self._cb['Moon'] = QCheckBox(names.planets['Moon'], self)58 mainGrid.addWidget(self._cb['Moon'], 0, 1)59 # mercury60 self._cb['Mercury'] = QCheckBox(names.planets['Mercury'], self)61 mainGrid.addWidget(self._cb['Mercury'], 0, 2)62 # venus63 self._cb['Venus'] = QCheckBox(names.planets['Venus'], self)64 mainGrid.addWidget(self._cb['Venus'], 0, 3)65 # mars66 self._cb['Mars'] = QCheckBox(names.planets['Mars'], self)67 mainGrid.addWidget(self._cb['Mars'], 0, 4)68 # jupiter69 self._cb['Jupiter'] = QCheckBox(names.planets['Jupiter'], self)70 mainGrid.addWidget(self._cb['Jupiter'], 1, 0)71 # saturn72 self._cb['Saturn'] = QCheckBox(names.planets['Saturn'], self)73 mainGrid.addWidget(self._cb['Saturn'], 1, 1)74 # uranus75 self._cb['Uranus'] = QCheckBox(names.planets['Uranus'], self)76 mainGrid.addWidget(self._cb['Uranus'], 1, 2)77 # neptune78 self._cb['Neptune'] = QCheckBox(names.planets['Neptune'], self)79 mainGrid.addWidget(self._cb['Neptune'], 1, 3)80 # pluto81 self._cb['Pluto'] = QCheckBox(names.planets['Pluto'], self)82 mainGrid.addWidget(self._cb['Pluto'], 1, 4)83 # earth84 self._cb['Earth'] = QCheckBox(names.planets['Earth'], self)85 mainGrid.addWidget(self._cb['Earth'], 2, 0)86 # chiron87 self._cb['Chiron'] = QCheckBox(names.planets['Chiron'], self)88 mainGrid.addWidget(self._cb['Chiron'], 2, 1)89 # pholus90 self._cb['Pholus'] = QCheckBox(names.planets['Pholus'], self)91 mainGrid.addWidget(self._cb['Pholus'], 2, 2)92 # ceres93 self._cb['Ceres'] = QCheckBox(names.planets['Ceres'], self)94 mainGrid.addWidget(self._cb['Ceres'], 2, 3)95 # pallas96 self._cb['Pallas'] = QCheckBox(names.planets['Pallas'], self)97 mainGrid.addWidget(self._cb['Pallas'], 2, 4)98 # juno99 self._cb['Juno'] = QCheckBox(names.planets['Juno'], self)100 mainGrid.addWidget(self._cb['Juno'], 3, 0)101 # vesta102 self._cb['Vesta'] = QCheckBox(names.planets['Vesta'], self)103 mainGrid.addWidget(self._cb['Vesta'], 3, 1)104 # rahu (mean)105 self._cb['Rahu (mean)'] = QCheckBox(names.planets['Rahu (mean)'], self)106 mainGrid.addWidget(self._cb['Rahu (mean)'], 3, 2)107 # rahu (true)108 self._cb['Rahu (true)'] = QCheckBox(names.planets['Rahu (true)'], self)109 mainGrid.addWidget(self._cb['Rahu (true)'], 3, 3)110 # ketu (mean)111 self._cb['Ketu (mean)'] = QCheckBox(names.planets['Ketu (mean)'], self)112 mainGrid.addWidget(self._cb['Ketu (mean)'], 3, 4)113 # ketu (true)114 self._cb['Ketu (true)'] = QCheckBox(names.planets['Ketu (true)'], self)115 mainGrid.addWidget(self._cb['Ketu (true)'], 4, 0)116 # lilith (mean)117 self._cb['Lilith (mean)'] = QCheckBox(names.planets['Lilith (mean)'], self)118 mainGrid.addWidget(self._cb['Lilith (mean)'], 4, 1)119 # lilith (true)120 self._cb['Lilith (true)'] = QCheckBox(names.planets['Lilith (true)'], self)121 mainGrid.addWidget(self._cb['Lilith (true)'], 4, 2)122 # priapus (mean)123 self._cb['Priapus (mean)'] = QCheckBox(names.planets['Priapus (mean)'], self)124 mainGrid.addWidget(self._cb['Priapus (mean)'], 4, 3)125 # priapus (true)126 self._cb['Priapus (true)'] = QCheckBox(names.planets['Priapus (true)'], self)127 mainGrid.addWidget(self._cb['Priapus (true)'], 4, 4)128 129 # ### uranians ###130 uranianWidget = QWidget()131 tabs.addTab(uranianWidget, tr('Uranians'))132 uranianGrid = QGridLayout()133 uranianWidget.setLayout(uranianGrid)134 # cupido135 self._cb['Cupido'] = QCheckBox(names.planets['Cupido'], self)136 uranianGrid.addWidget(self._cb['Cupido'], 0, 0)137 # hades138 self._cb['Hades'] = QCheckBox(names.planets['Hades'], self)139 uranianGrid.addWidget(self._cb['Hades'], 0, 1)140 # zeus141 self._cb['Zeus'] = QCheckBox(names.planets['Zeus'], self)142 uranianGrid.addWidget(self._cb['Zeus'], 0, 2)143 # kronos144 self._cb['Kronos'] = QCheckBox(names.planets['Kronos'], self)145 uranianGrid.addWidget(self._cb['Kronos'], 0, 3)146 # apollo147 self._cb['Apollon'] = QCheckBox(names.planets['Apollon'], self)148 uranianGrid.addWidget(self._cb['Apollon'], 1, 0)149 # admetos150 self._cb['Admetos'] = QCheckBox(names.planets['Admetos'], self)151 uranianGrid.addWidget(self._cb['Admetos'], 1, 1)152 # vulkanus153 self._cb['Vulkanus'] = QCheckBox(names.planets['Vulkanus'], self)154 uranianGrid.addWidget(self._cb['Vulkanus'], 1, 2)155 # poseidon156 self._cb['Poseidon'] = QCheckBox(names.planets['Poseidon'], self)157 uranianGrid.addWidget(self._cb['Poseidon'], 1, 3)158 159 # ### others fictitious ###160 othersWidget = QWidget()161 tabs.addTab(othersWidget, tr('Others'))162 othersGrid = QGridLayout()163 othersWidget.setLayout(othersGrid)164 # isis165 self._cb['Isis'] = QCheckBox(names.planets['Isis'], self)166 othersGrid.addWidget(self._cb['Isis'], 0, 0)167 # nibiru168 self._cb['Nibiru'] = QCheckBox(names.planets['Nibiru'], self)169 othersGrid.addWidget(self._cb['Nibiru'], 0, 1)170 # harrington171 self._cb['Harrington'] = QCheckBox(names.planets['Harrington'], self)172 othersGrid.addWidget(self._cb['Harrington'], 0, 2)173 # neptune (leverrier)174 self._cb['Neptune (Leverrier)'] = QCheckBox(names.planets['Neptune (Leverrier)'], self)175 othersGrid.addWidget(self._cb['Neptune (Leverrier)'], 0, 3)176 # neptune (adams)177 self._cb['Neptune (Adams)'] = QCheckBox(names.planets['Neptune (Adams)'], self)178 othersGrid.addWidget(self._cb['Neptune (Adams)'], 1, 0)179 # pluto (lowell)180 self._cb['Pluto (Lowell)'] = QCheckBox(names.planets['Pluto (Lowell)'], self)181 othersGrid.addWidget(self._cb['Pluto (Lowell)'], 1, 1)182 # pluto (pickering)183 self._cb['Pluto (Pickering)'] = QCheckBox(names.planets['Pluto (Pickering)'], self)184 othersGrid.addWidget(self._cb['Pluto (Pickering)'], 1, 2)185 # vulcan186 self._cb['Vulcan'] = QCheckBox(names.planets['Vulcan'], self)187 othersGrid.addWidget(self._cb['Vulcan'], 1, 3)188 # white moon189 self._cb['White Moon'] = QCheckBox(names.planets['White Moon'], self)190 othersGrid.addWidget(self._cb['White Moon'], 2, 0)191 # proserpina192 self._cb['Proserpina'] = QCheckBox(names.planets['Proserpina'], self)193 othersGrid.addWidget(self._cb['Proserpina'], 2, 1)194 # waldemath195 self._cb['Waldemath'] = QCheckBox(names.planets['Waldemath'], self)196 othersGrid.addWidget(self._cb['Waldemath'], 2, 2)197 # ### cusps ###198 cuspsWidget = QWidget()199 tabs.addTab(cuspsWidget, tr('Cusps'))200 cuspsGrid = QGridLayout()201 cuspsWidget.setLayout(cuspsGrid)202 # house cusps203 x = (0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2)204 y = (0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3)205 for i in range(12):206 self._cb['Cusp %.2d' % (i+1,)] = QCheckBox(207 names.houses['Cusp %.2d' % (i+1,)], self)208 cuspsGrid.addWidget(self._cb['Cusp %.2d' % (i+1,)], x[i], y[i])209 # asc210 self._cb['Asc'] = QCheckBox(names.planets['Asc'], self)211 cuspsGrid.addWidget(self._cb['Asc'], 3, 0)212 # mc213 self._cb['Mc'] = QCheckBox(names.planets['Mc'], self)214 cuspsGrid.addWidget(self._cb['Mc'], 3, 1)215 # dsc216 self._cb['Dsc'] = QCheckBox(names.planets['Dsc'], self)217 cuspsGrid.addWidget(self._cb['Dsc'], 3, 2)218 # ic219 self._cb['Ic'] = QCheckBox(names.planets['Ic'], self)220 cuspsGrid.addWidget(self._cb['Ic'], 3, 3)221 # armc222 self._cb['Armc'] = QCheckBox(names.planets['Armc'], self)223 cuspsGrid.addWidget(self._cb['Armc'], 4, 0)224 # vertex225 self._cb['Vertex'] = QCheckBox(names.planets['Vertex'], self)226 cuspsGrid.addWidget(self._cb['Vertex'], 4, 1)227 # equatorial asc228 self._cb['Equatorial Ascendant'] = QCheckBox(names.planets['Equatorial Ascendant'], self)229 cuspsGrid.addWidget(self._cb['Equatorial Ascendant'], 4, 2)230 # co-ascendant (koch)231 self._cb['Co-ascendant (Koch)'] = QCheckBox(names.planets['Co-ascendant (Koch)'], self)232 cuspsGrid.addWidget(self._cb['Co-ascendant (Koch)'], 4, 3)233 # co-ascendant (munkasey)234 self._cb['Co-ascendant (Munkasey)'] = QCheckBox(names.planets['Co-ascendant (Munkasey)'], self)235 cuspsGrid.addWidget(self._cb['Co-ascendant (Munkasey)'], 5, 0)236 # polar ascendant237 self._cb['Polar Ascendant (Munkasey)'] = QCheckBox(names.planets['Polar Ascendant (Munkasey)'], self)238 cuspsGrid.addWidget(self._cb['Polar Ascendant (Munkasey)'], 5, 1)239 240 # ### gauquelin ###241 gauquelinWidget = QWidget()242 tabs.addTab(gauquelinWidget, tr('Gauquelin'))243 gauquelinGrid = QGridLayout()244 gauquelinWidget.setLayout(gauquelinGrid)245 # sectors246 x = (0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4,5,5,5,5,5,5)247 y = (0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3,4,5)248 for i in range(36):249 self._cb['Sector %.2d' % (i+1,)] = QCheckBox(250 names.houses['Sector %.2d' % (i+1,)], self)251 gauquelinGrid.addWidget(self._cb['Sector %.2d' % (i+1,)], x[i], y[i])252 253 # ### parts ###254 partsWidget = QWidget()255 tabs.addTab(partsWidget, tr('Parts'))256 partsGrid = QGridLayout()257 partsWidget.setLayout(partsGrid)258 # part of fortune (rudhyar)259 self._cb['Part of Fortune (Rudhyar)'] = QCheckBox(names.planets['Part of Fortune (Rudhyar)'], self)260 partsGrid.addWidget(self._cb['Part of Fortune (Rudhyar)'], 0, 0)261 262 # ### fixed stars ###263 # get all stars264 sql = 'select name from Planets where family = 2 order by name;'265 res = db.execute(sql).fetchall()266 # stars tab267 starsScroll = QScrollArea(self)268 starsScroll.setWidgetResizable(True)269 starsWidget = QWidget()270 starsScroll.setWidget(starsWidget)271 tabs.addTab(starsScroll, tr('Stars'))272 starsGrid = QGridLayout()273 starsWidget.setLayout(starsGrid)274 y = 0275 for i, star in enumerate(res):276 s = str(star[0])277 self._cb[s] = QCheckBox(s, self)278 starsGrid.addWidget(self._cb[s], y, i % 6)279 if i % 6 == 5:280 y += 1281 282 # ### asteroids ###283 # get all asteroids284 sql = 'select name from Planets where family = 3 order by name;'285 res = db.execute(sql).fetchall()286 # asteroids tab287 asteroidsScroll = QScrollArea()288 asteroidsScroll.setWidgetResizable(True)289 asteroidsWidget = QWidget()290 asteroidsScroll.setWidget(asteroidsWidget)291 tabs.addTab(asteroidsScroll, tr('Asteroids'))292 asteroidsGrid = QGridLayout()293 asteroidsWidget.setLayout(asteroidsGrid)294 y = 0295 for i, ast in enumerate(res):296 s = str(ast[0])297 self._cb[s] = QCheckBox(s, self)298 asteroidsGrid.addWidget(self._cb[s], y, i % 6)299 if i % 6 == 5:300 y += 1301 302 # ### end planets ###303 304 # comment305 grid.addWidget(QLabel(tr('Comment')), 2, 0, Qt.AlignTop)306 self.commentEdit = QTextEdit('', self)307 grid.addWidget(self.commentEdit, 2, 1)308 # buttons309 buttonsLayout = QHBoxLayout()310 resetButton = QPushButton(tr('Reset'), self)311 self.connect(resetButton, SIGNAL('clicked()'), self.reset)312 buttonsLayout.addWidget(resetButton)313 cancelButton = QPushButton(tr('Cancel'), self)314 self.connect(cancelButton, SIGNAL('clicked()'), self.reject)315 buttonsLayout.addWidget(cancelButton)316 okButton = QPushButton(tr('Ok'), self)317 okButton.setDefault(True)318 self.connect(okButton, SIGNAL('clicked()'), self.accept)319 buttonsLayout.addWidget(okButton)320 grid.addLayout(buttonsLayout, 3, 0, 1, 2)321 # load entries322 self.reset()323 # resize324 self.resize(550, 300)325 326 def reset(self):327 """Reset entries."""328 # name329 self.nameEdit.setText(self._filt._name)330 # comment331 self.commentEdit.setPlainText(self._filt._comment)332 # values333 for pl, val in self._filt.items():334 self._cb[pl].setChecked(val)335 336 def accept(self):337 """Set filter new values and save."""338 tr = self.tr339 # name340 name = unicode(self.nameEdit.text())341 if name == '':342 QMessageBox.critical(self, tr('Missing Name'),343 tr('Please set filter name.'))344 self.nameEdit.setFocus()345 return346 # comment347 cmt = unicode(self.commentEdit.toPlainText())348 # set values349 self._filt.set(name=name, comment=cmt)350 for pl, cb in self._cb.items():351 self._filt[pl] = cb.isChecked()352 # save353 try:354 self._filt.save()355 except ValueError: # duplicate filter356 QMessageBox.critical(self, tr('Error'),357 unicode(tr('Duplicate filter name \xab %(filter)s \xbb.')) % {358 'filter': self._filt._name})359 self.nameEdit.setFocus()360 return361 # reload cfg in case filter is default,362 # and opened charts if using this filter363 if __name__ != '__main__':364 app.aspectsRestrictionsUpdatedEvent(self._filt._idx_)365 # done366 self.done(QDialog.Accepted)367def main():368 app = QApplication(sys.argv)369 main = AspectsRestrictionsDialog()370 main.show()371 sys.exit(app.exec_())372if __name__ == '__main__':373 main()...
plntfilterdialog.py
Source:plntfilterdialog.py
1#!/usr/bin/env python2# -*- coding: utf-8 -*-3"""4New/edit planets filters.5"""6import sys7import os.path8from PyQt4.QtCore import *9from PyQt4.QtGui import *10from oroboros.core import cfg11from oroboros.core import db12from oroboros.core.planetsfilters import PlanetsFilter13from oroboros.gui import app14from oroboros.gui import names15__all__ = ['PlanetsFilterDialog']16_baseDir = os.path.dirname(os.path.abspath(__file__))17class PlanetsFilterDialog(QDialog):18 19 def __init__(self, parent=None, filt=None):20 QDialog.__init__(self, parent)21 self._parent = parent22 tr = self.tr23 if isinstance(filt, PlanetsFilter):24 self._filt = filt25 title = unicode(tr('Edit Planets Filter \xab %(filter)s \xbb')) % {26 'filter': filt._name}27 else:28 self._filt = PlanetsFilter(cfg.dft_filter._planets._idx_)29 self._filt._idx_ = None # copy dft filter and set idx to None30 title = tr('New Planets Filter')31 self.setWindowTitle(title)32 # size33 self.setMinimumWidth(350)34 self.setMinimumHeight(350)35 self.setSizeGripEnabled(True)36 # layout37 grid = QGridLayout(self)38 self.setLayout(grid)39 # filter name40 grid.addWidget(QLabel(tr('Filter name')), 0, 0)41 self.nameEdit = QLineEdit(self)42 grid.addWidget(self.nameEdit, 0, 1)43 # tab widget44 tabs = QTabWidget(self)45 grid.addWidget(tabs, 1, 0, 1, 2)46 self._cb = dict() ## holds the checkboxes47 48 # ### main planets ###49 mainWidget = QWidget()50 tabs.addTab(mainWidget, tr('Main', 'Main planets'))51 mainGrid = QGridLayout()52 mainWidget.setLayout(mainGrid)53 # sun54 self._cb['Sun'] = QCheckBox(names.planets['Sun'], self)55 mainGrid.addWidget(self._cb['Sun'], 0, 0)56 # moon57 self._cb['Moon'] = QCheckBox(names.planets['Moon'], self)58 mainGrid.addWidget(self._cb['Moon'], 0, 1)59 # mercury60 self._cb['Mercury'] = QCheckBox(names.planets['Mercury'], self)61 mainGrid.addWidget(self._cb['Mercury'], 0, 2)62 # venus63 self._cb['Venus'] = QCheckBox(names.planets['Venus'], self)64 mainGrid.addWidget(self._cb['Venus'], 0, 3)65 # mars66 self._cb['Mars'] = QCheckBox(names.planets['Mars'], self)67 mainGrid.addWidget(self._cb['Mars'], 0, 4)68 # jupiter69 self._cb['Jupiter'] = QCheckBox(names.planets['Jupiter'], self)70 mainGrid.addWidget(self._cb['Jupiter'], 1, 0)71 # saturn72 self._cb['Saturn'] = QCheckBox(names.planets['Saturn'], self)73 mainGrid.addWidget(self._cb['Saturn'], 1, 1)74 # uranus75 self._cb['Uranus'] = QCheckBox(names.planets['Uranus'], self)76 mainGrid.addWidget(self._cb['Uranus'], 1, 2)77 # neptune78 self._cb['Neptune'] = QCheckBox(names.planets['Neptune'], self)79 mainGrid.addWidget(self._cb['Neptune'], 1, 3)80 # pluto81 self._cb['Pluto'] = QCheckBox(names.planets['Pluto'], self)82 mainGrid.addWidget(self._cb['Pluto'], 1, 4)83 # earth84 self._cb['Earth'] = QCheckBox(names.planets['Earth'], self)85 mainGrid.addWidget(self._cb['Earth'], 2, 0)86 # chiron87 self._cb['Chiron'] = QCheckBox(names.planets['Chiron'], self)88 mainGrid.addWidget(self._cb['Chiron'], 2, 1)89 # pholus90 self._cb['Pholus'] = QCheckBox(names.planets['Pholus'], self)91 mainGrid.addWidget(self._cb['Pholus'], 2, 2)92 # ceres93 self._cb['Ceres'] = QCheckBox(names.planets['Ceres'], self)94 mainGrid.addWidget(self._cb['Ceres'], 2, 3)95 # pallas96 self._cb['Pallas'] = QCheckBox(names.planets['Pallas'], self)97 mainGrid.addWidget(self._cb['Pallas'], 2, 4)98 # juno99 self._cb['Juno'] = QCheckBox(names.planets['Juno'], self)100 mainGrid.addWidget(self._cb['Juno'], 3, 0)101 # vesta102 self._cb['Vesta'] = QCheckBox(names.planets['Vesta'], self)103 mainGrid.addWidget(self._cb['Vesta'], 3, 1)104 # rahu (mean)105 self._cb['Rahu (mean)'] = QCheckBox(names.planets['Rahu (mean)'], self)106 mainGrid.addWidget(self._cb['Rahu (mean)'], 3, 2)107 # rahu (true)108 self._cb['Rahu (true)'] = QCheckBox(names.planets['Rahu (true)'], self)109 mainGrid.addWidget(self._cb['Rahu (true)'], 3, 3)110 # ketu (mean)111 self._cb['Ketu (mean)'] = QCheckBox(names.planets['Ketu (mean)'], self)112 mainGrid.addWidget(self._cb['Ketu (mean)'], 3, 4)113 # ketu (true)114 self._cb['Ketu (true)'] = QCheckBox(names.planets['Ketu (true)'], self)115 mainGrid.addWidget(self._cb['Ketu (true)'], 4, 0)116 # lilith (mean)117 self._cb['Lilith (mean)'] = QCheckBox(names.planets['Lilith (mean)'], self)118 mainGrid.addWidget(self._cb['Lilith (mean)'], 4, 1)119 # lilith (true)120 self._cb['Lilith (true)'] = QCheckBox(names.planets['Lilith (true)'], self)121 mainGrid.addWidget(self._cb['Lilith (true)'], 4, 2)122 # priapus (mean)123 self._cb['Priapus (mean)'] = QCheckBox(names.planets['Priapus (mean)'], self)124 mainGrid.addWidget(self._cb['Priapus (mean)'], 4, 3)125 # priapus (true)126 self._cb['Priapus (true)'] = QCheckBox(names.planets['Priapus (true)'], self)127 mainGrid.addWidget(self._cb['Priapus (true)'], 4, 4)128 129 # ### uranians ###130 uranianWidget = QWidget()131 tabs.addTab(uranianWidget, tr('Uranians'))132 uranianGrid = QGridLayout()133 uranianWidget.setLayout(uranianGrid)134 # cupido135 self._cb['Cupido'] = QCheckBox(names.planets['Cupido'], self)136 uranianGrid.addWidget(self._cb['Cupido'], 0, 0)137 # hades138 self._cb['Hades'] = QCheckBox(names.planets['Hades'], self)139 uranianGrid.addWidget(self._cb['Hades'], 0, 1)140 # zeus141 self._cb['Zeus'] = QCheckBox(names.planets['Zeus'], self)142 uranianGrid.addWidget(self._cb['Zeus'], 0, 2)143 # kronos144 self._cb['Kronos'] = QCheckBox(names.planets['Kronos'], self)145 uranianGrid.addWidget(self._cb['Kronos'], 0, 3)146 # apollo147 self._cb['Apollon'] = QCheckBox(names.planets['Apollon'], self)148 uranianGrid.addWidget(self._cb['Apollon'], 1, 0)149 # admetos150 self._cb['Admetos'] = QCheckBox(names.planets['Admetos'], self)151 uranianGrid.addWidget(self._cb['Admetos'], 1, 1)152 # vulkanus153 self._cb['Vulkanus'] = QCheckBox(names.planets['Vulkanus'], self)154 uranianGrid.addWidget(self._cb['Vulkanus'], 1, 2)155 # poseidon156 self._cb['Poseidon'] = QCheckBox(names.planets['Poseidon'], self)157 uranianGrid.addWidget(self._cb['Poseidon'], 1, 3)158 159 # ### others fictitious ###160 othersWidget = QWidget()161 tabs.addTab(othersWidget, tr('Others'))162 othersGrid = QGridLayout()163 othersWidget.setLayout(othersGrid)164 # isis165 self._cb['Isis'] = QCheckBox(names.planets['Isis'], self)166 othersGrid.addWidget(self._cb['Isis'], 0, 0)167 # nibiru168 self._cb['Nibiru'] = QCheckBox(names.planets['Nibiru'], self)169 othersGrid.addWidget(self._cb['Nibiru'], 0, 1)170 # harrington171 self._cb['Harrington'] = QCheckBox(names.planets['Harrington'], self)172 othersGrid.addWidget(self._cb['Harrington'], 0, 2)173 # neptune (leverrier)174 self._cb['Neptune (Leverrier)'] = QCheckBox(names.planets['Neptune (Leverrier)'], self)175 othersGrid.addWidget(self._cb['Neptune (Leverrier)'], 0, 3)176 # neptune (adams)177 self._cb['Neptune (Adams)'] = QCheckBox(names.planets['Neptune (Adams)'], self)178 othersGrid.addWidget(self._cb['Neptune (Adams)'], 1, 0)179 # pluto (lowell)180 self._cb['Pluto (Lowell)'] = QCheckBox(names.planets['Pluto (Lowell)'], self)181 othersGrid.addWidget(self._cb['Pluto (Lowell)'], 1, 1)182 # pluto (pickering)183 self._cb['Pluto (Pickering)'] = QCheckBox(names.planets['Pluto (Pickering)'], self)184 othersGrid.addWidget(self._cb['Pluto (Pickering)'], 1, 2)185 # vulcan186 self._cb['Vulcan'] = QCheckBox(names.planets['Vulcan'], self)187 othersGrid.addWidget(self._cb['Vulcan'], 1, 3)188 # white moon189 self._cb['White Moon'] = QCheckBox(names.planets['White Moon'], self)190 othersGrid.addWidget(self._cb['White Moon'], 2, 0)191 # proserpina192 self._cb['Proserpina'] = QCheckBox(names.planets['Proserpina'], self)193 othersGrid.addWidget(self._cb['Proserpina'], 2, 1)194 # waldemath195 self._cb['Waldemath'] = QCheckBox(names.planets['Waldemath'], self)196 othersGrid.addWidget(self._cb['Waldemath'], 2, 2)197 198 # ### cusps ###199 cuspsWidget = QWidget()200 tabs.addTab(cuspsWidget, tr('Cusps'))201 cuspsGrid = QGridLayout()202 cuspsWidget.setLayout(cuspsGrid)203 # house cusps204 x = (0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2)205 y = (0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3)206 for i in range(12):207 self._cb['Cusp %.2d' % (i+1,)] = QCheckBox(208 names.houses['Cusp %.2d' % (i+1,)], self)209 cuspsGrid.addWidget(self._cb['Cusp %.2d' % (i+1,)], x[i], y[i])210 # asc211 self._cb['Asc'] = QCheckBox(names.planets['Asc'], self)212 cuspsGrid.addWidget(self._cb['Asc'], 3, 0)213 # mc214 self._cb['Mc'] = QCheckBox(names.planets['Mc'], self)215 cuspsGrid.addWidget(self._cb['Mc'], 3, 1)216 # dsc217 self._cb['Dsc'] = QCheckBox(names.planets['Dsc'], self)218 cuspsGrid.addWidget(self._cb['Dsc'], 3, 2)219 # ic220 self._cb['Ic'] = QCheckBox(names.planets['Ic'], self)221 cuspsGrid.addWidget(self._cb['Ic'], 3, 3)222 # armc223 self._cb['Armc'] = QCheckBox(names.planets['Armc'], self)224 cuspsGrid.addWidget(self._cb['Armc'], 4, 0)225 # vertex226 self._cb['Vertex'] = QCheckBox(names.planets['Vertex'], self)227 cuspsGrid.addWidget(self._cb['Vertex'], 4, 1)228 # equatorial asc229 self._cb['Equatorial Ascendant'] = QCheckBox(names.planets['Equatorial Ascendant'], self)230 cuspsGrid.addWidget(self._cb['Equatorial Ascendant'], 4, 2)231 # co-ascendant (koch)232 self._cb['Co-ascendant (Koch)'] = QCheckBox(names.planets['Co-ascendant (Koch)'], self)233 cuspsGrid.addWidget(self._cb['Co-ascendant (Koch)'], 4, 3)234 # co-ascendant (munkasey)235 self._cb['Co-ascendant (Munkasey)'] = QCheckBox(names.planets['Co-ascendant (Munkasey)'], self)236 cuspsGrid.addWidget(self._cb['Co-ascendant (Munkasey)'], 5, 0)237 # polar ascendant238 self._cb['Polar Ascendant (Munkasey)'] = QCheckBox(names.planets['Polar Ascendant (Munkasey)'], self)239 cuspsGrid.addWidget(self._cb['Polar Ascendant (Munkasey)'], 5, 1)240 241 # ### gauquelin ###242 gauquelinWidget = QWidget()243 tabs.addTab(gauquelinWidget, tr('Gauquelin'))244 gauquelinGrid = QGridLayout()245 gauquelinWidget.setLayout(gauquelinGrid)246 # sectors247 x = (0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4,5,5,5,5,5,5)248 y = (0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3,4,5)249 for i in range(36):250 self._cb['Sector %.2d' % (i+1,)] = QCheckBox(251 names.houses['Sector %.2d' % (i+1,)], self)252 gauquelinGrid.addWidget(self._cb['Sector %.2d' % (i+1,)], x[i], y[i])253 254 # ### parts ###255 partsWidget = QWidget()256 tabs.addTab(partsWidget, tr('Parts'))257 partsGrid = QGridLayout()258 partsWidget.setLayout(partsGrid)259 # part of fortune (rudhyar)260 self._cb['Part of Fortune (Rudhyar)'] = QCheckBox(261 names.planets['Part of Fortune (Rudhyar)'], self)262 partsGrid.addWidget(self._cb['Part of Fortune (Rudhyar)'], 0, 0)263 264 # ### fixed stars ###265 # get all stars266 sql = 'select name from Planets where family = 2 order by name;'267 res = db.execute(sql).fetchall()268 # stars tab269 starsScroll = QScrollArea()270 starsScroll.setWidgetResizable(True)271 starsWidget = QWidget()272 starsScroll.setWidget(starsWidget)273 tabs.addTab(starsScroll, tr('Stars'))274 starsGrid = QGridLayout()275 starsWidget.setLayout(starsGrid)276 y = 0277 for i, star in enumerate(res):278 s = str(star[0])279 self._cb[s] = QCheckBox(s, self)280 starsGrid.addWidget(self._cb[s], y, i % 6)281 if i % 6 == 5:282 y += 1283 284 # ### asteroids ###285 # get all asteroids286 sql = 'select name from Planets where family = 3 order by name;'287 res = db.execute(sql).fetchall()288 # asteroids tab289 asteroidsScroll = QScrollArea()290 asteroidsScroll.setWidgetResizable(True)291 asteroidsWidget = QWidget()292 asteroidsScroll.setWidget(asteroidsWidget)293 tabs.addTab(asteroidsScroll, tr('Asteroids'))294 asteroidsGrid = QGridLayout()295 asteroidsWidget.setLayout(asteroidsGrid)296 y = 0297 for i, ast in enumerate(res):298 s = str(ast[0])299 self._cb[s] = QCheckBox(s, self)300 asteroidsGrid.addWidget(self._cb[s], y, i % 6)301 if i % 6 == 5:302 y += 1303 304 # ### end planets ###305 306 # comment307 grid.addWidget(QLabel(tr('Comment')), 2, 0, Qt.AlignTop)308 self.commentEdit = QTextEdit('', self)309 grid.addWidget(self.commentEdit, 2, 1)310 # buttons311 buttonsLayout = QHBoxLayout()312 resetButton = QPushButton(tr('Reset'), self)313 self.connect(resetButton, SIGNAL('clicked()'), self.reset)314 buttonsLayout.addWidget(resetButton)315 cancelButton = QPushButton(tr('Cancel'), self)316 self.connect(cancelButton, SIGNAL('clicked()'), self.reject)317 buttonsLayout.addWidget(cancelButton)318 okButton = QPushButton(tr('Ok'), self)319 okButton.setDefault(True)320 self.connect(okButton, SIGNAL('clicked()'), self.accept)321 buttonsLayout.addWidget(okButton)322 grid.addLayout(buttonsLayout, 3, 0, 1, 2)323 # load entries324 self.reset()325 # resize326 self.resize(550, 300)327 328 def reset(self):329 """Reset entries."""330 # name331 self.nameEdit.setText(self._filt._name)332 # comment333 self.commentEdit.setPlainText(self._filt._comment)334 # values335 for pl, val in self._filt.items():336 self._cb[pl].setChecked(val)337 338 def accept(self):339 """Set filter new values and save."""340 tr = self.tr341 # name342 name = unicode(self.nameEdit.text())343 if name == '':344 QMessageBox.critical(self, tr('Missing Name'),345 tr('Please set filter name.'))346 self.nameEdit.setFocus()347 return348 # comment349 cmt = unicode(self.commentEdit.toPlainText())350 # set values351 self._filt.set(name=name, comment=cmt)352 for pl, cb in self._cb.items():353 self._filt[pl] = cb.isChecked()354 # save355 try:356 self._filt.save()357 except ValueError: # duplicate filter358 QMessageBox.critical(self, tr('Error'),359 unicode(tr('Duplicate filter name \xab %(filter)s \xbb.')) % {360 'filter': self._filt._name})361 self.nameEdit.setFocus()362 return363 # reload cfg in case filter is default,364 # and opened charts if using this filter365 if __name__ != '__main__':366 app.planetsFilterUpdatedEvent(self._filt._idx_)367 # done368 self.done(QDialog.Accepted)369def main():370 app = QApplication(sys.argv)371 main = PlanetsFilterDialog()372 main.show()373 sys.exit(app.exec_())374if __name__ == '__main__':375 main()...
callbacksTrace.py
Source:callbacksTrace.py
2# import callbacksTrace3# This will make them all print something to stdout so you can see4# when they are called.5import nuke6def _cb(name):7 nuke.tprint(name + " " + nuke.thisNode().name())8def _cbk(name):9 nuke.tprint(name + " " + nuke.thisNode().name() + "." + nuke.thisKnob().name())10nuke.addOnUserCreate(_cb, ("onUserCreate"))11nuke.addOnCreate(_cb, ("onCreate"))12nuke.addOnScriptLoad(_cb, ("onScriptLoad"))13nuke.addOnScriptSave(_cb, ("onScriptSave"))14nuke.addOnScriptClose(_cb, ("onScriptClose"))15nuke.addOnDestroy(_cb, ("onDestroy"))16nuke.addKnobChanged(_cbk, ("knobChanged"))17nuke.addUpdateUI(_cb, ("updateUI"))18nuke.addAutolabel(_cb, ("autolabel"))19nuke.addBeforeRender(_cb, ("beforeRender"))20nuke.addBeforeFrameRender(_cb, ("beforeFrameRender"))...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!