def settings(self): if self.settings_window is None: window = QDialog(self) self.settings_window = window else: window = self.settings_window window = self.settings_window window.setWindowTitle('Settings') window.notelabel = QLabel("Currently these settings are only guaranteed to work prior to loading the first MIDI!\nYou'll have to restart ADLMIDI pyGui to change them again if they stop working. \n\nSorry! This will be fixed soon!") window.notelabel.setWordWrap(True) window.notelabel.setStyleSheet("font-size: 8pt; border-style: dotted; border-width: 1px; padding: 12px;") window.banklabel = QLabel("<B>Choose Instrument Bank</B>") window.space = QLabel("") window.optlabel = QLabel("<B>Options</B>") window.combo = QComboBox() window.combo.addItems(self.banks) #window.combo.setMaximumWidth(350) window.combo.setMaxVisibleItems(12) window.combo.setStyleSheet("combobox-popup: 0;") window.combo.setCurrentIndex(int(self.progset.value("sound/bank", 1))) window.combo.currentIndexChanged.connect(self.saveSettings) window.perc = QCheckBox("Adlib Percussion Instrument Mode") #window.perc.stateChanged.connect(self.checkOpts) window.tremamp = QCheckBox("Tremolo Amplification Mode") #window.tremamp.stateChanged.connect(self.checkOpts) window.vibamp = QCheckBox("Vibrato Amplification Mode") #window.vibamp.stateChanged.connect(self.checkOpts) window.modscale = QCheckBox("Scaling of Modulator Volume") #window.modscale.stateChanged.connect(self.checkOpts) window.okButton = QPushButton('OK') window.okButton.clicked.connect(window.hide) vbox = QVBoxLayout() vbox.addWidget(window.space) vbox.addWidget(window.banklabel) vbox.addWidget(window.combo) vbox.addWidget(window.space) vbox.addWidget(window.optlabel) vbox.addWidget(window.perc) vbox.addWidget(window.tremamp) vbox.addWidget(window.vibamp) vbox.addWidget(window.modscale) vbox.addWidget(window.notelabel) hbox = QHBoxLayout() hbox.addStretch(1) hbox.addWidget(window.okButton) vbox.addLayout(hbox) window.setLayout(vbox) window.setFixedSize(530, 369) window.show() window.activateWindow() window.raise_()
def _showpostviewerdialog(self, post): d = QDialog(self) d.resize(1024, 768) l = QVBoxLayout() w = PostViewerWidget(post, self._backend, self._masterobserver, self) w.nextpostrequested.connect(self._putnextpost) w.previouspostrequested.connect(self._putpreviouspost) w.closing.connect(d.close) l.addWidget(w) d.setLayout(l) d.setModal(False) d.show()
class createProject(): def __init__(self, parent): self.parent = parent self.directory = "" self.dialog = QDialog(parent.parent) mainLayout = QVBoxLayout() aux = QHBoxLayout() name = QLabel("Project Name: ") self.textBox = QLineEdit() aux.addWidget(name) aux.addWidget(self.textBox) aux2 = QWidget() aux2.setLayout(aux) mainLayout.addWidget(aux2) auxBox = QHBoxLayout() self.directoryLabel = QLabel("Directory: ") button = QPushButton("...") button.clicked.connect(self.fileChoosing) auxBox.addWidget(self.directoryLabel) auxBox.addWidget(button) auxWidget = QWidget() auxWidget.setLayout(auxBox) mainLayout.addWidget(auxWidget) buttonOk = QPushButton("Create Project") buttonOk.clicked.connect(self.okClicked) mainLayout.addWidget(buttonOk) self.dialog.setLayout(mainLayout) self.dialog.show() def fileChoosing(self): filePicker = QFileDialog() self.directory = filePicker.getExistingDirectory(self.parent, "Get Directory") self.directoryLabel.setText("Directory: " + self.directory) filePicker.destroy() def okClicked(self): if self.directory != "" and self.textBox.text() != "": try: if self.parent.parent.platform == "linux2": os.mkdir(self.directory + "/"+ self.textBox.text()) self.parent.parent.project = Project(self.directory + "/"+ self.textBox.text(), self.textBox.text(), "linux2") elif self.parent.parent.platform == "win32": os.mkdir(self.directory + "\\"+ self.textBox.text()) self.parent.parent.project = Project(self.directory + "\\"+ self.textBox.text(), self.textBox.text(), "win32") self.parent.parent.project.save() self.dialog.setVisible(False) self.parent.parent.fileMenu.saveProjectAction.setEnabled(True) self.parent.parent.signalMenu.addSignalAction.setEnabled(True) self.parent.parent.signalMenu.applyOperationAction.setEnabled(True) msg = QMessageBox(self.parent.parent) msg.setText("Project created") msg.show() except OSError: msg = QErrorMessage(self.parent.parent) msg.showMessage("Project already exists")
class addSignal(): def __init__(self, parent): self.parent = parent self.dialog = QDialog(self.parent.parent) mainLayout = QVBoxLayout() aux = QHBoxLayout() name = QLabel("Signal Name: ") self.nameBox = QLineEdit() aux.addWidget(name) aux.addWidget(self.nameBox) aux2 = QWidget() aux2.setLayout(aux) mainLayout.addWidget(aux2) auxBox = QHBoxLayout() self.fileLabel = QLabel("File: ") button = QPushButton("...") button.clicked.connect(self.fileChoosing) auxBox.addWidget(self.fileLabel) auxBox.addWidget(button) auxWidget = QWidget() auxWidget.setLayout(auxBox) mainLayout.addWidget(auxWidget) hBox = QHBoxLayout() hBox.addWidget(QLabel("Sample Rate (Hz): ")) self.sampleRate = QLineEdit() self.sampleRate.setText("60") hBox.addWidget(self.sampleRate) auxW = QWidget() auxW.setLayout(hBox) mainLayout.addWidget(auxW) auxBox = QHBoxLayout() commentaryLabel = QLabel("Commentary: ") self.commentaryBox = QTextEdit() auxBox.addWidget(commentaryLabel) auxBox.addWidget(self.commentaryBox) auxWidget = QWidget() auxWidget.setLayout(auxBox) mainLayout.addWidget(auxWidget) buttonOk = QPushButton("Add Signal") buttonOk.clicked.connect(self.addSignalClicked) mainLayout.addWidget(buttonOk) self.dialog.setLayout(mainLayout) self.dialog.show() def fileChoosing(self): filePicker = QFileDialog() self.fileName = filePicker.getOpenFileName(self.parent, 'Select File')[0] filePicker.destroy() self.fileLabel.setText("File: " + self.fileName) filePicker.destroy() def addSignalClicked(self): if self.fileName != "" and self.nameBox.text() != "": self.parent.parent.project.addSignal(self.nameBox.text(), self.fileName, self.commentaryBox.toPlainText(), self.sampleRate.text()) self.dialog.setVisible(False) label = self.parent.parent.project.signalList[-1][0].getImage() if self.parent.parent.table.columnCount() == 0: self.parent.parent.table.setColumnCount(1) self.parent.parent.table.setRowCount(self.parent.parent.table.rowCount() + 1) self.parent.parent.table.setCellWidget(len(self.parent.parent.project.signalList)-1,0,label) self.parent.parent.table.resizeColumnsToContents() self.parent.parent.table.resizeRowsToContents() self.parent.parent.setLabels() msg = QMessageBox(self.parent.parent) msg.setText("Signal added") msg.show()
class Thread(QThread): message = Signal(str) def __init__(self, parent, func, arg=None, progressText=None, pb_widget=None, redirect_stdout=False, abortButton=False): QThread.__init__(self, parent) self.func = func self.arg = arg self.progressText = progressText self.pb_widget = pb_widget self.redirect_stdout = redirect_stdout self.abortButton = abortButton self.finished.connect(self.hideProgressbar) self.showProgressbar() def run(self): if self.redirect_stdout: sys.stdout = self try: if self.arg: self.data = self.func(self.arg) else: self.data = self.func() self._executed = True except Exception as e: self._executed = False self._executedError = e traceback.print_exc() exctype, value = sys.exc_info()[:2] self._executedErrorInfo = '{} {} {}'.\ format(exctype, value, traceback.format_exc()) sys.stdout = sys.__stdout__ def showProgressbar(self): if self.progressText: # generate widget if not given in init if not self.pb_widget: self.pb_widget = QDialog(self.parent()) self.pb_widget.setWindowFlags(Qt.SplashScreen) self.pb_widget.setModal(True) # add button delete_button = QPushButton('X') delete_button.clicked.connect(self.exit) hl = QHBoxLayout() pb = QProgressBar() pb.setRange(0, 0) hl.addWidget(pb) hl.addWidget(QLabel(self.progressText)) if self.abortButton: hl.addWidget(delete_button) self.pb_widget.setLayout(hl) self.pb_widget.show() def hideProgressbar(self): if self.pb_widget: self.pb_widget.hide() def write(self, text): self.message.emit(text) def flush(self): pass
class MultiThread(QThread): finished = Signal(str) message = Signal(str) def __init__(self, parent, func, args, ncores=1, progressText=None, pb_widget=None, redirect_stdout=False): QThread.__init__(self, parent) self.func = func self.args = args self.ncores = ncores self.progressText = progressText self.pb_widget = pb_widget self.redirect_stdout = redirect_stdout self.finished.connect(self.hideProgressbar) self.showProgressbar() def run(self): if self.redirect_stdout: sys.stdout = self try: if not self.ncores: self.ncores = multiprocessing.cpu_count() pool = multiprocessing.Pool(self.ncores) self.data = pool.map_async(self.func, self.args, callback=self.emitDone) #self.data = pool.apply_async(self.func, self.shotlist, callback=self.emitDone) #emit each time returned pool.close() self._executed = True except Exception as e: self._executed = False self._executedError = e exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] print('Exception: {}, file: {}, line: {}'.format( exc_type, fname, exc_tb.tb_lineno)) sys.stdout = sys.__stdout__ def showProgressbar(self): if self.progressText: if not self.pb_widget: self.pb_widget = QDialog(self.parent()) self.pb_widget.setWindowFlags(Qt.SplashScreen) self.pb_widget.setModal(True) hl = QHBoxLayout() pb = QProgressBar() pb.setRange(0, 0) hl.addWidget(pb) hl.addWidget(QLabel(self.progressText)) self.pb_widget.setLayout(hl) self.pb_widget.show() def hideProgressbar(self): if self.pb_widget: self.pb_widget.hide() def write(self, text): self.message.emit(text) def flush(self): pass def emitDone(self, result): print('emitDone!') self.finished.emit('Done thread!') self.hideProgressbar()
def __init__(self, parent): dialog = QDialog(parent.parent) mainLayout = QVBoxLayout() aux = QHBoxLayout() name = QLabel("Signal Name: ") nameBox = QLineEdit() aux.addWidget(name) aux.addWidget(nameBox) aux2 = QWidget() aux2.setLayout(aux) mainLayout.addWidget(aux2) def fileChoosing(): global fileName filePicker = QFileDialog() fileName = filePicker.getOpenFileName(parent, 'Select File')[0] filePicker.destroy() fileLabel.setText("File: " + fileName) filePicker.destroy() def addSignalClicked(): global directory if fileName != "" and nameBox.text() != "": parent.parent.project.addSignal(nameBox.text(), fileName, commentaryBox.toPlainText()) dialog.setVisible(False) label = parent.parent.project.signalList[-1][0].getImage() if parent.parent.mainWidget.columnCount() == 0: parent.parent.mainWidget.setColumnCount(1) parent.parent.mainWidget.setRowCount(parent.parent.mainWidget.rowCount() + 1) parent.parent.mainWidget.setCellWidget(len(parent.parent.project.signalList)-1,0,label) parent.parent.mainWidget.resizeColumnsToContents() parent.parent.mainWidget.resizeRowsToContents() msg = QMessageBox(parent.parent) msg.setText("Signal added") msg.show() auxBox = QHBoxLayout() fileLabel = QLabel("File: ") button = QPushButton("...") button.clicked.connect(fileChoosing) auxBox.addWidget(fileLabel) auxBox.addWidget(button) auxWidget = QWidget() auxWidget.setLayout(auxBox) mainLayout.addWidget(auxWidget) auxBox = QHBoxLayout() commentaryLabel = QLabel("Commentary: ") commentaryBox = QTextEdit() auxBox.addWidget(commentaryLabel) auxBox.addWidget(commentaryBox) auxWidget = QWidget() auxWidget.setLayout(auxBox) mainLayout.addWidget(auxWidget) buttonOk = QPushButton("Add Signal") buttonOk.clicked.connect(addSignalClicked) mainLayout.addWidget(buttonOk) dialog.setLayout(mainLayout) dialog.show()
return "{} {}".format(self.name, self.price) # form_rendered._field_map['name'].set_value("king") # form_rendered._field_map['price'].set_value("1337") data = Data(name="King Kong", price=123) d = {'list': ['alpha', 'beta', 'gamma'], 'group': data} form_rendered = Render(form) form_rendered.set_all_values(data) form_rendered.read_all_values(data) print(data) d = QDialog() view = PySide.QtWebKit.QWebView(d) view.setZoomFactor(1.5) # view.setHtml("Hello world <a href='eulu.html'>Link</a>") # view.setUrl('file:///Users/stc/Dropbox/index.html') view.setUrl( 'file:///PORT-STC/PRIVATE/SlickGrid-2.2.6/examples/example14-highlighting.html' ) top_layout = QHBoxLayout() top_layout.addWidget(view) top_layout.addLayout(form_rendered.render()) d.setLayout(top_layout) d.show() d.exec_()
def __init__(self, parent): directory = "" dialog = QDialog(parent.parent) mainLayout = QVBoxLayout() aux = QHBoxLayout() name = QLabel("Project Name: ") textBox = QLineEdit() aux.addWidget(name) aux.addWidget(textBox) aux2 = QWidget() aux2.setLayout(aux) mainLayout.addWidget(aux2) def fileChoosing(): global directory filePicker = QFileDialog() directory = filePicker.getExistingDirectory(parent, "Get Directory") directoryLabel.setText("Directory: " + directory) filePicker.destroy() def okClicked(): global directory if directory != "" and textBox.text() != "": try: os.mkdir(directory + "/"+ textBox.text()) parent.parent.project = Project(directory + "/"+ textBox.text(), textBox.text()) parent.parent.project.save() dialog.setVisible(False) parent.parent.fileMenu.saveProjectAction.setEnabled(True) parent.parent.signalMenu.addSignalAction.setEnabled(True) parent.parent.signalMenu.applyOperationAction.setEnabled(True) msg = QMessageBox(parent.parent) msg.setText("Project created") msg.show() except OSError: msg = QErrorMessage(parent.parent) msg.showMessage("Project already exists") auxBox = QHBoxLayout() directoryLabel = QLabel("Directory: ") button = QPushButton("...") button.clicked.connect(fileChoosing) auxBox.addWidget(directoryLabel) auxBox.addWidget(button) auxWidget = QWidget() auxWidget.setLayout(auxBox) mainLayout.addWidget(auxWidget) buttonOk = QPushButton("Create Project") buttonOk.clicked.connect(okClicked) mainLayout.addWidget(buttonOk) dialog.setLayout(mainLayout) dialog.show()