def init_ui(self): self.setWindowTitle('Example Dialog') v = QVBoxLayout() self.text.setText("HELLO") v.addWidget(self.text, alignment=Qt.Alignment()) v.addWidget(self.btn_ok, alignment=Qt.Alignment()) v.addWidget(self.btn_cancel, alignment=Qt.Alignment()) self.setLayout(v) self.btn_ok.clicked.connect(self.ok) self.btn_cancel.clicked.connect(self.cancel)
def __init__(self, color_caption): TestableWidget.__init__(self) self.setWindowFlags(Qt.Popup) self._text = self.tr("Alignment text") main_layout = QVBoxLayout() main_layout.setContentsMargins(0, 0, 0, 0) b = "border: 1px solid #9b9b9b;" self._styles = { "border": b, "border_blue": "border: 0px solid blue;", "frame": 'QFrame[frameShape="4"]{color: #9b9b9b;}' } self.setStyleSheet(self._styles["frame"]) # -- CAPTION ---------------------------------- caption = QFrame(self, flags=Qt.WindowFlags()) caption_layout = QHBoxLayout() self._lbl_caption = QLabel(self._text) self._lbl_caption.setStyleSheet(self._styles["border_blue"]) caption_layout.addWidget(self._lbl_caption, alignment=Qt.Alignment()) caption.setLayout(caption_layout) caption_layout.setContentsMargins(9, 5, 9, 5) caption.setStyleSheet( f"background-color: {color_caption}; {self._styles['border']}") # -- CELLS GRID ------------------------------- cellsbox = QFrame(self, flags=Qt.WindowFlags()) cells = QGridLayout() cellsbox.setLayout(cells) cells.setContentsMargins(9, 0, 9, 9) self._clrbtn = [] for i in range(1, 4): for j in range(1, 5): self._clrbtn.append(QToolButton()) self._clrbtn[-1].clicked.connect( lambda z, y=i, x=j: self.select_align_(x, y)) self._clrbtn[-1].setAutoRaise(True) sz = 48 self._clrbtn[-1].setFixedSize(sz, sz) self._clrbtn[-1].setIconSize(QSize(sz, sz)) self._clrbtn[-1].setIcon(QIcon(img(f"editor/a{i}{j}.png"))) # noinspection PyArgumentList cells.addWidget(self._clrbtn[-1], i - 1, j - 1) # --------------------------------------------- main_layout.addWidget(caption, alignment=Qt.Alignment()) main_layout.addWidget(cellsbox, alignment=Qt.Alignment()) self.setLayout(main_layout)
def init_ui(self): self.setGeometry(900, 300, 500, 320) self.setWindowTitle('Simple APP') v = QVBoxLayout() self.text.setText( "In ten hours a day you have time to fall twice as far " + "behind your commitments as in five hours a day.\n" + "CORRECT:\n" + "Data expands to fill the space available for storage.") self.btn_msgbox.clicked.connect(self.msgbox) self.btn_mydlg.clicked.connect(self.mydlg) v.addWidget(self.text, alignment=Qt.Alignment()) v.addWidget(self.btn_msgbox, alignment=Qt.Alignment()) v.addWidget(self.btn_mydlg, alignment=Qt.Alignment()) self.setLayout(v)
def __init__(self, title, icon, width, height, x, y, type, text, parent=None, flags=Qt.WindowFlags()): super().__init__(title, icon, width, height, x, y, parent=parent, flags=flags) self.grid_layout = QGridLayout() self.grid_layout.setContentsMargins(0, 0, 0, 0) self.init_layout(title, icon) self.init_widget(type, text) self.finish_layout() pass
def setUpClass(cls): cls.test = QTestHelper() # --------------------------------------------------------------------- # customize editor # noinspection PyUnusedLocal def save(txt): # pragma: no cover return None def load(): return "HELLO hello1 hell привет приве 2" # i18n cls.widget = TestableWidget(None) cls.editor = TextEditor(cls.widget, Config(), save=save, load=load, spell=SpellChecker(enabled=True), auto_load=True, auto_key_switch=True) cls.keyswitcher = cls.editor._keyswitcher cls.spell = cls.editor._spell # --------------------------------------------------------------------- # customize the widget for placement layout = QHBoxLayout() layout.addWidget(cls.editor, alignment=Qt.Alignment()) cls.widget.setLayout(layout) cls.widget.resize(800, 450) cls.widget.move(800, 150) cls.test.show_and_wait_for_active(cls.widget)
def _set_widget(widget, layout=None, horizontal=None, vertical=None, size=None, alignment=None, hstretch=10, vstretch=10, style=None, **kwargs): if style is not None: widget.setStyleSheet("* {%s}" % style) if layout is not None: alignment = getattr(Qt, alignment) if alignment else Qt.Alignment(0) layout.addWidget(widget, alignment=alignment) if (horizontal, vertical, hstretch, vstretch) is not (None, None, None, None): policy = widget.sizePolicy() if horizontal is not None: policy.setHorizontalPolicy(getattr(QSizePolicy, horizontal)) if hstretch is not None: policy.setHorizontalStretch(int(hstretch)) if vstretch is not None: policy.setVerticalStretch(int(vstretch)) if vertical is not None: policy.setVerticalPolicy(getattr(QSizePolicy, vertical)) widget.setSizePolicy(policy) if size is not None: qsize = QSize(*size) if __debug__: print("Setting sizeHint to %s" % qsize) widget.sizeHint = lambda: qsize widget.setMinimumSize(qsize) widget.setMaximumSize(qsize) widget.updateGeometry() _set_object(widget, **kwargs)
def __init__(self, parent: TWidget, file_path=None, text_format="HTML", highlighter="", func_after_save=None, spell=None): super(TabEdit, self).__init__() self._editor = TextEditor(parent, parent.cfg, show_status_bar=True, show_tool_bar=True, format=text_format, load=self._load, save=self._save, spell=spell) self._editor.enabled_save_signal.connect(self.set_enabled_save) self._func_after_save = func_after_save layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout) layout.addWidget(self._editor, alignment=Qt.Alignment()) self._parent = parent self._file_path = file_path self._text_format = text_format.upper() name = "HTML" if text_format.upper() == "HTML" else "TEXT" self._prev_text_format = name self._highlighter = highlighter self._is_modified = False self._editor.set_option(highlighter=highlighter) self._editor.load()
def setUpClass(cls): cls.test = QTestHelper() # --------------------------------------------------------------------- # customize editor # noinspection PyUnusedLocal def save(txt): return None def load(): return "HELLO" cls.widget = TestableWidget(None) cls.spell = SpellChecker(enabled=True) cls.editor = TextEditor(cls.widget, Config(), save=save, load=load, spell=cls.spell) # --------------------------------------------------------------------- # customize the widget for placement layout = QHBoxLayout() layout.addWidget(cls.editor, alignment=Qt.Alignment()) cls.widget.setLayout(layout) cls.widget.resize(800, 450) cls.widget.move(800, 150) cls.test.show_and_wait_for_active(cls.widget)
def scroll_line(key, window, focus_widget, key_filter, *args, **kwargs): if focus_widget is not None: with key_filter.disable_filtering: QApplication.sendEvent( focus_widget, QKeyEvent(QEvent.KeyPress, key, Qt.KeyboardModifiers(0))) return True
def update_filename_box(self): doing_multiple = self.doing_multiple model = QStandardItemModel() self.filename_box.setModel(model) self.icon_file_names.sort(key=sort_key) if doing_multiple: item = QStandardItem(_('Open to see checkboxes')) item.setIcon(QIcon(I('blank.png'))) else: item = QStandardItem('') item.setFlags(Qt.ItemFlag(0)) model.appendRow(item) for i, filename in enumerate(self.icon_file_names): item = QStandardItem(filename) if doing_multiple: item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled) item.setData(Qt.Unchecked, Qt.CheckStateRole) else: item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) icon = QIcon( QPixmap(os.path.join(self.icon_folder, filename)).scaled( self.filenamebox_view.iconSize(), transformMode=Qt.SmoothTransformation)) item.setIcon(icon) model.appendRow(item)
def scroll_to_boundary(top, window, focus_widget, key_filter, *args, **kwargs): if focus_widget is not None: with key_filter.disable_filtering: key = Qt.Key_Home if top else Qt.Key_End QApplication.sendEvent( focus_widget, QKeyEvent(QEvent.KeyPress, key, Qt.KeyboardModifiers(0))) return True
def scroll_page(up, window, focus_widget, key_filter, *args, **kwargs): if focus_widget is not None: with key_filter.disable_filtering: key = Qt.Key_PageUp if up else Qt.Key_PageDown QApplication.sendEvent( focus_widget, QKeyEvent(QEvent.KeyPress, key, Qt.KeyboardModifiers(0))) return True
def __init__(self, parent, flags=Qt.WindowFlags()): QDialog.__init__(self, parent, flags) self.setModal(False) self.setWindowTitle("Select sources by...") lo = QVBoxLayout(self) lo.setContentsMargins(10, 10, 10, 10) lo.setSpacing(5) # select by lo1 = QHBoxLayout() lo.addLayout(lo1) lo1.setContentsMargins(0, 0, 0, 0) # lab = QLabel("Select:") # lo1.addWidget(lab) self.wselby = QComboBox(self) lo1.addWidget(self.wselby, 0) self.wselby.activated[str].connect(self._setup_selection_by) # under/over self.wgele = QComboBox(self) lo1.addWidget(self.wgele, 0) self.wgele.addItems([">", ">=", "<=", "<", "sum<=", "sum>", "=="]) self.wgele.activated[str].connect(self._select_threshold) # threshold value self.wthreshold = QLineEdit(self) self.wthreshold.editingFinished.connect(self._select_threshold) lo1.addWidget(self.wthreshold, 1) # min and max label self.wminmax = QLabel(self) lo.addWidget(self.wminmax) # selection slider lo1 = QHBoxLayout() lo.addLayout(lo1) self.wpercent = QSlider(self) self.wpercent.setTracking(False) self.wpercent.valueChanged[int].connect(self._select_percentile) self.wpercent.sliderMoved[int].connect( self._select_percentile_threshold) self.wpercent.setRange(0, 100) self.wpercent.setOrientation(Qt.Horizontal) lo1.addWidget(self.wpercent) self.wpercent_lbl = QLabel("0%", self) self.wpercent_lbl.setMinimumWidth(64) lo1.addWidget(self.wpercent_lbl) # # hide button # lo.addSpacing(10) # lo2 = QHBoxLayout() # lo.addLayout(lo2) # lo2.setContentsMargins(0,0,0,0) # hidebtn = QPushButton("Close",self) # hidebtn.setMinimumWidth(128) # QObject.connect(hidebtn,pyqtSignal("clicked()"),self.hide) # lo2.addStretch(1) # lo2.addWidget(hidebtn) # lo2.addStretch(1) # self.setMinimumWidth(384) self._in_select_threshold = False self._sort_index = None self.qerrmsg = QErrorMessage(self)
def __init__(self, title, icon, width, height, x, y, parent=None, flags=Qt.WindowFlags()): super().__init__(parent=parent, flags=flags) pass
def __init__(self, checked=False, is_tristate=False): QTableWidgetItem.__init__(self, '') self.setFlags(Qt.ItemFlags(Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)) if is_tristate: self.setFlags(self.flags() | Qt.ItemIsTristate) if checked: self.setCheckState(Qt.Checked) else: if is_tristate and checked is None: self.setCheckState(Qt.PartiallyChecked) else: self.setCheckState(Qt.Unchecked)
def setUpClass(cls): cls.test = QTestHelper() cls.insert_table = [] cls.w = TestableWidget() cls.w.setWindowTitle("Test insert table") cls.w.setGeometry(900, 300, 500, 500) cls.cp = InsertTable(config=Config()) cls.cp.insert_table.connect(lambda data: cls.insert_table.append(data)) cls.cw = cls.cp._colors_widget cls.v = QVBoxLayout() cls.v.addWidget(cls.cp, alignment=Qt.Alignment()) cls.v.addWidget(QLabel(""), alignment=Qt.Alignment()) cls.v.addItem( QSpacerItem(0, 0, QSizePolicy.Fixed, QSizePolicy.Expanding)) cls.lbl = QLabel("") cls.v.addWidget(cls.lbl, alignment=Qt.Alignment()) cls.w.setLayout(cls.v) cls.test.show_and_wait_for_active(cls.w)
def __init__(self, parent = None, flags = Qt.WindowFlags()): super().__init__(parent = parent, flags = flags) # set grid layout self.window_grid_layout = QGridLayout() self.window_grid_layout.setContentsMargins(0, 0, 0, 0) self.init_layout() self.init_widgets() self.finish_layout() self.events_of_window() self.message_box = MessageWindow(text = 'Here goes something you must attention before it\'s too late', title = 'Hey, there!', type = True) self.error_box = MessageWindow(text = 'It seems something wrong here...', title = 'Hey, STOP!', type = False) # alg settings self.alg = AnalyzeAlg() pass
def send_text_using_keys(self, text): if self.host_widget is not None and not sip.isdeleted( self.host_widget): self.host_widget.setFocus(Qt.OtherFocusReason) with QApplication.instance().key_filter.disable_filtering: for ch in text: key = getattr(Qt, f'Key_{ch.upper()}', Qt.Key_A) QApplication.sendEvent( self.host_widget, QKeyEvent(QKeyEvent.KeyPress, key, Qt.KeyboardModifiers(0), ch)) # Ensure key events are delivered before any other processing while QApplication.instance().processEvents(): pass
def __init__(self, parent, get_option, get_help, db=None, book_id=None): # Dummy attributes to fool the Widget() option handler code. We handle # everything in our *handler methods. for i in range(1, 4): x = 'sr%d_' % i for y in ('search', 'replace'): z = x + y setattr(self, 'opt_' + z, z) self.opt_search_replace = 'search_replace' Widget.__init__(self, parent, [ 'search_replace', 'sr1_search', 'sr1_replace', 'sr2_search', 'sr2_replace', 'sr3_search', 'sr3_replace' ]) self.db, self.book_id = db, book_id self.sr_search.set_msg(_('&Search Regular Expression')) self.sr_search.set_book_id(book_id) self.sr_search.set_db(db) self.sr_search.doc_update.connect(self.update_doc) proto = QTableWidgetItem() proto.setFlags(Qt.ItemFlags(Qt.ItemIsSelectable + Qt.ItemIsEnabled)) self.search_replace.setItemPrototype(proto) self.search_replace.setColumnCount(2) self.search_replace.setColumnWidth(0, 320) self.search_replace.setColumnWidth(1, 320) self.search_replace.setHorizontalHeaderLabels( [_('Search Regular Expression'), _('Replacement Text')]) self.sr_add.clicked.connect(self.sr_add_clicked) self.sr_change.clicked.connect(self.sr_change_clicked) self.sr_remove.clicked.connect(self.sr_remove_clicked) self.sr_load.clicked.connect(self.sr_load_clicked) self.sr_save.clicked.connect(self.sr_save_clicked) self.sr_up.clicked.connect(self.sr_up_clicked) self.sr_down.clicked.connect(self.sr_down_clicked) self.search_replace.currentCellChanged.connect( self.sr_currentCellChanged) self.initialize_options(get_option, get_help, db, book_id) try: self.rh_label.setText( self.rh_label.text() % localize_user_manual_link( 'https://manual.calibre-ebook.com/regexp.html')) except TypeError: pass # link already localized
def setUpClass(cls): cls.test = QTestHelper() cls.select_align = [] cls.w = TestableWidget() cls.w.setWindowTitle("Test align text") cls.w.setGeometry(900, 300, 500, 320) cls.cp = AlignText() cls.cp.select_align.connect(lambda h, v: cls.select_align.append( (h, v))) cls.cw = cls.cp._colors_widget cls.v = QVBoxLayout() cls.v.addWidget(cls.cp, alignment=Qt.Alignment()) cls.v.addWidget(QLabel(""), alignment=Qt.Alignment()) cls.v.addItem( QSpacerItem(0, 0, QSizePolicy.Fixed, QSizePolicy.Expanding)) cls.lbl = QLabel("") cls.v.addWidget(cls.lbl, alignment=Qt.Alignment()) cls.w.setLayout(cls.v) cls.test.show_and_wait_for_active(cls.w)
def setUpClass(cls): cls.test = QTestHelper() cls.selected_colors = [] cls.w = TestableWidget() cls.w.setWindowTitle("Test select color") cls.w.setGeometry(900, 300, 500, 320) cls.cp = ColorPicker(config=Config()) cls.cp.select_color.connect( lambda color: cls.selected_colors.append(color)) cls.cw = cls.cp._colors_widget cls.v = QVBoxLayout() cls.v.addWidget(cls.cp, alignment=Qt.Alignment()) cls.v.addWidget(QLabel(""), alignment=Qt.Alignment()) cls.v.addItem(QSpacerItem(0, 0, QSizePolicy.Fixed, QSizePolicy.Expanding)) cls.lbl = QLabel("") cls.v.addWidget(cls.lbl, alignment=Qt.Alignment()) cls.w.setLayout(cls.v) cls.test.show_and_wait_for_active(cls.w)
def __init__(self, text, checked=False, is_tristate=False): super(ReadOnlyCheckableTableWidgetItem, self).__init__(text) try: # TODO: For Qt Backwards compatibilyt. self.setFlags(Qt.ItemFlag.ItemIsSelectable | Qt.ItemFlag.ItemIsUserCheckable | Qt.ItemFlag.ItemIsEnabled ) except: self.setFlags(Qt.ItemFlags(Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled )) if is_tristate: self.setFlags(self.flags() | Qt.ItemIsTristate) if checked: self.setCheckState(Qt.Checked) else: if is_tristate and checked is None: self.setCheckState(Qt.PartiallyChecked) else: self.setCheckState(Qt.Unchecked)
def __init__(self, parent=None, flags=Qt.WindowFlags()): super().__init__(parent=parent, flags=flags) # set x, y, width, height for ui self.WINDOW_MAX_WIDTH = QApplication.desktop().width() self.WINDOW_MAX_HEIGHT = QApplication.desktop().height() self.WINDOW_INIT_HEIGHT = int(self.WINDOW_MAX_HEIGHT / 2) self.WINDOW_INIT_WIDTH = int(self.WINDOW_MAX_WIDTH / 2) self.X = int(self.WINDOW_MAX_WIDTH / 4) self.Y = int(self.WINDOW_MAX_HEIGHT / 4) # set x, y, width, height for box self.BOX_WIDTH = int(self.WINDOW_INIT_WIDTH / 2) self.BOX_HEIGHT = int(self.WINDOW_INIT_HEIGHT / 2) self.BOX_X = int(self.WINDOW_MAX_WIDTH *3 / 8) self.BOX_Y = int(self.WINDOW_MAX_HEIGHT * 3 / 8) # set height for buttons self.BUTTON_HEIGHT = int(self.WINDOW_INIT_HEIGHT / 6) pass
def __init__(self, title, icon, width=CONFIG.WINDOW_WIDTH, height=CONFIG.WINDOW_HEIGHT, x=CONFIG.WINDOW_X, y=CONFIG.WINDOW_Y, parent=None, flags=Qt.WindowFlags()): super().__init__(title, icon, width, height, x, y, parent=parent, flags=flags) self.grid_layout = QGridLayout() self.grid_layout.setContentsMargins(0, 0, 0, 0) self.init_layout(title, icon) self.init_widget() self.finish_layout() self.set_events() self.about_box = Box( title='About', icon=qta.icon('fa5s.broadcast-tower', color='red'), width=CONFIG.BOX_WIDTH, height=CONFIG.BOX_HEIGHT, x=CONFIG.BOX_X, y=CONFIG.BOX_Y, type=0, text='Here goes something you must attention before it\'s too late' ) self.predict_box = Box(title='Prediction', icon=qta.icon('fa5s.broadcast-tower', color='red'), width=CONFIG.BOX_WIDTH, height=CONFIG.BOX_HEIGHT, x=CONFIG.BOX_X, y=CONFIG.BOX_Y, type=1, text='') self.alg = AnalyzeAlg() pass
def __init__(self, str, owner: LabeledObject, owner_widget: GraphItem, parent=None, flags=Qt.WindowFlags()): super().__init__(str, parent=parent, flags=flags) self.__owner = owner self.__owner_widget = owner_widget font_database = QFontDatabase() # Build absolute path to prevent problems on macOS path = os.path.join(os.path.dirname(__file__), "../ressources/fonts/lmroman8-regular.otf") font_id = font_database.addApplicationFont(path) if (font_id == -1): raise IOError("Font could not be loaded") font_name = QFontDatabase.applicationFontFamilies(font_id)[0] font = QFont(font_name, 16) self.setFont(font) self.adjustSize() self.__reposition()
def __init__(self, parent, modal=True, flags=Qt.WindowFlags()): QDialog.__init__(self, parent, flags) self.model = None self.setModal(modal) self.setWindowTitle("Export Karma annotations") lo = QVBoxLayout(self) lo.setContentsMargins(10, 10, 10, 10) lo.setSpacing(5) # file selector self.wfile = FileSelector(self, label="Filename:", dialog_label="Karma annotations filename", default_suffix="ann", file_types="Karma annotations (*.ann)") lo.addWidget(self.wfile) # selected sources checkbox self.wsel = QCheckBox("selected sources only", self) lo.addWidget(self.wsel) # OK/cancel buttons lo.addSpacing(10) lo2 = QHBoxLayout() lo.addLayout(lo2) lo2.setContentsMargins(5, 5, 5, 5) self.wokbtn = QPushButton("OK", self) self.wokbtn.setMinimumWidth(128) self.wokbtn.clicked.connect(self.accept) self.wokbtn.setEnabled(False) cancelbtn = QPushButton("Cancel", self) cancelbtn.setMinimumWidth(128) cancelbtn.clicked.connect(self.reject) lo2.addWidget(self.wokbtn) lo2.addStretch(1) lo2.addWidget(cancelbtn) self.setMinimumWidth(384) # signals self.wfile.valid.connect(self.wokbtn.setEnabled) # internal state self.qerrmsg = QErrorMessage(self) self._model_filename = None
def __init__(self, parent=None, flags=Qt.WindowFlags()): super(MainWindow, self).__init__(parent, flags) self.setupUi(self) self.home_path = os.path.join(os.environ["USERPROFILE"], "Desktop") self.image_file_path = None self.get_save_path_history() self.bg_color = (0, 0, 0) self.save_path = "" self.clip_width = None self.clip_height = None self.image_counts = 0 self.success_counts = 0 self.is_running = False self.userPlatform = platform.system() self.pushButton.clicked.connect(self.load_image_files) self.treeWidget.itemDoubleClicked.connect(self.show_image) self.toolButton.clicked.connect(self.get_save_path) self.pushButton_2.clicked.connect(self.start_clip) self.clip_thread = ClipThread(self) self.clip_thread.output.connect(self.output_message) self.clip_thread.over.connect(self.over_clip) self.comboBox_3.activated.connect(self.update_save_item)
def expandingDirections(self): return Qt.Orientations(0)
def __init__(self, text, title = 'Hey, there!', type = True, parent = None, flags = Qt.WindowFlags()): super().__init__(parent = parent, flags = flags) # set grid layout self.window_grid_layout = QGridLayout() self.window_grid_layout.setContentsMargins(0, 0, 0, 0) self.init_layout(title) self.init_widgets(type, text) self.finish_layout() pass
def __init__(self, parent, modal=True, flags=Qt.WindowFlags()): QDialog.__init__(self, parent, flags) self.model = None self._model_dir = None self.setModal(modal) self.setWindowTitle("Add FITS brick") lo = QVBoxLayout(self) lo.setContentsMargins(10, 10, 10, 10) lo.setSpacing(5) # file selector self.wfile = FileSelector(self, label="FITS filename:", dialog_label="FITS file", default_suffix="fits", file_types="FITS files (*.fits *.FITS)", file_mode=QFileDialog.ExistingFile) lo.addWidget(self.wfile) # overwrite or add mode lo1 = QGridLayout() lo.addLayout(lo1) lo1.setContentsMargins(0, 0, 0, 0) lo1.addWidget(QLabel("Padding factor:", self), 0, 0) self.wpad = QLineEdit("2", self) self.wpad.setValidator(QDoubleValidator(self)) lo1.addWidget(self.wpad, 0, 1) lo1.addWidget(QLabel("Assign source name:", self), 1, 0) self.wname = QLineEdit(self) lo1.addWidget(self.wname, 1, 1) # OK/cancel buttons lo.addSpacing(10) lo2 = QHBoxLayout() lo.addLayout(lo2) lo2.setContentsMargins(0, 0, 0, 0) lo2.setContentsMargins(5, 5, 5, 5) self.wokbtn = QPushButton("OK", self) self.wokbtn.setMinimumWidth(128) self.wokbtn.clicked.connect(self.accept) self.wokbtn.setEnabled(False) cancelbtn = QPushButton("Cancel", self) cancelbtn.setMinimumWidth(128) cancelbtn.clicked.connect(self.reject) lo2.addWidget(self.wokbtn) lo2.addStretch(1) lo2.addWidget(cancelbtn) self.setMinimumWidth(384) # signals self.wfile.filenameSelected.connect(self._fileSelected) # internal state self.qerrmsg = QErrorMessage(self)