def settings(self, parent=None): if parent is None: parent = self settingw = pya.QWidget(self) vbox = pya.QVBoxLayout(settingw) settingw.setLayout(vbox) self.settingspath = kgit.settings_path self.settings = {} scrollarea = pya.QScrollArea(self) optionswidget = pya.QWidget(self) scrollarea.setWidget(optionswidget) scrollarea.setWidgetResizable(True) optionvbox = pya.QVBoxLayout(optionswidget) categorydict = vars(kgit.settings) hbSplitter = pya.QHBoxLayout() vboxbuttons = pya.QVBoxLayout() vbox.addLayout(hbSplitter) hbSplitter.addWidget(scrollarea) hbSplitter.addLayout(vboxbuttons) resetButton = pya.QPushButton('Restore Defaults', self) resetButton.clicked(self.restoreDefaults) vboxbuttons.addWidget(resetButton) vboxbuttons.addStretch() # Repository Settings cat = 'Repository' groupbox = pya.QGroupBox(cat, self) optionvbox.addWidget(groupbox) vb = pya.QVBoxLayout(groupbox) self.settings['repository'] = {} repdic = self.settings['repository'] repdic['url'] = [ kgit.settings.repository.url(), kgit.settings.repository.url ] l = pya.QHBoxLayout() le = pya.QLineEdit(repdic['url'][0], self) def assignurl(text): repdic['url'][0] = text le.textChanged = assignurl la = pya.QLabel(kgit.settings.repository.url.description, self) l.addWidget(le) l.addWidget(la) vb.addLayout(l) l = pya.QHBoxLayout() repdic['autoupdate'] = [ kgit.settings.repository.autoupdate(), kgit.settings.repository.autoupdate ] b = pya.QCheckBox(kgit.settings.repository.autoupdate.description, groupbox) if repdic['autoupdate'][0]: b.setChecked(True) else: b.setChecked(False) def updateclicked(checked): repdic['autoupdate'][0] = checked b.toggled = updateclicked l.addWidget(b) vb.addLayout(l) # Log settings cat = "Logs" groupbox = pya.QGroupBox(cat, self) optionvbox.addWidget(groupbox) vb = pya.QVBoxLayout(groupbox) self.settings['logging'] = {} logdic = self.settings['logging'] logdic['filelvl'] = [ kgit.settings.logging.logfilelevel.value.index, kgit.settings.logging.logfilelevel ] logdic['streamlvl'] = [ kgit.settings.logging.logstreamlevel.value.index, kgit.settings.logging.logstreamlevel ] ## File Logging v = pya.QComboBox(self) l = pya.QHBoxLayout() for i in kgit.settings.logging.levels(): v.addItem(i) v.currentIndex = logdic['filelvl'][0] vb.addLayout(l) l.addWidget(v) d = pya.QLabel(kgit.settings.logging.logfilelevel.description, self) def logfileindexchanged(index): logdic['filelvl'][0] = index v.currentIndexChanged = logfileindexchanged l.addWidget(d) l.addStretch() ## Stream Logging v = pya.QComboBox(self) l = pya.QHBoxLayout() for i in kgit.settings.logging.levels(): v.addItem(i) v.currentIndex = logdic['streamlvl'][0] vb.addLayout(l) l.addWidget(v) d = pya.QLabel(kgit.settings.logging.logfilelevel.description, self) def logfileindexchanged(index): logdic['streamlvl'][0] = index v.logfileindexchanged = logfileindexchanged l.addWidget(d) l.addStretch() vbox.addStretch() save = pya.QPushButton("Save", self) save.clicked = self.save abort = pya.QPushButton("Cancel", self) abort.clicked = self.abort hbox = pya.QHBoxLayout() vbox.addLayout(hbox) hbox.addWidget(abort) hbox.addStretch() hbox.addWidget(save) optionvbox.addStretch() return settingw
def __init__(self, parent=None): self.settingspath = kppc.settings_path self.vbox = pya.QVBoxLayout() self.setLayout(self.vbox) self.settings = {} self.setWindowTitle("KLayoutPhotonicPCells Settings") self.setMinimumWidth(300) vsize = len(vars(kppc.settings)) self.scrollarea = pya.QScrollArea(self) self.optionswidget = pya.QWidget(self) self.scrollarea.setWidget(self.optionswidget) self.scrollarea.setWidgetResizable(True) #self.vbox.addWidget(self.scrollarea) self.optionvbox = pya.QVBoxLayout(self.optionswidget) categorydict = vars(kppc.settings) hbSplitter = pya.QHBoxLayout() vboxbuttons = pya.QVBoxLayout() self.vbox.addLayout(hbSplitter) hbSplitter.addWidget(self.scrollarea) hbSplitter.addLayout(vboxbuttons) recompileButton = pya.QPushButton('Recompile', self) recompileButton.clicked(self.recompile) vboxbuttons.addWidget(recompileButton) resetButton = pya.QPushButton('Restore Defaults', self) resetButton.clicked(self.restoreDefaults) vboxbuttons.addWidget(resetButton) vboxbuttons.addStretch() for i, cat in enumerate(categorydict.keys()): groupbox = pya.QGroupBox(cat, self) self.optionvbox.addWidget(groupbox) vb = pya.QVBoxLayout(groupbox) self.settings[cat] = {} settingdict = vars(categorydict[cat]) for j, setting in enumerate(settingdict): if setting[0] == '_': continue opt = settingdict[setting] desc_str = f"_{setting}_DESC" if desc_str in settingdict: desc = settingdict[desc_str] else: desc = setting if isinstance(opt, bool): v = pya.QCheckBox(desc, self) vb.addWidget(v) v.toggeled = v.setChecked(opt) self.settings[cat][setting] = ( v, lambda x: bool(x.checkState.to_i())) elif isinstance(opt, int): l = pya.QHBoxLayout() vb.addLayout(l) t = pya.QLabel(desc, self) v = pya.QSpinBox(self) l.addWidget(v) l.addWidget(t) l.addStretch() v.value = opt minset = f"_{setting}_MIN" maxset = f"_{setting}_MAX" if minset in settingdict: v.minimum = settingdict[minset] if maxset in settingdict: v.maximum = settingdict[maxset] self.settings[cat][setting] = (v, lambda x: x.value) elif isinstance(opt, list): v = pya.QComboBox(self) l = pya.QHBoxLayout() index = int(opt[0]) strs = opt[1:] for i in strs: v.addItem(i) v.currentIndex = index vb.addLayout(l) l.addWidget(v) d = pya.QLabel(desc, self) l.addWidget(d) l.addStretch() self.settings[cat][setting] = ( v, lambda x, l=strs: [x.currentIndex] + l) else: continue self.vbox.addStretch() save = pya.QPushButton("Save", self) save.clicked = self.save abort = pya.QPushButton("Cancel", self) abort.clicked = self.abort self.hbox = pya.QHBoxLayout() self.vbox.addLayout(self.hbox) self.hbox.addWidget(abort) self.hbox.addStretch() self.hbox.addWidget(save)
def repoManager(self, parent=None): if parent is None: parent = self widget = pya.QWidget(self) vbox = pya.QVBoxLayout(widget) widget.setLayout(vbox) self.repolist = pya.QListWidget(widget) repos = kgit.getRepos() items = [] for r in repos: s = yaml.safe_load(r.read_text()) if '/' in s['name']: description = (f"Name:\t\t{s['name'].rsplit('/',1)[1]}\n" f"Project:\t\t{s['name'].rsplit('/',1)[0]}\n") else: description = f"Name:\t\t{s['name']}\n" description += "Location:\t\tlocal\n" if 'author' in s: description += f"Author:\t\t{s['author']}\n" pass description += f"Project URL:\t\t{s['url']}" if 'subdir' in s: description += f"\nProject Sub-URL:\t{s['subdir']}" item = pya.QListWidgetItem(description) item.whatsThis = s['name'] repo = git.Repo(r.parent) if repo.git.status('s'): pass items.append(item) self.repolist.addItem(item) remoterepos = kgit.getRemoteRepos() if remoterepos is not None: for r in remoterepos: if r['name'] in [i.whatsThis for i in items]: continue if '/' in r['name']: description = ( f"Name:\t\t{r['name'].rsplit('/',1)[1]}\n" f"Project:\t\t{r['name'].rsplit('/',1)[0]}\n") else: description = f"Name:\t\t{r['name']}\n" description += "Location:\t\tremote\n" description += f"Project URL:\t\t{r['url']}" if 'subdir' in r: description += f"\nProject Sub-URL:\t{r['subdir']}" item = pya.QListWidgetItem(description) item.whatsThis = r['name'] self.repolist.addItem(item) vbox.addWidget(self.repolist) buttonbox = pya.QHBoxLayout(widget) downloadbutton = pya.QPushButton("Download && Install", widget) downloadbutton.clicked = self.downloadRepos buttonbox.addWidget(downloadbutton) buttonbox.addStretch() removebutton = pya.QPushButton("Remove", widget) buttonbox.addWidget(removebutton) vbox.addLayout(buttonbox) return widget
def settings(self, parent=None): if parent is None: parent = self settingw = pya.QWidget(self) vbox = pya.QVBoxLayout(settingw) settingw.setLayout(vbox) self.settingspath = kgit.settings_path self.settings = {} scrollarea = pya.QScrollArea(self) optionswidget = pya.QWidget(self) scrollarea.setWidget(optionswidget) scrollarea.setWidgetResizable(True) optionvbox = pya.QVBoxLayout(optionswidget) categorydict = vars(kgit.settings) hbSplitter = pya.QHBoxLayout() vboxbuttons = pya.QVBoxLayout() vbox.addLayout(hbSplitter) hbSplitter.addWidget(scrollarea) hbSplitter.addLayout(vboxbuttons) resetButton = pya.QPushButton('Restore Defaults', self) resetButton.clicked(self.restoreDefaults) vboxbuttons.addWidget(resetButton) vboxbuttons.addStretch() # General Settings cat = 'Repository' groupbox = pya.QGroupBox(cat, self) optionvbox.addWidget(groupbox) vb = pya.QVBoxLayout(groupbox) self.settings['repository'] = {} repdic = self.settings['repository'] repdic['url'] = (kgit.settings.repository.url(), kgit.settings.repository.url) l = pya.QHBoxLayout() le = pya.QLineEdit(repdic['url'][0], self) la = pya.QLabel(kgit.settings.repository.url.description, self) l.addWidget(le) l.addWidget(la) vb.addLayout(l) # Log settings cat = "Logs" groupbox = pya.QGroupBox(cat, self) optionvbox.addWidget(groupbox) vb = pya.QVBoxLayout(groupbox) self.settings['logging'] = {} logdic = self.settings['logging'] logdic['filelvl'] = (kgit.settings.logging.logfilelevel.value.index, kgit.settings.logging.logfilelevel) logdic['streamlvl'] = ( kgit.settings.logging.logstreamlevel.value.index, kgit.settings.logging.logstreamlevel) ## File Logging v = pya.QComboBox(self) l = pya.QHBoxLayout() for i in kgit.settings.logging.levels(): v.addItem(i) v.currentIndex = logdic['filelvl'][0] vb.addLayout(l) l.addWidget(v) d = pya.QLabel(kgit.settings.logging.logfilelevel.description, self) l.addWidget(d) l.addStretch() ## Stream Logging v = pya.QComboBox(self) l = pya.QHBoxLayout() for i in kgit.settings.logging.levels(): v.addItem(i) v.currentIndex = logdic['streamlvl'][0] vb.addLayout(l) l.addWidget(v) d = pya.QLabel(kgit.settings.logging.logfilelevel.description, self) l.addWidget(d) l.addStretch() vbox.addStretch() save = pya.QPushButton("Save", self) save.clicked = self.save abort = pya.QPushButton("Cancel", self) abort.clicked = self.abort hbox = pya.QHBoxLayout() vbox.addLayout(hbox) hbox.addWidget(abort) hbox.addStretch() hbox.addWidget(save) optionvbox.addStretch() return settingw