def _confirm_remove_team(self): self.progress.quit() self.progess = None self.repos = matching_repositories(self.repos, self.pattern) self.repos = self.repos.loc[self.repos.id.isin(self.team_repos.id)] self.repos = self.repos.sort_values('name') N = len(self.repos.index) label = QtWidgets.QLabel() label.setText((f"Remove team {self.team} from {N} repositories?\n" + "Double click repository to view on GitHub.")) model = PandasModel(self.repos[['name']]) table = QtWidgets.QListView() table.setModel(model) table.doubleClicked.connect(self._open_repo) buttons = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) self.search_popup = Popup(label, table, title="Remove Team", bbox=buttons) buttons.accepted.connect(self._do_remove_team) self.search_popup.show()
def setupUi(self, Dialog): Dialog.setObjectName("ProcessingRule") self.intValidator = QtGui.QIntValidator() self.setWindowTitle('Remove Processing Rule(s)') QBtn = QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel self.buttonBox = QtWidgets.QDialogButtonBox(QBtn) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) self.labelRuleName = QtWidgets.QLabel(Dialog) self.labelRuleName.setObjectName("Name") self.labelRuleName.setText('Choose Rule(s) to remove:') self.listWidget = QtWidgets.QListWidget(Dialog) self.listWidget.setAlternatingRowColors(False) self.listWidget.setSelectionMode( QtWidgets.QAbstractItemView.ExtendedSelection) self.listWidget.setSortingEnabled(True) self.layout = QtWidgets.QVBoxLayout() self.layout.addWidget(self.labelRuleName) self.layout.addWidget(self.listWidget) self.layout.addWidget(self.buttonBox) self.setLayout(self.layout) for potential_rule_name_for_removal in self.potential_rule_names_for_removal: self.listWidget.addItem(potential_rule_name_for_removal) self.listWidget.clearSelection()
def __init__(self, *args, **kwargs): super(TrainModelDialog, self).__init__(*args, **kwargs) self.setWindowTitle("Train models") self.raidoButtons() self.slider() self.batch_size = 8 self.algo = 'MaskRCNN' self.config_file = None self.out_dir = None self.max_iterations = 2000 qbtn = QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel self.buttonbox = QtWidgets.QDialogButtonBox(qbtn) self.buttonbox.accepted.connect(self.accept) self.buttonbox.rejected.connect(self.reject) self.label1 = QtWidgets.QLabel(f"Please select batch size default=8") self.inputFileLineEdit = QtWidgets.QLineEdit(self) self.inputFileButton = QtWidgets.QPushButton('Open', self) self.inputFileButton.clicked.connect(self.onInputFileButtonClicked) self.label2 = QtWidgets.QLabel( f"Please select training max iterations default 2000 (Optional)") hboxLayOut = QtWidgets.QHBoxLayout() self.groupBoxFiles = QtWidgets.QGroupBox("Please choose a config file") hboxLayOut.addWidget(self.inputFileLineEdit) hboxLayOut.addWidget(self.inputFileButton) self.groupBoxFiles.setLayout(hboxLayOut) self.groupBoxOutDir = QtWidgets.QGroupBox( "Please choose output directory (Optional)") self.outFileDirEdit = QtWidgets.QLineEdit(self) self.outDirButton = QtWidgets.QPushButton('Select', self) self.outDirButton.clicked.connect(self.onOutDirButtonClicked) hboxLayOutDir = QtWidgets.QHBoxLayout() hboxLayOutDir.addWidget(self.outFileDirEdit) hboxLayOutDir.addWidget(self.outDirButton) self.groupBoxOutDir.setLayout(hboxLayOutDir) vbox = QtWidgets.QVBoxLayout() vbox.addWidget(self.groupBox) vbox.addWidget(self.label1) vbox.addWidget(self.slider) vbox.addWidget(self.groupBoxFiles) if self.algo == 'MaskRCNN': self.max_iter_slider() # self.label1.hide() # self.slider.hide() vbox.addWidget(self.label2) vbox.addWidget(self.max_iter_slider) vbox.addWidget(self.groupBoxOutDir) vbox.addWidget(self.buttonbox) self.setLayout(vbox) self.show()
def __init__(self, app, exc_type, exc_value, exc_traceback): super().__init__() self.app = app import traceback self.setWindowTitle('Bug Report') traceback_list = traceback.format_exception(exc_type, exc_value, exc_traceback) self.traceback = ''.join( [element.rstrip() + '\n' for element in traceback_list]) self.buttonBox = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok) self.buttonBox.accepted.connect(self.accept) copyButton = QtWidgets.QPushButton('Copy To Clipboard') copyButton.pressed.connect(self.copyToClipboard) self.buttonBox.addButton(copyButton, QtWidgets.QDialogButtonBox.ApplyRole) main_layout = QtWidgets.QVBoxLayout() self.textEdit = QtWidgets.QTextEdit() self.textEdit.setLineWrapMode(0) self.textEdit.setText(self.traceback.replace('\n', '\r')) self.textEdit.setReadOnly(True) main_layout.addWidget(self.textEdit) main_layout.addWidget(self.buttonBox) self.setFixedWidth(self.textEdit.width() + main_layout.getContentsMargins()[0] + main_layout.getContentsMargins()[2]) self.setLayout(main_layout)
def initUI(self, as_dialog: bool = True): self.setWindowTitle(self.title) # self.setGeometry(self.left, self.top, self.width, self.height) self.createTable() self.createButtons() # Add box layout, add table to box layout and add box layout to widget self.layout = QtWidgets.QVBoxLayout() self.layout.addWidget(self.table) self.button_layout = QtWidgets.QHBoxLayout() self.button_layout.addWidget(self.add_button) self.button_layout.addWidget(self.delete_button) self.button_layout.addWidget(self.load_button) self.button_layout.addWidget(self.save_button) self.layout.addLayout(self.button_layout) if as_dialog: buttons = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self) buttons.accepted.connect(self.accept) buttons.rejected.connect(self.reject) self.layout.addWidget(buttons) self.setLayout(self.layout)
def __init__(self, material_widget_class, parent=None): super().__init__(parent) # Variables self._materials = [] # Widgets self.wdg_material = material_widget_class() self.buttons = QtWidgets.QDialogButtonBox() self.buttons.setStandardButtons(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) self.buttons.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(False) # Layouts layout = QtWidgets.QVBoxLayout() layout.addWidget(self.wdg_material) layout.addWidget(self.buttons) self.setLayout(layout) # Signals self.buttons.accepted.connect(self._on_ok) self.buttons.rejected.connect(self._on_cancel) self.wdg_material.materialsChanged.connect(self._on_materials_changed)
def __init__(self, title="", msg="", parent=None): super(OverwriteFilesQuery, self).__init__(parent) self.verticalLayout = QtWidgets.QVBoxLayout(self) self.textBrowser = QtWidgets.QTextBrowser(self) self.verticalLayout.addWidget(self.textBrowser) self.horizontalLayout = QtWidgets.QHBoxLayout() self.buttonBox = QtWidgets.QDialogButtonBox(self) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons( QtWidgets.QDialogButtonBox.Cancel | QtWidgets.QDialogButtonBox.No | QtWidgets.QDialogButtonBox.Yes | QtWidgets.QDialogButtonBox.YesToAll) self.choice = None self.yes = self.buttonBox.button(QtWidgets.QDialogButtonBox.Yes) self.yesToAll = self.buttonBox.button( QtWidgets.QDialogButtonBox.YesToAll) self.no = self.buttonBox.button(QtWidgets.QDialogButtonBox.No) self.cancel = self.buttonBox.button(QtWidgets.QDialogButtonBox.Cancel) self.yes.clicked.connect(self.set_yes) self.yesToAll.clicked.connect(self.set_yesToAll) self.no.clicked.connect(self.set_no) self.cancel.clicked.connect(self.set_cancel) self.horizontalLayout.addWidget(self.buttonBox) self.verticalLayout.addLayout(self.horizontalLayout) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) self.setWindowTitle(title) self.textBrowser.setText(msg)
def __init__( self, text="Enter value for key", parent=None, ): super(ValueDialog, self).__init__(parent) layout = QtWidgets.QVBoxLayout() self.edit = QtWidgets.QLineEdit() self.edit.setMinimumWidth(500) font = self.edit.font() font.setPointSize(16) self.edit.setFont(font) self.edit.setPlaceholderText(text) self.edit.setStyleSheet("QLineEdit { padding: 6 }") self.edit.editingFinished.connect(self.postProcess) layout_edit = QtWidgets.QHBoxLayout() layout_edit.addWidget(self.edit) layout.addLayout(layout_edit) # buttons self.buttonBox = bb = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self, ) bb.button(bb.Ok).setIcon(labelme.utils.newIcon("done")) bb.button(bb.Cancel).setIcon(labelme.utils.newIcon("undo")) bb.accepted.connect(self.validate) bb.rejected.connect(self.reject) layout.addWidget(bb) self.setLayout(layout)
def _init_ui(self, items, item_cat): """ Initialize the user interface """ tree = QtWidgets.QTreeWidget() tree.setColumnCount(1) # tree.setHeaderHidden(True) tree.setHeaderLabel(item_cat) # parent = QtWidgets.QTreeWidgetItem(tree) # parent.setText(0, '{}'.format(item_cat)) # parent.setFlags(parent.flags() | QtCore.Qt.ItemIsTristate | QtCore.Qt.ItemIsUserCheckable) for item in items: tree_item = QtWidgets.QTreeWidgetItem(tree) tree_item.setText(0, '{}'.format(item)) tree_item.setFlags(tree_item.flags() | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsSelectable) tree_item.setCheckState(0, QtCore.Qt.Unchecked) tree.itemChanged.connect(self._on_item_toggled) btn_box = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel ) btn_box.accepted.connect(self.accept) btn_box.rejected.connect(self.reject) vbox_layout = QtWidgets.QVBoxLayout() vbox_layout.addWidget(tree) vbox_layout.addWidget(btn_box) self.setLayout(vbox_layout)
def __init__(self, parent=None): super().__init__(parent) self.setWindowTitle("Periodic table") # Variables self._required_selection = True # Widgets self._wdg_table = PeriodicTableWidget() buttons = QtWidgets.QDialogButtonBox() buttons.setStandardButtons( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel ) # Layouts layout = QtWidgets.QVBoxLayout() layout.addWidget(self._wdg_table) layout.addWidget(buttons) self.setLayout(layout) # Signals self._wdg_table.selectionChanged.connect(self.selectionChanged) buttons.accepted.connect(self._on_ok) buttons.rejected.connect(self._on_cancel)
def _setup_widgets(self): self.layout = QtWidgets.QFormLayout() self.size_widget = QtWidgets.QSpinBox() self.size_widget.setMinimum(1) self.size_widget.setMaximum(40) self.size_widget.setValue(self.layer.style.markersize) self.label_widget = QtWidgets.QLineEdit() self.label_widget.setText(self.layer.label) self.label_widget.selectAll() self.color_widget = ColorWidget() self.color_widget.setStyleSheet('ColorWidget {border: 1px solid;}') color = self.layer.style.color color = mpl_to_qt4_color(color, alpha=self.layer.style.alpha) self.set_color(color) self.okcancel = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) if self._edit_label: self.layout.addRow("Label", self.label_widget) self.layout.addRow("Color", self.color_widget) self.layout.addRow("Size", self.size_widget) self.layout.addWidget(self.okcancel) self.setLayout(self.layout) self.layout.setContentsMargins(6, 6, 6, 6)
def show_overshoot(self): """ """ dialog = QtWidgets.QDialog() vlayout = QtWidgets.QVBoxLayout() tree = ParameterTree() tree.setMinimumWidth(400) tree.setMinimumHeight(500) tree.setParameters(self.overshoot_params, showTop=False) vlayout.addWidget(tree) dialog.setLayout(vlayout) buttonBox = QtWidgets.QDialogButtonBox(parent=dialog) buttonBox.addButton('Save', buttonBox.AcceptRole) buttonBox.accepted.connect(dialog.accept) buttonBox.addButton('Cancel', buttonBox.RejectRole) buttonBox.rejected.connect(dialog.reject) vlayout.addWidget(buttonBox) dialog.setWindowTitle('Fill in information about this managers') res = dialog.exec() if res == dialog.Accepted: # save managers parameters in a xml file # start = os.path.split(os.path.split(os.path.realpath(__file__))[0])[0] # start = os.path.join("..",'daq_scan') ioxml.parameter_to_xml_file( self.overshoot_params, os.path.join(overshoot_path, self.overshoot_params.child('filename').value()))
def __init__(self, parent=None): super(ProjectNewDlg, self).__init__(parent) self.setWindowTitle("new project") layout = QtWidgets.QVBoxLayout() self.name_layout = QtWidgets.QHBoxLayout() self.label_name = QtWidgets.QLabel(self) self.label_name.setObjectName("video_label") self.label_name.setText("name") self.name_layout.addWidget(self.label_name) self.edit_name = QtWidgets.QLineEdit() self.edit_name.setPlaceholderText("project name") self.edit_name.setFocusPolicy(QtCore.Qt.StrongFocus) self.name_layout.addWidget(self.edit_name) layout.addLayout(self.name_layout) bb = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self, ) bb.button(bb.Ok).setIcon(QtGui.QIcon(":/menu/done.png")) bb.button(bb.Cancel).setIcon(QtGui.QIcon(":/menu/undo.png")) bb.accepted.connect(self.check_valid) bb.rejected.connect(self.reject) layout.addWidget(bb) self.setLayout(layout) self.edit_name.setCursorPosition(2)
def pick_dialog(self): self.dialog = QtWidgets.QDialog() self.dialog.setMinimumWidth(500) vlayout = QtWidgets.QVBoxLayout() self.list_widget = QtWidgets.QListWidget() self.list_widget.addItems(self.list) vlayout.addWidget(self.list_widget, 10) self.dialog.setLayout(vlayout) buttonBox = QtWidgets.QDialogButtonBox() buttonBox.addButton('Apply', buttonBox.AcceptRole) buttonBox.accepted.connect(self.dialog.accept) buttonBox.addButton('Cancel', buttonBox.RejectRole) buttonBox.rejected.connect(self.dialog.reject) vlayout.addWidget(buttonBox) self.dialog.setWindowTitle('Select an entry in the list') res = self.dialog.show() pass if res == self.dialog.Accepted: # save managers parameters in a xml file return [ self.list_widget.currentIndex(), self.list_widget.currentItem().text() ] else: return [-1, ""]
def __init__(self, *args, **kwargs): super(ImgProcessSelector, self).__init__(*args, **kwargs) self.buttonBox = QtWidgets.QDialogButtonBox() self.buttonBox.setStandardButtons( QtWidgets.QDialogButtonBox.Cancel | QtWidgets.QDialogButtonBox.Ok ) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) lay = QtWidgets.QVBoxLayout() self.setLayout(lay) self.setWindowModality(QtCore.Qt.ApplicationModal) self.setWindowTitle("Select an Image Processor to add") self.lstwdg = QtWidgets.QListWidget() self.lstwdg.itemDoubleClicked.connect(self.accept) self.lstwdg.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) self.D = {} # add built-in imageprocessors self._search_module(imgprocessors) # check plugins dir for module in import_plugins(): self._search_module(module) # if os.path.exists(IMP_DIR): # if IMP_DIR not in sys.path: # sys.path.insert(0, IMP_DIR) # for fname in os.listdir(IMP_DIR): # if fname.endswith(".py"): # module = __import__(os.path.splitext(fname)[0]) # self._search_module(module) lay.addWidget(self.lstwdg) lay.addWidget(self.buttonBox)
def setupUI(self): layout = QtWidgets.QVBoxLayout() self.setLayout(layout) label = QtWidgets.QLabel('Press a button or move an axis on the Joystick:') layout.addWidget(label) params = [{'title': 'Joystick ID', 'name': 'joystickID', 'type': 'int', 'value': -1}, {'title': 'Button ID', 'name': 'buttonID', 'type': 'int', 'value': -1, 'visible': False}, {'title': 'Axis ID', 'name': 'axisID', 'type': 'int', 'value': -1, 'visible': False}, {'title': 'Value:', 'name': 'axis_value', 'type': 'float', 'value': 0., 'visible': False}, {'title': 'Hat ID', 'name': 'hatID', 'type': 'int', 'value': -1, 'visible': False}, {'title': 'Value x:', 'name': 'hat_value1', 'type': 'int', 'value': 0, 'visible': False}, {'title': 'Value y:', 'name': 'hat_value2', 'type': 'int', 'value': 0, 'visible': False}, ] self.settings = Parameter.create(name='settings', type='group', children=params) self.settings_tree = ParameterTree() # tree.setMinimumWidth(400) # self.settings_tree.setMinimumHeight(500) self.settings_tree.setParameters(self.settings, showTop=False) layout.addWidget(self.settings_tree) buttonBox = QtWidgets.QDialogButtonBox() buttonBox.addButton(QtWidgets.QDialogButtonBox.Ok) buttonBox.addButton(QtWidgets.QDialogButtonBox.Cancel) layout.addWidget(buttonBox) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject)
def __init__(self): super().__init__() #create layout for dialog self.layout = QtWidgets.QVBoxLayout() #create label for displaying text self.label = QtWidgets.QLabel( 'Something has happened! Press accept if you want whatever it is to continue, press cancel if you want it to stop!' ) self.proceedbox = QtWidgets.QDialogButtonBox() self.proceedbox.setOrientation(QtCore.Qt.Horizontal) self.proceedbox.setStandardButtons(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) self.layout.addWidget(self.label) self.layout.addWidget(self.proceedbox) self.setLayout(self.layout) self.proceedbox.rejected.connect(self.reject) self.proceedbox.accepted.connect(self.accept)
def init(self): """ Sets up the exception dialog after it has been initialized. This function is mainly responsible for gathering all required information; formatting it; and drawing the dialog. """ # Create a window layout grid_layout = GL.QGridLayout(self) grid_layout.setColumnStretch(2, 1) grid_layout.setRowStretch(3, 1) # Set properties of message box self.setWindowModality(QC.Qt.ApplicationModal) self.setAttribute(QC.Qt.WA_DeleteOnClose) self.setWindowTitle("ERROR") self.setWindowFlags(QC.Qt.MSWindowsOwnDC | QC.Qt.Dialog | QC.Qt.WindowTitleHint | QC.Qt.WindowSystemMenuHint | QC.Qt.WindowCloseButtonHint) # Set the icon of the exception on the left icon_label = GW.QLabel() pixmap = GW.QMessageBox.standardIcon(GW.QMessageBox.Critical) icon_label.setPixmap(pixmap) grid_layout.addWidget(icon_label, 0, 0, 2, 1, QC.Qt.AlignTop) # Add a spacer item spacer_item = QW.QSpacerItem(7, 1, QW.QSizePolicy.Fixed, QW.QSizePolicy.Fixed) grid_layout.addItem(spacer_item, 0, 1, 2, 1) # Set the text of the exception exc_str = self.format_exception() exc_label = GW.QLabel(exc_str) grid_layout.addWidget(exc_label, 0, 2, 1, 1) # Create a button box for the buttons button_box = QW.QDialogButtonBox() grid_layout.addWidget(button_box, 2, 0, 1, grid_layout.columnCount()) # Create traceback box self.tb_box = self.create_traceback_box() grid_layout.addWidget(self.tb_box, 3, 0, 1, grid_layout.columnCount()) # Create traceback button self.tb_but =\ button_box.addButton(self.tb_labels[self.tb_box.isHidden()], button_box.ActionRole) self.tb_but.clicked.connect(self.toggle_traceback_box) # Create an 'ok' button ok_but = button_box.addButton(button_box.Ok) ok_but.clicked.connect(self.close) ok_but.setDefault(True) # Update the size self.update_size()
def __init__(self, current_runs, instrument, parent=None): QtWidgets.QDialog.__init__(self, parent) self.setWindowTitle('Run Selection') layout = QtWidgets.QVBoxLayout(self) self.message = QtWidgets.QLabel() self.message.setText('Which run do you wish to use for calculation?') layout.addWidget(self.message) current_runs_as_string = [ instrument + str(run[0]) for run in current_runs ] self.run_selector_combo = QtWidgets.QComboBox() self.run_selector_combo.addItems(current_runs_as_string) layout.addWidget(self.run_selector_combo) buttons = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self) buttons.accepted.connect(self.accept) buttons.rejected.connect(self.reject) layout.addWidget(buttons) self.setLayout(layout)
def show_tree(self): dialog = QtWidgets.QDialog() vlayout = QtWidgets.QVBoxLayout() add_scan = QtWidgets.QPushButton('Add Scan') add_scan.clicked.connect(self.add_scan) self.tree.setParameters(self.settings, showTop=False) vlayout.addWidget(add_scan) vlayout.addWidget(self.tree) dialog.setLayout(vlayout) buttonBox = QtWidgets.QDialogButtonBox(parent=dialog) buttonBox.addButton('Save', buttonBox.AcceptRole) buttonBox.accepted.connect(dialog.accept) buttonBox.addButton('Cancel', buttonBox.RejectRole) buttonBox.rejected.connect(dialog.reject) vlayout.addWidget(buttonBox) dialog.setWindowTitle('Fill in information about this Scan batch') res = dialog.exec() if res == dialog.Accepted: # save managers parameters in a xml file # start = os.path.split(os.path.split(os.path.realpath(__file__))[0])[0] # start = os.path.join("..",'daq_scan') ioxml.parameter_to_xml_file( self.settings, os.path.join(self.batch_path, self.settings.child('filename').value())) return res == dialog.Accepted
def show_remote(self): """ """ dialog = QtWidgets.QDialog() vlayout = QtWidgets.QVBoxLayout() tree = ParameterTree() # tree.setMinimumWidth(400) tree.setMinimumHeight(500) tree.setParameters(self.remote_params, showTop=False) vlayout.addWidget(tree) dialog.setLayout(vlayout) buttonBox = QtWidgets.QDialogButtonBox(parent=dialog) buttonBox.addButton('Save', buttonBox.AcceptRole) buttonBox.accepted.connect(dialog.accept) buttonBox.addButton('Cancel', buttonBox.RejectRole) buttonBox.rejected.connect(dialog.reject) vlayout.addWidget(buttonBox) dialog.setWindowTitle('Fill in information about the actions and their shortcuts') res = dialog.exec() if res == dialog.Accepted: # save preset parameters in a xml file ioxml.parameter_to_xml_file( self.remote_params, os.path.join(remote_path, self.remote_params.child('filename').value()))
def _build_form(self): fitter = self.fitter l = QtWidgets.QFormLayout() options = fitter.options self.widgets = {} self.forms = {} for k in sorted(options): item = build_form_item(fitter, k) l.addRow(item.label, item.widget) self.widgets[k] = item.widget self.forms[k] = item # need to prevent garbage collection constraints = fitter.constraints if constraints: self.constraints = ConstraintsWidget(constraints) l.addRow(self.constraints) else: self.constraints = None self.okcancel = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) l.addRow(self.okcancel) self.setLayout(l)
def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(717, 301) self.verticalLayout = QtWidgets.QVBoxLayout(Dialog) self.verticalLayout.setObjectName("verticalLayout") self.label = QtWidgets.QLabel(Dialog) self.label.setObjectName("label") self.verticalLayout.addWidget(self.label) self.listWidget = QtWidgets.QListWidget(Dialog) self.listWidget.setSelectionMode( QtWidgets.QAbstractItemView.ExtendedSelection) self.listWidget.setObjectName("listWidget") self.verticalLayout.addWidget(self.listWidget) self.buttonBox = QtWidgets.QDialogButtonBox(Dialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel | QtWidgets.QDialogButtonBox.Discard | QtWidgets.QDialogButtonBox.SaveAll) self.buttonBox.setObjectName("buttonBox") self.verticalLayout.addWidget(self.buttonBox) self.retranslateUi(Dialog) self.buttonBox.accepted.connect(Dialog.accept) self.buttonBox.rejected.connect(Dialog.reject) QtCore.QMetaObject.connectSlotsByName(Dialog)
def create_group_buttons(self, window_layout): """ Creates the button box that is shown at the bottom of the options dialog and registers it in the provided `window_layout`. """ # Create a button_box button_box = QW.QDialogButtonBox() window_layout.addWidget(button_box) # Make a 'Reset' button reset_but = button_box.addButton(button_box.Reset) reset_but.setToolTip("Reset to defaults") reset_but.clicked.connect(self.reset_options) self.reset_but = reset_but # Make an 'Apply' button save_but = button_box.addButton(button_box.Apply) save_but.setToolTip("Apply changes") save_but.clicked.connect(self.save_options) save_but.setEnabled(False) self.save_but = save_but # Make a 'Close' button close_but = button_box.addButton(button_box.Close) close_but.setToolTip("Close without saving") close_but.clicked.connect(self.close) close_but.setDefault(True) self.close_but = close_but
def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(346, 309) Dialog.setSizeGripEnabled(True) Dialog.setModal(True) self.verticalLayout_4 = QtWidgets.QVBoxLayout(Dialog) self.verticalLayout_4.setObjectName("verticalLayout_4") self.main_label = QtWidgets.QLabel(Dialog) self.main_label.setObjectName("main_label") self.verticalLayout_4.addWidget(self.main_label) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.verticalLayout_3 = QtWidgets.QVBoxLayout() self.verticalLayout_3.setObjectName("verticalLayout_3") self.other_label = QtWidgets.QLabel(Dialog) self.other_label.setObjectName("other_label") self.verticalLayout_3.addWidget(self.other_label) self.other_list = QtWidgets.QListWidget(Dialog) self.other_list.setObjectName("other_list") self.verticalLayout_3.addWidget(self.other_list) self.horizontalLayout.addLayout(self.verticalLayout_3) self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") self.targets_add = QtWidgets.QPushButton(Dialog) self.targets_add.setMaximumSize(QtCore.QSize(30, 16777215)) self.targets_add.setObjectName("targets_add") self.verticalLayout.addWidget(self.targets_add) self.other_add = QtWidgets.QPushButton(Dialog) self.other_add.setMaximumSize(QtCore.QSize(30, 16777215)) self.other_add.setObjectName("other_add") self.verticalLayout.addWidget(self.other_add) self.horizontalLayout.addLayout(self.verticalLayout) self.verticalLayout_2 = QtWidgets.QVBoxLayout() self.verticalLayout_2.setObjectName("verticalLayout_2") self.targets_label = QtWidgets.QLabel(Dialog) self.targets_label.setObjectName("targets_label") self.verticalLayout_2.addWidget(self.targets_label) self.targets_list = QtWidgets.QListWidget(Dialog) self.targets_list.setObjectName("targets_list") self.verticalLayout_2.addWidget(self.targets_list) self.horizontalLayout.addLayout(self.verticalLayout_2) self.verticalLayout_4.addLayout(self.horizontalLayout) self.horizontalLayout_2 = QtWidgets.QHBoxLayout() self.horizontalLayout_2.setObjectName("horizontalLayout_2") spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_2.addItem(spacerItem) self.button_box = QtWidgets.QDialogButtonBox(Dialog) self.button_box.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel | QtWidgets.QDialogButtonBox.Ok) self.button_box.setObjectName("button_box") self.horizontalLayout_2.addWidget(self.button_box) self.verticalLayout_4.addLayout(self.horizontalLayout_2) self.retranslateUi(Dialog) self.button_box.accepted.connect(Dialog.accept) self.button_box.rejected.connect(Dialog.reject) QtCore.QMetaObject.connectSlotsByName(Dialog)
def __init__(self, parent=None): super().__init__(parent) self.setWindowTitle(_('Import dataset')) self.set_default_window_flags(self) self.setWindowModality(Qt.NonModal) layout = QtWidgets.QVBoxLayout() self.setLayout(layout) self.formats = QtWidgets.QComboBox() for key, val in Export.config('formats').items(): self.formats.addItem(val) self.formats.setCurrentIndex(0) self.formats.currentTextChanged.connect(self.on_format_change) self.selected_format = list(Export.config('formats').keys())[0] format_group = QtWidgets.QGroupBox() format_group.setTitle(_('Format')) format_group_layout = QtWidgets.QVBoxLayout() format_group.setLayout(format_group_layout) format_group_layout.addWidget(self.formats) layout.addWidget(format_group) self.data_folder = QtWidgets.QLineEdit() self.data_folder.setReadOnly(True) data_browse_btn = QtWidgets.QPushButton(_('Browse')) data_browse_btn.clicked.connect(self.data_browse_btn_clicked) data_folder_group = QtWidgets.QGroupBox() data_folder_group.setTitle(_('Dataset folder')) data_folder_group_layout = QtWidgets.QHBoxLayout() data_folder_group.setLayout(data_folder_group_layout) data_folder_group_layout.addWidget(self.data_folder) data_folder_group_layout.addWidget(data_browse_btn) layout.addWidget(data_folder_group) self.output_folder = QtWidgets.QLineEdit() self.output_folder.setReadOnly(True) output_browse_btn = QtWidgets.QPushButton(_('Browse')) output_browse_btn.clicked.connect(self.output_browse_btn_clicked) output_folder_group = QtWidgets.QGroupBox() output_folder_group.setTitle(_('Output folder')) output_folder_group_layout = QtWidgets.QHBoxLayout() output_folder_group.setLayout(output_folder_group_layout) output_folder_group_layout.addWidget(self.output_folder) output_folder_group_layout.addWidget(output_browse_btn) layout.addWidget(output_folder_group) layout.addStretch() button_box = QtWidgets.QDialogButtonBox() export_btn = button_box.addButton( _('Import'), QtWidgets.QDialogButtonBox.AcceptRole) export_btn.clicked.connect(self.import_btn_clicked) cancel_btn = button_box.addButton( _('Cancel'), QtWidgets.QDialogButtonBox.RejectRole) cancel_btn.clicked.connect(self.cancel_btn_clicked) layout.addWidget(button_box)
def setupUi(self, CalculatorDialog): CalculatorDialog.setObjectName("CalculatorDialog") CalculatorDialog.resize(640, 480) self.gridLayout = QtWidgets.QGridLayout(CalculatorDialog) self.gridLayout.setObjectName("gridLayout") self.main_layout = QtWidgets.QHBoxLayout() self.main_layout.setObjectName("main_layout") self.save_layout = QtWidgets.QVBoxLayout() self.save_layout.setObjectName("save_layout") self.saved_label = QtWidgets.QLabel(CalculatorDialog) self.saved_label.setObjectName("saved_label") self.save_layout.addWidget(self.saved_label) self.saved_list = QtWidgets.QListWidget(CalculatorDialog) self.saved_list.setObjectName("saved_list") self.save_layout.addWidget(self.saved_list) self.list_buttons_layout = QtWidgets.QHBoxLayout() self.list_buttons_layout.setObjectName("list_buttons_layout") self.save_button = QtWidgets.QPushButton(CalculatorDialog) self.save_button.setObjectName("save_button") self.list_buttons_layout.addWidget(self.save_button) self.remove_button = QtWidgets.QPushButton(CalculatorDialog) self.remove_button.setObjectName("remove_button") self.list_buttons_layout.addWidget(self.remove_button) self.save_layout.addLayout(self.list_buttons_layout) self.main_layout.addLayout(self.save_layout) self.evaluation_layout = QtWidgets.QVBoxLayout() self.evaluation_layout.setObjectName("evaluation_layout") self.statements_label = QtWidgets.QLabel(CalculatorDialog) self.statements_label.setObjectName("statements_label") self.evaluation_layout.addWidget(self.statements_label) self.statements_edit = QtWidgets.QTextEdit(CalculatorDialog) self.statements_edit.setObjectName("statements_edit") self.evaluation_layout.addWidget(self.statements_edit) self.expression_label = QtWidgets.QLabel(CalculatorDialog) self.expression_label.setObjectName("expression_label") self.evaluation_layout.addWidget(self.expression_label) self.expression_edit = QtWidgets.QTextEdit(CalculatorDialog) self.expression_edit.setObjectName("expression_edit") self.evaluation_layout.addWidget(self.expression_edit) self.result_label = QtWidgets.QLabel(CalculatorDialog) self.result_label.setObjectName("result_label") self.evaluation_layout.addWidget(self.result_label) self.result_edit = QtWidgets.QLineEdit(CalculatorDialog) self.result_edit.setObjectName("result_edit") self.evaluation_layout.addWidget(self.result_edit) self.main_layout.addLayout(self.evaluation_layout) self.main_layout.setStretch(0, 1) self.main_layout.setStretch(1, 3) self.gridLayout.addLayout(self.main_layout, 0, 0, 1, 1) self.buttons = QtWidgets.QDialogButtonBox(CalculatorDialog) self.buttons.setStandardButtons(QtWidgets.QDialogButtonBox.Apply | QtWidgets.QDialogButtonBox.Close) self.buttons.setObjectName("buttons") self.gridLayout.addWidget(self.buttons, 1, 0, 1, 1) self.retranslateUi(CalculatorDialog) QtCore.QMetaObject.connectSlotsByName(CalculatorDialog)
def setupUi(self, rsd, sources_json): # setup static elements rsd.setObjectName("Restore Sources") rsd.resize(1150, 640) self.buttonBox = QtWidgets.QDialogButtonBox(rsd) self.buttonBox.setGeometry(QtCore.QRect(10, 600, 1130, 35)) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel | QtWidgets.QDialogButtonBox.Ok) self.buttonBox.setObjectName("buttonBoxOkCancel") self.label = QtWidgets.QLabel(rsd) self.label.setGeometry(QtCore.QRect(20, 10, 1120, 140)) self.label.setWordWrap(True) self.label.setObjectName("labelInstructions") self.scrollArea = QtWidgets.QScrollArea(rsd) self.scrollArea.setGeometry(QtCore.QRect(10, 150, 1130, 440)) self.scrollArea.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) self.scrollArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) self.scrollArea.setWidgetResizable(True) self.scrollArea.setObjectName("scrollArea") self.scrollAreaWidget = QtWidgets.QWidget() self.scrollAreaWidgetContents = QtWidgets.QFormLayout() self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") # Create 1 set of (checkbox, label, combobox per fromcategory for index, source in enumerate(sources_json): objectdict = {'checkbox': None, 'label': None} layout = QtWidgets.QHBoxLayout() objectdict['checkbox'] = QtWidgets.QCheckBox() objectdict['checkbox'].setGeometry(QtCore.QRect(0, 0, 20, 20)) objectdict['checkbox'].setText("") objectdict['checkbox'].setObjectName("checkBox" + str(index)) objectdict['checkbox'].setCheckState(2) layout.addWidget(objectdict['checkbox']) objectdict['label'] = QtWidgets.QLabel() objectdict['label'].setGeometry(QtCore.QRect(0, 0, 480, 25)) objectdict['label'].setObjectName("label" + str(index)) if 'name' in source: objectdict['label'].setText(source['name']) elif 'config' in source: objectdict['label'].setText(source['config']['name']) layout.addWidget(objectdict['label']) self.objectlist.append(objectdict) self.scrollAreaWidgetContents.addRow(layout) self.scrollAreaWidget.setLayout(self.scrollAreaWidgetContents) self.scrollArea.setWidget(self.scrollAreaWidget) self.scrollArea.show() self.retranslateUi(rsd) self.buttonBox.accepted.connect(rsd.accept) self.buttonBox.rejected.connect(rsd.reject) QtCore.QMetaObject.connectSlotsByName(rsd)
def __init__(self, text="Enter object label", parent=None, labels=None, sort_labels=True, show_text_field=True, completion='startswith'): super(LabelDialog, self).__init__(parent) self.edit = LabelQLineEdit() self.edit.setPlaceholderText(text) self.edit.setValidator(labelme.utils.labelValidator()) self.edit.editingFinished.connect(self.postProcess) layout = QtWidgets.QVBoxLayout() if show_text_field: layout.addWidget(self.edit) # buttons self.buttonBox = bb = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self, ) bb.button(bb.Ok).setIcon(labelme.utils.newIcon('done')) bb.button(bb.Cancel).setIcon(labelme.utils.newIcon('undo')) bb.accepted.connect(self.validate) bb.rejected.connect(self.reject) layout.addWidget(bb) # label_list self.labelList = QtWidgets.QListWidget() self._sort_labels = sort_labels if labels: self.labelList.addItems(labels) if self._sort_labels: self.labelList.sortItems() else: self.labelList.setDragDropMode( QtGui.QAbstractItemView.InternalMove) self.labelList.currentItemChanged.connect(self.labelSelected) self.edit.setListWidget(self.labelList) layout.addWidget(self.labelList) self.setLayout(layout) # completion completer = QtWidgets.QCompleter() if not QT5 and completion != 'startswith': logger.warn("completion other than 'startswith' is only " "supported with Qt5. Using 'startswith'") completion = 'startswith' if completion == 'startswith': completer.setCompletionMode(QtWidgets.QCompleter.InlineCompletion) # Default settings. # completer.setFilterMode(QtCore.Qt.MatchStartsWith) elif completion == 'contains': completer.setCompletionMode(QtWidgets.QCompleter.PopupCompletion) completer.setFilterMode(QtCore.Qt.MatchContains) else: raise ValueError('Unsupported completion: {}'.format(completion)) completer.setModel(self.labelList.model()) self.edit.setCompleter(completer)
def __init__(self, parent=None): self.parent = parent super().__init__(parent) self.setWindowTitle(_('Merge datasets')) self.set_default_window_flags(self) self.setWindowModality(Qt.NonModal) layout = QtWidgets.QVBoxLayout() self.setLayout(layout) self.dataset_file_table = QtWidgets.QTableWidget(0, 4) self.dataset_file_table.setHorizontalHeaderLabels([_('Dataset'), _('Format'), _('# Samples'), _('Directory')]) header = self.dataset_file_table.horizontalHeader() header.setMinimumSectionSize(100) self.dataset_file_table.setColumnWidth(2, 160) header.setSectionResizeMode(0, QtWidgets.QHeaderView.Interactive) header.setSectionResizeMode(1, QtWidgets.QHeaderView.Interactive) header.setSectionResizeMode(2, QtWidgets.QHeaderView.Interactive) header.setSectionResizeMode(3, QtWidgets.QHeaderView.Stretch) dataset_files_browse_btn = QtWidgets.QPushButton(_('Add dataset file')) dataset_files_browse_btn.clicked.connect(self.dataset_files_browse_btn_clicked) dataset_files_group = QtWidgets.QGroupBox() dataset_files_group.setTitle(_('Datasets')) dataset_files_group_layout = QtWidgets.QGridLayout() dataset_files_group.setLayout(dataset_files_group_layout) dataset_files_group_layout.addWidget(self.dataset_file_table, 0, 0, 1, 4) dataset_files_group_layout.addWidget(dataset_files_browse_btn, 1, 0) layout.addWidget(dataset_files_group) self.export_file = QtWidgets.QLineEdit() export_browse_btn = QtWidgets.QPushButton(_('Browse')) export_browse_btn.clicked.connect(self.export_browse_btn_clicked) export_file_group = QtWidgets.QGroupBox() export_file_group.setTitle(_('Export folder')) export_file_group_layout = QtWidgets.QHBoxLayout() export_file_group.setLayout(export_file_group_layout) export_file_group_layout.addWidget(self.export_file) export_file_group_layout.addWidget(export_browse_btn) layout.addWidget(export_file_group) layout.addStretch() button_box = QtWidgets.QDialogButtonBox() merge_btn = button_box.addButton(_('Merge'), QtWidgets.QDialogButtonBox.AcceptRole) merge_btn.clicked.connect(self.merge_btn_clicked) cancel_btn = button_box.addButton(_('Cancel'), QtWidgets.QDialogButtonBox.RejectRole) cancel_btn.clicked.connect(self.cancel_btn_clicked) layout.addWidget(button_box) self.resize(750, 400)