def __init__(self, show_strength=True, parent=None): super(PinMatrixWidget, self).__init__(parent) self.password = QLineEdit() self.password.setValidator(QRegExpValidator(QRegExp('[1-9]+'), None)) self.password.setEchoMode(QLineEdit.Password) QObject.connect(self.password, SIGNAL('textChanged(QString)'), self._password_changed) self.strength = QLabel() self.strength.setMinimumWidth(75) self.strength.setAlignment(Qt.AlignCenter) self._set_strength(0) grid = QGridLayout() grid.setSpacing(0) for y in range(3)[::-1]: for x in range(3): button = PinButton(self.password, x + y * 3 + 1) button.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) button.setFocusPolicy(Qt.NoFocus) grid.addWidget(button, 3 - y, x) hbox = QHBoxLayout() hbox.addWidget(self.password) if show_strength: hbox.addWidget(self.strength) vbox = QVBoxLayout() vbox.addLayout(grid) vbox.addLayout(hbox) self.setLayout(vbox)
class DebugDevice(QDialog): def __init__(self, parent=None): QDialog.__init__(self, parent) self._layout = QVBoxLayout(self) self.setLayout(self._layout) self.log = QPlainTextEdit(self) self._layout.addWidget(self.log) self.log.setPlainText(_('Getting debug information')+'...') self.copy = QPushButton(_('Copy to &clipboard')) self.copy.setDefault(True) self.setWindowTitle(_('Debug device detection')) self.setWindowIcon(QIcon(I('debug.png'))) self.copy.clicked.connect(self.copy_to_clipboard) self.ok = QPushButton('&OK') self.ok.setAutoDefault(False) self.ok.clicked.connect(self.accept) self.bbox = QDialogButtonBox(self) self.bbox.addButton(self.copy, QDialogButtonBox.ActionRole) self.bbox.addButton(self.ok, QDialogButtonBox.AcceptRole) self._layout.addWidget(self.bbox) self.resize(750, 500) self.bbox.setEnabled(False) QTimer.singleShot(1000, self.debug) def debug(self): try: from calibre.devices import debug raw = debug() self.log.setPlainText(raw) finally: self.bbox.setEnabled(True) def copy_to_clipboard(self): QApplication.clipboard().setText(self.log.toPlainText())
def show_config_widget(category, name, gui=None, show_restart_msg=False, parent=None, never_shutdown=False): ''' Show the preferences plugin identified by category and name :param gui: gui instance, if None a hidden gui is created :param show_restart_msg: If True and the preferences plugin indicates a restart is required, show a message box telling the user to restart :param parent: The parent of the displayed dialog :return: True iff a restart is required for the changes made by the user to take effect ''' from calibre.gui2 import gprefs pl = get_plugin(category, name) d = ConfigDialog(parent) d.resize(750, 550) conf_name = 'config_widget_dialog_geometry_%s_%s'%(category, name) geom = gprefs.get(conf_name, None) d.setWindowTitle(_('Configure ') + name) d.setWindowIcon(QIcon(I('config.png'))) bb = QDialogButtonBox(d) bb.setStandardButtons(bb.Apply|bb.Cancel|bb.RestoreDefaults) bb.accepted.connect(d.accept) bb.rejected.connect(d.reject) w = pl.create_widget(d) d.set_widget(w) bb.button(bb.RestoreDefaults).clicked.connect(w.restore_defaults) bb.button(bb.RestoreDefaults).setEnabled(w.supports_restoring_to_defaults) bb.button(bb.Apply).setEnabled(False) bb.button(bb.Apply).clicked.connect(d.accept) def onchange(): b = bb.button(bb.Apply) b.setEnabled(True) b.setDefault(True) b.setAutoDefault(True) w.changed_signal.connect(onchange) bb.button(bb.Cancel).setFocus(True) l = QVBoxLayout() d.setLayout(l) l.addWidget(w) l.addWidget(bb) mygui = gui is None if gui is None: gui = init_gui() mygui = True w.genesis(gui) w.initialize() if geom is not None: d.restoreGeometry(geom) d.exec_() geom = bytearray(d.saveGeometry()) gprefs[conf_name] = geom rr = getattr(d, 'restart_required', False) if show_restart_msg and rr: from calibre.gui2 import warning_dialog warning_dialog(gui, 'Restart required', 'Restart required', show=True) if mygui and not never_shutdown: gui.shutdown() return rr
def setupWidgets(self): """Override this.""" self.setCentralWidget(QWidget(self)) _layout = QVBoxLayout(self.centralWidget()) self.centralWidget().setLayout(_layout) _layout.setContentsMargins(0,0,0,0) self.centralWidget().layout().addWidget(QLabel("This is normal text", self))
class Comments(Base): def setup_ui(self, parent): self._box = QGroupBox(parent) self._box.setTitle('&'+self.col_metadata['name']) self._layout = QVBoxLayout() self._tb = CommentsEditor(self._box) self._tb.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum) # self._tb.setTabChangesFocus(True) self._layout.addWidget(self._tb) self._box.setLayout(self._layout) self.widgets = [self._box] def setter(self, val): if not val or not val.strip(): val = '' else: val = comments_to_html(val) self._tb.html = val self._tb.wyswyg_dirtied() def getter(self): val = unicode(self._tb.html).strip() if not val: val = None return val
class HelpView(SizePersistedDialog): """ Modeless dialog for presenting HTML help content """ def __init__(self, parent, icon, prefs, html=None, page=None, title=""): self.prefs = prefs # QDialog.__init__(self, parent=parent) super(HelpView, self).__init__(parent, "help_dialog") self.setWindowTitle(title) self.setWindowIcon(icon) self.l = QVBoxLayout(self) self.setLayout(self.l) self.wv = QWebView() if html is not None: self.wv.setHtml(html) elif page is not None: self.wv.load(QUrl(page)) self.wv.setMinimumHeight(100) self.wv.setMaximumHeight(16777215) self.wv.setMinimumWidth(400) self.wv.setMaximumWidth(16777215) self.wv.setGeometry(0, 0, 400, 100) self.wv.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.l.addWidget(self.wv) # Sizing sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(sizePolicy) self.resize_dialog()
def _init_controls(self): layout = QVBoxLayout(self) self.setLayout(layout) ml = QHBoxLayout() layout.addLayout(ml, 1) self.keys_list = QListWidget(self) self.keys_list.setSelectionMode(QAbstractItemView.SingleSelection) self.keys_list.setFixedWidth(150) self.keys_list.setAlternatingRowColors(True) ml.addWidget(self.keys_list) self.value_text = QTextEdit(self) self.value_text.setTabStopWidth(24) self.value_text.setReadOnly(False) ml.addWidget(self.value_text, 1) button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) button_box.accepted.connect(self._apply_changes) button_box.rejected.connect(self.reject) self.clear_button = button_box.addButton('Clear', QDialogButtonBox.ResetRole) self.clear_button.setIcon(get_icon('trash.png')) self.clear_button.setToolTip('Clear all settings for this plugin') self.clear_button.clicked.connect(self._clear_settings) layout.addWidget(button_box)
def __init__(self, parent=None,): QDialog.__init__(self, parent) self.parent = parent self.setWindowTitle(u"{0} {1}: Add New EInk Kindle Serial Number".format(PLUGIN_NAME, PLUGIN_VERSION)) layout = QVBoxLayout(self) self.setLayout(layout) data_group_box = QGroupBox(u"", self) layout.addWidget(data_group_box) data_group_box_layout = QVBoxLayout() data_group_box.setLayout(data_group_box_layout) key_group = QHBoxLayout() data_group_box_layout.addLayout(key_group) key_group.addWidget(QLabel(u"EInk Kindle Serial Number:", self)) self.key_ledit = QLineEdit("", self) self.key_ledit.setToolTip(u"Enter an eInk Kindle serial number. EInk Kindle serial numbers are 16 characters long and usually start with a 'B' or a '9'. Kindle Serial Numbers are case-sensitive, so be sure to enter the upper and lower case letters unchanged.") key_group.addWidget(self.key_ledit) key_label = QLabel(_(''), self) key_label.setAlignment(Qt.AlignHCenter) data_group_box_layout.addWidget(key_label) self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.button_box.accepted.connect(self.accept) self.button_box.rejected.connect(self.reject) layout.addWidget(self.button_box) self.resize(self.sizeHint())
def __init__(self, parent=None,): QDialog.__init__(self, parent) self.parent = parent self.setWindowTitle(u"{0} {1}: Add New Mobipocket PID".format(PLUGIN_NAME, PLUGIN_VERSION)) layout = QVBoxLayout(self) self.setLayout(layout) data_group_box = QGroupBox(u"", self) layout.addWidget(data_group_box) data_group_box_layout = QVBoxLayout() data_group_box.setLayout(data_group_box_layout) key_group = QHBoxLayout() data_group_box_layout.addLayout(key_group) key_group.addWidget(QLabel(u"PID:", self)) self.key_ledit = QLineEdit("", self) self.key_ledit.setToolTip(u"Enter a Mobipocket PID. Mobipocket PIDs are 8 or 10 characters long. Mobipocket PIDs are case-sensitive, so be sure to enter the upper and lower case letters unchanged.") key_group.addWidget(self.key_ledit) key_label = QLabel(_(''), self) key_label.setAlignment(Qt.AlignHCenter) data_group_box_layout.addWidget(key_label) self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.button_box.accepted.connect(self.accept) self.button_box.rejected.connect(self.reject) layout.addWidget(self.button_box) self.resize(self.sizeHint())
class ConfigWidget(QWidget): config_help_message = 'Set your API keys and access information for online querying services' def __init__(self, plugin): super(ConfigWidget, self).__init__() self.vlayout = QVBoxLayout() self.setLayout(self.vlayout) self.dcinput = {} for key in prefs.defaults: hlayout = QHBoxLayout() txtlabel = QLabel(key.replace("_", " ")) txtinput = QLineEdit() txtinput.setText(str(prefs[key])) txtlabel.setBuddy(txtinput) self.dcinput[key] = txtinput hlayout.addWidget(txtlabel) hlayout.addWidget(txtinput) self.vlayout.addLayout(hlayout) def save_settings(self): for key in prefs.defaults: prefs[key] = unicode(self.dcinput[key].text())
def message_dialog(self, msg): self.clear_dialog() self.dialog = dialog = WindowModalDialog(self.top_level_window(), _("Ledger Status")) l = QLabel(msg) vbox = QVBoxLayout(dialog) vbox.addWidget(l) dialog.show()
class CapturePhotoCover(QDialog): def __init__(self, gui, icon, do_user_config, qaction, us): QDialog.__init__(self, gui) self.main_gui = gui self.do_user_config = do_user_config self.qaction = qaction self.us = us #- main UI layout ----------------------------------------------------- self.ll = QVBoxLayout() self.l = QHBoxLayout() self.l.setSpacing(0) #self.l.setMargin(0) # not in Qt5 self.w = QWidget() self.w.setLayout(self.l) self.setLayout(self.ll) self.setWindowIcon(icon) self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) #- webkit ------------------------------------------------------------- self.webview = QWebView() self.webview.setMaximumWidth(680) self.webview.setMaximumHeight(320) self.webview.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) # self.webview.load(QUrl.fromLocalFile( # os.path.join(self.us.portable_directory, # "portable/kaliweb.html"))) self.loadUrl() self.webview.page().networkAccessManager().sslErrors.connect(self.sslErrorHandler) #self.connect(self.webview.page().networkAccessManager(), # SIGNAL("sslErrors (QNetworkReply *, \ # const QList<QSslError> &)"), # self.sslErrorHandler) logger.info("KALIWEB PATH: {}".format( os.path.join(self.us.portable_directory, "portable/kaliweb.html"))) self.ll.addWidget(self.webview) def loadUrl(self): if self.us.initial: self.webview.page().mainFrame().load(QUrl("https://google.com")) self.us.initial = False def keyPressEvent(self, event): if event.key() == Qt.Key_Escape: pass def sslErrorHandler(self, reply, errorList): reply.ignoreSslErrors() logger.debug("SSL ERRORS: {}".format(errorList)) return def closeEvent(self, e): self.hide()
def message_dialog(self): self.d = QDialog() self.d.setModal(1) self.d.setWindowTitle("Please Check Trezor Device") self.d.setWindowFlags(self.d.windowFlags() | QtCore.Qt.WindowStaysOnTopHint) l = QLabel(self.message) vbox = QVBoxLayout(self.d) vbox.addWidget(l) self.d.show()
def __init__(self): QGroupBox.__init__(self) self.treemodel = treemodel = TestNe1Model() self.view = view = ModelTree("Model tree", treemodel, self) view.mt_update() def thunk(str): def _thunk(str=str): print str return _thunk self.chunkNum = 2 self.gbox = QGroupBox() vl = QVBoxLayout(self) vl.setSpacing(0) vl.setMargin(0) vl.addWidget(self.view) self.buttonLayout = hl = QHBoxLayout() hl.setSpacing(0) hl.setMargin(0) vl.addLayout(hl) self.buttonNum = 1 for func in (self.addmol, self.addjig, self.selected): self.addButton(func)
class Dialog(QDialog): def __init__(self, title, widget=None, closeButton=True, keySequence=None, isDialog=False, icon=None): QDialog.__init__(self, ctx.mainScreen) self.setObjectName("dialog") self.isDialog = isDialog self.layout = QVBoxLayout() self.setLayout(self.layout) self.wlayout= QHBoxLayout() if icon: self.setStyleSheet("""QDialog QLabel{ margin-left:16px;margin-right:10px} QDialog#dialog {background-image:url(':/images/%s.png'); background-repeat:no-repeat; background-position: top left; padding-left:500px;} """ % icon) self.windowTitle = windowTitle(self, closeButton) self.setTitle(title) self.layout.setMargin(0) self.layout.addWidget(self.windowTitle) if widget: self.addWidget(widget) QObject.connect(widget, SIGNAL("finished(int)"), self.reject) QObject.connect(widget, SIGNAL("resizeDialog(int,int)"), self.resize) if closeButton: QObject.connect(self.windowTitle.pushButton, SIGNAL("clicked()"), self.reject) if keySequence: shortCut = QShortcut(keySequence, self) QObject.connect(shortCut, SIGNAL("activated()"), self.reject) QMetaObject.connectSlotsByName(self) self.resize(10,10) def setTitle(self, title): self.windowTitle.label.setText(title) def addWidget(self, widget): self.content = widget self.wlayout.addWidget(self.content) if self.isDialog: widget.setStyleSheet("QMessageBox { background:none }") self.layout.addItem(QSpacerItem(10, 10, QSizePolicy.Fixed, QSizePolicy.MinimumExpanding)) self.layout.setContentsMargins(0, 0, 0, 8) self.layout.addLayout(self.wlayout) def setCentered(self): self.move(ctx.mainScreen.width()/2 - self.width()/2, ctx.mainScreen.height()/2 - self.height()/2) def exec_(self): QTimer.singleShot(0, self.setCentered) return QDialog.exec_(self)
def __init__(self, parent = None, name = None, modal = 1, fl = 0): #QDialog.__init__(self,parent,name,modal,fl) QDialog.__init__(self,parent) self.setModal(modal) qt4todo("handle flags in TextMessageBox.__init__") if name is None: name = "TextMessageBox" self.setObjectName(name) self.setWindowTitle(name) TextMessageLayout = QVBoxLayout(self) TextMessageLayout.setMargin(5) TextMessageLayout.setSpacing(1) self.text_edit = QTextEdit(self) TextMessageLayout.addWidget(self.text_edit) self.close_button = QPushButton(self) self.close_button.setText("Close") TextMessageLayout.addWidget(self.close_button) self.resize(QSize(350, 300).expandedTo(self.minimumSizeHint())) # Width changed from 300 to 350. Now hscrollbar doesn't appear in # Help > Graphics Info textbox. mark 060322 qt4todo('self.clearWState(Qt.WState_Polished)') # what is this? self.connect(self.close_button, SIGNAL("clicked()"),self.close)
def _init_controls(self): # Add the control set vbl = QVBoxLayout() self.move_rule_up_tb = QToolButton() self.move_rule_up_tb.setObjectName("move_rule_up_tb") self.move_rule_up_tb.setToolTip('Move rule up') self.move_rule_up_tb.setIcon(QIcon(I('arrow-up.png'))) self.move_rule_up_tb.clicked.connect(self.move_row_up) vbl.addWidget(self.move_rule_up_tb) self.add_rule_tb = QToolButton() self.add_rule_tb.setObjectName("add_rule_tb") self.add_rule_tb.setToolTip('Add a new rule') self.add_rule_tb.setIcon(QIcon(I('plus.png'))) self.add_rule_tb.clicked.connect(self.add_row) vbl.addWidget(self.add_rule_tb) self.delete_rule_tb = QToolButton() self.delete_rule_tb.setObjectName("delete_rule_tb") self.delete_rule_tb.setToolTip('Delete selected rule') self.delete_rule_tb.setIcon(QIcon(I('list_remove.png'))) self.delete_rule_tb.clicked.connect(self.delete_row) vbl.addWidget(self.delete_rule_tb) self.move_rule_down_tb = QToolButton() self.move_rule_down_tb.setObjectName("move_rule_down_tb") self.move_rule_down_tb.setToolTip('Move rule down') self.move_rule_down_tb.setIcon(QIcon(I('arrow-down.png'))) self.move_rule_down_tb.clicked.connect(self.move_row_down) vbl.addWidget(self.move_rule_down_tb) self.layout.addLayout(vbl)
def _init_controls(self): # Add the control set vbl = QVBoxLayout() self.move_element_up_tb = QToolButton() self.move_element_up_tb.setObjectName("move_element_up_tb") self.move_element_up_tb.setToolTip('Move element up') self.move_element_up_tb.setIcon(QIcon(I('arrow-up.png'))) self.move_element_up_tb.clicked.connect(self.move_row_up) vbl.addWidget(self.move_element_up_tb) self.undo_css_tb = QToolButton() self.undo_css_tb.setObjectName("undo_css_tb") self.undo_css_tb.setToolTip('Restore CSS to last saved') self.undo_css_tb.setIcon(QIcon(I('edit-undo.png'))) self.undo_css_tb.clicked.connect(partial(self.undo_reset_button_clicked, 'undo')) vbl.addWidget(self.undo_css_tb) self.reset_css_tb = QToolButton() self.reset_css_tb.setObjectName("reset_css_tb") self.reset_css_tb.setToolTip('Reset CSS to default') self.reset_css_tb.setIcon(QIcon(I('trash.png'))) self.reset_css_tb.clicked.connect(partial(self.undo_reset_button_clicked, 'reset')) vbl.addWidget(self.reset_css_tb) self.move_element_down_tb = QToolButton() self.move_element_down_tb.setObjectName("move_element_down_tb") self.move_element_down_tb.setToolTip('Move element down') self.move_element_down_tb.setIcon(QIcon(I('arrow-down.png'))) self.move_element_down_tb.clicked.connect(self.move_row_down) vbl.addWidget(self.move_element_down_tb) self.layout.addLayout(vbl)
def __init__(self, parent): super(CharacterDialog, self).__init__(parent) self.setWindowTitle(_("KeepKey Seed Recovery")) self.character_pos = 0 self.word_pos = 0 self.loop = QEventLoop() self.word_help = QLabel() self.char_buttons = [] vbox = QVBoxLayout(self) vbox.addWidget(WWLabel(CHARACTER_RECOVERY)) hbox = QHBoxLayout() hbox.addWidget(self.word_help) for i in range(4): char_button = CharacterButton('*') char_button.setMaximumWidth(36) self.char_buttons.append(char_button) hbox.addWidget(char_button) self.accept_button = CharacterButton(_("Accept Word")) self.accept_button.clicked.connect(partial(self.process_key, 32)) self.rejected.connect(partial(self.loop.exit, 1)) hbox.addWidget(self.accept_button) hbox.addStretch(1) vbox.addLayout(hbox) self.finished_button = QPushButton(_("Seed Entered")) self.cancel_button = QPushButton(_("Cancel")) self.finished_button.clicked.connect(partial(self.process_key, Qt.Key_Return)) self.cancel_button.clicked.connect(self.rejected) buttons = Buttons(self.finished_button, self.cancel_button) vbox.addSpacing(40) vbox.addLayout(buttons) self.refresh() self.show()
def add_checkbuttons(self, table, row, col): wid = QWidget() lo = QVBoxLayout() wid.setLayout(lo) cb = QCheckBox() lo.addWidget(cb) wid.setFixedHeight(32) table.setCellWidget(row, col, wid) return cb
def start(self, message): self.d = QDialog() self.d.setModal(1) self.d.setWindowTitle("Please Wait") self.d.setWindowFlags(self.d.windowFlags() | QtCore.Qt.WindowStaysOnTopHint) l = QLabel(message) vbox = QVBoxLayout(self.d) vbox.addWidget(l) self.d.show() if not self.waiting: self.waiting = True self.d.connect(waitDialog, SIGNAL("dongle_done"), self.stop)
def message_dialog(self, msg, cancel_callback): # Called more than once during signing, to confirm output and fee self.clear_dialog() title = _('Please check your %s device') % self.device self.dialog = dialog = WindowModalDialog(self.window_stack[-1], title) l = QLabel(msg) vbox = QVBoxLayout(dialog) if cancel_callback: vbox.addLayout(Buttons(CancelButton(dialog))) dialog.connect(dialog, SIGNAL('rejected()'), cancel_callback) vbox.addWidget(l) dialog.show()
def start(self, message): self.d = QDialog() self.d.setModal(1) self.d.setWindowTitle('Please Check Trezor Device') self.d.setWindowFlags(self.d.windowFlags() | QtCore.Qt.WindowStaysOnTopHint) l = QLabel(message) vbox = QVBoxLayout(self.d) vbox.addWidget(l) self.d.show() if not self.waiting: self.waiting = True self.d.connect(twd, SIGNAL('trezor_done'), self.stop)
def message_dialog(self, msg, on_cancel): # Called more than once during signing, to confirm output and fee self.clear_dialog() title = _('Please check your %s device') % self.device self.dialog = dialog = WindowModalDialog(self.top_level_window(), title) l = QLabel(msg) vbox = QVBoxLayout(dialog) vbox.addWidget(l) if on_cancel: dialog.rejected.connect(on_cancel) vbox.addLayout(Buttons(CancelButton(dialog))) dialog.show()
class DBCheck(QDialog): # {{{ update_msg = pyqtSignal(object) def __init__(self, parent, db): QDialog.__init__(self, parent) self.l = QVBoxLayout() self.setLayout(self.l) self.l1 = QLabel(_('Vacuuming database to improve performance.') + ' ' + _('This will take a while, please wait...')) self.setWindowTitle(_('Vacuuming...')) self.l1.setWordWrap(True) self.l.addWidget(self.l1) self.msg = QLabel('') self.update_msg.connect(self.msg.setText, type=Qt.QueuedConnection) self.l.addWidget(self.msg) self.msg.setWordWrap(True) self.resize(self.sizeHint() + QSize(100, 50)) self.error = None self.db = db.new_api self.closed_orig_conn = False self.rejected = False def start(self): t = self.thread = Thread(target=self.vacuum) t.daemon = True t.start() QTimer.singleShot(100, self.check) self.exec_() def vacuum(self): try: self.db.vacuum() except Exception as e: import traceback self.error = (as_unicode(e), traceback.format_exc()) def reject(self): self.rejected = True return QDialog.reject(self) def check(self): if self.rejected: return if self.thread.is_alive(): QTimer.singleShot(100, self.check) else: self.accept() def break_cycles(self): self.db = self.thread = None
def __init__(self, parent): QDialog.__init__(self, parent) self.setWindowTitle(_('Choose stores')) button_box = QDialogButtonBox(QDialogButtonBox.Close) button_box.accepted.connect(self.accept) button_box.rejected.connect(self.reject) v = QVBoxLayout(self) self.config_widget = StoreChooserWidget() v.addWidget(self.config_widget) v.addWidget(button_box) self.resize(800, 600)
def message_dialog(self): self.d = QDialog() self.d.setModal(1) self.d.setWindowTitle("Please Check KeepKey Device") self.d.setWindowFlags(self.d.windowFlags() | QtCore.Qt.WindowStaysOnTopHint) l = QLabel(self.message) vbox = QVBoxLayout(self.d) vbox.addWidget(l) if self.messsage_code in (3, 8): vbox.addLayout(Buttons(CancelButton(self.d))) self.d.connect(self.d, SIGNAL("rejected()"), self.client.cancel) self.d.show()
class DebugDevice(QDialog): def __init__(self, gui, parent=None): QDialog.__init__(self, parent) self.gui = gui self._layout = QVBoxLayout(self) self.setLayout(self._layout) self.log = QPlainTextEdit(self) self._layout.addWidget(self.log) self.log.setPlainText(_('Getting debug information, please wait')+'...') self.copy = QPushButton(_('Copy to &clipboard')) self.copy.setDefault(True) self.setWindowTitle(_('Debug device detection')) self.setWindowIcon(QIcon(I('debug.png'))) self.copy.clicked.connect(self.copy_to_clipboard) self.ok = QPushButton('&OK') self.ok.setAutoDefault(False) self.ok.clicked.connect(self.accept) self.bbox = QDialogButtonBox(self) self.bbox.addButton(self.copy, QDialogButtonBox.ActionRole) self.bbox.addButton(self.ok, QDialogButtonBox.AcceptRole) self._layout.addWidget(self.bbox) self.resize(750, 500) self.bbox.setEnabled(False) QTimer.singleShot(1000, self.debug) def debug(self): if self.gui.device_manager.is_device_connected: error_dialog(self, _('Device already detected'), _('A device (%s) is already detected by calibre.' ' If you wish to debug the detection of another device' ', first disconnect this device.')% self.gui.device_manager.connected_device.get_gui_name(), show=True) self.bbox.setEnabled(True) return self.gui.debug_detection(self) def __call__(self, job): if not self.isVisible(): return self.bbox.setEnabled(True) if job.failed: return error_dialog(self, _('Debugging failed'), _('Running debug device detection failed. Click Show ' 'Details for more information.'), det_msg=job.details, show=True) self.log.setPlainText(job.result) def copy_to_clipboard(self): QApplication.clipboard().setText(self.log.toPlainText())
class DBRestore(QDialog): update_signal = pyqtSignal(object, object) def __init__(self, parent, library_path): QDialog.__init__(self, parent) self.l = QVBoxLayout() self.setLayout(self.l) self.l1 = QLabel('<b>'+_('Restoring database from backups, do not' ' interrupt, this will happen in three stages')+'...') self.setWindowTitle(_('Restoring database')) self.l.addWidget(self.l1) self.pb = QProgressBar(self) self.l.addWidget(self.pb) self.pb.setMaximum(0) self.pb.setMinimum(0) self.msg = QLabel('') self.l.addWidget(self.msg) self.msg.setWordWrap(True) self.bb = QDialogButtonBox(QDialogButtonBox.Cancel) self.l.addWidget(self.bb) self.bb.rejected.connect(self.reject) self.resize(self.sizeHint() + QSize(100, 50)) self.error = None self.rejected = False self.library_path = library_path self.update_signal.connect(self.do_update, type=Qt.QueuedConnection) self.restorer = Restore(library_path, self) self.restorer.daemon = True # Give the metadata backup thread time to stop QTimer.singleShot(2000, self.start) def start(self): self.restorer.start() QTimer.singleShot(10, self.update) def reject(self): self.rejected = True self.restorer.progress_callback = lambda x, y: x QDialog.reject(self) def update(self): if self.restorer.is_alive(): QTimer.singleShot(10, self.update) else: self.restorer.progress_callback = lambda x, y: x self.accept() def __call__(self, msg, step): self.update_signal.emit(msg, step) def do_update(self, msg, step): if msg is None: self.pb.setMaximum(step) else: self.msg.setText(msg) self.pb.setValue(step)
def __init__(self, title, widget=None, closeButton=True, keySequence=None, isDialog=False, icon=None): QDialog.__init__(self, ctx.mainScreen) self.setObjectName("dialog") self.isDialog = isDialog self.layout = QVBoxLayout() self.setLayout(self.layout) self.wlayout = QHBoxLayout() if icon: self.setStyleSheet( """QDialog QLabel{ margin-left:16px;margin-right:10px} QDialog#dialog {background-image:url(':/images/%s.png'); background-repeat:no-repeat; background-position: top left; padding-left:500px;} """ % icon) self.windowTitle = windowTitle(self, closeButton) self.setTitle(title) self.layout.setMargin(0) self.layout.addWidget(self.windowTitle) if widget: self.addWidget(widget) QObject.connect(widget, SIGNAL("finished(int)"), self.reject) QObject.connect(widget, SIGNAL("resizeDialog(int,int)"), self.resize) if closeButton: QObject.connect(self.windowTitle.pushButton, SIGNAL("clicked()"), self.reject) if keySequence: shortCut = QShortcut(keySequence, self) QObject.connect(shortCut, SIGNAL("activated()"), self.reject) QMetaObject.connectSlotsByName(self) self.resize(10, 10)
def __init__(self, default_status_msg=_('Welcome to') + ' ' + __appname__+' console', parent=None): QDialog.__init__(self, parent) self.restart_requested = False self.l = QVBoxLayout() self.setLayout(self.l) self.resize(800, 600) geom = dynamic.get('console_window_geometry', None) if geom is not None: self.restoreGeometry(geom) # Setup tool bar {{{ self.tool_bar = QToolBar(self) self.tool_bar.setToolButtonStyle(Qt.ToolButtonTextOnly) self.l.addWidget(self.tool_bar) # }}} # Setup status bar {{{ self.status_bar = QStatusBar(self) self.status_bar.defmsg = QLabel(__appname__ + _(' console ') + __version__) self.status_bar._font = QFont() self.status_bar._font.setBold(True) self.status_bar.defmsg.setFont(self.status_bar._font) self.status_bar.addWidget(self.status_bar.defmsg) # }}} self.console = Console(parent=self) self.console.running.connect(partial(self.status_bar.showMessage, _('Code is running'))) self.console.running_done.connect(self.status_bar.clearMessage) self.l.addWidget(self.console) self.l.addWidget(self.status_bar) self.setWindowTitle(__appname__ + ' console') self.setWindowIcon(QIcon(I('console.png'))) self.restart_action = QAction(_('Restart console'), self) self.restart_action.setShortcut(_('Ctrl+R')) self.addAction(self.restart_action) self.restart_action.triggered.connect(self.restart) self.console.context_menu.addAction(self.restart_action)
def __init__(self, gui, icon, do_user_config): QDialog.__init__(self, gui) self.gui = gui self.do_user_config = do_user_config # The current database shown in the GUI # db is an instance of the class LibraryDatabase2 from database.py # This class has many, many methods that allow you to do a lot of # things. self.db = gui.current_db self.l = QVBoxLayout() self.setLayout(self.l) self.label = QLabel(prefs['hello_world_msg']) self.l.addWidget(self.label) self.setWindowTitle('Interface Plugin Demo') self.setWindowIcon(icon) self.about_button = QPushButton('About', self) self.about_button.clicked.connect(self.about) self.l.addWidget(self.about_button) self.marked_button = QPushButton( 'Show books with only one format in the calibre GUI', self) self.marked_button.clicked.connect(self.marked) self.l.addWidget(self.marked_button) self.view_button = QPushButton('View the most recently added book', self) self.view_button.clicked.connect(self.view) self.l.addWidget(self.view_button) self.update_metadata_button = QPushButton( 'Update metadata in a book\'s files', self) self.update_metadata_button.clicked.connect(self.update_metadata) self.l.addWidget(self.update_metadata_button) self.conf_button = QPushButton('Configure this plugin', self) self.conf_button.clicked.connect(self.config) self.l.addWidget(self.conf_button) self.resize(self.sizeHint())
def do_config(self): # Save values that need to be synced between the dialog and the # search widget. self.config['open_external'] = self.open_external.isChecked() # Create the config dialog. It's going to put two config widgets # into a QTabWidget for displaying all of the settings. d = QDialog(self) button_box = QDialogButtonBox(QDialogButtonBox.Close) v = QVBoxLayout(d) button_box.accepted.connect(d.accept) button_box.rejected.connect(d.reject) d.setWindowTitle(_('Customize get books search')) tab_widget = QTabWidget(d) v.addWidget(tab_widget) v.addWidget(button_box) chooser_config_widget = StoreChooserWidget() search_config_widget = StoreConfigWidget(self.config) tab_widget.addTab(chooser_config_widget, _('Choose stores')) tab_widget.addTab(search_config_widget, _('Configure search')) # Restore dialog state. geometry = self.config.get('config_dialog_geometry', None) if geometry: d.restoreGeometry(geometry) else: d.resize(800, 600) tab_index = self.config.get('config_dialog_tab_index', 0) tab_index = min(tab_index, tab_widget.count() - 1) tab_widget.setCurrentIndex(tab_index) d.exec_() # Save dialog state. self.config['config_dialog_geometry'] = bytearray(d.saveGeometry()) self.config['config_dialog_tab_index'] = tab_widget.currentIndex() search_config_widget.save_settings() self.config_changed() self.gui.load_store_plugins() self.setup_store_checks()
def __init__(self): QWidget.__init__(self) self.l = QVBoxLayout() self.setLayout(self.l) self.l5 = QHBoxLayout() self.server_prefix_label = QLabel('Server prefix:') self.l5.addWidget(self.server_prefix_label) self.server_prefix = QLineEdit(self) self.server_prefix.setText(prefs['server_prefix']) self.l5.addWidget(self.server_prefix) self.server_prefix_label.setBuddy(self.server_prefix) self.l.addLayout(self.l5) self.ll = QHBoxLayout() self.server_label = QLabel('Server:') self.ll.addWidget(self.server_label) self.lsb_server = QLineEdit(self) self.lsb_server.setText(prefs['lsb_server']) self.ll.addWidget(self.lsb_server) self.server_label.setBuddy(self.lsb_server) self.l.addLayout(self.ll) self.lll = QHBoxLayout() self.librarian_label = QLabel('Librarian:') self.lll.addWidget(self.librarian_label) self.librarian = QLineEdit(self) self.librarian.setText(prefs['librarian']) self.lll.addWidget(self.librarian) self.librarian_label.setBuddy(self.librarian) self.l.addLayout(self.lll) self.llll = QHBoxLayout() self.library_uuid_label = QLabel('Library ID:') self.llll.addWidget(self.library_uuid_label) self.library_uuid = QLabel(self) self.library_uuid.setText(prefs['library_uuid']) self.llll.addWidget(self.library_uuid) self.library_uuid_label.setBuddy(self.library_uuid) self.l.addLayout(self.llll)
class Browser(QScrollArea): # {{{ show_plugin = pyqtSignal(object) def __init__(self, parent=None): QScrollArea.__init__(self, parent) self.setWidgetResizable(True) category_map, category_names = {}, {} for plugin in preferences_plugins(): if plugin.category not in category_map: category_map[plugin.category] = plugin.category_order if category_map[plugin.category] < plugin.category_order: category_map[plugin.category] = plugin.category_order if plugin.category not in category_names: category_names[plugin.category] = (plugin.gui_category if plugin.gui_category else plugin.category) self.category_names = category_names categories = list(category_map.keys()) categories.sort(cmp=lambda x, y: cmp(category_map[x], category_map[y])) self.category_map = OrderedDict() for c in categories: self.category_map[c] = [] for plugin in preferences_plugins(): self.category_map[plugin.category].append(plugin) for plugins in self.category_map.values(): plugins.sort(cmp=lambda x, y: cmp(x.name_order, y.name_order)) self.widgets = [] self._layout = QVBoxLayout() self.container = QWidget(self) self.container.setLayout(self._layout) self.setWidget(self.container) for name, plugins in self.category_map.items(): w = Category(name, plugins, self.category_names[name], parent=self) self.widgets.append(w) self._layout.addWidget(w) w.plugin_activated.connect(self.show_plugin.emit)
def __init__(self, parent, db): QDialog.__init__(self, parent) self.l = QVBoxLayout() self.setLayout(self.l) self.l1 = QLabel( _('Vacuuming database to improve performance.') + ' ' + _('This will take a while, please wait...')) self.setWindowTitle(_('Vacuuming...')) self.l1.setWordWrap(True) self.l.addWidget(self.l1) self.msg = QLabel('') self.update_msg.connect(self.msg.setText, type=Qt.QueuedConnection) self.l.addWidget(self.msg) self.msg.setWordWrap(True) self.resize(self.sizeHint() + QSize(100, 50)) self.error = None self.db = db.new_api self.closed_orig_conn = False self.rejected = False
def __init__(self, win): QDialog.__init__(self, win) self.setupUi(self) self.connect(self.closePTableButton,SIGNAL("clicked()"),self.close) self.connect(self.TransmuteButton,SIGNAL("clicked()"),self.transmutePressed) self.connect(self.elementButtonGroup,SIGNAL("clicked(int)"),self.setElementInfo) self.w = win self.elemTable = PeriodicTable self.displayMode = diTUBES self.elemGLPane = ElementView(self.elementFrame, "element glPane", self.w.glpane) # Put the GL widget inside the frame flayout = QVBoxLayout(self.elementFrame,1,1,'flayout') flayout.addWidget(self.elemGLPane,1) self.elementFrame.setWhatsThis("""3D view of current atom type""") self.TransmuteButton.setWhatsThis("""Transmutes selected atoms in the 3D workspace to current atom above.""") self.transmuteCheckBox.setWhatsThis("""Check if transmuted atoms should keep all existing bonds, even if chemistry is wrong.""")
def __init__(self, parent=None): QWidget.__init__(self, parent) self.bottomwidget = QWidget(self) self.bottomwidget.setMaximumHeight(200) self.bottomwidget.setMinimumHeight(0) self.glwidget = DemoWidget(self) self.mlayout = QVBoxLayout() self.setLayout(self.mlayout) self.mlayout.addWidget(self.glwidget) self.mlayout.addWidget(self.bottomwidget) self.mlayout.setSpacing(0) self.mlayout.setContentsMargins(0, 0, 0, 0) self.bottomwidget.hide() self.frame = self.glwidget
def __init__(self, raw, parent=None): QDialog.__init__(self, parent) self.edit = QPlainTextEdit(self) self.highlighter = PythonHighlighter(self.edit.document()) self.l = QVBoxLayout() self.setLayout(self.l) self.msg = QLabel( _('Add/edit tweaks for any custom plugins you have installed. ' 'Documentation for these tweaks should be available ' 'on the website from where you downloaded the plugins.')) self.msg.setWordWrap(True) self.l.addWidget(self.msg) self.l.addWidget(self.edit) self.edit.setPlainText(raw) self.bb = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel, Qt.Horizontal, self) self.bb.accepted.connect(self.accept) self.bb.rejected.connect(self.reject) self.l.addWidget(self.bb) self.resize(550, 300)
class Wizard(QDialog): def __init__(self, parent=None): QDialog.__init__(self, parent) self.resize(440, 480) self.verticalLayout = QVBoxLayout(self) self.widget = WizardWidget(self) self.verticalLayout.addWidget(self.widget) self.buttonBox = QDialogButtonBox(self) self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) self.verticalLayout.addWidget(self.buttonBox) self.connect(self.buttonBox, SIGNAL("accepted()"), self.accept) self.connect(self.buttonBox, SIGNAL("rejected()"), self.reject) self.setModal(Qt.WindowModal) @property def xpath(self): return self.widget.xpath
def pin_dialog(self, msg): # Needed e.g. when resetting a device self.clear_dialog() dialog = WindowModalDialog(self.top_level_window(), _("Enter PIN")) matrix = self.pin_matrix_widget_class() vbox = QVBoxLayout() vbox.addWidget(QLabel(msg)) vbox.addWidget(matrix) vbox.addLayout(Buttons(CancelButton(dialog), OkButton(dialog))) dialog.setLayout(vbox) dialog.exec_() self.response = str(matrix.get_value()) self.done.set()
def __init__(self, current_cover=None, parent=None): QDialog.__init__(self, parent) self.current_cover = current_cover self.log = Log() self.book = self.cover_pixmap = None self.setWindowTitle(_('Downloading metadata...')) self.setWindowIcon(QIcon(I('metadata.png'))) self.stack = QStackedWidget() self.l = l = QVBoxLayout() self.setLayout(l) l.addWidget(self.stack) self.bb = QDialogButtonBox(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) l.addWidget(self.bb) self.bb.rejected.connect(self.reject) self.next_button = self.bb.addButton(_('Next'), self.bb.AcceptRole) self.next_button.setDefault(True) self.next_button.setEnabled(False) self.next_button.setIcon(QIcon(I('ok.png'))) self.next_button.clicked.connect(self.next_clicked) self.ok_button = self.bb.button(self.bb.Ok) self.ok_button.clicked.connect(self.ok_clicked) self.prev_button = self.bb.addButton(_('Back'), self.bb.ActionRole) self.prev_button.setIcon(QIcon(I('back.png'))) self.prev_button.clicked.connect(self.back_clicked) self.log_button = self.bb.addButton(_('View log'), self.bb.ActionRole) self.log_button.clicked.connect(self.view_log) self.log_button.setIcon(QIcon(I('debug.png'))) self.ok_button.setVisible(False) self.prev_button.setVisible(False) self.identify_widget = IdentifyWidget(self.log, self) self.identify_widget.rejected.connect(self.reject) self.identify_widget.results_found.connect(self.identify_results_found) self.identify_widget.book_selected.connect(self.book_selected) self.stack.addWidget(self.identify_widget) self.covers_widget = CoversWidget(self.log, self.current_cover, parent=self) self.covers_widget.chosen.connect(self.ok_clicked) self.stack.addWidget(self.covers_widget) # Workaround for Qt 4.8.0 bug that causes the frame of the window to go # off the top of the screen if a max height is not set for the # QWebView. Seems to only happen on windows, but keep it for all # platforms just in case. self.identify_widget.comments_view.setMaximumHeight(500) self.resize(850, 600) self.finished.connect(self.cleanup)
def __init__(self, gui, icon, do_user_config, qaction, us): QDialog.__init__(self, gui) self.main_gui = gui self.do_user_config = do_user_config self.qaction = qaction self.us = us #- main UI layout ----------------------------------------------------- self.ll = QVBoxLayout() self.l = QHBoxLayout() self.l.setSpacing(0) #self.l.setMargin(0) # not in Qt5 self.w = QWidget() self.w.setLayout(self.l) self.setLayout(self.ll) self.setWindowIcon(icon) self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) #- webkit ------------------------------------------------------------- self.webview = QWebView() self.webview.setMaximumWidth(680) self.webview.setMaximumHeight(320) self.webview.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) # self.webview.load(QUrl.fromLocalFile( # os.path.join(self.us.portable_directory, # "portable/kaliweb.html"))) self.loadUrl() self.webview.page().networkAccessManager().sslErrors.connect( self.sslErrorHandler) #self.connect(self.webview.page().networkAccessManager(), # SIGNAL("sslErrors (QNetworkReply *, \ # const QList<QSslError> &)"), # self.sslErrorHandler) logger.info("KALIWEB PATH: {}".format( os.path.join(self.us.portable_directory, "portable/kaliweb.html"))) self.ll.addWidget(self.webview)
def __init__(self, parent=None, layerSet=None, linkedCanvas=None): GDocker.__init__(self, parent) maxDockerElem = 4 if len(layerSet) < maxDockerElem: maxDockerElem = len(layerSet) widgetsWidth = parent.width() / maxDockerElem # Set dock parameters self.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea) self.setFeatures(QDockWidget.DockWidgetMovable) self.setMinimumWidth(widgetsWidth) # Set main container parameter self._container = QWidget(self) self._container.setMinimumWidth(widgetsWidth) self.setWidget(self._container) # Vertical layout for the container (vertical dock) self._layout = QVBoxLayout(self._container) # Store the canvas of layers self._layerPortfolio = [] # For each layer in layer set : for i in range(0, len(layerSet)): # Create a new widget layerWidget = GAppLayerW(layerSet[i], layerSet.rawLayers[i], linkedCanvas, self) # Set its properties layerWidget.setMinimumWidth(widgetsWidth) # Connect its with main canvas self.connect(linkedCanvas, SIGNAL("mapCanvasRefreshed()"), layerWidget.refreshExtent) # Add it to portfolio and display it self._layerPortfolio.append(layerWidget) self._layout.addWidget(layerWidget)
def create_donate_widget(button): w = QWidget() w.setLayout(QVBoxLayout()) w.layout().addWidget(button) if isosx: w.setStyleSheet( 'QWidget, QToolButton {background-color: none; border: none; }') w.layout().setContentsMargins(0, 0, 0, 0) w.setContentsMargins(0, 0, 0, 0) w.filler = QLabel(u'\u00a0') w.layout().addWidget(w.filler) return w
def __init__(self): QGroupBox.__init__(self) self.treemodel = treemodel = TestNe1Model() self.view = view = ModelTreeGui(TestMainWindow(), "Model tree", treemodel, self) view.mt_update() self.chunkNum = 2 self.gbox = QGroupBox() vl = QVBoxLayout(self) vl.setSpacing(0) vl.setMargin(0) vl.addWidget(self.view) self.buttonLayout = hl = QHBoxLayout() hl.setSpacing(0) hl.setMargin(0) vl.addLayout(hl) self.buttonNum = 1 for func in (self.addmol, self.addjig, self.selected): self.addButton(func)
def __init__(self, current_cover=None, parent=None): QDialog.__init__(self, parent) self.current_cover = current_cover self.log = Log() self.book = self.cover_pixmap = None self.setWindowTitle(_('Downloading metadata...')) self.setWindowIcon(QIcon(I('metadata.png'))) self.stack = QStackedWidget() self.l = l = QVBoxLayout() self.setLayout(l) l.addWidget(self.stack) self.bb = QDialogButtonBox(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) l.addWidget(self.bb) self.bb.rejected.connect(self.reject) self.bb.accepted.connect(self.accept) self.next_button = self.bb.addButton(_('Next'), self.bb.ActionRole) self.next_button.setDefault(True) self.next_button.setEnabled(False) self.next_button.setIcon(QIcon(I('ok.png'))) self.next_button.clicked.connect(self.next_clicked) self.ok_button = self.bb.button(self.bb.Ok) self.ok_button.setEnabled(False) self.ok_button.clicked.connect(self.ok_clicked) self.prev_button = self.bb.addButton(_('Back'), self.bb.ActionRole) self.prev_button.setIcon(QIcon(I('back.png'))) self.prev_button.clicked.connect(self.back_clicked) self.log_button = self.bb.addButton(_('View log'), self.bb.ActionRole) self.log_button.clicked.connect(self.view_log) self.log_button.setIcon(QIcon(I('debug.png'))) self.prev_button.setVisible(False) self.identify_widget = IdentifyWidget(self.log, self) self.identify_widget.rejected.connect(self.reject) self.identify_widget.results_found.connect(self.identify_results_found) self.identify_widget.book_selected.connect(self.book_selected) self.stack.addWidget(self.identify_widget) self.covers_widget = CoversWidget(self.log, self.current_cover, parent=self) self.covers_widget.chosen.connect(self.ok_clicked) self.stack.addWidget(self.covers_widget) self.resize(850, 600) geom = gprefs.get('metadata_single_gui_geom', None) if geom is not None and geom: self.restoreGeometry(geom) self.finished.connect(self.cleanup)
def __init__(self, parent, db): QDialog.__init__(self, parent) self.l = QVBoxLayout() self.setLayout(self.l) self.l1 = QLabel(_('Checking database integrity') + '...') self.setWindowTitle(_('Checking database integrity')) self.l.addWidget(self.l1) self.pb = QProgressBar(self) self.l.addWidget(self.pb) self.pb.setMaximum(0) self.pb.setMinimum(0) self.msg = QLabel('') self.l.addWidget(self.msg) self.msg.setWordWrap(True) self.bb = QDialogButtonBox(QDialogButtonBox.Cancel) self.l.addWidget(self.bb) self.bb.rejected.connect(self.reject) self.resize(self.sizeHint() + QSize(100, 50)) self.error = None self.db = db self.closed_orig_conn = False
def __init__(self, parent=None, mm=None, choices=None): SizePersistedDialog.__init__(self, parent, 'casanova plugin:author update dialog') self.setWindowTitle('Select authors to update:') self.gui = parent self.mm = mm self.choices = choices layout = QVBoxLayout(self) self.setLayout(layout) self.values_list = QListWidget(self) self.values_list.setSelectionMode(QAbstractItemView.ExtendedSelection) layout.addWidget(self.values_list) self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.button_box.accepted.connect(self._accept_clicked) self.button_box.rejected.connect(self.reject) layout.addWidget(self.button_box) self._display_choices() # Cause our dialog size to be restored from prefs or created on first usage self.resize_dialog()
def __init__(self, *args): QWidget.__init__(self, *args) # init layout self._lo = QVBoxLayout(self) self._lo.setContentsMargins(0, 0, 0, 0) self._lo.setSpacing(0) # init internal state self._currier = PersistentCurrier() self._z0 = 0 # z-depth of first image, the rest count down from it self._updating_imap = False self._locked_display_range = False self._imagecons = [] self._imagecon_loadorder = [] self._center_image = None self._plot = None self._border_pen = None self._drawing_key = None self._load_image_dialog = None self._model_imagecons = set() # init menu and standard actions self._menu = QMenu("&Image", self) qag = QActionGroup(self) # exclusive controls for plotting topmost or all images self._qa_plot_top = qag.addAction("Display topmost image only") self._qa_plot_all = qag.addAction("Display all images") self._qa_plot_top.setCheckable(True) self._qa_plot_all.setCheckable(True) self._qa_plot_top.setChecked(True) QObject.connect(self._qa_plot_all, SIGNAL("toggled(bool)"), self._displayAllImages) self._closing = False self._qa_load_clipboard = None self._clipboard_mode = QClipboard.Clipboard QObject.connect(QApplication.clipboard(), SIGNAL("changed(QClipboard::Mode)"), self._checkClipboardPath) # populate the menu self._repopulateMenu()
class BlockingBusy(QDialog): def __init__(self, msg, parent=None, window_title=_('Working')): QDialog.__init__(self, parent) self._layout = QVBoxLayout() self.setLayout(self._layout) self.msg = QLabel(msg) #self.msg.setWordWrap(True) self.font = QFont() self.font.setPointSize(self.font.pointSize() + 8) self.msg.setFont(self.font) self.pi = ProgressIndicator(self) self.pi.setDisplaySize(100) self._layout.addWidget(self.pi, 0, Qt.AlignHCenter) self._layout.addSpacing(15) self._layout.addWidget(self.msg, 0, Qt.AlignHCenter) self.start() self.setWindowTitle(window_title) self.resize(self.sizeHint()) def start(self): self.pi.startAnimation() def stop(self): self.pi.stopAnimation() def accept(self): self.stop() return QDialog.accept(self) def reject(self): pass # Cannot cancel this dialog
def pin_dialog(self, msg): d = QDialog(None) d.setModal(1) d.setWindowTitle(_("Enter PIN")) matrix = PinMatrixWidget() vbox = QVBoxLayout() vbox.addWidget(QLabel(msg)) vbox.addWidget(matrix) vbox.addLayout(ok_cancel_buttons(d)) d.setLayout(vbox) if not d.exec_(): return return str(matrix.get_value())
def set_viewer_group(self): ''' 1. Load Items from viewer factory ''' view_fact = ViewerPluginFactory() self.viewer_stack = QtGui.QStackedWidget() self.viewer_cbox = self.builder.combobox(self.groupb_viewer, [], self.set_cb_changed_event_view) self.set_start_button = self.builder.pushbutton(self.groupb_viewer, 'Start Simulation', self.create_aut_env) self.set_start_button.setFixedWidth(200) self.set_start_button.setFixedHeight(25) for viewer_plugin in view_fact.createable_objects(): view = view_fact.make(viewer_plugin) if view != None: view.set_monitor(self.monitor) self.viewer_stack.addWidget(view.get_widget(self)) self.viewer_cbox.addItem(view.get_combobox_name()) ''' layout ''' v_layout = QVBoxLayout() self.viewer_cbox.setFixedHeight(25) v_layout.addWidget(self.viewer_stack) hl = QHBoxLayout() hl.addWidget(self.viewer_cbox) hl.addWidget(self.set_start_button) v_layout.addLayout(hl) self.groupb_viewer.setLayout(v_layout)
def __init__(self, parent=None, dm=None, casanova_id=None): SizePersistedDialog.__init__(self, parent, 'casanova plugin:format download dialog') self.setWindowTitle('Select format to download:') self.gui = parent self.dm = dm self.casanova_id = casanova_id layout = QVBoxLayout(self) self.setLayout(layout) self.values_list = QListWidget(self) self.values_list.setSelectionMode(QAbstractItemView.ExtendedSelection) layout.addWidget(self.values_list) self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.button_box.accepted.connect(self._accept_clicked) self.button_box.rejected.connect(self.reject) layout.addWidget(self.button_box) self._display_formats() # Cause our dialog size to be restored from prefs or created on first usage self.resize_dialog()
def setup_ui(self): self.l = l = QVBoxLayout(self) self.setLayout(l) self.h = h = QHBoxLayout() l.addLayout(h) names = [n for n, linear in self.container.spine_names] fn, f = create_filterable_names_list(names, filter_text=_('Filter files'), parent=self) self.file_names, self.file_names_filter = fn, f fn.selectionModel().selectionChanged.connect(self.selected_file_changed) self.fnl = fnl = QVBoxLayout() self.la1 = la = QLabel(_('Choose a &file to link to:')) la.setBuddy(fn) fnl.addWidget(la), fnl.addWidget(f), fnl.addWidget(fn) h.addLayout(fnl), h.setStretch(0, 2) fn, f = create_filterable_names_list([], filter_text=_('Filter locations'), parent=self) self.anchor_names, self.anchor_names_filter = fn, f fn.selectionModel().selectionChanged.connect(self.update_target) fn.doubleClicked.connect(self.accept, type=Qt.QueuedConnection) self.anl = fnl = QVBoxLayout() self.la2 = la = QLabel(_('Choose a &location (anchor) in the file:')) la.setBuddy(fn) fnl.addWidget(la), fnl.addWidget(f), fnl.addWidget(fn) h.addLayout(fnl), h.setStretch(1, 1) self.tl = tl = QFormLayout() self.target = t = QLineEdit(self) t.setPlaceholderText(_('The destination (href) for the link')) tl.addRow(_('&Target:'), t) l.addLayout(tl) self.text_edit = t = QLineEdit(self) la.setBuddy(t) tl.addRow(_('Te&xt:'), t) t.setText(self.initial_text or '') t.setPlaceholderText(_('The (optional) text for the link')) l.addWidget(self.bb)
class Comments(Base): def setup_ui(self, parent): self._box = QGroupBox(parent) self._box.setTitle('&' + self.col_metadata['name']) self._layout = QVBoxLayout() self._tb = CommentsEditor(self._box) self._tb.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum) # self._tb.setTabChangesFocus(True) self._layout.addWidget(self._tb) self._box.setLayout(self._layout) self.widgets = [self._box] def setter(self, val): if val is None: val = '' self._tb.html = comments_to_html(val) def getter(self): val = unicode(self._tb.html).strip() if not val: val = None return val
def __init__(self, parent=None): QDialog.__init__(self, parent) self._layout = QVBoxLayout(self) self.setLayout(self._layout) self.log = QPlainTextEdit(self) self._layout.addWidget(self.log) self.log.setPlainText(_('Getting device information')+'...') self.copy = QPushButton(_('Copy to &clipboard')) self.copy.setDefault(True) self.setWindowTitle(_('User-defined device information')) self.setWindowIcon(QIcon(I('debug.png'))) self.copy.clicked.connect(self.copy_to_clipboard) self.ok = QPushButton('&OK') self.ok.setAutoDefault(False) self.ok.clicked.connect(self.accept) self.bbox = QDialogButtonBox(self) self.bbox.addButton(self.copy, QDialogButtonBox.ActionRole) self.bbox.addButton(self.ok, QDialogButtonBox.AcceptRole) self._layout.addWidget(self.bbox) self.resize(750, 500) self.bbox.setEnabled(False) QTimer.singleShot(1000, self.device_info)
def __init__(self, parent, plugin, locations): QDialog.__init__(self, parent) self.locations = locations self.setWindowTitle(_('Add "%s" to toolbars or menus') % plugin.name) self._layout = QVBoxLayout(self) self.setLayout(self._layout) self._header_label = QLabel( _('Select the toolbars and/or menus to add <b>%s</b> to:') % plugin.name) self._layout.addWidget(self._header_label) self._locations_list = QListWidget(self) self._locations_list.setSelectionMode(QAbstractItemView.MultiSelection) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) self._locations_list.setSizePolicy(sizePolicy) for key, text in locations: self._locations_list.addItem(text) if key in {'toolbar', 'toolbar-device'}: self._locations_list.item(self._locations_list.count() - 1).setSelected(True) self._layout.addWidget(self._locations_list) self._footer_label = QLabel( _('You can also customise the plugin locations ' 'using <b>Preferences -> Customise the toolbar</b>')) self._layout.addWidget(self._footer_label) button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) button_box.accepted.connect(self.accept) button_box.rejected.connect(self.reject) self._layout.addWidget(button_box) self.resize(self.sizeHint())