def __init__(self, parent, key_defs): QDialog.__init__( self, parent, Qt.WindowStaysOnTopHint | Qt.X11BypassWindowManagerHint | Qt.FramelessWindowHint, ) self.setVisible(False) self.filter_items = {} layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) frame = QFrame() frame.setFrameStyle(QFrame.StyledPanel | QFrame.Raised) layout.addWidget(frame) self.__layout = QVBoxLayout() self.__layout.setSizeConstraint(QLayout.SetFixedSize) self.__layout.addWidget(QLabel("Filter by data type:")) filters = {k["metadata"]["data_origin"] for k in key_defs} for f in filters: self.addFilterItem(f, f) frame.setLayout(self.__layout) self.setLayout(layout) self.adjustSize()
def __init__(self, parent=None, set_tree=False, set_db=False, test=False): """Initialize. :param parent: parent :type parent: QWidget :param set_tree: set connection to tree :type set_tree: bool :param set_db: set connection to DB :type set_db: bool :param test: test mode :type test: bool """ QDialog.__init__(self, parent) self.setWindowTitle(self.NAME) self.layout = QVBoxLayout() self.setLayout(self.layout) self.parent = parent self.treebase = parent # for grab object self.object_name = None # Use less wires and more signal/slot if set_tree: self.treebase = parent # connection wire to outside world if self.treebase is not None: self.mainwindow = self.treebase.main if set_db and self.treebase is not None: self.database = self.treebase.object_data if test: self.test()
def __init__(self, parent, plugin, tabs, data, icon): QDialog.__init__(self, parent) # Variables self.plugins_tabs = [] self.plugins_data = [] self.plugins_instances = [] self.add_plugin(plugin, tabs, data, icon) self.plugin = None # Last plugin with focus self.mode = self.FILE_MODE # By default start in this mode self.initial_cursors = None # {fullpath: QCursor} self.initial_path = None # Fullpath of initial active editor self.initial_widget = None # Initial active editor self.line_number = None # Selected line number in filer self.is_visible = False # Is the switcher visible? help_text = _("Press <b>Enter</b> to switch files or <b>Esc</b> to " "cancel.<br><br>Type to filter filenames.<br><br>" "Use <b>:number</b> to go to a line, e.g. " "<b><code>main:42</code></b><br>" "Use <b>@symbol_text</b> to go to a symbol, e.g. " "<b><code>@init</code></b>" "<br><br> Press <b>Ctrl+W</b> to close current tab.<br>") # Either allow searching for a line number or a symbol but not both regex = QRegExp("([A-Za-z0-9_]{0,100}@[A-Za-z0-9_]{0,100})|" + "([A-Za-z0-9_]{0,100}:{0,1}[0-9]{0,100})") # Widgets self.edit = FilesFilterLine(self) self.help = HelperToolButton() self.list = QListWidget(self) self.filter = KeyPressFilter() regex_validator = QRegExpValidator(regex, self.edit) # Widgets setup self.setWindowFlags(Qt.Popup | Qt.FramelessWindowHint) self.setWindowOpacity(0.95) self.edit.installEventFilter(self.filter) self.edit.setValidator(regex_validator) self.help.setToolTip(help_text) self.list.setItemDelegate(HTMLDelegate(self)) # Layout edit_layout = QHBoxLayout() edit_layout.addWidget(self.edit) edit_layout.addWidget(self.help) layout = QVBoxLayout() layout.addLayout(edit_layout) layout.addWidget(self.list) self.setLayout(layout) # Signals self.rejected.connect(self.restore_initial_state) self.filter.sig_up_key_pressed.connect(self.previous_row) self.filter.sig_down_key_pressed.connect(self.next_row) self.edit.returnPressed.connect(self.accept) self.edit.textChanged.connect(self.setup) self.list.itemSelectionChanged.connect(self.item_selection_changed) self.list.clicked.connect(self.edit.setFocus)
def __init__(self, autosave_mapping, parent=None): """ Constructor Parameters ---------- autosave_mapping : List[Tuple[str]] List of tuples, containing the name of the original file and the name of the corresponding autosave file. The first entry of the tuple may be `None` to indicate that the original file is unknown. parent : QWidget, optional Parent of the dialog window. The default is None. """ QDialog.__init__(self, parent) self.layout = QVBoxLayout(self) self.setLayout(self.layout) self.layout.setSpacing(self.layout.spacing() * 3) self.files_to_open = [] self.gather_data(autosave_mapping) self.add_label() self.add_table() self.add_cancel_button() self.setWindowTitle(_('Recover from autosave')) self.setFixedSize(670, 400) self.setWindowFlags( Qt.Dialog | Qt.MSWindowsFixedSizeDialogHint | Qt.WindowStaysOnTopHint) # This is needed because of an error in MacOS. # See https://bugreports.qt.io/browse/QTBUG-49576 if parent and hasattr(parent, 'splash'): self.splash = parent.splash self.splash.hide() else: self.splash = None
def __init__(self, action, error): """ Constructor. Args: action (str): what Spyder was trying to do when error occurred error (Exception): the error that occurred """ logger.error(action, exc_info=error) QDialog.__init__(self) self.setWindowTitle(_('Autosave error')) self.setModal(True) layout = QVBoxLayout() header = _('Error message:') txt = '<br>{}<br><br>{}<br>{!s}'.format(action, header, error) layout.addWidget(QLabel(txt)) layout.addSpacing(15) txt = _("Hide all future autosave-related errors during this session") self.dismiss_box = QCheckBox(txt) layout.addWidget(self.dismiss_box) layout.addSpacing(15) button_box = QDialogButtonBox(QDialogButtonBox.Ok) button_box.accepted.connect(self.accept) layout.addWidget(button_box) self.setLayout(layout)
def __init__(self, parent=None): self.parent = parent QDialog.__init__(self, parent=parent) self.ui = load_ui('reduction_configuration_dialog.ui', baseinstance=self) self.init_widgets() set_default_folder_path(self.parent)
def __init__(self, autosave_mapping, parent=None): """ Constructor Parameters ---------- autosave_mapping : List[Tuple[str]] List of tuples, containing the name of the original file and the name of the corresponding autosave file. The first entry of the tuple may be `None` to indicate that the original file is unknown. parent : QWidget, optional Parent of the dialog window. The default is None. """ QDialog.__init__(self, parent) self.layout = QVBoxLayout(self) self.setLayout(self.layout) self.layout.setSpacing(self.layout.spacing() * 3) self.files_to_open = [] self.gather_data(autosave_mapping) self.add_label() self.add_table() self.add_cancel_button() self.setWindowTitle(_('Recover from autosave')) self.setFixedSize(670, 400) self.setWindowFlags(Qt.Dialog | Qt.MSWindowsFixedSizeDialogHint)
def __init__(self, appdata: CnaData, central_widget): QDialog.__init__(self) self.setWindowTitle("Rename map") self.appdata = appdata self.central_widget = central_widget self.layout = QVBoxLayout() h1 = QHBoxLayout() label = QLabel("Enter new map name") self.layout.addWidget(label) self.idx = self.central_widget.map_tabs.currentIndex() self.old_name = self.central_widget.map_tabs.tabText(self.idx) self.name_field = QLineEdit(self.old_name) h1.addWidget(self.name_field) self.layout.addItem(h1) l2 = QHBoxLayout() self.button = QPushButton("Rename") self.cancel = QPushButton("Cancel") l2.addWidget(self.button) l2.addWidget(self.cancel) self.layout.addItem(l2) self.setLayout(self.layout) # Connecting the signal self.cancel.clicked.connect(self.reject) self.button.clicked.connect(self.apply)
def __init__(self, parent): QDialog.__init__(self, parent) self.setWindowTitle("Spyder %s: %s" % (__version__, _("Dependencies"))) self.setWindowIcon(ima.icon('tooloptions')) self.setModal(True) self.treewidget = DependenciesTreeWidget(self) self.label = QLabel( _("Optional modules are not required to run " "Spyder but enhance its functions.")) self.label2 = QLabel( _("<b>Note:</b> New dependencies or changed ones " "will be correctly detected only after Spyder " "is restarted.")) btn = QPushButton(_("Copy to clipboard"), ) btn.clicked.connect(self.copy_to_clipboard) bbox = QDialogButtonBox(QDialogButtonBox.Ok) bbox.accepted.connect(self.accept) hlayout = QHBoxLayout() hlayout.addWidget(btn) hlayout.addStretch() hlayout.addWidget(bbox) vlayout = QVBoxLayout() vlayout.addWidget(self.treewidget) vlayout.addWidget(self.label) vlayout.addWidget(self.label2) vlayout.addLayout(hlayout) self.setLayout(vlayout) self.resize(840, 560)
def __init__(self, appdata: CnaData, centralwidget): QDialog.__init__(self) self.setWindowTitle("Elementary Flux Mode Computation") self.appdata = appdata self.centralwidget = centralwidget self.layout = QVBoxLayout() l1 = QHBoxLayout() self.constraints = QCheckBox("consider 0 in current scenario as off") self.constraints.setCheckState(Qt.Checked) l1.addWidget(self.constraints) self.layout.addItem(l1) lx = QHBoxLayout() self.button = QPushButton("Compute") self.cancel = QPushButton("Close") lx.addWidget(self.button) lx.addWidget(self.cancel) self.layout.addItem(lx) self.setLayout(self.layout) # Connecting the signal self.cancel.clicked.connect(self.reject) self.button.clicked.connect(self.compute)
def __init__(self, parent, fig): QDialog.__init__(self, parent) self.ui = Ui_Dialog_preview() self.ui.setupUi(self) self._canvas = FigureCanvas(fig) self.ui.verticalLayout_2.addWidget(self._canvas) self.resize(self.sizeHint())
def __init__(self, parent=None): QDialog.__init__(self, parent) self.main = parent # Widgets self.pages_widget = QStackedWidget() self.pages_widget.setMinimumWidth(600) self.contents_widget = QListWidget() self.button_reset = QPushButton(_('Reset to defaults')) bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Apply | QDialogButtonBox.Cancel) self.apply_btn = bbox.button(QDialogButtonBox.Apply) self.ok_btn = bbox.button(QDialogButtonBox.Ok) # Widgets setup # 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.setWindowTitle(_('Preferences')) self.setWindowIcon(ima.icon('configure')) self.contents_widget.setMovement(QListView.Static) self.contents_widget.setSpacing(1) self.contents_widget.setCurrentRow(0) self.contents_widget.setMinimumWidth(220) self.contents_widget.setMinimumHeight(400) # Layout hsplitter = QSplitter() hsplitter.addWidget(self.contents_widget) hsplitter.addWidget(self.pages_widget) hsplitter.setStretchFactor(0, 1) hsplitter.setStretchFactor(1, 2) btnlayout = QHBoxLayout() btnlayout.addWidget(self.button_reset) btnlayout.addStretch(1) btnlayout.addWidget(bbox) vlayout = QVBoxLayout() vlayout.addWidget(hsplitter) vlayout.addLayout(btnlayout) self.setLayout(vlayout) # Signals and slots if self.main: self.button_reset.clicked.connect(self.main.reset_spyder) self.pages_widget.currentChanged.connect(self.current_page_changed) self.contents_widget.currentRowChanged.connect( self.pages_widget.setCurrentIndex) bbox.accepted.connect(self.accept) bbox.rejected.connect(self.reject) bbox.clicked.connect(self.button_clicked) # Ensures that the config is present on spyder first run CONF.set('main', 'interface_language', load_lang_conf())
def __init__( self, wintitle="guiqwt plot", icon="guiqwt.svg", edit=False, toolbar=False, options=None, parent=None, panels=None, ): if not PYQT5: QDialog.__init__(self, parent) self.edit = edit self.button_box = None self.button_layout = None if PYQT5: super(CurveDialog, self).__init__( parent, wintitle=wintitle, icon=icon, toolbar=toolbar, options=options, panels=panels, ) else: CurveWidgetMixin.__init__( self, wintitle=wintitle, icon=icon, toolbar=toolbar, options=options, panels=panels, ) self.setWindowFlags(Qt.Window) win32_fix_title_bar_background(self)
def __init__(self, parent=None): QDialog.__init__(self, parent) # Set style of all QPushButton's inside the dialog. css = qstylizer.style.StyleSheet() css.QPushButton.setValues(padding='3px 15px 3px 15px', ) self.setStyleSheet(css.toString())
def __init__(self): QDialog.__init__(self) # setup UI self.form = QFormLayout(self) self.editPosition = QLineEdit('') self.form.addRow(QLabel('Position'), self.editPosition) self.editVelocity = QLineEdit('') self.form.addRow(QLabel('Velocity'), self.editVelocity) # configure network (take first available servo) self._net, self._servo = il.lucky(il.NET_PROT.EUSB) # create data model model = QStandardItemModel() pos = QStandardItem() vel = QStandardItem() model.appendRow([pos, vel]) # configure and start watcher self._watcher = RegisterWatcher(self._servo) self._watcher.add(POS_ACT, 500, pos) self._watcher.add(VEL_ACT, 100, vel) self._watcher.start(100) # map model fields to widgets self._mapper = QDataWidgetMapper() self._mapper.setModel(model) self._mapper.addMapping(self.editPosition, 0) self._mapper.addMapping(self.editVelocity, 1) self._mapper.toFirst()
def __init__(self, parent=None): QDialog.__init__( self, parent, flags=Qt.WindowSystemMenuHint | Qt.WindowTitleHint) self.setWindowTitle('Import Names') self.treeview = parent self.setAttribute(Qt.WA_DeleteOnClose) self.importSelected = QCheckBox(_("Import selected"), self) self.importSelected.setCheckState(Qt.Checked) self.importChildren = QCheckBox(_("Import children"), self) self.importChildren.setCheckState(Qt.Checked) self.replaceExisting = QCheckBox(_("Replace existing names"), self) self.replaceExisting.setCheckState(Qt.Checked) self.buttonBox = QDialogButtonBox(self) self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons( QDialogButtonBox.Cancel|QDialogButtonBox.Ok) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) mainLayout = QGridLayout(self) mainLayout.addWidget(self.importSelected) mainLayout.addWidget(self.importChildren) mainLayout.addWidget(self.replaceExisting) mainLayout.addWidget(self.buttonBox) self.setLayout(mainLayout)
def __init__(self, parent=None): QDialog.__init__( self, parent, flags=Qt.WindowSystemMenuHint | Qt.WindowTitleHint) self.setWindowTitle('Read Model') self.treeview = parent self.setAttribute(Qt.WA_DeleteOnClose) fixed_dir_layout = QHBoxLayout() browse_btn = QPushButton(ima.icon('DirOpenIcon'), '', self) browse_btn.setToolTip(_("Select model directory")) browse_btn.clicked.connect(self.select_directory) self.wd_edit = QLineEdit() fixed_dir_layout.addWidget(self.wd_edit) fixed_dir_layout.addWidget(browse_btn) fixed_dir_layout.setContentsMargins(0, 0, 0, 0) namelabel = QLabel(_("Model Name")) self.nameEdit = QLineEdit(self) self.importWidget = ImportAsWidget(self, self.nameEdit) self.buttonBox = QDialogButtonBox(self) self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons( QDialogButtonBox.Cancel|QDialogButtonBox.Ok) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) mainLayout = QGridLayout(self) mainLayout.addLayout(fixed_dir_layout, 0, 0, 1, 2) mainLayout.addWidget(namelabel, 1, 0) mainLayout.addWidget(self.nameEdit, 1, 1) mainLayout.addWidget(self.importWidget, 2, 0, 1, 2) mainLayout.addWidget(self.buttonBox, 3, 0, 1, 2) # mainLayout.setContentsMargins(0, 0, 0, 0) self.setLayout(mainLayout)
def __init__(self, parent): QDialog.__init__(self, parent) self.setWindowTitle("Spyder %s: %s" % (__version__, _("Dependencies"))) self.setWindowIcon(ima.icon('tooloptions')) self.setModal(True) self.treewidget = DependenciesTreeWidget(self) self.label = QLabel(_("Optional modules are not required to run " "Spyder but enhance its functions.")) self.label2 = QLabel(_("<b>Note:</b> New dependencies or changed ones " "will be correctly detected only after Spyder " "is restarted.")) btn = QPushButton(_("Copy to clipboard"), ) btn.clicked.connect(self.copy_to_clipboard) bbox = QDialogButtonBox(QDialogButtonBox.Ok) bbox.accepted.connect(self.accept) hlayout = QHBoxLayout() hlayout.addWidget(btn) hlayout.addStretch() hlayout.addWidget(bbox) vlayout = QVBoxLayout() vlayout.addWidget(self.treewidget) vlayout.addWidget(self.label) vlayout.addWidget(self.label2) vlayout.addLayout(hlayout) self.setLayout(vlayout) self.resize(840, 560)
def __init__(self, parent=None): QDialog.__init__( self, parent, Qt.WindowStaysOnTopHint | Qt.X11BypassWindowManagerHint | Qt.FramelessWindowHint) self.setVisible(False) self.filter_items = {} layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) frame = QFrame() frame.setFrameStyle(QFrame.StyledPanel | QFrame.Raised) layout.addWidget(frame) self.__layout = QVBoxLayout() self.__layout.setSizeConstraint(QLayout.SetFixedSize) self.__layout.addWidget(QLabel("Filter by data type:")) self.addFilterItem("Summary", "summary") # self.addFilterItem("Block", "block") self.addFilterItem("Gen KW", "gen_kw") self.addFilterItem("Gen Data", "gen_data") self.addFilterItem("Custom KW", "custom_kw") # self.addFilterItem("Custom PCA", "custom_pca") frame.setLayout(self.__layout) self.setLayout(layout) self.adjustSize()
def __init__(self, parent=None): self.parent = parent QDialog.__init__(self, parent=parent) self.ui = UiDialog() self.ui.setupUi(self) self.parent.load_intermediate_step_ok = False
def __init__(self, parent, jack_client, jack_name=PROGRAM): QDialog.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.fFreewheel = False self.fLastTime = -1 self.fMaxTime = 180 self.fTimer = QTimer(self) self.fProcess = QProcess(self) self.fJackClient = jack_client self.fJackName = jack_name self.fBufferSize = self.fJackClient.get_buffer_size() self.fSampleRate = self.fJackClient.get_sample_rate() # Selected ports used as recording sources self.rec_sources = set() self.createUi() self.loadSettings() self.populatePortLists(init=True) # listen to changes to JACK ports self._refresh_timer = None self.fJackClient.ports_changed.connect(self.slot_refreshPortsLists)
def __init__(self, parent=None): QDialog.__init__(self, parent) self.main = parent # Widgets self.pages_widget = QStackedWidget() self.pages_widget.setMinimumWidth(600) self.contents_widget = QListWidget() self.button_reset = QPushButton(_('Reset to defaults')) bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Apply | QDialogButtonBox.Cancel) self.apply_btn = bbox.button(QDialogButtonBox.Apply) # Widgets setup # 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.setWindowTitle(_('Preferences')) self.setWindowIcon(ima.icon('configure')) self.contents_widget.setMovement(QListView.Static) self.contents_widget.setSpacing(1) self.contents_widget.setCurrentRow(0) self.contents_widget.setMinimumWidth(220) self.contents_widget.setMinimumHeight(400) # Layout hsplitter = QSplitter() hsplitter.addWidget(self.contents_widget) hsplitter.addWidget(self.pages_widget) hsplitter.setStretchFactor(0, 1) hsplitter.setStretchFactor(1, 2) btnlayout = QHBoxLayout() btnlayout.addWidget(self.button_reset) btnlayout.addStretch(1) btnlayout.addWidget(bbox) vlayout = QVBoxLayout() vlayout.addWidget(hsplitter) vlayout.addLayout(btnlayout) self.setLayout(vlayout) # Signals and slots if self.main: self.button_reset.clicked.connect(self.main.reset_spyder) self.pages_widget.currentChanged.connect(self.current_page_changed) self.contents_widget.currentRowChanged.connect( self.pages_widget.setCurrentIndex) bbox.accepted.connect(self.accept) bbox.rejected.connect(self.reject) bbox.clicked.connect(self.button_clicked) # Ensures that the config is present on spyder first run CONF.set('main', 'interface_language', load_lang_conf())
def __init__(self, text, title='', font=None, parent=None, readonly=False, size=(400, 300)): QDialog.__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.text = None self.btn_save_and_close = None # Display text as unicode if it comes as bytes, so users see # its right representation if is_binary_string(text): self.is_binary = True text = to_text_string(text, 'utf8') else: self.is_binary = False self.layout = QVBoxLayout() self.setLayout(self.layout) # Text edit self.edit = QTextEdit(parent) self.edit.setReadOnly(readonly) self.edit.textChanged.connect(self.text_changed) self.edit.setPlainText(text) if font is None: font = get_font() self.edit.setFont(font) self.layout.addWidget(self.edit) # Buttons configuration btn_layout = QHBoxLayout() btn_layout.addStretch() if not readonly: self.btn_save_and_close = QPushButton(_('Save and Close')) self.btn_save_and_close.setDisabled(True) self.btn_save_and_close.clicked.connect(self.accept) btn_layout.addWidget(self.btn_save_and_close) self.btn_close = QPushButton(_('Close')) self.btn_close.setAutoDefault(True) self.btn_close.setDefault(True) self.btn_close.clicked.connect(self.reject) btn_layout.addWidget(self.btn_close) self.layout.addLayout(btn_layout) # Make the dialog act as a window self.setWindowFlags(Qt.Window) self.setWindowIcon(ima.icon('edit')) self.setWindowTitle(_("Text editor") + \ "%s" % (" - "+str(title) if str(title) else "")) self.resize(size[0], size[1])
def __init__(self, parent=None, objname=None): QDialog.__init__(self, parent) # If used for data object in tree, the main is the tree widget. self.parent = parent self.objname = objname # Widgets self.pages_widget = QStackedWidget() self.contents_widget = QListWidget() self.button_reset = QPushButton(_('Reset to defaults')) bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Apply | QDialogButtonBox.Cancel) self.apply_btn = bbox.button(QDialogButtonBox.Apply) # Widgets setup # 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 Ezcad), thus leading to # a segmentation fault on UNIX or an application crash on Windows self.setAttribute(Qt.WA_DeleteOnClose) if self.objname is None: self.setWindowTitle(_('Preferences')) else: self.setWindowTitle(_('Preferences of ') + self.objname) self.setWindowIcon(ima.icon('configure')) self.contents_widget.setMovement(QListView.Static) self.contents_widget.setSpacing(1) self.contents_widget.setCurrentRow(0) # Layout hsplitter = QSplitter() hsplitter.addWidget(self.contents_widget) hsplitter.addWidget(self.pages_widget) hsplitter.setSizes([150,500]) btnlayout = QHBoxLayout() btnlayout.addWidget(self.button_reset) btnlayout.addStretch(1) btnlayout.addWidget(bbox) vlayout = QVBoxLayout() vlayout.addWidget(hsplitter) vlayout.addLayout(btnlayout) self.setLayout(vlayout) # Signals and slots self.pages_widget.currentChanged.connect(self.current_page_changed) self.contents_widget.currentRowChanged.connect( self.pages_widget.setCurrentIndex) bbox.accepted.connect(self.accept) bbox.rejected.connect(self.reject) bbox.clicked.connect(self.button_clicked) # Ensures that the config is present on ezcad first run CONF.set('main', 'interface_language', load_lang_conf())
def __init__(self, parent=None): QDialog.__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.is_series = False self.layout = None
def __init__(self): QDialog.__init__(self, None) self.setupUi(self) self.bClose.clicked.connect(self.leave) self.bClear.clicked.connect(self.clear) self.setWindowTitle("%s: Log" % OCTXT._ToolName) self.eLog.setReadOnly(True) self.eLog.setAcceptRichText(False) self.eLog.setStyleSheet("font: 12pt \"Courier\";")
def __init__(self, control, code): QDialog.__init__(self, None) self.setupUi(self) self.bOK.clicked.connect(self.runOK) self.bCANCEL.clicked.connect(self.runCANCEL) self.bInfo.setDisabled(True) self._text = '' self._control = control self._code = 0
def __init__( self, title="Title", description="Description", unique_names=None, choose_from_list=False, ): QDialog.__init__(self) self.setModal(True) self.setWindowTitle(title) # self.setMinimumWidth(250) # self.setMinimumHeight(150) if unique_names is None: unique_names = [] self.unique_names = unique_names self.choose_from_list = choose_from_list self.layout = QFormLayout() self.layout.setSizeConstraint(QLayout.SetFixedSize) label = QLabel(description) label.setAlignment(Qt.AlignHCenter) self.layout.addRow(self.createSpace(5)) self.layout.addRow(label) self.layout.addRow(self.createSpace(10)) buttons = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self) self.ok_button = buttons.button(QDialogButtonBox.Ok) self.ok_button.setEnabled(False) if choose_from_list: self.param_name_combo = QComboBox() self.param_name.currentIndexChanged.connect(self.validateChoice) for item in unique_names: self.param_name_combo.addItem(item) self.layout.addRow("Job:", self.param_name_combo) else: self.param_name = QLineEdit(self) self.param_name.setFocus() self.param_name.textChanged.connect(self.validateName) self.validColor = self.param_name.palette().color( self.param_name.backgroundRole()) self.layout.addRow("Name:", self.param_name) self.layout.addRow(self.createSpace(10)) self.layout.addRow(buttons) buttons.accepted.connect(self.accept) buttons.rejected.connect(self.reject) self.setLayout(self.layout)
def __init__(self, numbersOnly: bool): QDialog.__init__(self) self.ui = Ui_SetId() self.ui.setupUi(self) self.ui.btnOk.accepted.connect(self.accepted) if numbersOnly: self.ui.txtId.setInputMask("99999999")
def __init__(self): QDialog.__init__(self) self.ui = Ui_MovieSettings() self.ui.setupUi(self) self.actualizePreview() self.ui.txtMSOutFormat.textChanged[str].connect(self.actualizePreview) self.ui.txtMSOutFormat.setText(guiConfig['movie_output_format']) self.ui.buttonBox.accepted.connect(self.accepted)
def __init__(self, url, version, win_parent=None): self.win_parent = win_parent self.url = url self.version = version QDialog.__init__(self, win_parent) self.setWindowTitle('pyNastran Update') self.create_widgets() self.create_layout() self.set_connections()
def __init__(self, configuration_path, parent=None): QDialog.__init__(self, parent) self.setModal(True) self.setWindowTitle("New configuration file") self.setMinimumWidth(250) self.setMinimumHeight(150) layout = QFormLayout() directory, filename = os.path.split(configuration_path) if directory.strip() == "": directory = os.path.abspath(os.curdir) self.configuration_path = "%s/%s" % (directory, filename) else: self.configuration_path = configuration_path configuration_location = QLabel() configuration_location.setText(directory) configuration_name = QLabel() configuration_name.setText(filename) self.db_type = QComboBox() self.db_type.addItem("BLOCK_FS") self.db_type.addItem("PLAIN") self.num_realizations = QSpinBox() self.num_realizations.setMinimum(1) self.num_realizations.setMaximum(1000) self.num_realizations.setValue(10) self.storage_path = QLineEdit() self.storage_path.setText("Storage") self.storage_path.textChanged.connect(self._validateName) layout.addRow(createSpace(10)) layout.addRow("Configuration name:", configuration_name) layout.addRow("Configuration location:", configuration_location) layout.addRow("Path to store DBase:", self.storage_path) layout.addRow("DBase type:", self.db_type) layout.addRow("Number of realizations", self.num_realizations) layout.addRow(createSpace(10)) buttons = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self) self.ok_button = buttons.button(QDialogButtonBox.Ok) layout.addRow(buttons) buttons.accepted.connect(self.accept) buttons.rejected.connect(self.reject) self.setLayout(layout)
def __init__(self, parent=None, pathlist=None, ro_pathlist=None, not_active_pathlist=None, sync=True): QDialog.__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) assert isinstance(pathlist, list) self.pathlist = pathlist if not_active_pathlist is None: not_active_pathlist = [] self.not_active_pathlist = not_active_pathlist if ro_pathlist is None: ro_pathlist = [] self.ro_pathlist = ro_pathlist self.last_path = getcwd_or_home() self.setWindowTitle(_("PYTHONPATH manager")) self.setWindowIcon(ima.icon('pythonpath')) self.resize(500, 300) self.selection_widgets = [] layout = QVBoxLayout() self.setLayout(layout) top_layout = QHBoxLayout() layout.addLayout(top_layout) self.toolbar_widgets1 = self.setup_top_toolbar(top_layout) self.listwidget = QListWidget(self) self.listwidget.currentRowChanged.connect(self.refresh) self.listwidget.itemChanged.connect(self.update_not_active_pathlist) layout.addWidget(self.listwidget) bottom_layout = QHBoxLayout() layout.addLayout(bottom_layout) self.sync_button = None self.toolbar_widgets2 = self.setup_bottom_toolbar(bottom_layout, sync) # Buttons configuration bbox = QDialogButtonBox(QDialogButtonBox.Close) bbox.rejected.connect(self.reject) bottom_layout.addWidget(bbox) self.update_list() self.refresh()
def __init__(self, parent=None): self.parent = parent QDialog.__init__(self, parent=parent) self.ui = load_ui('filter_rule_editor.ui', baseinstance=self) #self.ui = UiDialog() #self.ui.setupUi(self) self.init_widgets() self.load_global_rule_dict() self.refresh_global_rule() self.check_widgets()
def __init__(self, instrument_list=None): QDialog.__init__(self) self.ui = load_ui(__file__, 'ui/instrument_dialog.ui', baseinstance=self) self.instrument_list = instrument_list self.instr_combo.clear() self.facility_combo.clear() instruments = sorted(INSTRUMENT_DICT.keys()) instruments.reverse() for facility in instruments: self.facility_combo.addItem(facility) self._facility_changed(instruments[0]) self.facility_combo.activated.connect(self._facility_changed)
def __init__(self, parent=None, pathlist=None, ro_pathlist=None, not_active_pathlist=None, sync=True): QDialog.__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) assert isinstance(pathlist, list) self.pathlist = pathlist if not_active_pathlist is None: not_active_pathlist = [] self.not_active_pathlist = not_active_pathlist if ro_pathlist is None: ro_pathlist = [] self.ro_pathlist = ro_pathlist self.last_path = getcwd() self.setWindowTitle(_("PYTHONPATH manager")) self.setWindowIcon(ima.icon('pythonpath')) self.resize(500, 300) self.selection_widgets = [] layout = QVBoxLayout() self.setLayout(layout) top_layout = QHBoxLayout() layout.addLayout(top_layout) self.toolbar_widgets1 = self.setup_top_toolbar(top_layout) self.listwidget = QListWidget(self) self.listwidget.currentRowChanged.connect(self.refresh) self.listwidget.itemChanged.connect(self.update_not_active_pathlist) layout.addWidget(self.listwidget) bottom_layout = QHBoxLayout() layout.addLayout(bottom_layout) self.sync_button = None self.toolbar_widgets2 = self.setup_bottom_toolbar(bottom_layout, sync) # Buttons configuration bbox = QDialogButtonBox(QDialogButtonBox.Close) bbox.rejected.connect(self.reject) bottom_layout.addWidget(bbox) self.update_list() self.refresh()
def __init__(self, parent=None, father=None): self.parent = parent self.father = father QDialog.__init__(self, parent=parent) self.ui = load_ui('launchMantid.ui', baseinstance=self) _title = "Launching Mantid Reduction" self.setWindowTitle(_title) _runs = self.father.parameters['runs'] nbr_jobs = len(_runs) _message = 'You are about to launch {} Mantid Reductions jobs!'.format(nbr_jobs) self.ui.label.setText(_message)
def __init__(self, ui_module, parent, modal=True, connect_actions=True): self.gui = parent QtGuiApplication.__init__(self, ui_module) QDialog.__init__(self, parent) self.modal = modal self.setModal(modal) try: self.ui = ui_module.Ui_Form() self.setupUI(self) except: self.compile_ui(ui_module, True) self.ui = ui_module.Ui_Form() self.setupUI(self) if connect_actions: self.connect_actions()
def __init__(self, parent=None): QDialog.__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.data = None self.arraywidget = None self.stack = None self.layout = None # Values for 3d array editor self.dim_indexes = [{}, {}, {}] self.last_dim = 0 # Adjust this for changing the startup dimension
def __init__(self, parent=None, key=None, data_type='sample'): self.parent = parent self.key = key self.data_type = data_type QDialog.__init__(self, parent=parent) self.ui = load_ui('dimensions_setter.ui', baseinstance=self) self.group_widgets() self.init_widgets_layout() self.init_widgets_content() if parent.geometry_ui_position: self.move(parent.geometry_ui_position) self.check_save_button() self.set_column_index()
def __init__(self, parent): QDialog.__init__(self, parent) self.setWindowTitle("Spyder %s: %s" % (__version__, _("Dependencies"))) self.setWindowIcon(ima.icon('tooloptions')) self.setModal(True) self.view = DependenciesTableView(self, []) opt_mods = ['NumPy', 'Matplotlib', 'Pandas', 'SymPy'] self.label = QLabel(_("Spyder depends on several Python modules to " "provide the right functionality for all its " "panes. The table below shows the required " "and installed versions (if any) of all of " "them.<br><br>" "<b>Note</b>: You can safely use Spyder " "without the following modules installed: " "<b>%s</b> and <b>%s</b>.<br><br>" "Please also note that new " "dependencies or changed ones will be correctly " "detected only after Spyder is restarted.") % (', '.join(opt_mods[:-1]), opt_mods[-1])) self.label.setWordWrap(True) self.label.setAlignment(Qt.AlignJustify) self.label.setContentsMargins(5, 8, 12, 10) btn = QPushButton(_("Copy to clipboard"), ) btn.clicked.connect(self.copy_to_clipboard) bbox = QDialogButtonBox(QDialogButtonBox.Ok) bbox.accepted.connect(self.accept) hlayout = QHBoxLayout() hlayout.addWidget(btn) hlayout.addStretch() hlayout.addWidget(bbox) vlayout = QVBoxLayout() vlayout.addWidget(self.label) vlayout.addWidget(self.view) vlayout.addLayout(hlayout) self.setLayout(vlayout) self.resize(630, 420)
def __init__(self, data, title="", comment="", icon=None, parent=None, apply=None): QDialog.__init__(self, parent) self.apply_callback = apply # Form if isinstance(data[0][0], (list, tuple)): self.formwidget = FormTabWidget(data, comment=comment, parent=self) elif len(data[0])==3: self.formwidget = FormComboWidget(data, comment=comment, parent=self) else: self.formwidget = FormWidget(data, comment=comment, parent=self) layout = QVBoxLayout() layout.addWidget(self.formwidget) self.float_fields = [] self.formwidget.setup() # Button box self.bbox = bbox = QDialogButtonBox(QDialogButtonBox.Ok |QDialogButtonBox.Cancel) self.formwidget.update_buttons.connect(self.update_buttons) if self.apply_callback is not None: apply_btn = bbox.addButton(QDialogButtonBox.Apply) apply_btn.clicked.connect(self.apply) bbox.accepted.connect(self.accept) bbox.rejected.connect(self.reject) layout.addWidget(bbox) self.setLayout(layout) self.setWindowTitle(title) if not isinstance(icon, QIcon): icon = QWidget().style().standardIcon(QStyle.SP_MessageBoxQuestion) self.setWindowIcon(icon)
def __init__(self, parent=None): QDialog.__init__(self, parent) self.setWindowTitle('Periodic table') # Variables self._required_selection = True # Widgets self._wdg_table = PeriodicTableWidget() buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) # Layouts layout = QVBoxLayout() layout.addWidget(self._wdg_table) layout.addWidget(buttons) self.setLayout(layout) # Signals self._wdg_table.selectionChanged.connect(self.selectionChanged) buttons.accepted.connect(self._onOk) buttons.rejected.connect(self._onCancel)
def __init__(self, parent=None): self.parent = parent QDialog.__init__(self, parent=parent) self.ui = load_ui('iptsFileTransfer.ui', baseinstance=self)
def __init__(self, parent=None): self.parent = parent QDialog.__init__(self, parent=parent) self.ui = load_ui('import_from_run_number.ui', baseinstance=self) self.init_widgets()
def __init__(self, parent=None, inline=True, offset=0, force_float=False): QDialog.__init__(self, parent=parent) self._parent = parent self._text = None self._valid = None self._offset = offset # TODO: add this as an option in the General Preferences? self._force_float = force_float self._help_inline = _(""" <b>Numpy Array/Matrix Helper</b><br> Type an array in Matlab : <code>[1 2;3 4]</code><br> or Spyder simplified syntax : <code>1 2;3 4</code> <br><br> Hit 'Enter' for array or 'Ctrl+Enter' for matrix. <br><br> <b>Hint:</b><br> Use two spaces or two tabs to generate a ';'. """) self._help_table = _(""" <b>Numpy Array/Matrix Helper</b><br> Enter an array in the table. <br> Use Tab to move between cells. <br><br> Hit 'Enter' for array or 'Ctrl+Enter' for matrix. <br><br> <b>Hint:</b><br> Use two tabs at the end of a row to move to the next row. """) # Widgets self._button_warning = QToolButton() self._button_help = HelperToolButton() self._button_help.setIcon(ima.icon('MessageBoxInformation')) style = """ QToolButton { border: 1px solid grey; padding:0px; border-radius: 2px; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f6f7fa, stop: 1 #dadbde); } """ self._button_help.setStyleSheet(style) if inline: self._button_help.setToolTip(self._help_inline) self._text = NumpyArrayInline(self) self._widget = self._text else: self._button_help.setToolTip(self._help_table) self._table = NumpyArrayTable(self) self._widget = self._table style = """ QDialog { margin:0px; border: 1px solid grey; padding:0px; border-radius: 2px; }""" self.setStyleSheet(style) style = """ QToolButton { margin:1px; border: 0px solid grey; padding:0px; border-radius: 0px; }""" self._button_warning.setStyleSheet(style) # widget setup self.setWindowFlags(Qt.Window | Qt.Dialog | Qt.FramelessWindowHint) self.setModal(True) self.setWindowOpacity(0.90) self._widget.setMinimumWidth(200) # layout self._layout = QHBoxLayout() self._layout.addWidget(self._widget) self._layout.addWidget(self._button_warning, 1, Qt.AlignTop) self._layout.addWidget(self._button_help, 1, Qt.AlignTop) self.setLayout(self._layout) self._widget.setFocus()
def __init__(self, parent=None): QDialog.__init__(self, parent) self.ui = load_ui(__file__, '../../../ui/diffraction/diffraction_info.ui', baseinstance=self)
def __init__(self, parent=None): self.parent = parent QDialog.__init__(self, parent=parent) self.ui = load_ui('loadTableIntermediateStep.ui', baseinstance=self) self.parent.load_intermediate_step_ok = False
def __init__(self, parent, text, title=None, icon=None, contents_title=None, varname=None): QDialog.__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) if title is None: title = _("Import wizard") self.setWindowTitle(title) if icon is None: self.setWindowIcon(ima.icon('fileimport')) if contents_title is None: contents_title = _("Raw text") if varname is None: varname = _("variable_name") self.var_name, self.clip_data = None, None # Setting GUI self.tab_widget = QTabWidget(self) self.text_widget = ContentsWidget(self, text) self.table_widget = PreviewWidget(self) self.tab_widget.addTab(self.text_widget, _("text")) self.tab_widget.setTabText(0, contents_title) self.tab_widget.addTab(self.table_widget, _("table")) self.tab_widget.setTabText(1, _("Preview")) self.tab_widget.setTabEnabled(1, False) name_layout = QHBoxLayout() name_label = QLabel(_("Variable Name")) name_layout.addWidget(name_label) self.name_edt = QLineEdit() self.name_edt.setText(varname) name_layout.addWidget(self.name_edt) btns_layout = QHBoxLayout() cancel_btn = QPushButton(_("Cancel")) btns_layout.addWidget(cancel_btn) cancel_btn.clicked.connect(self.reject) h_spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) btns_layout.addItem(h_spacer) self.back_btn = QPushButton(_("Previous")) self.back_btn.setEnabled(False) btns_layout.addWidget(self.back_btn) self.back_btn.clicked.connect(ft_partial(self._set_step, step=-1)) self.fwd_btn = QPushButton(_("Next")) btns_layout.addWidget(self.fwd_btn) self.fwd_btn.clicked.connect(ft_partial(self._set_step, step=1)) self.done_btn = QPushButton(_("Done")) self.done_btn.setEnabled(False) btns_layout.addWidget(self.done_btn) self.done_btn.clicked.connect(self.process) self.text_widget.asDataChanged.connect(self.fwd_btn.setEnabled) self.text_widget.asDataChanged.connect(self.done_btn.setDisabled) layout = QVBoxLayout() layout.addLayout(name_layout) layout.addWidget(self.tab_widget) layout.addLayout(btns_layout) self.setLayout(layout)
def __init__(self, parent=None, is_report=False): QDialog.__init__(self, parent) self.is_report = is_report self.setWindowTitle(_("Issue reporter")) self.setModal(True) # To save the traceback sent to the internal console self.error_traceback = "" # Dialog main label if self.is_report: title = _("Please fill the following information") else: title = _("Spyder has encountered an internal problem!") main_label = QLabel( _("<h3>{title}</h3>" "Before reporting this problem, <i>please</i> consult our " "comprehensive " "<b><a href=\"{trouble_url}\">Troubleshooting Guide</a></b> " "which should help solve most issues, and search for " "<b><a href=\"{project_url}\">known bugs</a></b> " "matching your error message or problem description for a " "quicker solution." ).format(title=title, trouble_url=__trouble_url__, project_url=__project_url__)) main_label.setOpenExternalLinks(True) main_label.setWordWrap(True) main_label.setAlignment(Qt.AlignJustify) main_label.setStyleSheet('font-size: 12px;') # Issue title self.title = QLineEdit() self.title.textChanged.connect(self._contents_changed) self.title_chars_label = QLabel(_("{} more characters " "to go...").format(TITLE_MIN_CHARS)) form_layout = QFormLayout() form_layout.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow) red_asterisk = '<font color="Red">*</font>' title_label = QLabel(_("<b>Title</b>: {}").format(red_asterisk)) form_layout.setWidget(0, QFormLayout.LabelRole, title_label) form_layout.setWidget(0, QFormLayout.FieldRole, self.title) # Description steps_header = QLabel( _("<b>Steps to reproduce:</b> {}").format(red_asterisk)) steps_text = QLabel(_("Please enter a detailed step-by-step " "description (in English) of what led up to " "the problem below. Issue reports without a " "clear way to reproduce them will be closed.")) steps_text.setWordWrap(True) steps_text.setAlignment(Qt.AlignJustify) steps_text.setStyleSheet('font-size: 12px;') # Field to input the description of the problem self.input_description = DescriptionWidget(self) # Only allow to submit to Github if we have a long enough description self.input_description.textChanged.connect(self._contents_changed) # Widget to show errors self.details = ShowErrorWidget(self) self.details.set_pythonshell_font(get_font()) self.details.hide() # Label to show missing chars self.initial_chars = len(self.input_description.toPlainText()) self.desc_chars_label = QLabel(_("{} more characters " "to go...").format(DESC_MIN_CHARS)) # Checkbox to dismiss future errors self.dismiss_box = QCheckBox(_("Hide all future errors during this " "session")) if self.is_report: self.dismiss_box.hide() # Dialog buttons gh_icon = ima.icon('github') self.submit_btn = QPushButton(gh_icon, _('Submit to Github')) self.submit_btn.setEnabled(False) self.submit_btn.clicked.connect(self._submit_to_github) self.details_btn = QPushButton(_('Show details')) self.details_btn.clicked.connect(self._show_details) if self.is_report: self.details_btn.hide() self.close_btn = QPushButton(_('Close')) if self.is_report: self.close_btn.clicked.connect(self.reject) # Buttons layout buttons_layout = QHBoxLayout() buttons_layout.addWidget(self.submit_btn) buttons_layout.addWidget(self.details_btn) buttons_layout.addWidget(self.close_btn) # Main layout layout = QVBoxLayout() layout.addWidget(main_label) layout.addSpacing(20) layout.addLayout(form_layout) layout.addWidget(self.title_chars_label) layout.addSpacing(12) layout.addWidget(steps_header) layout.addSpacing(-1) layout.addWidget(steps_text) layout.addSpacing(1) layout.addWidget(self.input_description) layout.addWidget(self.details) layout.addWidget(self.desc_chars_label) layout.addSpacing(15) layout.addWidget(self.dismiss_box) layout.addSpacing(15) layout.addLayout(buttons_layout) layout.setContentsMargins(25, 20, 25, 10) self.setLayout(layout) self.resize(570, 600) self.title.setFocus() # Set Tab key focus order self.setTabOrder(self.title, self.input_description)
def __init__(self, parent=None): QDialog.__init__(self, parent=parent) self._shortcuts_summary_title = _("Spyder Keyboard ShortCuts") # Calculate font and amount of elements in each column according screen size width, height = self.get_screen_resolution() font_size = height / 80 font_size = max(min(font_size, MAX_FONT_SIZE), MIN_FONT_SIZE) shortcuts_column = (height - 8 * font_size) / (font_size +16) # Widgets style = """ QDialog { margin:0px; padding:0px; border-radius: 2px; }""" self.setStyleSheet(style) font_names = QFont() font_names.setPointSize(font_size) font_names.setBold(True) font_keystr = QFont() font_keystr.setPointSize(font_size) font_title = QFont() font_title.setPointSize(font_size+2) font_title.setBold(True) title_label = QLabel(self._shortcuts_summary_title) title_label.setAlignment(Qt.AlignCenter) title_label.setFont(font_title) # iter over shortcuts and create GroupBox for each context # with shortcuts in a grid columns_layout = QHBoxLayout() added_shortcuts = 0 group = None # group shortcuts by context shortcuts = groupby(sorted(iter_shortcuts()), key=itemgetter(0)) for context, group_shortcuts in shortcuts: for i, (context, name, keystr) in enumerate(group_shortcuts): # start of every column if added_shortcuts == 0: column_layout = QVBoxLayout() # at start of new context add previous context group if i == 0 and added_shortcuts > 0: column_layout.addWidget(group) # create group at start of column or context if added_shortcuts == 0 or i == 0: if context == '_': context = 'Global' group = QGroupBox(context.capitalize()) group.setFont(font_names) group_layout = QGridLayout() group.setLayout(group_layout) # Count space for titles added_shortcuts += 1 # Widgets label_name = QLabel(name.capitalize().replace('_', ' ')) label_name.setFont(font_names) keystr = QKeySequence(keystr).toString(QKeySequence.NativeText) label_keystr = QLabel(keystr) label_keystr.setFont(font_keystr) group_layout.addWidget(label_name, i, 0) group_layout.addWidget(label_keystr, i, 1) added_shortcuts += 1 if added_shortcuts >= shortcuts_column: column_layout.addWidget(group) columns_layout.addLayout(column_layout) added_shortcuts = 0 column_layout.addWidget(group) column_layout.addStretch() # avoid lasts sections to appear too big columns_layout.addLayout(column_layout) # Scroll widget self.scroll_widget = QWidget() self.scroll_widget.setLayout(columns_layout) self.scroll_area = QScrollArea() self.scroll_area.setWidget(self.scroll_widget) # widget setup self.setWindowFlags(Qt.FramelessWindowHint) self.setWindowOpacity(0.95) # layout self._layout = QVBoxLayout() self._layout.addWidget(title_label) self._layout.addWidget(self.scroll_area) self.setLayout(self._layout) self.setGeometry(0, 0, width, height)
def __init__(self, parent, username, password, token, remember=False, remember_token=False): QDialog.__init__(self, parent) title = _("Sign in to Github") self.resize(415, 375) self.setWindowTitle(title) self.setWindowFlags( self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # Header html = ('<html><head/><body><p align="center">' '{title}</p></body></html>') lbl_html = QLabel(html.format(title=title)) lbl_html.setStyleSheet('font-size: 16px;') # Tabs self.tabs = QTabWidget() # Basic form layout basic_form_layout = QFormLayout() basic_form_layout.setContentsMargins(-1, 0, -1, -1) basic_lbl_msg = QLabel(_("For regular users, i.e. users <b>without</b>" " two-factor authentication enabled")) basic_lbl_msg.setWordWrap(True) basic_lbl_msg.setAlignment(Qt.AlignJustify) lbl_user = QLabel(_("Username:"******"", QWidget()) lbl_password = QLabel(_("Password: "******"Remember me")) self.cb_remember.setToolTip(_("Spyder will save your credentials " "safely")) self.cb_remember.setChecked(remember) basic_form_layout.setWidget(4, QFormLayout.FieldRole, self.cb_remember) # Basic auth tab basic_auth = QWidget() basic_layout = QVBoxLayout() basic_layout.addSpacerItem(QSpacerItem(QSpacerItem(0, 8))) basic_layout.addWidget(basic_lbl_msg) basic_layout.addSpacerItem( QSpacerItem(QSpacerItem(0, 50, vPolicy=QSizePolicy.Expanding))) basic_layout.addLayout(basic_form_layout) basic_layout.addSpacerItem( QSpacerItem(QSpacerItem(0, 50, vPolicy=QSizePolicy.Expanding))) basic_auth.setLayout(basic_layout) self.tabs.addTab(basic_auth, _("Password Only")) # Token form layout token_form_layout = QFormLayout() token_form_layout.setContentsMargins(-1, 0, -1, -1) token_lbl_msg = QLabel(_("For users <b>with</b> two-factor " "authentication enabled, or who prefer a " "per-app token authentication.<br><br>" "You can go <b><a href=\"{}\">here</a></b> " "and click \"Generate token\" at the bottom " "to create a new token to use for this, with " "the appropriate permissions.").format( TOKEN_URL)) token_lbl_msg.setOpenExternalLinks(True) token_lbl_msg.setWordWrap(True) token_lbl_msg.setAlignment(Qt.AlignJustify) lbl_token = QLabel("Token: ") token_form_layout.setWidget(1, QFormLayout.LabelRole, lbl_token) self.le_token = QLineEdit() self.le_token.setEchoMode(QLineEdit.Password) self.le_token.textChanged.connect(self.update_btn_state) token_form_layout.setWidget(1, QFormLayout.FieldRole, self.le_token) self.cb_remember_token = None # Same validation as with cb_remember if self.is_keyring_available() and valid_py_os: self.cb_remember_token = QCheckBox(_("Remember token")) self.cb_remember_token.setToolTip(_("Spyder will save your " "token safely")) self.cb_remember_token.setChecked(remember_token) token_form_layout.setWidget(3, QFormLayout.FieldRole, self.cb_remember_token) # Token auth tab token_auth = QWidget() token_layout = QVBoxLayout() token_layout.addSpacerItem(QSpacerItem(QSpacerItem(0, 8))) token_layout.addWidget(token_lbl_msg) token_layout.addSpacerItem( QSpacerItem(QSpacerItem(0, 50, vPolicy=QSizePolicy.Expanding))) token_layout.addLayout(token_form_layout) token_layout.addSpacerItem( QSpacerItem(QSpacerItem(0, 50, vPolicy=QSizePolicy.Expanding))) token_auth.setLayout(token_layout) self.tabs.addTab(token_auth, _("Access Token")) # Sign in button self.bt_sign_in = QPushButton(_("Sign in")) self.bt_sign_in.clicked.connect(self.accept) self.bt_sign_in.setDisabled(True) # Main layout layout = QVBoxLayout() layout.addWidget(lbl_html) layout.addWidget(self.tabs) layout.addWidget(self.bt_sign_in) self.setLayout(layout) # Final adjustments if username and password: self.le_user.setText(username) self.le_password.setText(password) self.bt_sign_in.setFocus() elif username: self.le_user.setText(username) self.le_password.setFocus() elif token: self.le_token.setText(token) else: self.le_user.setFocus() self.setFixedSize(self.width(), self.height()) self.le_password.installEventFilter(self) self.le_user.installEventFilter(self) self.tabs.currentChanged.connect(self.update_btn_state)
def __init__(self, parent=None, list_of_runs=[], message=''): QDialog.__init__(self, parent=parent) self.ui = load_ui('oncat_error_message.ui', baseinstance=self) self.init_widgets(list_of_runs=list_of_runs) self.ui.message.setText(message)
def __init__(self, parent=None): QDialog.__init__(self, parent) self.setWindowTitle(_("Spyder internal error")) self.setModal(True) # To save the traceback sent to the internal console self.error_traceback = "" # Dialog main label self.main_label = QLabel( _("""<b>Spyder has encountered an internal problem</b><hr> Please enter below a step-by-step description of your problem (in English). Issue reports without a clear way to reproduce them will be closed. <br><br> <b>Note</b>: You need a Github account for this. """)) self.main_label.setWordWrap(True) self.main_label.setAlignment(Qt.AlignJustify) # Field to input the description of the problem self.input_description = DescriptionWidget(self) # Only allow to submit to Github if we have a long enough description self.input_description.textChanged.connect(self._description_changed) # Widget to show errors self.details = ShowErrorWidget(self) self.details.set_pythonshell_font(get_font()) self.details.hide() # Label to show missing chars self.initial_chars = len(self.input_description.toPlainText()) self.chars_label = QLabel(_("Enter at least {} " "characters".format(MIN_CHARS))) # Checkbox to dismiss future errors self.dismiss_box = QCheckBox() self.dismiss_box.setText(_("Don't show again during this session")) # Labels layout labels_layout = QHBoxLayout() labels_layout.addWidget(self.chars_label) labels_layout.addWidget(self.dismiss_box, 0, Qt.AlignRight) # Dialog buttons self.submit_btn = QPushButton(_('Submit to Github')) self.submit_btn.setEnabled(False) self.submit_btn.clicked.connect(self._submit_to_github) self.details_btn = QPushButton(_('Show details')) self.details_btn.clicked.connect(self._show_details) self.close_btn = QPushButton(_('Close')) # Buttons layout buttons_layout = QHBoxLayout() buttons_layout.addWidget(self.submit_btn) buttons_layout.addWidget(self.details_btn) buttons_layout.addWidget(self.close_btn) # Main layout vlayout = QVBoxLayout() vlayout.addWidget(self.main_label) vlayout.addWidget(self.input_description) vlayout.addWidget(self.details) vlayout.addLayout(labels_layout) vlayout.addLayout(buttons_layout) self.setLayout(vlayout) self.resize(600, 420) self.input_description.setFocus()
def __init__(self, parent=None): QDialog.__init__(self, parent) self.ui = load_ui(__file__, '../../../ui/sans/eqsans_info.ui', baseinstance=self)