class TemplatesCollectionWidgetDialog(QDialog): def __init__(self, parent, doc_service): super(TemplatesCollectionWidgetDialog, self).__init__(parent) layout = QVBoxLayout() self.setWindowTitle(_("Templates library")) tw = TitleWidget(_("Templates library"), self) layout.addWidget(tw) l = QLabel( _("Here you can add or remove templates documents from the library. " "If needed, you can change their name and add a description. " "If you want to replace a reference document (one with a special " "Horse reference, then simply drag and drop the document on " "the appropriate row")) l.setWordWrap(True) layout.addWidget(l) self.widget = TemplatesCollectionWidget(self, doc_service) layout.addWidget(self.widget) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.Ok) self.buttons.accepted.connect(self.accept) layout.addWidget(self.buttons) self.setLayout(layout) place_dialog_on_screen(self, 0.5, 0.7)
def __init__(self, parent, dao): super(EditTaskTeamDialog, self).__init__(parent) self.setModal(True) self.team_out_scene = EmployeePicturePlanScene(self) for employee in dao.all(): self.team_out_scene.addItem( SelectableEmployeePictureItem( employee.picture(), employee)) # Scene takes ownership of the item self.team_out_view = QGraphicsView(self.team_out_scene, self) self.team_out_view.setAlignment(Qt.AlignLeft | Qt.AlignTop) buttons = QDialogButtonBox(self) buttons.addButton(QDialogButtonBox.StandardButton.Cancel) buttons.addButton(QDialogButtonBox.Ok) top_layout = QVBoxLayout(self) top_layout.addWidget(self.team_out_view) top_layout.addWidget(buttons) self.setLayout(top_layout) buttons.accepted.connect(self.accept) buttons.rejected.connect(self.reject)
class AddAccountDialog(QDialog): def __init__(self, parent, ok_handler, cancel_handler): super(AdminWidget.AddAccountDialog, self).__init__(parent) self.setWindowTitle("Add account") self.setFixedSize(300, 100) self.setModal(True) self.layout = QGridLayout(self) self.username_label = QLabel(self) self.username_label.setText("Username") self.edit_username = QLineEdit(self) self.buttons = QDialogButtonBox(self) self.buttons.addButton(QDialogButtonBox.Ok) self.buttons.addButton(QDialogButtonBox.Cancel) self.buttons.button(QDialogButtonBox.Ok).setText("Add") self.buttons.button(QDialogButtonBox.Cancel).setText("Cancel") self.buttons.button(QDialogButtonBox.Cancel).clicked.connect(cancel_handler) self.buttons.button(QDialogButtonBox.Ok).clicked.connect(lambda: ok_handler(self.edit_username.text())) self.layout.addWidget(self.username_label, 0, 0) self.layout.addWidget(self.edit_username, 0, 1) self.layout.addWidget(self.buttons, 1, 0, 1, 2, Qt.AlignCenter) self.setLayout(self.layout)
def _create_buttons ( self, parent ): buttons = QDialogButtonBox() # 'OK' button. # FIXME v3: Review how this is supposed to work for non-modal dialogs # (ie. how does anything act on a button click?) if self.ok_label: btn = buttons.addButton( self.ok_label, QDialogButtonBox.AcceptRole ) else: btn = buttons.addButton( QDialogButtonBox.Ok ) btn.setDefault( True ) # 'Cancel' button. # FIXME v3: Review how this is supposed to work for non-modal dialogs # (ie. how does anything act on a button click?) if self.cancel_label: buttons.addButton( self.cancel_label, QDialogButtonBox.RejectRole ) else: buttons.addButton( QDialogButtonBox.Cancel ) # 'Help' button. # FIXME v3: In the original code the only possible hook into the help # was to reimplement self._on_help(). However this was a private # method. Obviously nobody uses the Help button. For the moment we # display it but can't actually use it. if len( self.help_id ) > 0: if self.help_label: buttons.addButton( self.help_label, QDialogButtonBox.HelpRole ) else: buttons.addButton( QDialogButtonBox.Help ) return buttons
class VersionDialog(QDialog): def __init__(self, parent): super(VersionDialog, self).__init__() layout = QVBoxLayout(self) layout.addWidget(QLabel("Which version do you want to download ?")) self.line_edit = QLineEdit() layout.addWidget(self.line_edit) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.StandardButton.Cancel) self.buttons.addButton(QDialogButtonBox.Ok) layout.addWidget(self.buttons) self.setLayout(layout) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) @Slot() def accept(self): try: StrictVersion(self.line_edit.text()) return super(VersionDialog, self).accept() except: pass @Slot() def reject(self): return super(VersionDialog, self).reject()
class AskIPAddress(QDialog): def __init__(self, parent): super(AskIPAddress, self).__init__() layout = QVBoxLayout(self) layout.addWidget(QLabel("Please enter a valid address")) glayout = QGridLayout() self.address = QLineEdit() glayout.addWidget(QLabel("IP Address"), 0, 0) glayout.addWidget(self.address, 0, 1) self.address.setText(guess_server_public_ip()) layout.addLayout(glayout) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.Ok) layout.addWidget(self.buttons) self.setLayout(layout) self.buttons.accepted.connect(self.accept) @Slot() def accept(self): return super(AskIPAddress, self).accept()
class YesConfirm(QDialog): def __init__(self, parent): super(YesConfirm, self).__init__() layout = QVBoxLayout(self) layout.addWidget( QLabel( "The following operation is irreversible. Type 'yes' to confirm" )) self.line_edit = QLineEdit() layout.addWidget(self.line_edit) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.StandardButton.Cancel) self.buttons.addButton(QDialogButtonBox.Ok) layout.addWidget(self.buttons) self.setLayout(layout) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) @Slot() def accept(self): if self.line_edit.text() == 'yes': return super(YesConfirm, self).accept() @Slot() def reject(self): return super(YesConfirm, self).reject()
class ProfileCreation(QDialog): ''' classdocs ''' profileCreated = Signal(Athlete) def __init__(self): ''' Constructor ''' QDialog.__init__(self) self._initGUI() self.athleteProfile = False def _initGUI(self): self.setWindowTitle("Profile Creation") self.profileWidget = ProfileFormWidget() self.buttonBox = QDialogButtonBox(QDialogButtonBox.Cancel) self.okBtn = QPushButton("Ok") self.okBtn.setDefault(True) self.okBtn.clicked.connect(self._createProfile) self.buttonBox.addButton(self.okBtn, QDialogButtonBox.AcceptRole) vLayout = QVBoxLayout() vLayout.addWidget(QLabel("<h3>Create a new profile!</h3><hr>")) vLayout.addWidget(self.profileWidget) vLayout.addWidget(self.buttonBox) self.setLayout(vLayout) def _createProfile(self): athleteProfile = self.profileWidget.getProfile() self.profileCreated.emit(athleteProfile)
class ProfileCreation(QDialog): ''' classdocs ''' profileCreated = Signal(Athlete) def __init__(self): ''' Constructor ''' QDialog.__init__(self) self._initGUI() self.athleteProfile = False def _initGUI(self): self.setWindowTitle("Profile Creation") self.profileWidget = ProfileFormWidget() self.buttonBox = QDialogButtonBox(QDialogButtonBox.Cancel) self.okBtn = QPushButton("Ok") self.okBtn.setDefault(True) self.okBtn.clicked.connect(self._createProfile) self.buttonBox.addButton(self.okBtn, QDialogButtonBox.AcceptRole) vLayout = QVBoxLayout() vLayout.addWidget(QLabel("<h3>Create a new profile!</h3><hr>")) vLayout.addWidget(self.profileWidget) vLayout.addWidget(self.buttonBox) self.setLayout(vLayout) def _createProfile(self): athleteProfile = self.profileWidget.getProfile() self.profileCreated.emit(athleteProfile)
def __init__(self): super(DirectoryDialog, self).__init__() self.setWindowTitle("Query") rect = QApplication.desktop().screenGeometry() height = rect.height() width = rect.width() self.setGeometry(width / 3, height / 3, width / 3, height / 8) formLayout = QFormLayout() self.dir = QLineEdit() self.dir.setReadOnly(True) formLayout.addRow(QLabel("Select a folder"), self.dir) browseBtn = QPushButton("Browse") browseBtn.clicked.connect(self.browseAction) formLayout.addWidget(browseBtn) btnOk = QPushButton("Ok") btnOk.clicked.connect(self.okAction) btnCancel = QPushButton("Cancel") btnCancel.clicked.connect(self.reject) group = QDialogButtonBox() group.addButton(btnOk, QDialogButtonBox.AcceptRole) group.addButton(btnCancel, QDialogButtonBox.RejectRole) formLayout.addRow(group) self.setLayout(formLayout) self.setWindowIcon(QIcon("res/SplashScreen.png")) self.__result = None
class GiveNewNameDialog(QDialog): def __init__(self, parent): super(GiveNewNameDialog, self).__init__() self.setWindowTitle(_("Choose filter's name")) layout = QVBoxLayout(self) layout.addWidget(QLabel(_("Please give a name to the filter"))) self.line_edit = QLineEdit() layout.addWidget(self.line_edit) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.StandardButton.Cancel) self.buttons.addButton(QDialogButtonBox.Ok) layout.addWidget(self.buttons) self.setLayout(layout) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) @Slot() def accept(self): if self.line_edit.text().strip(): return super(GiveNewNameDialog, self).accept() @Slot() def reject(self): return super(GiveNewNameDialog, self).reject()
def layoutWidgets(self): layout = QVBoxLayout() layout.addWidget(self.tabWidget) layout.addStretch() buttonBox = QDialogButtonBox() buttonBox.addButton(self.helpButton, QDialogButtonBox.HelpRole) buttonBox.addButton(self.closeButton, QDialogButtonBox.AcceptRole) layout.addWidget(buttonBox) self.setLayout(layout)
class AboutDialog(QDialog): def __init__(self, parent): super(AboutDialog, self).__init__(parent) title = _("About {}...").format(configuration.get("Globals", "name")) self.setWindowTitle(title) top_layout = QVBoxLayout() self.title_widget = TitleWidget(title, self) top_layout.addWidget(self.title_widget) text = QLabel(u"{}<br/>Version : {}<br/><br/>".format( copyright(), str(configuration.this_version)) + _("""This program is given to you with a few important freedoms and duties as specified in the license below. <b>We believe they will help to make a better world</b>. They are also <b>legally binding</b> (see Free Software Foundation's website), so make sure you read the license carefully. We give you the right to <ul> <li>run the program,</li> <li>inspect it to make sure it is safe to use,</li> <li>modify it to suit your needs,</li> <li>distribute copies of it,</li> </ul> as long as you give those freedoms and duties to anybody you give this program to. """)) text.setTextFormat(Qt.RichText) text.setWordWrap(True) # text.setMaximumWidth(400) top_layout.addWidget(text) browser = QTextBrowser() browser.setLineWrapMode(QTextEdit.NoWrap) browser.setPlainText(license()) browser.setMinimumWidth(browser.document().documentLayout(). documentSize().toSize().width()) browser.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) top_layout.addWidget(browser) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.Ok) top_layout.addWidget(self.buttons) self.setLayout(top_layout) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) @Slot() def accept(self): self.deleteLater() return super(AboutDialog, self).accept() @Slot() def reject(self): self.deleteLater() return super(AboutDialog, self).reject()
def __init__(self): ''' Constructor ''' super(LoginDialog, self).__init__() formLayout = QFormLayout() self.input1 = QLineEdit() self.input2 = QLineEdit() self.input2.setEchoMode(QLineEdit.EchoMode.Password) self.input3 = QLineEdit() self.input3.setEchoMode(QLineEdit.EchoMode.Password) self.cb = QComboBox() self.cb.addItems(["Sef stanice", "Radnik u centrali", "Radnik na naplatnom mestu", "Admin"]) palete = QPalette() palete.setColor(self.backgroundRole(), Qt.black) self.setPalette(palete) self.setWindowTitle("Login") self.resize(370, 100) label2 = QLabel("<font color='White'>Username</font>") label3 = QLabel("<font color='White'>Password</font>") label4 = QLabel("<font color='White'>Registration key</font>") label5 = QLabel("<font color='White'>Role</font>") formLayout.addRow(label2, self.input1) formLayout.addRow(label3, self.input2) btnOK = QPushButton("Login") btnOK.clicked.connect(self.loginAction) btnCancel = QPushButton("Cancel") btnCancel.clicked.connect(self.reject) btnRegister = QPushButton("Register") btnRegister.clicked.connect(self.registerAction) group = QDialogButtonBox() group.addButton(btnOK, QDialogButtonBox.AcceptRole) group.addButton(btnCancel, QDialogButtonBox.RejectRole) formLayout.addRow(group) formLayout.addRow(label4, self.input3) formLayout.addRow(label5, self.cb) formLayout.addWidget(btnRegister) self.result = None self.setLayout(formLayout)
class HelpDialog(QDialog): def __init__(self,parent): super(HelpDialog,self).__init__(parent) title = _("A bit of help") self.setWindowTitle(title) top_layout = QVBoxLayout() self.title_widget = TitleWidget(title,self) top_layout.addWidget(self.title_widget) browser = QTextBrowser() import os.path from koi.Configurator import resource_dir with open( os.path.join(resource_dir,"manual.html"), encoding='utf-8') as input: html = input.read() browser.setHtml(html) # browser.setLineWrapMode(QTextEdit.NoWrap) # browser.setHtml("""<h1>Tables</h1> # # In tables you can edit, don't forget these few useful shortcuts : # <ul> # <li><b>F5</b> : will insert a line under your cursor</li> # <li><b>Shift + F5</b> : will append a line at the end of the table</li> # <li><b>F8</b> : will delete the line under your cursor (if you're allowed to)</li> # <li><b>F1</b> and <b>Shift + F1</b> : will allow you to move up/move down a row </li> # </ul> # """) # browser.setMinimumWidth(browser.document().documentLayout().documentSize().toSize().width()) browser.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) top_layout.addWidget(browser) self.buttons = QDialogButtonBox() self.buttons.addButton( QDialogButtonBox.Ok) top_layout.addWidget(self.buttons) self.setLayout(top_layout) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) @Slot() def accept(self): self.deleteLater() return super(HelpDialog,self).accept() @Slot() def reject(self): self.deleteLater() return super(HelpDialog,self).reject()
class NonConformityDialog(QDialog): def set_blank_quality_issue(self, kind, order_part_id): order_part_dto = dao.order_part_dao.find_by_id_frozen(order_part_id) self.current_qe = make_quality_event_dto(kind, order_part_dto.order_part_id) self._explanation.setText( _("<p>Please fill in some details about the non conformity. This non conformity is concerns</p> <p> <b>{}</b> : {}</p>" ).format(order_part_dto.human_identifier, order_part_dto.description)) self._quality_widget.set_quality_issue(self.current_qe) def quality_event(self): return self.current_qe def __init__(self, parent, remote_documents_service): super(NonConformityDialog, self).__init__(parent) self._quality_widget = Nonconformity2Widget(self, remote_documents_service) title = _("Create a non conformity") self.setWindowTitle(title) top_layout = QVBoxLayout() self.title_widget = TitleWidget(title, self) top_layout.addWidget(self.title_widget) self._explanation = QLabel() self._explanation.setWordWrap(True) top_layout.addWidget(self._explanation) top_layout.addWidget(self._quality_widget) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.Ok) self.buttons.addButton(QDialogButtonBox.Cancel) top_layout.addWidget(self.buttons) self.setLayout(top_layout) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) @Slot() def accept(self): return super(NonConformityDialog, self).accept() @Slot() def reject(self): return super(NonConformityDialog, self).reject()
def __init__(self, log, parent=None): super(EditConfigurationDialog, self).__init__(parent) layout = QVBoxLayout() self._log = log self.text_edit_widget = QTextEdit() layout.addWidget(self.text_edit_widget) buttons = QDialogButtonBox() # buttons.addButton( QDialogButtonBox.StandardButton.Cancel) buttons.addButton(QDialogButtonBox.StandardButton.Save) layout.addWidget(buttons) buttons.button(QDialogButtonBox.StandardButton.Save).clicked.connect( self._save) self.setLayout(layout)
def _create_buttons(self, dialog, layout): """ Creates the buttons. """ if not (self.can_cancel or self.can_ok): return # Create the button. buttons = QDialogButtonBox() if self.can_cancel: cancel_button = buttons.addButton(self.cancel_button_label, QDialogButtonBox.RejectRole) cancel_button.clicked.connect(self.cancel) if self.can_ok: ok_button = buttons.addButton(QDialogButtonBox.Ok) ok_button.clicked.connect(self.accept) layout.addWidget(buttons)
class AskWindowsShare(QDialog): def __init__(self, parent): super(AskWindowsShare, self).__init__() layout = QVBoxLayout(self) layout.addWidget( QLabel( "Please give the connection parameter to the Windows share.<br/>" + "The address is the regular Windows network address, for example : //the-server/Share<br/>" + "You can also use IP addresses : //192.168.0.86/horse_backup")) glayout = QGridLayout() self.address = QLineEdit() glayout.addWidget(QLabel("Address"), 0, 0) glayout.addWidget(self.address, 0, 1) self.user = QLineEdit() glayout.addWidget(QLabel("User name"), 1, 0) glayout.addWidget(self.user, 1, 1) self.password = QLineEdit() glayout.addWidget(QLabel("Password"), 2, 0) glayout.addWidget(self.password, 2, 1) layout.addLayout(glayout) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.Ok) self.buttons.addButton(QDialogButtonBox.Cancel) layout.addWidget(self.buttons) self.setLayout(layout) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) @Slot() def accept(self): return super(AskWindowsShare, self).accept() @Slot() def reject(self): return super(AskWindowsShare, self).reject()
class AboutDemoDialog(QDialog): def __init__(self, parent): super(AboutDemoDialog, self).__init__(parent) title = _("Welcome to {}...").format( configuration.get("Globals", "name")) self.setWindowTitle(title) top_layout = QVBoxLayout() self.title_widget = TitleWidget(title, self) top_layout.addWidget(self.title_widget) text = QLabel( _(""" <p>Welcome to the demo of {0}. This demo is fully functional and it comes with an example database. That should be enough to have a full tour of {0}.</p> <p>The first screen you'll see is a list of orders that were done in our imaginary company. If you double click on one of them, you'll see its details. From there on, you can browse around and test everything.</p> <p>As it is the demo version, all the data you'll change will be visible on internet. The demonstration database will be reased from time to time.</p> <p>Enjoy and feel free to contact us in case of problems : <a href="mailto:[email protected]">[email protected]</a></p> """).format(configuration.get("Globals", "name"))) text.setTextFormat(Qt.RichText) text.setWordWrap(True) top_layout.addWidget(text) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.Ok) top_layout.addWidget(self.buttons) self.setLayout(top_layout) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) @Slot() def accept(self): self.deleteLater() return super(AboutDemoDialog, self).accept() @Slot() def reject(self): self.deleteLater() return super(AboutDemoDialog, self).reject()
def _create_buttons(self, dialog, layout): """ Creates the buttons. """ if not (self.can_cancel or self.can_ok): return # Create the button. buttons = QDialogButtonBox() if self.can_cancel: cancel_button = buttons.addButton(self.cancel_button_label, QDialogButtonBox.RejectRole) cancel_button.clicked.connect(self.cancel) if self.can_ok: ok_button = buttons.addButton(QDialogButtonBox.Ok) ok_button.clicked.connect(self.accept) layout.addWidget(buttons)
class ChangePasswordDialog(QDialog): """Represents change password dialog window""" def __init__(self, window, ok_handler, cancel_handler): super(ChangePasswordDialog, self).__init__(window) self.setWindowTitle("Change password") self.setFixedSize(300, 160) self.setModal(True) self.layout = QGridLayout(self) self.old_password_label = QLabel(self) self.old_password_label.setText("Old password") self.edit_old_password = QLineEdit(self) self.edit_old_password.setEchoMode(QLineEdit.Password) self.password_label = QLabel(self) self.password_label.setText("New password") self.edit_password = QLineEdit(self) self.edit_password.setEchoMode(QLineEdit.Password) self.confirm_label = QLabel(self) self.confirm_label.setText("Confirm password") self.edit_confirm = QLineEdit(self) self.edit_confirm.setEchoMode(QLineEdit.Password) self.buttons = QDialogButtonBox(self) self.buttons.addButton(QDialogButtonBox.Ok) self.buttons.addButton(QDialogButtonBox.Cancel) self.buttons.button(QDialogButtonBox.Ok).setText("Change") self.buttons.button(QDialogButtonBox.Cancel).setText("Cancel") self.buttons.button(QDialogButtonBox.Cancel).clicked.connect(cancel_handler) self.buttons.button(QDialogButtonBox.Ok).clicked.connect( lambda: ok_handler(self.edit_old_password.text(), self.edit_password.text(), self.edit_confirm.text())) self.layout.addWidget(self.old_password_label, 0, 0) self.layout.addWidget(self.edit_old_password, 0, 1) self.layout.addWidget(self.password_label, 1, 0) self.layout.addWidget(self.edit_password, 1, 1) self.layout.addWidget(self.confirm_label, 2, 0) self.layout.addWidget(self.edit_confirm, 2, 1) self.layout.addWidget(self.buttons, 3, 0, 1, 2, Qt.AlignCenter) self.setLayout(self.layout)
class MonthTimeCorrectionDialog(QDialog): def __init__(self, parent): super(MonthTimeCorrectionDialog, self).__init__(parent) self.setWindowTitle(_("Correction for month")) self.info = QLabel(_("Correction for month"), self) self.info.setWordWrap(True) self.correction_time_widget = DurationEdit(self) form_layout = QFormLayout() form_layout.addRow(_("Correction (hours)"), self.correction_time_widget) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.Ok) self.buttons.addButton(QDialogButtonBox.Cancel) self.buttons.accepted.connect(self.save_and_accept) self.buttons.rejected.connect(self.cancel) top_layout = QVBoxLayout() top_layout.addWidget(self.info) top_layout.addLayout(form_layout) top_layout.addWidget(self.buttons) self.setLayout(top_layout) def set_data(self, employee_fullname, d, correction): self.year = d.year self.month = d.month self.info.setText( _("Correction for {} on {}").format(employee_fullname, date_to_my(d, True))) self.correction_time_widget.setText(str(correction)) @Slot() def save_and_accept(self): self.correction_time = self.correction_time_widget.value() return super(MonthTimeCorrectionDialog, self).accept() @Slot() def cancel(self): self.correction_time = 0 return super(MonthTimeCorrectionDialog, self).reject()
def layoutWidgets(self): buttonBox = QDialogButtonBox() buttonBox.addButton(self.recreateButton, QDialogButtonBox.ActionRole) buttonBox.addButton(self.deleteButton, QDialogButtonBox.ActionRole) buttonBox.addButton(self.closeButton, QDialogButtonBox.AcceptRole) buttonBox.addButton(self.helpButton, QDialogButtonBox.HelpRole) layout = QVBoxLayout() layout.addWidget(self.listWidget) layout.addWidget(self.recreateSubentriesCheckBox) layout.addWidget(buttonBox) self.setLayout(layout)
def nowords(self): label = QLabel("<p>No ignored or index dictionary words to " "remove") self.helpButton = QPushButton(QIcon(":/help.svg"), "Help") self.helpButton.clicked.connect(self.help) self.tooltips.append((self.helpButton, "Help on the Forget Spelling Words dialog")) closeButton = QPushButton(QIcon(":/dialog-close.svg"), "&Close") self.tooltips.append((closeButton, """<p><b>Close</b></p> <p>Close the dialog.</p>""")) buttonBox = QDialogButtonBox() buttonBox.addButton(closeButton, QDialogButtonBox.RejectRole) buttonBox.rejected.connect(self.reject) buttonBox.addButton(self.helpButton, QDialogButtonBox.HelpRole) layout = QVBoxLayout() layout.addWidget(label) layout.addWidget(buttonBox) self.setLayout(layout)
class DeleteLastDeliverySlipDialog(QDialog): def __init__(self,parent): global dao super(DeleteLastDeliverySlipDialog,self).__init__(parent) title = _("Delete the last delivery slip") self.setWindowTitle(title) top_layout = QVBoxLayout() self.title_widget = TitleWidget(title,self) top_layout.addWidget(self.title_widget) self.info_label = QLabel() self.info_label.setWordWrap(True) top_layout.addWidget(self.info_label) self.buttons = QDialogButtonBox() self.buttons.addButton( QDialogButtonBox.StandardButton.Cancel) self.buttons.addButton( QDialogButtonBox.Ok) top_layout.addWidget(self.buttons) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) self.setLayout(top_layout) def set_last_id(self,last_id): self.last_id = dao.delivery_slip_part_dao.find_last_slip_id() self.info_label.setText(_("You're about to delete the delivery slip number {}. Do you confirm ?").format(self.last_id)) @Slot() def accept(self): try: dao.delivery_slip_part_dao.delete_last(self.last_id) super(DeleteLastDeliverySlipDialog,self).accept() except DataException as ex: showErrorBox(_("Unable to delete the last delivery slip"), str(ex)) super(DeleteLastDeliverySlipDialog,self).reject()
def layoutWidgets(self): layout = QVBoxLayout() hbox = QHBoxLayout() hbox.addWidget(self.filenameLabelLabel) hbox.addWidget(self.filenameLabel, 1) hbox.addWidget(self.filenameButton) layout.addLayout(hbox) grid = QGridLayout() grid.addWidget(self.configCheckBox, 0, 0) grid.addWidget(self.autoReplaceCheckBox, 0, 1) grid.addWidget(self.spellWordsCheckBox, 1, 0) grid.addWidget(self.ignoredFirstWordsCheckBox, 1, 1) grid.addWidget(self.groupsCheckBox, 2, 0) grid.addWidget(self.customMarkupCheckBox, 2, 1) hbox = QHBoxLayout() hbox.addLayout(grid) hbox.addStretch() self.copyGroupBox.setLayout(hbox) layout.addWidget(self.copyGroupBox) layout.addStretch() buttonBox = QDialogButtonBox() buttonBox.addButton(self.newCopyButton, QDialogButtonBox.AcceptRole) buttonBox.addButton(self.cancelButton, QDialogButtonBox.RejectRole) buttonBox.addButton(self.helpButton, QDialogButtonBox.HelpRole) layout.addWidget(buttonBox) self.setLayout(layout)
def _create_buttons ( self, dialog, layout ): """ Creates the buttons. """ # Create the button: buttons = QDialogButtonBox() if self.can_cancel: buttons.addButton( self.cancel_button_label, QDialogButtonBox.RejectRole ) buttons.addButton( QDialogButtonBox.Ok ) # TODO: hookup the buttons to our methods, this may involve subclassing # from QDialog if self.can_cancel: buttons.connect( buttons, SIGNAL( 'rejected()' ), dialog, SLOT( 'reject() ' ) ) buttons.connect( buttons, SIGNAL( 'accepted()' ), dialog, SLOT( 'accept()' ) ) layout.addWidget( buttons )
class SignInDialog(QDialog): """Represents sign in dialog window""" def __init__(self, window, ok_handler, cancel_handler): super(SignInDialog, self).__init__(window) self.setWindowTitle("Login") self.setFixedSize(300, 130) self.setModal(True) self.layout = QGridLayout(self) self.username_label = QLabel(self) self.username_label.setText("Username:"******"Password:"******"Login") self.buttons.button(QDialogButtonBox.Cancel).setText("Cancel") self.buttons.button(QDialogButtonBox.Cancel).clicked.connect(cancel_handler) self.buttons.button(QDialogButtonBox.Ok).clicked.connect( lambda: ok_handler(self.edit_username.text(), self.edit_password.text())) self.layout.addWidget(self.username_label, 0, 0) self.layout.addWidget(self.edit_username, 0, 1) self.layout.addWidget(self.password_label, 1, 0) self.layout.addWidget(self.edit_password, 1, 1) self.layout.addWidget(self.buttons, 3, 0, 1, 2, Qt.AlignCenter) self.setLayout(self.layout)
def layoutWidgets(self): buttonBox = QDialogButtonBox() buttonBox.addButton(self.helpButton, QDialogButtonBox.HelpRole) buttonBox.addButton(self.addButton, QDialogButtonBox.ActionRole) buttonBox.addButton(self.deleteButton, QDialogButtonBox.ActionRole) buttonBox.addButton(self.closeButton, QDialogButtonBox.AcceptRole) hbox = QHBoxLayout() hbox.addWidget(self.extensionLabel) hbox.addWidget(self.extensionComboBox) hbox.addStretch() hbox.addWidget(buttonBox) vbox = QVBoxLayout() vbox.addLayout(hbox) vbox.addWidget(self.tabWidget, 1) self.setLayout(vbox)
class DatePick(QDialog): def accept(self, *args, **kwargs): return super(DatePick,self).accept() def reject(self, *args, **kwargs): return super(DatePick,self).reject() @Slot(date) def date_chosen(self, chosen_date): self.accepted_date = date( chosen_date.year(), chosen_date.month(), chosen_date.day()) self.accept() def resizeEvent(self, *args, **kwargs): self.info_label.setMaximumWidth( self.qw.width()) def __init__(self, info_text, no_date_allowed = True): super(DatePick, self).__init__() self.accepted_date = None layout = QVBoxLayout() title = _("Pick a date") self.setWindowTitle(title) layout.addWidget(TitleWidget(title, self)) self.info_label =QLabel(info_text) self.qw = QCalendarWidget() self.info_label.setWordWrap(True) self.info_label.setMaximumWidth(self.qw.minimumWidth()) layout.addWidget( self.info_label) layout.addWidget( self.qw) self.qw.activated.connect(self.date_chosen) self.buttons = QDialogButtonBox() if no_date_allowed: self.buttons.addButton( QPushButton("No date"), QDialogButtonBox.ButtonRole.AcceptRole) self.buttons.addButton( QDialogButtonBox.StandardButton.Cancel) self.buttons.addButton( QDialogButtonBox.Ok) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) layout.addWidget(self.buttons) layout.addStretch() self.setLayout(layout)
class ChooseSupplierDialog(QDialog): @Slot(QModelIndex) def _item_selected(self, ndx): self.accept() def __init__(self, parent): global dao super(ChooseSupplierDialog, self).__init__(parent) title = _("Choose supplier") self.setWindowTitle(title) top_layout = QVBoxLayout() self.title_widget = TitleWidget(title, self) top_layout.addWidget(self.title_widget) self.supplier_plate_widget = SupplierContactDataWidget(self) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.StandardButton.Cancel) self.buttons.addButton(QDialogButtonBox.Ok) hlayout = QHBoxLayout() # suppliers = dao.supplier_dao.all_frozen() suppliers = generic_load_all_frozen(Supplier, Supplier.fullname) table_prototype = [ TextLinePrototype('fullname', _('Name'), editable=False) ] self.filter_view = QuickPrototypedFilter(table_prototype, self) self.filter_view.selected_object_changed.connect( self.supplier_plate_widget.set_contact_data) self.filter_view.set_data(suppliers, lambda c: c.indexed_fullname) hlayout.addWidget(self.filter_view) hlayout.addWidget(self.supplier_plate_widget, 1000) # hlayout.addStretch() top_layout.addLayout(hlayout) #top_layout.addStretch() top_layout.addWidget(self.buttons) self.setLayout(top_layout) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) self.filter_view.list_view.doubleClicked.connect(self._item_selected) # self.supplier_plate_widget.set_contact_data(suppliers[0]) @Slot() def accept(self): self.supplier_id = None self.supplier = None if self.filter_view.last_selected_object: supplier_id = self.filter_view.last_selected_object.supplier_id else: supplier_id = None if supplier_id is None: msgBox = makeErrorBox( _("Please choose a supplier for the new order")) msgBox.exec_() super(ChooseSupplierDialog, self).reject() return False mainlog.debug( "ChooseSupplierDialog.accept() : supplier_id = {}".format( supplier_id)) self.supplier_id = supplier_id self.supplier = self.filter_view.last_selected_object return super(ChooseSupplierDialog, self).accept() @Slot() def reject(self): self.supplier_id = None return super(ChooseSupplierDialog, self).reject()
class Dialog(QDialog): def __init__(self): super(Dialog, self).__init__() self.rotableWidgets = [] self.createRotableGroupBox() self.createOptionsGroupBox() self.createButtonBox() mainLayout = QGridLayout() mainLayout.addWidget(self.rotableGroupBox, 0, 0) mainLayout.addWidget(self.optionsGroupBox, 1, 0) mainLayout.addWidget(self.buttonBox, 2, 0) mainLayout.setSizeConstraint(QLayout.SetMinimumSize) self.mainLayout = mainLayout self.setLayout(self.mainLayout) self.setWindowTitle("Dynamic Layouts") def rotateWidgets(self): count = len(self.rotableWidgets) if count % 2 == 1: raise AssertionError("Number of widgets must be even") for widget in self.rotableWidgets: self.rotableLayout.removeWidget(widget) self.rotableWidgets.append(self.rotableWidgets.pop(0)) for i in range(count//2): self.rotableLayout.addWidget(self.rotableWidgets[count - i - 1], 0, i) self.rotableLayout.addWidget(self.rotableWidgets[i], 1, i) def buttonsOrientationChanged(self, index): self.mainLayout.setSizeConstraint(QLayout.SetNoConstraint); self.setMinimumSize(0, 0); orientation = Qt.Orientation(int(self.buttonsOrientationComboBox.itemData(index))) if orientation == self.buttonBox.orientation(): return self.mainLayout.removeWidget(self.buttonBox); spacing = self.mainLayout.spacing() oldSizeHint = self.buttonBox.sizeHint() + QSize(spacing, spacing); self.buttonBox.setOrientation(orientation) newSizeHint = self.buttonBox.sizeHint() + QSize(spacing, spacing) if orientation == Qt.Horizontal: self.mainLayout.addWidget(self.buttonBox, 2, 0); self.resize(self.size() + QSize(-oldSizeHint.width(), newSizeHint.height())) else: self.mainLayout.addWidget(self.buttonBox, 0, 3, 2, 1); self.resize(self.size() + QSize(newSizeHint.width(), -oldSizeHint.height())) self.mainLayout.setSizeConstraint(QLayout.SetDefaultConstraint) def show_help(self): QMessageBox.information(self, "Dynamic Layouts Help", "This example shows how to change layouts " "dynamically.") def createRotableGroupBox(self): self.rotableGroupBox = QGroupBox("Rotable Widgets") self.rotableWidgets.append(QSpinBox()) self.rotableWidgets.append(QSlider()) self.rotableWidgets.append(QDial()) self.rotableWidgets.append(QProgressBar()) count = len(self.rotableWidgets) for i in range(count): self.rotableWidgets[i].valueChanged[int].\ connect(self.rotableWidgets[(i+1) % count].setValue) self.rotableLayout = QGridLayout() self.rotableGroupBox.setLayout(self.rotableLayout) self.rotateWidgets() def createOptionsGroupBox(self): self.optionsGroupBox = QGroupBox("Options") buttonsOrientationLabel = QLabel("Orientation of buttons:") buttonsOrientationComboBox = QComboBox() buttonsOrientationComboBox.addItem("Horizontal", Qt.Horizontal) buttonsOrientationComboBox.addItem("Vertical", Qt.Vertical) buttonsOrientationComboBox.currentIndexChanged[int].connect(self.buttonsOrientationChanged) self.buttonsOrientationComboBox = buttonsOrientationComboBox optionsLayout = QGridLayout() optionsLayout.addWidget(buttonsOrientationLabel, 0, 0) optionsLayout.addWidget(self.buttonsOrientationComboBox, 0, 1) optionsLayout.setColumnStretch(2, 1) self.optionsGroupBox.setLayout(optionsLayout) def createButtonBox(self): self.buttonBox = QDialogButtonBox() closeButton = self.buttonBox.addButton(QDialogButtonBox.Close) helpButton = self.buttonBox.addButton(QDialogButtonBox.Help) rotateWidgetsButton = self.buttonBox.addButton("Rotate &Widgets", QDialogButtonBox.ActionRole) rotateWidgetsButton.clicked.connect(self.rotateWidgets) closeButton.clicked.connect(self.close) helpButton.clicked.connect(self.show_help)
class Form(QDialog): def __init__(self, state, parent=None): super().__init__(parent) Lib.prepareModalDialog(self) self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding) self.setWindowTitle("Copy Character — {}".format( QApplication.applicationName())) QShortcut(QKeySequence(QKeySequence.FindNext), self, self.findNext) self.state = state self.createWidgets() self.layoutWidgets() self.createConnections() self.findSizes(self.fontComboBox.currentFont()) self.setToFamily(self.state.stdFontFamily) self.setToNearestSize(self.state.stdFontSize) settings = QSettings() self.updateToolTips( bool( int( settings.value(Gopt.Key.ShowDialogToolTips, Gopt.Default.ShowDialogToolTips)))) def createWidgets(self): self.fontLabel = QLabel("Fon&t:") self.fontComboBox = QFontComboBox() self.tooltips.append((self.fontComboBox, """\ <p><b>Font</b></p> <p>The font for displaying the characters.</p>""")) self.fontLabel.setBuddy(self.fontComboBox) self.sizeLabel = QLabel("&Size:") self.sizeComboBox = QComboBox() self.tooltips.append((self.sizeComboBox, """\ <p><b>Size</b></p> <p>The size of font for displaying the characters.</p>""")) self.sizeLabel.setBuddy(self.sizeComboBox) self.scrollArea = QScrollArea() self.scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.panel = Panel() self.scrollArea.setWidget(self.panel) self.copyTextLabel = QLabel("Copy T&ext") self.copyTextLineEdit = QLineEdit() self.tooltips.append((self.copyTextLineEdit, """\ <p><b>Copy Text editor</b></p> <p>The text for copying to the clipboard when <b>Copy</b> is pressed.</p>""")) self.copyTextLabel.setBuddy(self.copyTextLineEdit) self.findTextLabel = QLabel("&Find Text") self.findTextLineEdit = QLineEdit() self.tooltips.append((self.findTextLineEdit, """\ <p><b>Find Text editor</b></p> <p>The name or partial name of Unicode characters to be found, e.g., “star” will match many characters, including U+22C6 “Star operator”.</p>""")) self.findTextLabel.setBuddy(self.findTextLineEdit) self.buttonBox = QDialogButtonBox() self.addSelectedButton = QPushButton(QIcon(":/add.svg"), "&Add Selected") self.tooltips.append((self.addSelectedButton, """\ <p><b>Add Selected</b></p> <p>Append the selected character to the <b>Copy Text</b> editor.</p>""")) self.buttonBox.addButton(self.addSelectedButton, QDialogButtonBox.ActionRole) self.findNextButton = QPushButton(QIcon(":/edit-find.svg"), "Find &Next") self.tooltips.append((self.findNextButton, """\ <p><b>Find Next</b></p> <p>Find the next character whose Unicode name contains or equals the <b>Find Text</b>.</p>""")) self.buttonBox.addButton(self.findNextButton, QDialogButtonBox.ActionRole) self.helpButton = QPushButton(QIcon(":/help.svg"), "Help") self.tooltips.append( (self.helpButton, "Help on the Copy Character dialog")) self.buttonBox.addButton(self.helpButton, QDialogButtonBox.HelpRole) self.closeButton = QPushButton(QIcon(":/dialog-close.svg"), "&Close") self.tooltips.append((self.closeButton, """<p><b>Cancel</b></p> <p>Close the dialog.</p>""")) self.buttonBox.addButton(self.closeButton, QDialogButtonBox.RejectRole) def layoutWidgets(self): topLayout = QHBoxLayout() topLayout.addWidget(self.fontLabel) topLayout.addWidget(self.fontComboBox, 1) topLayout.addWidget(self.sizeLabel) topLayout.addWidget(self.sizeComboBox) bottomLayout = QHBoxLayout() bottomLayout.addWidget(self.copyTextLabel) bottomLayout.addWidget(self.copyTextLineEdit) bottomLayout.addWidget(self.findTextLabel) bottomLayout.addWidget(self.findTextLineEdit) layout = QVBoxLayout() layout.addLayout(topLayout) layout.addWidget(self.scrollArea, 1) layout.addLayout(bottomLayout) layout.addWidget(self.buttonBox) self.setLayout(layout) def createConnections(self): self.fontComboBox.activated[str].connect(self.panel.updateFont) self.sizeComboBox.currentIndexChanged[str].connect( self.panel.updateSize) self.panel.characterSelected.connect(self.copyTextLineEdit.insert) self.panel.fontResized.connect(self.updateSize) self.addSelectedButton.clicked.connect(self.addSelected) self.helpButton.clicked.connect(self.help) self.buttonBox.rejected.connect(self.accept) self.findNextButton.clicked.connect(self.findNext) self.findTextLineEdit.returnPressed.connect(self.findNext) def help(self): self.state.help("xix_ref_dlg_copychr.html") def findSizes(self, font): fontDatabase = QFontDatabase() currentSize = self.sizeComboBox.currentText() with Lib.BlockSignals(self.sizeComboBox): self.sizeComboBox.clear() if fontDatabase.isSmoothlyScalable(font.family(), fontDatabase.styleString(font)): for size in QFontDatabase.standardSizes(): self.sizeComboBox.addItem(str(size)) else: for size in fontDatabase.smoothSizes( font.family(), fontDatabase.styleString(font)): self.sizeComboBox.addItem(str(size)) self.sizeComboBox.setEditable(False) sizeIndex = self.sizeComboBox.findText(currentSize) if sizeIndex == -1: self.sizeComboBox.setCurrentIndex( max(0, self.sizeComboBox.count() / 3)) else: self.sizeComboBox.setCurrentIndex(sizeIndex) def accept(self): clipboard = QApplication.clipboard() text = self.copyTextLineEdit.text() or self.panel.currentChar clipboard.setText(text, QClipboard.Clipboard) clipboard.setText(text, QClipboard.Selection) if text: say("Copied “{}” to the clipboard".format(text), SAY_TIMEOUT) super().accept() def addSelected(self): char = self.panel.currentChar if char: self.copyTextLineEdit.setText(self.copyTextLineEdit.text() + char) self.findNextButton.setFocus() def setToFamily(self, family): family = family.casefold() for i in range(self.fontComboBox.count()): if self.fontComboBox.itemText(i).casefold() == family: self.fontComboBox.setCurrentIndex(i) break def setToNearestSize(self, size): below = 0 belowIndex = -1 above = 999 aboveIndex = -1 for i in range(self.sizeComboBox.count()): sz = int(self.sizeComboBox.itemText(i)) if sz == size: self.sizeComboBox.setCurrentIndex(i) break if sz < size and sz > below: below = sz belowIndex = i if sz > size and sz < above: above = sz aboveIndex = i else: if abs(size - below) < abs(size - above): self.sizeComboBox.setCurrentIndex(belowIndex) else: self.sizeComboBox.setCurrentIndex(aboveIndex) def findNext(self): text = self.findTextLineEdit.text().strip().casefold() if text: start = self.panel.currentChar start = ord(start) if start else ord(" ") for i in range(start + 1, MAX_CHAR): try: char = chr(i) name = unicodedata.name(char).casefold() if text in name: self.panel.currentChar = char self.panel.update() y = (self.panel.squareSize * i) // COLUMNS self.scrollArea.ensureVisible(0, y) break except ValueError: pass else: self.panel.currentChar = " " self.findNext() def keyPressEvent(self, event): key = event.key() if key in {Qt.Key_Enter, Qt.Key_Return}: if self.findTextLineEdit.text().strip(): self.findNext() else: self.addSelectedButton.setFocus() def updateSize(self, squareSize): self.setMinimumWidth((COLUMNS + (1.5 if WIN else 1)) * squareSize)
class EditTimeTracksDialog(QDialog): @Slot(QStandardItem) def data_changed_slot(self, item): # mainlog.debug("data_changed_slot") self.model_data_changed = True m = self.controller.model sum_hours = 0 for i in range(m.rowCount()): ndx = m.index(i, 2) #mainlog.debug("editTT : {}: {}".format(i, m.data(ndx,Qt.UserRole))) try: sum_hours = sum_hours + float(m.data(ndx, Qt.UserRole)) except: pass mainlog.debug("Sum = {}".format(sum_hours)) self.sum_hours_label.setText(duration_to_hm(sum_hours)) def __init__(self, parent, dao, day): super(EditTimeTracksDialog, self).__init__(parent) self.edit_date = day title = _("Time spent on tasks") self.setWindowTitle(title) top_layout = QVBoxLayout() self.title_widget = TitleWidget(title, self) top_layout.addWidget(self.title_widget) hlayout = QHBoxLayout() self.timesheet_info_label = QLabel("Name", self) hlayout.addWidget(self.timesheet_info_label) hlayout.addStretch() top_layout.addLayout(hlayout) info = QLabel( _("On the table below you can have two kinds of line. The grey line which shows the time spent on a task computed on the basis of the actual time recordings. Since those are computed automaticaly, you can't change them. The other lines in black, are those that you will encode have encoded yourself. They represent hours to add or remove to those of the grey lines. So, for example, if you want to remove 3 hours on a task, you encode the task with a duration of three hours." ), self) info.setWordWrap(True) top_layout.addWidget(info) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.StandardButton.Cancel) self.buttons.addButton(QDialogButtonBox.Ok) if dao.task_dao.tasks_count() > 0: prototype = [] prototype.append( ImputableSelectorPrototype(None, _('Order Part'), nullable=True)) # BUG today is wrong... Must be the imputation date self.task_on_orderpart_prototype = ProxyTaskComboPrototype( 'task', _('Task'), on_date=date.today(), editable=True, nullable=False) prototype.append(self.task_on_orderpart_prototype) prototype.append( DurationPrototype('duration', _('Duration'), format_as_float=False)) prototype.append( ConstrainedMachineSelectorPrototype('machine_id', _('Machine'), nullable=True)) # prototype.append( TimestampPrototype('start_time',_('Start time'),fix_date=day,nullable=True,editable=True)) # prototype.append( TimestampPrototype('encoding_date',_('Recorded at'),editable=False)) self.controller = PrototypeController(self, prototype) self.controller.setModel(TrackingProxyModel(self, prototype)) self.controller.view.horizontalHeader().setResizeMode( 1, QHeaderView.Stretch) self.controller.view.enable_edit_panel() self.controller.model.rowsInserted.connect(self.data_changed_slot) self.controller.model.rowsRemoved.connect(self.data_changed_slot) self.controller.model.dataChanged.connect(self.data_changed_slot) # self.employee_select = QComboBox() # self.employee_select.setModel(self.dao.employee_dao.list_model()) # self.employee_select.setCurrentIndex(0) # self.set_on_selected_employee() # top_layout.addWidget(self.employee_select) top_layout.addWidget( self.controller.view) # self.time_tracks_view) hlayout = QHBoxLayout() self.sum_hours_label = QLabel("12345") self.sum_hours_label.setObjectName("important") # Used for CSS hlayout.addStretch() hlayout.addWidget(QLabel(_("Sum of durations"))) hlayout.addWidget(self.sum_hours_label) top_layout.addLayout(hlayout) top_layout.addWidget(self.buttons) self.setLayout(top_layout) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) # self.employee_select.activated.connect(self.employee_changed) self.resize(800, 400) self.setSizeGripEnabled(True) else: top_layout.addWidget( QLabel( "There are no task in the system " + "for you to report on. Create some " + "tasks first", self)) top_layout.addWidget(self.buttons) self.setLayout(top_layout) self.buttons.accepted.connect(self.accept_direct) self.buttons.rejected.connect(self.reject) def keyPressEvent(self, event): # The goal here is to make sure the accept signal is called only # if the user clicks on the "OK" button /with the mouse/ and, # not with the keyboard. if event.key() in (Qt.Key_Enter, Qt.Key_Return): return else: super(EditTimeTracksDialog, self).keyPressEvent(event) def set_employee_and_date( self, employee_id, edit_date ): # FIXME move this into constructore and remove call in using class... Or change the timestamp prototype employee = dao.employee_dao.find_by_id_frozen(employee_id) timetracks = dao.timetrack_dao.all_work_for_employee_date( employee_id, edit_date) self.task_cache = PotentialTasksCache(dao.task_dao, edit_date) mainlog.debug("set_employee_and_date : timetracks are") proxified_timetracks = [] for timetrack in timetracks: mainlog.debug(timetrack) proxified_timetracks.append(TimetrackProxy(timetrack)) mainlog.debug("done") self.edit_date = edit_date self.task_on_orderpart_prototype.on_date = edit_date self.timesheet_info_label.setText( _("Timesheet for <b>{}</b> on <b>{}</b>").format( employee.fullname, date_to_s(edit_date, True))) self.task_on_orderpart_prototype.set_task_cache(self.task_cache) self.controller.model._buildModelFromObjects(proxified_timetracks) self.controller.model.set_row_protect_func( lambda obj, row: obj is not None and obj.managed_by_code, prevent_row_delete_message) self.controller.model.row_update_protect_func = lambda obj, row: obj and obj.managed_by_code self.controller.model.row_update_protect_announce = prevent_row_update_message for i in range(len(timetracks)): row = self.controller.model.table[i] imputable = ImputableProxy(edit_date) imputable.set_on_timetrack(timetracks[i]) row[0] = imputable # for row in self.controller.model.table: # if row[1]: # row[0] = row[1].operation.production_file.order_part # self.controller.model_data_changed = False # FIXME dirty (encapsulate in controller plz) self.current_employee_id_selected = employee_id self.controller.view.setFocus(Qt.OtherFocusReason) self.controller.view.setCurrentIndex(self.controller.model.index(0, 0)) # FIXME Better separate presentation and data layer !!! session().commit() self.data_changed_slot(None) # @Slot(int) # def employee_changed(self,ndx): # # Pay attention ! At this point the rdopdown already report the # # new selection, not the one that is used for the table ! # mainlog.debug("Employee changed to {}, was {}".format(ndx,employee)) # if self.current_employee_selected != ndx: # # Actually changed # if not self.model_data_changed: # self.set_on_selected_employee() # else: # ret = saveCheckBox() # if ret == QMessageBox.Save: # if self.save(): # self.set_on_selected_employee() # else: # self.employee_select.setCurrentIndex(self.current_employee_selected) # elif ret == QMessageBox.Cancel: # # User has cancelled or save didn't work out => we reset to the old value # self.employee_select.setCurrentIndex(self.current_employee_selected) # else: # QMessageBox.Discard # self.set_on_selected_employee() def save(self): mainlog.debug("EditTimeTracksDialog.save()") errors = self.controller.model.validate() if errors: showTableEntryErrorBox(errors) return False tt_start_time = datetime(self.edit_date.year, self.edit_date.month, self.edit_date.day, 6, 0, 0) edited_proxy_tts = self.controller.model.model_to_objects( lambda: TimetrackProxy()) employee_id = self.current_employee_id_selected # for tt in edited_proxy_tts: # mainlog.debug(type(tt)) # mainlog.debug(str(tt)) try: save_proxy_timetracks(edited_proxy_tts, tt_start_time, employee_id) return True except Exception as e: msgBox = QMessageBox(self) msgBox.setIcon(QMessageBox.Critical) msgBox.setText("There was an error while saving your data") msgBox.setInformativeText(str(e)) msgBox.setStandardButtons(QMessageBox.Ok) # msgBox.setDefaultButton(QMessageBox.Ok); ret = msgBox.exec_() return False @Slot() def accept(self): if self.save(): mainlog.debug("Clearing model {}".format(self.controller.model)) # Don't forget to clear the model so we don't keep any # references to anything self.controller.model.clear() return super(EditTimeTracksDialog, self).accept() else: mainlog.debug("accept was not accepted :-)") @Slot() def accept_direct(self): super(EditTimeTracksDialog, self).accept() self.controller.model.clear() @Slot() def reject(self): super(EditTimeTracksDialog, self).reject() self.controller.model.clear()
class AddPresetDialog(QDialog): def __init__(self, parent=None): super(AddPresetDialog, self).__init__(parent) self.setWindowTitle(self.tr("Add IMAP Server Preset")) self.resize(388, 125) self.buttonBox = QDialogButtonBox(self) self.buttonBox.setGeometry(QRect(184, 80, 181, 32)) self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setCenterButtons(False) self.save_btn = QPushButton("&Save") self.save_btn.setDefault(True) self.save_btn.setEnabled(False) self.cancel_btn = QPushButton(self.tr("&Cancel")) self.cancel_btn.setCheckable(True) self.cancel_btn.setAutoDefault(False) self.buttonBox.addButton(self.save_btn, QDialogButtonBox.AcceptRole) self.buttonBox.addButton(self.cancel_btn, QDialogButtonBox.RejectRole) self.preset_name_le = QLineEdit(self) self.preset_name_le.setGeometry(QRect(134, 12, 231, 20)) self.lb_name = QLabel(self) self.lb_name.setGeometry(QRect(14, 16, 58, 14)) self.lb_name.setText(self.tr("Name")) self.server_address_le = QLineEdit(self) self.server_address_le.setGeometry(QRect(134, 45, 231, 20)) self.lb_server = QLabel(self) self.lb_server.setGeometry(QRect(14, 48, 81, 16)) self.lb_server.setText(self.tr("IMAP Server")) self.lb_info = QLabel(self) self.lb_info.setGeometry(QRect(14, 90, 161, 16)) self.lb_info.setText(self.tr("(SSL is always on.)")) self.buttonBox.accepted.connect(self.act_save_preset) self.buttonBox.rejected.connect(self.reject) self.init_settings() self.settings.beginGroup("Server Presets") self.presetNameList = [] for preset in self.settings.allKeys(): self.presetNameList.append(preset) self.settings.endGroup() self.preset_name_le.textChanged.connect(self.check_preset_name_availability) self.server_address_le.textChanged.connect(self.check_server_address) # --------------------------------------------------------------------- def init_settings(self): QCoreApplication.setOrganizationName("erdinc.me") QCoreApplication.setOrganizationDomain("erdinc.me") QCoreApplication.setApplicationName("IMAPLinkParser") self.settings = QSettings() # self.settings.clear() # --------------------------------------------------------------------- @Slot() def act_save_preset(self): try: self.settings.beginGroup("Server Presets") self.settings.setValue(self.preset_name_le.text(), self.server_address_le.text()) self.settings.endGroup() except: self.reject() self.accept() # --------------------------------------------------------------------- @Slot(unicode) def check_preset_name_availability(self, text): if text in self.presetNameList: self.save_btn.setEnabled(False) self.lb_info.setText('<p style="color:red;">Preset name exists!') else: if self.server_address_le.text() and self.preset_name_le.text(): self.save_btn.setEnabled(True) self.lb_info.setText(self.tr("(SSL is always on.)")) else: self.save_btn.setEnabled(False) self.lb_info.setText(self.tr("(SSL is always on.)")) # --------------------------------------------------------------------- @Slot(unicode) def check_server_address(self): if self.server_address_le.text(): preset = self.preset_name_le.text() if preset and preset not in self.presetNameList: self.save_btn.setEnabled(True) else: self.save_btn.setEnabled(False)
class Dialog(QDialog): def __init__(self): super(Dialog, self).__init__() self.rotableWidgets = [] self.createRotableGroupBox() self.createOptionsGroupBox() self.createButtonBox() mainLayout = QGridLayout() mainLayout.addWidget(self.rotableGroupBox, 0, 0) mainLayout.addWidget(self.optionsGroupBox, 1, 0) mainLayout.addWidget(self.buttonBox, 2, 0) mainLayout.setSizeConstraint(QLayout.SetMinimumSize) self.mainLayout = mainLayout self.setLayout(self.mainLayout) self.setWindowTitle("Dynamic Layouts") def rotateWidgets(self): count = len(self.rotableWidgets) if count % 2 == 1: raise AssertionError("Number of widgets must be even") for widget in self.rotableWidgets: self.rotableLayout.removeWidget(widget) self.rotableWidgets.append(self.rotableWidgets.pop(0)) for i in range(count//2): self.rotableLayout.addWidget(self.rotableWidgets[count - i - 1], 0, i) self.rotableLayout.addWidget(self.rotableWidgets[i], 1, i) def buttonsOrientationChanged(self, index): self.mainLayout.setSizeConstraint(QLayout.SetNoConstraint); self.setMinimumSize(0, 0); orientation = Qt.Orientation(int(self.buttonsOrientationComboBox.itemData(index))) if orientation == self.buttonBox.orientation(): return self.mainLayout.removeWidget(self.buttonBox); spacing = self.mainLayout.spacing() oldSizeHint = self.buttonBox.sizeHint() + QSize(spacing, spacing); self.buttonBox.setOrientation(orientation) newSizeHint = self.buttonBox.sizeHint() + QSize(spacing, spacing) if orientation == Qt.Horizontal: self.mainLayout.addWidget(self.buttonBox, 2, 0); self.resize(self.size() + QSize(-oldSizeHint.width(), newSizeHint.height())) else: self.mainLayout.addWidget(self.buttonBox, 0, 3, 2, 1); self.resize(self.size() + QSize(newSizeHint.width(), -oldSizeHint.height())) self.mainLayout.setSizeConstraint(QLayout.SetDefaultConstraint) def show_help(self): QMessageBox.information(self, "Dynamic Layouts Help", "This example shows how to change layouts " "dynamically.") def createRotableGroupBox(self): self.rotableGroupBox = QGroupBox("Rotable Widgets") self.rotableWidgets.append(QSpinBox()) self.rotableWidgets.append(QSlider()) self.rotableWidgets.append(QDial()) self.rotableWidgets.append(QProgressBar()) count = len(self.rotableWidgets) for i in range(count): self.rotableWidgets[i].valueChanged[int].\ connect(self.rotableWidgets[(i+1) % count].setValue) self.rotableLayout = QGridLayout() self.rotableGroupBox.setLayout(self.rotableLayout) self.rotateWidgets() def createOptionsGroupBox(self): self.optionsGroupBox = QGroupBox("Options") buttonsOrientationLabel = QLabel("Orientation of buttons:") buttonsOrientationComboBox = QComboBox() buttonsOrientationComboBox.addItem("Horizontal", Qt.Horizontal) buttonsOrientationComboBox.addItem("Vertical", Qt.Vertical) buttonsOrientationComboBox.currentIndexChanged[int].connect(self.buttonsOrientationChanged) self.buttonsOrientationComboBox = buttonsOrientationComboBox optionsLayout = QGridLayout() optionsLayout.addWidget(buttonsOrientationLabel, 0, 0) optionsLayout.addWidget(self.buttonsOrientationComboBox, 0, 1) optionsLayout.setColumnStretch(2, 1) self.optionsGroupBox.setLayout(optionsLayout) def createButtonBox(self): self.buttonBox = QDialogButtonBox() closeButton = self.buttonBox.addButton(QDialogButtonBox.Close) helpButton = self.buttonBox.addButton(QDialogButtonBox.Help) rotateWidgetsButton = self.buttonBox.addButton("Rotate &Widgets", QDialogButtonBox.ActionRole) rotateWidgetsButton.clicked.connect(self.rotateWidgets) closeButton.clicked.connect(self.close) helpButton.clicked.connect(self.show_help)
def __init__(self, parent=None): """Default class constructor.""" super(AboutDialog, self).__init__(parent) p = self.palette() p.setColor(self.backgroundRole(), Qt.white) self.setPalette(p) if parent: self.gImgDir = parent.gImgDir self.gIconDir = parent.gIconDir elif __name__ == '__main__': self.gImgDir = gAppDir + os.sep + 'images' self.gIconDir = gAppDir + os.sep + 'icons' + os.sep + 'default' # The tiled theme background texture. self.bgLogo = QPixmap(self.gImgDir + os.sep + 'texture-spirals.png') self.bgBrush = QBrush(self.bgLogo) self.setWhatsThis(self.tr("""\ The background is a tiled image of an actual design that was stitched out during the pre-alpha stage. It was created by Nina Paley and Theodore Gray using Mathematica in conjunction with our software. They have graciously allowed us to use it for the project in whichever way we wish. We thought it looked so good, that it has become the new theme for Embroidermodder 2. To check out some of the more interesting embroidery projects they are working on, visit http://blog.ninapaley.com/""")) self.imgLbl = EmbroidermodderLogo(self) aboutLbl = QTextBrowser(self) aboutLbl.setReadOnly(True) aboutLbl.setOpenExternalLinks(True) aboutLbl.setText('<b>%s</b>' % '<br>'.join(__doc__.split('\n'))) aboutLbl.setWhatsThis(self.tr('This is the AWESOME people that brought Embroidermodder 2 to life.')) # We want very slight opacity of the white background # so the seamless texture shows slightly through. opacityStyleSheet = """\ QTextEdit:read-only { color: rgb(50, 50, 50); font-size: 12px; font-weight: bold; background-color: rgba(255, 255, 255, 240); border: 1px solid rgba(0, 0, 0, 255); } """ aboutLbl.setStyleSheet(opacityStyleSheet) op = QGraphicsOpacityEffect(aboutLbl) op.setOpacity(0.95) aboutLbl.setGraphicsEffect(op) self.notebook = QTabWidget(self) self.notebook.setMinimumWidth(500) self.notebook.addTab(aboutLbl, self.tr('About')) self.notebook.setTabIcon(0, QIcon(self.gIconDir + os.sep + 'app.png')) self.notebook.setTabIcon(1, QIcon(self.gImgDir + os.sep + 'kickstarter-logo-k-color.png')) notebookStyleSheet = """\ QTabWidget::pane { /* The tab widget frame */ border-top: 1px solid #000000; position: absolute; top: -0.5em; } QTabWidget::tab-bar { alignment: center; } /* Style the tab using the tab sub-control. Note that it reads QTabBar _not_ QTabWidget */ QTabBar::tab { margin-top: 2px; /* make non-selected tabs look smaller */ font-size: 14px; font-weight: bold; background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #E1E1E1, stop: 0.4 #DDDDDD, stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3); border: 1px solid #000000; /* border-bottom-color: #C2C7CB; */ /* same as the pane color */ border-top-left-radius: 4px; border-top-right-radius: 4px; min-width: 40ex; min-height: 5ex; padding: 3px; } QTabBar::tab:selected { margin-top: 0px; font-size: 16px; font-weight: bold; background: qlineargradient(x1: 0, y1: 0, x2: 2, y2: 2, stop: 0 #0C6AB0, stop: 0.15 #55C4E6, stop: 0.15 #55C4E6, stop: 0.5 #FFFFFF, stop: 0.5 #FFFFFF, stop: 0.85 #55C4E6, stop: 0.85 #55C4E6, stop: 1.0 #0C6AB0); border: 1px solid #000000; } QTabBar::tab:!selected:hover { margin-top: 2px; /* make non-selected tabs look smaller */ font-size: 14px; font-weight: bold; background: qlineargradient(x1: 0, y1: 0, x2: 2, y2: 2, stop: 0 #888888, stop: 0.15 #BBBBBB, stop: 0.15 #BBBBBB, stop: 0.5 #FFFFFF, stop: 0.5 #FFFFFF, stop: 0.85 #BBBBBB, stop: 0.85 #BBBBBB, stop: 1.0 #888888); border: 1px solid #000000; } QTabBar::tab:selected { border-color: #000000; border-bottom-color: #000000; /* same as pane color */ } """ self.notebook.setStyleSheet(notebookStyleSheet) self.notebook.currentChanged.connect(self.CurrentTabChanged) buttonbox = QDialogButtonBox(Qt.Horizontal, self) button = QPushButton(self) button.setText(self.tr("Oh, Yeah!")) button.setWhatsThis(self.tr('This is the Oh, Yeah! button!') + '\n' + self.tr('Oh, Yeah!')) buttonbox.addButton(button, QDialogButtonBox.AcceptRole) buttonbox.setCenterButtons(True) buttonbox.accepted.connect(self.accept) hbLayout1 = QHBoxLayout() hbLayout2 = QHBoxLayout() vbLayout = QVBoxLayout() hbLayout1.addStretch() hbLayout1.addWidget(self.imgLbl) hbLayout1.addStretch() hbLayout2.addStretch() hbLayout2.addWidget(self.notebook) hbLayout2.addStretch() vbLayout.addLayout(hbLayout1) vbLayout.addLayout(hbLayout2) vbLayout.addWidget(buttonbox) self.setLayout(vbLayout) self.setWindowTitle(self.tr('About Embroidermodder Version 2.0')) QApplication.restoreOverrideCursor() # TODO/???/PORT# don't mess with the window resize cursors.
class Form(QDialog): def __init__(self, state, term, candidates, result, parent=None): super().__init__(parent) Lib.prepareModalDialog(self) self.state = state self.term = term self.candidates = [] for candidate in candidates: self.candidates.append(humanizedCandidate( term, candidate.candidate, candidate.saf)) self.result = result self.setWindowTitle("Sort As — {}".format( QApplication.applicationName())) self.createWidgets() self.layoutWidgets() self.createConnections() self.updateUi() settings = QSettings() self.updateToolTips(bool(int(settings.value( Gopt.Key.ShowDialogToolTips, Gopt.Default.ShowDialogToolTips)))) def createWidgets(self): self.termLabel = Widgets.Label.HtmlLabel( "<p>Sort “{}” with</p>".format(Lib.elidePatchHtml(self.term, self.state))) self.radioButtons = [] seen = set() for index, candidate in enumerate(self.candidates, 1): candidate_word = str(candidate.candidate_word) name = self.nameForKind(candidate.kind, candidate_word) extra = "" if candidate_word in seen: extra = " (treat roman numbers as literal text)" else: seen.add(candidate_word) radioButton = QRadioButton("&{} “{}” as{} “{}”{}".format( index, candidate.term_word, name, candidate_word, extra)) self.radioButtons.append(radioButton) self.radioButtons[0].setChecked(True) self.customRadioButton = QRadioButton("&Custom:") self.tooltips.append((self.customRadioButton, """\ <p><b>Custom</b></p> <p>If checked, this entry's <b>Automatically Calculate Sort As</b> setting will be <i>unchecked</i>, and the sort as text entered here will be used as ther entry's sort as text.</p>""")) self.sortAsEdit = Widgets.LineEdit.LineEdit(self.state) self.tooltips.append((self.sortAsEdit, """\ <p><b>Custom Sort As editor</b></p> <p>If <b>Custom</b> is checked, this entry's <b>Automatically Calculate Sort As</b> setting will be <i>unchecked</i>, and the sort as text entered here will be used as ther entry's sort as text.</p>""")) self.sortAsEdit.setText(self.candidates[0].candidate) self.sortAsEdit.selectAll() self.buttonBox = QDialogButtonBox() self.okButton = QPushButton(QIcon(":/ok.svg"), "&OK") self.tooltips.append((self.okButton, """\ <p><b>OK</b></p> <p>Use the specified or custom sort as text for entry “{}”.</p>""".format(Lib.elidePatchHtml(self.term, self.state)))) self.buttonBox.addButton( self.okButton, QDialogButtonBox.AcceptRole) self.helpButton = QPushButton(QIcon(":/help.svg"), "Help") self.tooltips.append((self.helpButton, "Help on the Sort As dialog")) self.buttonBox.addButton( self.helpButton, QDialogButtonBox.HelpRole) def nameForKind(self, kind, candidate_word): name = kind.name.lower() if name == "unchanged": name = "" elif (name == "roman" or ( name == "phrase" and re.fullmatch(r"[\d.]+", candidate_word) is not None)): name = "number" if name: name = " " + name return name def layoutWidgets(self): vbox = QVBoxLayout() vbox.addWidget(self.termLabel) for radioButton in self.radioButtons: vbox.addWidget(radioButton) hbox = QHBoxLayout() hbox.addWidget(self.customRadioButton) hbox.addWidget(self.sortAsEdit) vbox.addLayout(hbox) vbox.addWidget(self.buttonBox) self.setLayout(vbox) def createConnections(self): for radioButton in itertools.chain((self.customRadioButton,), self.radioButtons): radioButton.toggled.connect(self.updateUi) self.sortAsEdit.textChanged.connect(self.updateUi) self.okButton.clicked.connect(self.accept) self.helpButton.clicked.connect(self.help) def help(self): self.state.help("xix_ref_dlg_sortas.html") def updateUi(self): self.sortAsEdit.setEnabled(self.customRadioButton.isChecked()) with Lib.BlockSignals(self.sortAsEdit): for i, radioButton in enumerate(self.radioButtons): if radioButton.isChecked(): self.sortAsEdit.setText(self.candidates[i].candidate) self.sortAsEdit.selectAll() break self.okButton.setEnabled( not self.customRadioButton.isChecked() or (self.customRadioButton.isChecked() and bool(self.sortAsEdit.toPlainText()))) def reject(self): self.accept() def accept(self): if self.customRadioButton.isChecked(): self.result.sortas = self.sortAsEdit.toPlainText() self.result.saf = Saf.CUSTOM else: for index, radioButton in enumerate(self.radioButtons): if radioButton.isChecked(): self.result.sortas = self.candidates[index].candidate kind = self.candidates[index].kind if kind is CandidateKind.LITERAL: saf = Saf.AUTO_BASIC elif kind is CandidateKind.NUMBER: saf = Saf.AUTO_NUMBER elif kind is CandidateKind.ROMAN: saf = Saf.AUTO_NUMBER_ROMAN elif kind is CandidateKind.PHRASE: saf = Saf.AUTO elif kind is CandidateKind.UNCHANGED: saf = self.candidates[index].saf self.result.saf = saf break super().accept()
def __init__(self, parent=None): QMainWindow.__init__(self, parent) # Destroying the C++ object right after closing the dialog box, # otherwise it may be garbage-collected in another QThread # (e.g. the editor's analysis thread in Spyder), thus leading to # a segmentation fault on UNIX or an application crash on Windows self.setAttribute(Qt.WA_DeleteOnClose) self.statusBar().showMessage('Ready') self.saveButton = QPushButton(self.tr("Save")) self.saveButton.setDefault(True) self.quitButton = QPushButton(self.tr("Quit")) self.quitButton.setAutoDefault(False) buttonBox = QDialogButtonBox() buttonBox.addButton(self.saveButton, QDialogButtonBox.ActionRole) buttonBox.addButton(self.quitButton, QDialogButtonBox.RejectRole) self.connect(self.saveButton, SIGNAL('clicked()'), self.save_file) self.connect(self.quitButton, SIGNAL('clicked()'), self.close) """ bbox = QDialogButtonBox(QDialogButtonBox.Apply |QDialogButtonBox.Cancel) self.apply_btn = bbox.button(QDialogButtonBox.Apply) self.connect(bbox, SIGNAL("accepted()"), SLOT("accept()")) self.connect(bbox, SIGNAL("rejected()"), SLOT("reject()")) self.connect(bbox, SIGNAL("clicked(QAbstractButton*)"), self.button_clicked) """ self.lineedits = {} self.comboboxes = {} self.spinboxes = {} self.availability_label = None self.job_name_widget = self.create_lineedit('Job Name', 'job_name') self.job_script_widget = self.create_lineedit('Job Script', 'job_script') self.job_output_widget = self.create_lineedit('Job Output', 'job_output') self.project_name_widget = self.create_lineedit('Project/Account', 'project_name') self.queue_widget = self.create_combobox('Queue', [], 'queues') self.availability_label = QLabel('Available:') self.num_tasks_widget = self.create_spinbox('Number tasks', '', 'ntasks', NoDefault, 1, 1, 1, 'total number of tasks') self.task_per_node_widget = self.create_spinbox('Task per node', '', 'task_per_node', NoDefault, 1, 2, 1, 'tasks per node') self.runtime_widget = self.create_spinbox('Runtime', 'hrs', 'runtime', NoDefault, 1, 36, 1, 'runtime in hrs') self.app_script_widget = self.create_combobox('Application Script', [('mycluster-zcfd.bsh','mycluster-zcfd.bsh'), ('mycluster-paraview.bsh','mycluster-paraview.bsh'), ('mycluster-fluent.bsh','mycluster-fluent.bsh')], 'app_script') # hsplitter = QSplitter() # hsplitter.addWidget(self.pages_widget) btnlayout = QHBoxLayout() btnlayout.addStretch(1) btnlayout.addWidget(buttonBox) vlayout = QVBoxLayout() # vlayout.addWidget(hsplitter) vlayout.addWidget(self.job_name_widget) vlayout.addWidget(self.job_script_widget) vlayout.addWidget(self.job_output_widget) vlayout.addWidget(self.project_name_widget) hlayout = QHBoxLayout() hlayout.addWidget(self.queue_widget) hlayout.addWidget(self.availability_label) vlayout.addLayout(hlayout) vlayout.addWidget(self.num_tasks_widget) vlayout.addWidget(self.task_per_node_widget) vlayout.addWidget(self.runtime_widget) vlayout.addWidget(self.app_script_widget) vlayout.addSpacing(10) vlayout.addLayout(btnlayout) self.widget = QWidget() self.widget.setLayout(vlayout) self.setCentralWidget(self.widget) # self.setGeometry(300, 300, 350, 250) self.setWindowTitle("MyCluster Job Configurator") self.lineedits['job_name'].textChanged.connect(self.job_name_changed) self.lineedits['job_script'].textChanged.connect(self.job_script_changed) self.lineedits['job_name'].setText('myjob') self.lineedits['project_name'].setText('default') #self.lineedits['app_script'].setText('myscript.bsh') self.comboboxes['app_script'].setEditable(True) self.comboboxes['app_script'].lineEdit().editingFinished.connect(self.check_app_script) from mycluster import mycluster mycluster.init() self.init_queue_info()
class Dialog(QDialog): def __init__(self): super(Dialog, self).__init__() self.osc = OSCSender() self.createPreControlBox() self.createPlayControlBox() self.createButtonBox() mainLayout = QGridLayout() mainLayout.addWidget(self.preControlBox, 0, 0) mainLayout.addWidget(self.playControlBox, 1, 0) mainLayout.addWidget(self.buttonBox, 2, 0) mainLayout.setSizeConstraint(QLayout.SetMinimumSize) self.mainLayout = mainLayout self.setLayout(self.mainLayout) self.setWindowTitle("Confidence Man") def createButtonBox(self): self.buttonBox = QDialogButtonBox() closeButton = self.buttonBox.addButton(QDialogButtonBox.Close) helpButton = self.buttonBox.addButton(QDialogButtonBox.Help) closeButton.clicked.connect(self.close) helpButton.clicked.connect(self.show_help) def createPlayControlBox(self): self.playControlBox = QGroupBox("Player Controls") playControlLayout = QHBoxLayout() playButton = QPushButton("Play") playButton.clicked.connect(self.playClicked) playControlLayout.addWidget(playButton) pauseButton = QPushButton("Pause") pauseButton.clicked.connect(self.pauseClicked) playControlLayout.addWidget(pauseButton) resumeButton = QPushButton("Resume") resumeButton.clicked.connect(self.resumeClicked) playControlLayout.addWidget(resumeButton) self.playControlBox.setLayout(playControlLayout) def createPreControlBox(self): self.preControlBox = QGroupBox("Pre-Show Controls") preControlLayout = QHBoxLayout() resetButton = QPushButton("Reset") resetButton.clicked.connect(self.resetClicked) preControlLayout.addWidget(resetButton) # TODO - make togglePushButton.setCheckable(True) prepareButton = QPushButton("Prepare") prepareButton.clicked.connect(self.prepareClicked) preControlLayout.addWidget(prepareButton) bgButton = QPushButton("Background") bgButton.clicked.connect(self.bgClicked) preControlLayout.addWidget(bgButton) self.preControlBox.setLayout(preControlLayout) def playClicked(self): logger.debug("Play clicked") self.osc.start() def pauseClicked(self): logger.debug("Pause clicked") self.osc.pause() def resumeClicked(self): logger.debug("Resume clicked") self.osc.resume() def resetClicked(self): logger.debug("Reset clicked") self.osc.reset() def prepareClicked(self): logger.debug("Prepare clicked") self.osc.prepare() def bgClicked(self): logger.debug("Background clicked") self.osc.bg() def show_help(self): QMessageBox.information(self, "Confidence Man Help", "Help yourself.")
class Form(QDialog): def __init__(self, state, parent=None): super().__init__(parent) Lib.prepareModalDialog(self) self.state = state self.setWindowTitle("Forget Spelling Words — {}".format( QApplication.applicationName())) words = sorted( self.state.entryPanel.spellHighlighter.wordsToIgnore | set(self.state.model.spellWords()), key=str.casefold) if words: self.initialize(words) else: self.nowords() settings = QSettings() self.updateToolTips(bool(int(settings.value( Gopt.Key.ShowDialogToolTips, Gopt.Default.ShowDialogToolTips)))) def nowords(self): label = QLabel("<p>No ignored or index dictionary words to " "remove") self.helpButton = QPushButton(QIcon(":/help.svg"), "Help") self.helpButton.clicked.connect(self.help) self.tooltips.append((self.helpButton, "Help on the Forget Spelling Words dialog")) closeButton = QPushButton(QIcon(":/dialog-close.svg"), "&Close") self.tooltips.append((closeButton, """<p><b>Close</b></p> <p>Close the dialog.</p>""")) buttonBox = QDialogButtonBox() buttonBox.addButton(closeButton, QDialogButtonBox.RejectRole) buttonBox.rejected.connect(self.reject) buttonBox.addButton(self.helpButton, QDialogButtonBox.HelpRole) layout = QVBoxLayout() layout.addWidget(label) layout.addWidget(buttonBox) self.setLayout(layout) def initialize(self, words): self.removeComboBox = QComboBox() self.removeComboBox.addItems(words) self.tooltips.append((self.removeComboBox, """\ <p><b>Spelling Words combobox</b></p> <p>This index's list of words that have been remembered as correctly spelled or to be ignored even though they aren't in the dictionary for the index's language.</p>""")) self.helpButton = QPushButton(QIcon(":/help.svg"), "Help") self.tooltips.append((self.helpButton, "Help on the Forget Spelling Words dialog")) self.removeButton = QPushButton(QIcon(":/spelling-remove.svg"), "&Forget") self.tooltips.append((self.removeButton, """\ <p><b>Forget</b></p> <p>Permanently forget the selected word from the index's spelling words list. Afterwards, if this word appears in any entry, it will be highlighted as misspelled.</p>""")) closeButton = QPushButton(QIcon(":/dialog-close.svg"), "&Close") self.tooltips.append((closeButton, """<p><b>Close</b></p> <p>Close the dialog.</p>""")) self.buttonBox = QDialogButtonBox() self.buttonBox.addButton(closeButton, QDialogButtonBox.RejectRole) self.buttonBox.addButton( self.removeButton, QDialogButtonBox.ApplyRole) self.buttonBox.addButton(self.helpButton, QDialogButtonBox.HelpRole) layout = QFormLayout() layout.addRow("F&orget", self.removeComboBox) layout.addRow(self.buttonBox) self.setLayout(layout) self.helpButton.clicked.connect(self.help) self.removeButton.clicked.connect(self.remove) self.buttonBox.rejected.connect(self.reject) def help(self): self.state.help("xix_ref_dlg_spelldel.html") def remove(self): word = self.removeComboBox.currentText() if word: i = self.removeComboBox.currentIndex() self.removeComboBox.removeItem(i) self.state.entryPanel.spellHighlighter.wordsToIgnore.discard( word) self.state.model.removeSpellWord(word) Spell.remove(word, self.state.language.value) self.state.entryPanel.spellHighlighter.rehighlight() if not self.removeComboBox.count(): self.accept()
def __init__(self, parent=None): super(AddAccountDialog, self).__init__(parent) # self.setAttribute(Qt.WA_DeleteOnClose) lbMinWidth = 150 leMinWidth = 200 self.isMatch = False # self.keyDialog.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.setWindowTitle("Create a new account preset") baseLayout = QVBoxLayout(self) nameLayout = QHBoxLayout() keyLayout = QHBoxLayout() keyConfirmLayout = QHBoxLayout() baseLayout.addLayout(nameLayout) baseLayout.addLayout(keyLayout) baseLayout.addLayout(keyConfirmLayout) lb_name = QLabel('Account Preset Name: ', self) lb_name.setMinimumWidth(lbMinWidth) self.name_le = QLineEdit(self) self.name_le.setMinimumWidth(leMinWidth) nameLayout.addWidget(lb_name) nameLayout.addWidget(self.name_le) lb_key = QLabel('Encryption Key: ', self) lb_key.setMinimumWidth(lbMinWidth) self.key_le = QLineEdit(self) # self.key_le.setPlaceholderText('Encryption Key') self.key_le.setEchoMode(self.key_le.Password) self.key_le.setMinimumWidth(leMinWidth) keyLayout.addWidget(lb_key) keyLayout.addWidget(self.key_le) lb_keyConfirm = QLabel('Confirm Key: ', self) lb_keyConfirm.setMinimumWidth(lbMinWidth) self.keyConfirm_le = QLineEdit(self) # self.keyConfirm_le.setPlaceholderText('Encryption Key') self.keyConfirm_le.setEchoMode(self.key_le.Password) self.keyConfirm_le.setMinimumWidth(leMinWidth) keyConfirmLayout.addWidget(lb_keyConfirm) keyConfirmLayout.addWidget(self.keyConfirm_le) self.okBtn = QPushButton(self.tr("&Ok")) self.okBtn.setDefault(True) self.okBtn.setEnabled(False) cancelBtn = QPushButton(self.tr("&Cancel")) cancelBtn.setAutoDefault(False) buttonBox = QDialogButtonBox(Qt.Horizontal, self) buttonBox.addButton(self.okBtn, QDialogButtonBox.AcceptRole) buttonBox.addButton(cancelBtn, QDialogButtonBox.RejectRole) baseLayout.addWidget(buttonBox) self.name_le.textChanged.connect(self.name_confirmator) self.key_le.textChanged.connect(self.key_confirmator) self.keyConfirm_le.textChanged.connect(self.key_confirmator) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject)