def __init__(self, mainWindow): # call the base class constructor: QWidget.__init__(self, mainWindow) self.mw = mainWindow # remember he application main windwos # Attributes (persistant data) self.__figure = Figure() # the plot figure self.__axes = None # axis system self.__canvas = None # area for matplotlib plot self.__toolbar = None # plot tool bar self.__xlim = None # xmin, xmay of the plo self.__ylim = None # ymin, ymax of the plot self.__axes_aspect = 'equal' # 'equal' or 'auto' self.btn_imageSize = QRadioButton("ImageSize", self) self.btn_autoSize = QRadioButton("AutoSize", self) self.btn_axesEqual = QRadioButton("Equal", self) self.btn_axesAuto = QRadioButton("Auto", self) group = QButtonGroup(self) # pour les 2 boutons imageSize, autoSize group.addButton(self.btn_imageSize) group.addButton(self.btn_autoSize) group = QButtonGroup(self) group.addButton(self.btn_axesEqual) group.addButton(self.btn_axesAuto) self.__initUI() # Initialisation de l'interface utilisateur
def __init__(self, mainWindow, quantity): # appel du constructeur de la classe de base : QWidget.__init__(self, mainWindow) self.mw = mainWindow # la fenêtre de l'application principale # Attributs (objets persistants) self.__quantity = quantity # "position" or "velocity" self.__data1 = None # data for the first plot self.__data2 = None # data for tthe second self.__figure = None # figure tracé self.__axes1 = None # système d'axes tracé 1 self.__axes2 = None # système d'axes tracé 2 self.__canvas = None # pour le tracé matplot.lib self.__toolbar = None # barre d'outils tracé self.__time = None # abcissa values for plot self.__xlim = None # xmin, xmay tracé self.__xlabel = None # étiquette axe X (n° image ou temps [s]) self.__ylim1 = None # ymin, ymax tracé x(t) self.__ylim2 = None # ymin, ymax tracé y(t) self.btn_imageSize = QRadioButton("ImageSize", self) self.btn_autoSize = QRadioButton("AutoSize", self) self.btn_smooth_Vx = QCheckBox("Lissage Vx", self) self.btn_smooth_Vy = QCheckBox("Lissage Vy", self) self.x_mav_nb_pts = QSpinBox(parent=self) # X velocity moving average self.y_mav_nb_pts = QSpinBox(parent=self) # Y velocity moving average self.__initUI() # Initialisation de l'interface utilisateur
def __init__(self, names, txt, parent=None): QDialog.__init__(self, parent) self.l = l = QVBoxLayout(self) self.setLayout(l) self.la = la = QLabel(_('Create a Virtual library based on %s') % txt) l.addWidget(la) self._names = QListWidget(self) self._names.addItems(sorted(names, key=sort_key)) self._names.setSelectionMode(self._names.ExtendedSelection) l.addWidget(self._names) self._or = QRadioButton(_('Match any of the selected %s names') % txt) self._and = QRadioButton(_('Match all of the selected %s names') % txt) self._or.setChecked(True) l.addWidget(self._or) l.addWidget(self._and) self.bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.bb.accepted.connect(self.accept) self.bb.rejected.connect(self.reject) l.addWidget(self.bb) self.resize(self.sizeHint())
def __init__(self, dicTitle, dicList): super(LLT_MC, self).__init__() self.w = QWidget() self.setCentralWidget(self.w) self.title = dicTitle self.wordList = dicList self.setWindowTitle("Multiple Choice") self.setGeometry(0, 0, 300, 400) self.currentWordS = random.sample(self.wordList, 3) self.currentQWord = self.currentWordS[0][0] self.currentAWord = self.currentWordS[0][1] self.topLabel = QLabel("Multiple Choice: " + str(dicTitle)) self.wordLabel = QLabel() self.wordLabel.setFont(QFont('Times New Roman', 16)) self.wordLabel.setAlignment(Qt.AlignCenter) self.resultLabel = QLabel() self.resultLabel.setAlignment(Qt.AlignCenter) self.aRad = QRadioButton() self.bRad = QRadioButton() self.cRad = QRadioButton() self.group = QButtonGroup() self.group.addButton(self.aRad) self.group.addButton(self.bRad) self.group.addButton(self.cRad) self.checkBut = QPushButton("Check") self.checkBut.setMinimumWidth(100) self.checkBut.setMinimumHeight(70) self.checkBut.clicked.connect(self.check) self.nextBut = QPushButton("Next Word") self.nextBut.setMinimumWidth(100) self.nextBut.setMinimumHeight(70) self.nextBut.clicked.connect(self.next) self.exitBut = QPushButton("Exit") self.exitBut.setMinimumWidth(130) self.exitBut.setMinimumHeight(70) self.exitBut.clicked.connect(self.exit) self.hbox = QHBoxLayout() self.hbox.addWidget(self.checkBut) self.hbox.addWidget(self.nextBut) self.vbox = QVBoxLayout() self.vbox.addWidget(self.topLabel) self.vbox.addWidget(self.wordLabel) self.vbox.addWidget(self.aRad) self.vbox.addWidget(self.bRad) self.vbox.addWidget(self.cRad) self.vbox.addWidget(self.resultLabel) self.vbox.addLayout(self.hbox) self.vbox.addWidget(self.exitBut) self.w.setLayout(self.vbox) self.setWord()
def __init__(self, names, parent=None): QDialog.__init__(self, parent) self.names = names self.setWindowTitle(_('Choose master file')) self.l = l = QVBoxLayout() self.setLayout(l) self.la = la = QLabel( _('Choose the master file. All selected files will be merged into the master file:' )) la.setWordWrap(True) l.addWidget(la) self.sa = sa = QScrollArea(self) l.addWidget(sa) self.bb = bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) l.addWidget(bb) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) self.w = w = QWidget(self) w.l = QVBoxLayout() w.setLayout(w.l) buttons = self.buttons = [QRadioButton(n) for n in names] buttons[0].setChecked(True) map(w.l.addWidget, buttons) sa.setWidget(w) self.resize(self.sizeHint() + QSize(150, 20))
def b(name, text, tt): ans = QRadioButton(text, w) l.addWidget(ans) ans.setToolTip(tt) setattr(w, name, ans) ans.setObjectName(name) return ans
def __init__(self, parent=None): QFrame.__init__(self, parent) self.setFocusPolicy(Qt.FocusPolicy.StrongFocus) self.setAutoFillBackground(True) self.capture = 0 self.setFrameShape(self.StyledPanel) self.setFrameShadow(self.Raised) self._layout = l = QGridLayout(self) self.setLayout(l) self.header = QLabel('') l.addWidget(self.header, 0, 0, 1, 2) self.use_default = QRadioButton('') self.use_custom = QRadioButton(_('&Custom')) l.addWidget(self.use_default, 1, 0, 1, 3) l.addWidget(self.use_custom, 2, 0, 1, 3) self.use_custom.toggled.connect(self.custom_toggled) off = 2 for which in (1, 2): text = _('&Shortcut:') if which == 1 else _('&Alternate shortcut:') la = QLabel(text) la.setStyleSheet('QLabel { margin-left: 1.5em }') l.addWidget(la, off + which, 0, 1, 3) setattr(self, 'label%d' % which, la) button = QPushButton(_('None'), self) button.clicked.connect(partial(self.capture_clicked, which=which)) button.installEventFilter(self) setattr(self, 'button%d' % which, button) clear = QToolButton(self) clear.setIcon(QIcon(I('clear_left.png'))) clear.clicked.connect(partial(self.clear_clicked, which=which)) setattr(self, 'clear%d' % which, clear) l.addWidget(button, off + which, 1, 1, 1) l.addWidget(clear, off + which, 2, 1, 1) la.setBuddy(button) self.done_button = doneb = QPushButton(_('Done'), self) l.addWidget(doneb, 0, 2, 1, 1) doneb.clicked.connect(lambda: self.editing_done.emit(self)) l.setColumnStretch(0, 100) self.custom_toggled(False)
def npkModeBox(self): label_ = QLabel(self) label_.resize(self.width() // 3, 25) label_.setText("NPK提取模式:") label_.setAlignment(Qt.AlignCenter) label_.setStyleSheet("font-size: 15px") # 选项AB npkYes = QRadioButton(self) npkYes.resize(self.width() // 3, 25) npkYes.move(self.width() // 3, 0) npkYes.setText("提取") npkNo = QRadioButton(self) npkNo.resize(self.width() // 3, 25) npkNo.move(self.width() // 3 * 2, 0) npkNo.setText("不提取") npkNo.setChecked(True) def npkYesFunc(): if not self.mainWin.npkDict: QMessageBox.warning(self, "未设置NPK词典", "未设置NPK词典将不能设置NPK提取", QMessageBox.Yes, QMessageBox.Yes) npkNo.setChecked(True) return False if not self.mainWin.img2Dir: QMessageBox.warning(self, "未设置img2目录", "未设置img2目录将不能设置NPK提取", QMessageBox.Yes, QMessageBox.Yes) npkNo.setChecked(True) return False npkYes.clicked.connect(npkYesFunc) def yes(): self.mainWin.npkMode = True npkYes.toggled.connect(yes) def no(): self.mainWin.npkMode = False npkNo.toggled.connect(no) self.npkModeGroup.setObjectName("npkExtractMode") self.npkModeGroup.addButton(npkYes) self.npkModeGroup.addButton(npkNo)
def __init__(self, index, dup_check, parent=None): QFrame.__init__(self, parent) self.setFrameShape(self.StyledPanel) self.setFrameShadow(self.Raised) self.setFocusPolicy(Qt.StrongFocus) self.setAutoFillBackground(True) self.l = l = QVBoxLayout(self) self.header = la = QLabel(self) la.setWordWrap(True) l.addWidget(la) self.default_shortcuts = QRadioButton(_("&Default"), self) self.custom = QRadioButton(_("&Custom"), self) self.custom.toggled.connect(self.custom_toggled) l.addWidget(self.default_shortcuts) l.addWidget(self.custom) for which in 1, 2: la = QLabel( _("&Shortcut:") if which == 1 else _("&Alternate shortcut:")) setattr(self, 'label%d' % which, la) h = QHBoxLayout() l.addLayout(h) h.setContentsMargins(25, -1, -1, -1) h.addWidget(la) b = QPushButton(_("Click to change"), self) la.setBuddy(b) b.clicked.connect(partial(self.capture_clicked, which=which)) b.installEventFilter(self) setattr(self, 'button%d' % which, b) h.addWidget(b) c = QToolButton(self) c.setIcon(QIcon(I('clear_left.png'))) c.setToolTip(_('Clear')) h.addWidget(c) c.clicked.connect(partial(self.clear_clicked, which=which)) setattr(self, 'clear%d' % which, c) self.data_model = index.model() self.capture = 0 self.key = None self.shorcut1 = self.shortcut2 = None self.dup_check = dup_check self.custom_toggled(False)
def init_ui(self): layout = QGridLayout() self.controls.append(QRadioButton(self.tr("english"))) # noinspection PyArgumentList layout.addWidget(self.controls[-1], 0, 0) self.controls.append(QRadioButton(self.tr("russian"))) # noinspection PyArgumentList layout.addWidget(self.controls[-1], 1, 0) self.controls.append(QCheckBox(self.tr("auto switch language"))) # noinspection PyArgumentList layout.addWidget(self.controls[-1], 2, 0) self.controls.append(QPushButton(self.tr("Apply"))) # noinspection PyArgumentList layout.addWidget(self.controls[-1], 4, 0) self.controls[-1].clicked.connect(self.apply) self.setWindowTitle(self.tr("Auto switch params")) # self.setGeometry(300, 300, 200, 100) self.setLayout(layout)
def allExtractBox(self): label_ = QLabel(self) label_.resize(self.width() // 3, 25) label_.move(0, 25) label_.setText("全部提取模式:") label_.setAlignment(Qt.AlignCenter) label_.setStyleSheet("font-size: 15px") # 选项AB allYes = QRadioButton(self) allYes.resize(self.width() // 3, 25) allYes.move(self.width() // 3, 25) allYes.setText("全部提取") allNo = QRadioButton(self) allNo.resize(self.width() // 3, 25) allNo.move(self.width() // 3 * 2, 25) allNo.setText("单个提取") allNo.setChecked(True) self.allModeGroup.setObjectName("allExtractMode") self.allModeGroup.addButton(allYes) self.allModeGroup.addButton(allNo)
def _initialize_file_type_settings(self, layout): '''Initialize file creation/sending type settings''' separator_b = QFrame() separator_b.setFrameStyle(QFrame.HLine) separator_b.setFrameShadow(QFrame.Sunken) layout.addWidget(separator_b) book_types_to_create = QGroupBox() book_types_to_create.setTitle('Book types to create files for:') book_types_to_create.setLayout(QHBoxLayout(book_types_to_create)) self._settings['mobi'] = QCheckBox('MOBI') self._settings['mobi'].setChecked('mobi' in __prefs__['formats']) book_types_to_create.layout().addWidget(self._settings['mobi']) self._settings['azw3'] = QCheckBox('AZW3') self._settings['azw3'].setChecked('azw3' in __prefs__['formats']) book_types_to_create.layout().addWidget(self._settings['azw3']) layout.addWidget(book_types_to_create) file_preference_layout = QGroupBox() file_preference_layout.setTitle( 'If device has both (mobi and azw3) formats, prefer:') file_preference_layout.setLayout(QHBoxLayout(file_preference_layout)) file_preference_group = QButtonGroup() self._settings['file_preference_mobi'] = QRadioButton('MOBI') self._settings['file_preference_mobi'].setChecked( __prefs__['file_preference'] == 'mobi') file_preference_group.addButton(self._settings['file_preference_mobi']) file_preference_layout.layout().addWidget( self._settings['file_preference_mobi']) self._settings['file_preference_azw3'] = QRadioButton('AZW3') self._settings['file_preference_azw3'].setChecked( __prefs__['file_preference'] == 'azw3') file_preference_group.addButton(self._settings['file_preference_azw3']) file_preference_layout.layout().addWidget( self._settings['file_preference_azw3']) layout.addWidget(file_preference_layout)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.l = l = QVBoxLayout(self) self.h = h = QHBoxLayout() self.filter_edit = e = QLineEdit(self) l.addWidget(e) e.setPlaceholderText(_('Filter')) self.model = m = self.MODEL(self) self.proxy = p = self.PROXY(self) p.setSourceModel(m) self.view = f = QTreeView(self) f.setAlternatingRowColors(True) f.setHeaderHidden(True), f.setExpandsOnDoubleClick(False) f.setModel(p) l.addWidget(f) f.doubleClicked.connect(self.double_clicked) e.textChanged.connect(p.filter_text) l.addLayout(h) h.addWidget(QLabel(_('Sort by:'))) self.counts_button = b = QRadioButton(_('&Counts'), self) b.setChecked(self.read_state('sort-on-counts', True)) h.addWidget(b) self.name_button = b = QRadioButton(_('&Name'), self) b.setChecked(not self.read_state('sort-on-counts', True)) h.addWidget(b) b.toggled.connect(self.resort) h.addStrut(20) self._sort_order = o = QComboBox(self) o.addItems([_('Ascending'), _('Descending')]) o.setCurrentIndex(0 if self.read_state('sort-ascending', True) else 1) o.setEditable(False) o.currentIndexChanged[int].connect(self.resort) h.addWidget(o) h.addStretch(10) self.summary = la = QLabel('\xa0') h.addWidget(la)
def __init__(self): QWidget.__init__(self) self.vl = QVBoxLayout() self.setLayout(self.vl) self.xray_button = QRadioButton('X-Ray', self) self.xray_button.setChecked(prefs['x-ray']) self.vl.addWidget(self.xray_button) self.donate_button = QPushButton('Donate', self) self.donate_button.clicked.connect(self.donate) self.vl.addWidget(self.donate_button) self.github_button = QPushButton('Source code', self) self.github_button.clicked.connect(self.github) self.vl.addWidget(self.github_button)
def __init__(self, gui, formats, parent=None): QDialog.__init__(self, parent=parent) self.gui = gui self.formats = formats buttonBox = QDialogButtonBox(QDialogButtonBox.Ok) msg = '\nThis book has multiple formats which could be scrambled.\n' \ 'Please select one of the following:\n' label = QLabel(msg) self.dradio = {} for k in self.formats: self.dradio[k] = QRadioButton(k) gpbox1 = QGroupBox('Formats available:') lay1 = QHBoxLayout() gpbox1.setLayout(lay1) for fmt in self.formats: lay1.addWidget(self.dradio[fmt]) if 'EPUB' in self.formats: self.dradio['EPUB'].setChecked(True) else: self.dradio[self.formats[0]].setChecked(True) lay = QVBoxLayout() lay.addWidget(label) lay.addWidget(gpbox1) lay.addStretch() lay.addWidget(buttonBox) self.setLayout(lay) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject) self.setWindowTitle('ScrambleEbook: Select a single format') self.setWindowIcon(get_icons('images/plugin_icon.png'))
def setup_ui(self): self.quote_for_trad_target = _("Update quotes: "",'' -> 「」,『』") self.quote_for_simp_target = _("Update quotes: 「」,『』 -> "",''") # Create layout for entire dialog layout = QVBoxLayout(self) self.setLayout(layout) #Create a scroll area for the top part of the dialog self.scrollArea = QScrollArea(self) self.scrollArea.setWidgetResizable(True) # Create widget for all the contents of the dialog except the OK and Cancel buttons self.scrollContentWidget = QWidget(self.scrollArea) self.scrollArea.setWidget(self.scrollContentWidget) widgetLayout = QVBoxLayout(self.scrollContentWidget) # Add scrollArea to dialog layout.addWidget(self.scrollArea) self.operation_group_box = QGroupBox(_('Conversion Direction')) widgetLayout.addWidget(self.operation_group_box) operation_group_box_layout = QVBoxLayout() self.operation_group_box.setLayout(operation_group_box_layout) operation_group = QButtonGroup(self) self.no_conversion_button = QRadioButton(_('No Conversion')) operation_group.addButton(self.no_conversion_button) self.trad_to_simp_button = QRadioButton(_('Traditional to Simplified')) operation_group.addButton(self.trad_to_simp_button) self.simp_to_trad_button = QRadioButton(_('Simplified to Traditional')) operation_group.addButton(self.simp_to_trad_button) self.trad_to_trad_button = QRadioButton( _('Traditional to Traditional')) operation_group.addButton(self.trad_to_trad_button) operation_group_box_layout.addWidget(self.no_conversion_button) operation_group_box_layout.addWidget(self.trad_to_simp_button) operation_group_box_layout.addWidget(self.simp_to_trad_button) operation_group_box_layout.addWidget(self.trad_to_trad_button) self.no_conversion_button.toggled.connect(self.update_gui) self.trad_to_simp_button.toggled.connect(self.update_gui) self.simp_to_trad_button.toggled.connect(self.update_gui) self.trad_to_trad_button.toggled.connect(self.update_gui) self.style_group_box = QGroupBox(_('Language Styles')) widgetLayout.addWidget(self.style_group_box) style_group_box_layout = QVBoxLayout() self.style_group_box.setLayout(style_group_box_layout) input_layout = QHBoxLayout() style_group_box_layout.addLayout(input_layout) self.input_region_label = QLabel(_('Input:')) input_layout.addWidget(self.input_region_label) self.input_combo = QComboBox() input_layout.addWidget(self.input_combo) self.input_combo.addItems([_('Mainland'), _('Hong Kong'), _('Taiwan')]) self.input_combo.setToolTip(_('Select the origin region of the input')) self.input_combo.currentIndexChanged.connect(self.update_gui) output_layout = QHBoxLayout() style_group_box_layout.addLayout(output_layout) self.output_region_label = QLabel(_('Output:')) output_layout.addWidget(self.output_region_label) self.output_combo = QComboBox() output_layout.addWidget(self.output_combo) self.output_combo.addItems( [_('Mainland'), _('Hong Kong'), _('Taiwan')]) self.output_combo.setToolTip( _('Select the desired region of the output')) self.output_combo.currentIndexChanged.connect(self.update_gui) self.use_target_phrases = QCheckBox( _('Use output target phrases if possible')) self.use_target_phrases.setToolTip( _('Check to allow region specific word replacements if available')) style_group_box_layout.addWidget(self.use_target_phrases) self.use_target_phrases.stateChanged.connect(self.update_gui) self.quotation_group_box = QGroupBox(_('Quotation Marks')) widgetLayout.addWidget(self.quotation_group_box) quotation_group_box_layout = QVBoxLayout() self.quotation_group_box.setLayout(quotation_group_box_layout) quotation_group = QButtonGroup(self) self.quotation_no_conversion_button = QRadioButton(_('No Conversion')) quotation_group.addButton(self.quotation_no_conversion_button) self.quotation_trad_to_simp_button = QRadioButton( self.quote_for_simp_target) quotation_group.addButton(self.quotation_trad_to_simp_button) self.quotation_simp_to_trad_button = QRadioButton( self.quote_for_trad_target) quotation_group.addButton(self.quotation_simp_to_trad_button) quotation_group_box_layout.addWidget( self.quotation_no_conversion_button) quotation_group_box_layout.addWidget( self.quotation_simp_to_trad_button) quotation_group_box_layout.addWidget( self.quotation_trad_to_simp_button) self.quotation_no_conversion_button.toggled.connect(self.update_gui) self.quotation_trad_to_simp_button.toggled.connect(self.update_gui) self.quotation_simp_to_trad_button.toggled.connect(self.update_gui) self.use_smart_quotes = QCheckBox( """Use curved 'Smart" quotes if applicable""") self.use_smart_quotes.setToolTip( _('Use smart curved half-width quotes rather than straight full-width quotes' )) quotation_group_box_layout.addWidget(self.use_smart_quotes) self.use_smart_quotes.stateChanged.connect(self.update_gui) self.other_group_box = QGroupBox(_('Other Changes')) widgetLayout.addWidget(self.other_group_box) other_group_box_layout = QVBoxLayout() self.other_group_box.setLayout(other_group_box_layout) text_dir_layout = QHBoxLayout() other_group_box_layout.addLayout(text_dir_layout) direction_label = QLabel(_('Text Direction:')) text_dir_layout.addWidget(direction_label) self.text_dir_combo = QComboBox() text_dir_layout.addWidget(self.text_dir_combo) self.text_dir_combo.addItems( [_('No Conversion'), _('Horizontal'), _('Vertical')]) self.text_dir_combo.setToolTip( _('Select the desired text orientation')) self.text_dir_combo.currentIndexChanged.connect(self.update_gui) self.optimization_group_box = QGroupBox( _('Reader Device Optimization')) other_group_box_layout.addWidget(self.optimization_group_box) optimization_group_box_layout = QVBoxLayout() self.optimization_group_box.setLayout(optimization_group_box_layout) punc_group = QButtonGroup(self) self.text_dir_punc_none_button = QRadioButton( """No presentation optimization""") optimization_group_box_layout.addWidget(self.text_dir_punc_none_button) self.text_dir_punc_button = QRadioButton( """Optimize presentation for Readium reader""") self.text_dir_punc_button.setToolTip( _('Use vert/horiz punctuation presentation forms for Chrome Readium Epub3 reader' )) optimization_group_box_layout.addWidget(self.text_dir_punc_button) self.text_dir_punc_kindle_button = QRadioButton( """Optimize presentation for Kindle reader""") self.text_dir_punc_kindle_button.setToolTip( _('Use vert/horiz puncuation presentation forms for Kindle reader') ) optimization_group_box_layout.addWidget( self.text_dir_punc_kindle_button) self.text_dir_punc_none_button.toggled.connect(self.update_gui) self.text_dir_punc_button.toggled.connect(self.update_gui) self.text_dir_punc_kindle_button.toggled.connect(self.update_gui) source_group = QButtonGroup(self) self.file_source_button = QRadioButton(_('Selected File Only')) self.book_source_button = QRadioButton(_('Entire eBook')) source_group.addButton(self.file_source_button) source_group.addButton(self.book_source_button) self.source_group_box = QGroupBox(_('Source')) if not self.force_entire_book: widgetLayout.addWidget(self.source_group_box) source_group_box_layout = QVBoxLayout() self.source_group_box.setLayout(source_group_box_layout) source_group_box_layout.addWidget(self.file_source_button) source_group_box_layout.addWidget(self.book_source_button) layout.addSpacing(10) self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.button_box.accepted.connect(self._ok_clicked) self.button_box.rejected.connect(self.reject) layout.addWidget(self.button_box) self.input_combo.setCurrentIndex(self.prefs['input_format']) self.output_combo.setCurrentIndex(self.prefs['output_format']) self.no_conversion_button.setChecked(self.prefs['no_conversion']) self.trad_to_simp_button.setChecked(self.prefs['trad_to_simp']) self.simp_to_trad_button.setChecked(self.prefs['simp_to_trad']) self.trad_to_trad_button.setChecked(self.prefs['trad_to_trad']) if not self.force_entire_book: self.file_source_button.setChecked(self.prefs['use_html_file']) self.book_source_button.setChecked(self.prefs['use_entire_book']) else: self.file_source_button.setChecked(False) self.book_source_button.setChecked(True) self.quotation_no_conversion_button.setChecked( self.prefs['quote_no_conversion']) self.quotation_trad_to_simp_button.setChecked( self.prefs['quote_trad_to_simp']) self.quotation_simp_to_trad_button.setChecked( self.prefs['quote_simp_to_trad']) self.use_smart_quotes.setChecked(self.prefs['use_smart_quotes']) self.text_dir_combo.setCurrentIndex(self.prefs['orientation']) self.text_dir_punc_none_button.setChecked( self.prefs['no_optimization']) self.text_dir_punc_button.setChecked( self.prefs['readium_optimization']) self.text_dir_punc_kindle_button.setChecked( self.prefs['kindle_optimization']) self.update_gui()
def setup_ui(self): self.setWindowIcon(QIcon(I('diff.png'))) self.stacks = st = QStackedLayout(self) self.busy = BusyWidget(self) self.w = QWidget(self) st.addWidget(self.busy), st.addWidget(self.w) self.setLayout(st) self.l = l = QGridLayout() self.w.setLayout(l) self.view = v = DiffView(self, show_open_in_editor=self.show_open_in_editor) l.addWidget(v, l.rowCount(), 0, 1, -1) r = l.rowCount() self.bp = b = QToolButton(self) b.setIcon(QIcon(I('back.png'))) b.clicked.connect(partial(self.view.next_change, -1)) b.setToolTip(_('Go to previous change') + ' [p]') b.setText(_('&Previous change')), b.setToolButtonStyle( Qt.ToolButtonTextBesideIcon) l.addWidget(b, r, 0) self.bn = b = QToolButton(self) b.setIcon(QIcon(I('forward.png'))) b.clicked.connect(partial(self.view.next_change, 1)) b.setToolTip(_('Go to next change') + ' [n]') b.setText(_('&Next change')), b.setToolButtonStyle( Qt.ToolButtonTextBesideIcon) l.addWidget(b, r, 1) self.search = s = HistoryLineEdit2(self) s.initialize('diff_search_history') l.addWidget(s, r, 2) s.setPlaceholderText(_('Search for text')) s.returnPressed.connect(partial(self.do_search, False)) self.sbn = b = QToolButton(self) b.setIcon(QIcon(I('arrow-down.png'))) b.clicked.connect(partial(self.do_search, False)) b.setToolTip(_('Find next match')) b.setText(_('Next &match')), b.setToolButtonStyle( Qt.ToolButtonTextBesideIcon) l.addWidget(b, r, 3) self.sbp = b = QToolButton(self) b.setIcon(QIcon(I('arrow-up.png'))) b.clicked.connect(partial(self.do_search, True)) b.setToolTip(_('Find previous match')) b.setText(_('P&revious match')), b.setToolButtonStyle( Qt.ToolButtonTextBesideIcon) l.addWidget(b, r, 4) self.lb = b = QRadioButton(_('Left panel'), self) b.setToolTip(_('Perform search in the left panel')) l.addWidget(b, r, 5) self.rb = b = QRadioButton(_('Right panel'), self) b.setToolTip(_('Perform search in the right panel')) l.addWidget(b, r, 6) b.setChecked(True) self.pb = b = QToolButton(self) b.setIcon(QIcon(I('config.png'))) b.setText(_('&Options')), b.setToolButtonStyle( Qt.ToolButtonTextBesideIcon) b.setToolTip(_('Change how the differences are displayed')) b.setPopupMode(b.InstantPopup) m = QMenu(b) b.setMenu(m) cm = self.cm = QMenu(_('Lines of context around each change')) for i in (3, 5, 10, 50): cm.addAction( _('Show %d lines of context') % i, partial(self.change_context, i)) cm.addAction(_('Show all text'), partial(self.change_context, None)) self.beautify_action = m.addAction('', self.toggle_beautify) self.set_beautify_action_text() m.addMenu(cm) l.addWidget(b, r, 7) self.hl = QHBoxLayout() l.addLayout(self.hl, l.rowCount(), 0, 1, -1) self.names = QLabel('') self.hl.addWidget(self.names, r) self.bb.setStandardButtons(self.bb.Close) if self.revert_button_msg is not None: self.rvb = b = self.bb.addButton(self.revert_button_msg, self.bb.ActionRole) b.setIcon(QIcon(I('edit-undo.png'))), b.setAutoDefault(False) b.clicked.connect(self.revert_requested) b.clicked.connect(self.reject) self.bb.button(self.bb.Close).setDefault(True) self.hl.addWidget(self.bb, r) self.view.setFocus(Qt.OtherFocusReason)
def setTableTabLayout(self): # Create Table Tab --------------------### # Create Layouts self.Vlayout = QVBoxLayout() self.H1layout = QHBoxLayout() self.H11layout = QHBoxLayout() self.H12layout = QHBoxLayout() self.H21layout = QHBoxLayout() self.V11layout = QVBoxLayout() self.V21layout = QVBoxLayout() # Create Widgets for H1layout # First buttons self.clearTableButt = QPushButton('Clear Table') self.clearTableButt.clicked.connect(self.clearTable) self.autoClearCheck = QCheckBox('Auto Clear') self.autoClearCheck.stateChanged.connect(self.checkAutoClearChanged) self.searchInputField = QLineEdit() self.searchInputField.setPlaceholderText('Enter search term, then click search') self.searchButt = QPushButton('Search Table') self.searchButt.clicked.connect(lambda: self.searchInTable(self.searchInputField.text(),2)) self.showSummaryButt = QPushButton('Show Summary') self.showSummaryButt.clicked.connect(self.showSummary) self.filterGroup = QButtonGroup() self.localFilterRadio = QRadioButton('Local',self) self.globalFilterRadio = QRadioButton('Global', self) self.configureFilterButt = QPushButton('Configure Filter') self.configureFilterButt.clicked.connect(self.configureFilter) self.localFilterRadio.clicked.connect(self.localRadioSelected) self.globalFilterRadio.clicked.connect(self.globalRadioSelected) self.H21layout.addWidget(self.localFilterRadio) self.H21layout.addWidget(self.globalFilterRadio) self.H21layout.addWidget(self.showSummaryButt) self.V21layout.addLayout(self.H21layout) self.V21layout.addWidget(self.configureFilterButt) # Add Widgets to H11layout self.H11layout.addWidget(self.clearTableButt) self.H11layout.addWidget(self.autoClearCheck) # Add Widgets to H12layout self.H12layout.addWidget(self.searchInputField) self.H12layout.addWidget(self.searchButt) self.H12layout.addStretch() self.V11layout.addLayout(self.H11layout) self.V11layout.addLayout(self.H12layout) self.H1layout.addLayout(self.V11layout) self.H1layout.addLayout(self.V21layout) self.syncUiToConfig() #------------------------------------ # Create Table self.detailTableIndex = 0 self.detailTable = QTableWidget() self.detailTableItem = QTableWidgetItem() self.detailTable.setRowCount(0) self.detailTable.setColumnCount(6) self.detailTable.setHorizontalHeaderLabels('packID;Tick;Timer;Type;Message;Length'.split(';')) self.detailTable.resizeColumnsToContents() self.detailTableHeader = self.detailTable.horizontalHeader() self.detailTableHeader.setSectionResizeMode(0, QHeaderView.ResizeToContents) self.detailTableHeader.setSectionResizeMode(1, QHeaderView.ResizeToContents) self.detailTableHeader.setSectionResizeMode(2, QHeaderView.ResizeToContents) self.detailTableHeader.setSectionResizeMode(3, QHeaderView.ResizeToContents) self.detailTableHeader.setSectionResizeMode(4, QHeaderView.Stretch) self.detailTableHeader.setSectionResizeMode(5, QHeaderView.ResizeToContents) #------------------------------------ self.Vlayout.addLayout(self.H1layout) self.Vlayout.addWidget(self.detailTable) self.dockContents.setLayout(self.Vlayout)
def setup_ui(self): # Create layout for entire dialog layout = QVBoxLayout(self) self.setLayout(layout) #Create a scroll area for the top part of the dialog self.scrollArea = QScrollArea(self) self.scrollArea.setWidgetResizable(True) # Create widget for all the contents of the dialog except the OK and Cancel buttons self.scrollContentWidget = QWidget(self.scrollArea) self.scrollArea.setWidget(self.scrollContentWidget) widgetLayout = QVBoxLayout(self.scrollContentWidget) # Add scrollArea to dialog layout.addWidget(self.scrollArea) self.other_group_box = QGroupBox(_('Other Changes')) widgetLayout.addWidget(self.other_group_box) other_group_box_layout = QVBoxLayout() self.other_group_box.setLayout(other_group_box_layout) text_dir_layout = QHBoxLayout() other_group_box_layout.addLayout(text_dir_layout) direction_label = QLabel(_('Text Direction:')) text_dir_layout.addWidget(direction_label) self.text_dir_combo = QComboBox() text_dir_layout.addWidget(self.text_dir_combo) self.text_dir_combo.addItems([_('No Conversion'), _('Horizontal'), _('Vertical')]) self.text_dir_combo.setToolTip(_('Select the desired text orientation')) self.text_dir_combo.currentIndexChanged.connect(self.update_gui) self.optimization_group_box = QGroupBox(_('Reader Device Optimization')) other_group_box_layout.addWidget(self.optimization_group_box) optimization_group_box_layout = QVBoxLayout() self.optimization_group_box.setLayout(optimization_group_box_layout) punc_group=QButtonGroup(self) self.text_dir_punc_none_button = QRadioButton("""No presentation optimization""") optimization_group_box_layout.addWidget(self.text_dir_punc_none_button) self.text_dir_punc_button = QRadioButton("""Optimize presentation for Readium reader""") self.text_dir_punc_button.setToolTip(_('Use vert/horiz punctuation presentation forms for Chrome Readium Epub3 reader')) optimization_group_box_layout.addWidget(self.text_dir_punc_button) self.text_dir_punc_kindle_button = QRadioButton("""Optimize presentation for Kindle reader""") self.text_dir_punc_kindle_button.setToolTip(_('Use vert/horiz puncuation presentation forms for Kindle reader')) optimization_group_box_layout.addWidget(self.text_dir_punc_kindle_button) self.text_dir_punc_none_button.toggled.connect(self.update_gui) self.text_dir_punc_button.toggled.connect(self.update_gui) self.text_dir_punc_kindle_button.toggled.connect(self.update_gui) source_group=QButtonGroup(self) self.file_source_button = QRadioButton(_('Selected File Only')) self.book_source_button = QRadioButton(_('Entire eBook')) source_group.addButton(self.file_source_button) source_group.addButton(self.book_source_button) self.source_group_box = QGroupBox(_('Source')) if not self.force_entire_book: widgetLayout.addWidget(self.source_group_box) source_group_box_layout = QVBoxLayout() self.source_group_box.setLayout(source_group_box_layout) source_group_box_layout.addWidget(self.file_source_button) source_group_box_layout.addWidget(self.book_source_button) layout.addSpacing(10) self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.button_box.accepted.connect(self._ok_clicked) self.button_box.rejected.connect(self.reject) layout.addWidget(self.button_box) if not self.force_entire_book: self.file_source_button.setChecked(self.prefs['use_html_file']) self.book_source_button.setChecked(self.prefs['use_entire_book']) else: self.file_source_button.setChecked(False) self.book_source_button.setChecked(True) self.text_dir_combo.setCurrentIndex(self.prefs['orientation']) self.text_dir_punc_none_button.setChecked(self.prefs['no_optimization']) self.text_dir_punc_button.setChecked(self.prefs['readium_optimization']) self.text_dir_punc_kindle_button.setChecked(self.prefs['kindle_optimization']) self.update_gui()
def request_octo_init_settings(self, wizard, method): vbox = QVBoxLayout() next_enabled = True label = QLabel(_("Enter a label to name your device:")) name = QLineEdit() hl = QHBoxLayout() hl.addWidget(label) hl.addWidget(name) hl.addStretch(1) vbox.addLayout(hl) def clean_text(widget): text = widget.toPlainText().strip() return ' '.join(text.split()) if method in [TIM_NEW, TIM_RECOVER]: gb = QGroupBox() hbox1 = QHBoxLayout() gb.setLayout(hbox1) vbox.addWidget(gb) gb.setTitle(_("Select your seed length:")) bg_numwords = QButtonGroup() for i, count in enumerate([12, 18, 24]): rb = QRadioButton(gb) rb.setText(_("%d words") % count) bg_numwords.addButton(rb) bg_numwords.setId(rb, i) hbox1.addWidget(rb) rb.setChecked(True) cb_pin = QCheckBox(_('Enable PIN protection')) cb_pin.setChecked(True) else: text = QTextEdit() text.setMaximumHeight(60) if method == TIM_MNEMONIC: msg = _("Enter your BIP39 mnemonic:") else: msg = _("Enter the master private key beginning with xprv:") def set_enabled(): from electrum.keystore import is_xprv wizard.next_button.setEnabled(is_xprv(clean_text(text))) text.textChanged.connect(set_enabled) next_enabled = False vbox.addWidget(QLabel(msg)) vbox.addWidget(text) pin = QLineEdit() pin.setValidator(QRegExpValidator(QRegExp('[1-9]{0,9}'))) pin.setMaximumWidth(100) hbox_pin = QHBoxLayout() hbox_pin.addWidget(QLabel(_("Enter your PIN (digits 1-9):"))) hbox_pin.addWidget(pin) hbox_pin.addStretch(1) if method in [TIM_NEW, TIM_RECOVER]: vbox.addWidget(WWLabel(RECOMMEND_PIN)) vbox.addWidget(cb_pin) else: vbox.addLayout(hbox_pin) passphrase_msg = WWLabel(PASSPHRASE_HELP_SHORT) passphrase_warning = WWLabel(PASSPHRASE_NOT_PIN) passphrase_warning.setStyleSheet("color: red") cb_phrase = QCheckBox(_('Enable passphrases')) cb_phrase.setChecked(False) vbox.addWidget(passphrase_msg) vbox.addWidget(passphrase_warning) vbox.addWidget(cb_phrase) # ask for recovery type (random word order OR matrix) if method == TIM_RECOVER: gb_rectype = QGroupBox() hbox_rectype = QHBoxLayout() gb_rectype.setLayout(hbox_rectype) vbox.addWidget(gb_rectype) gb_rectype.setTitle(_("Select recovery type:")) bg_rectype = QButtonGroup() rb1 = QRadioButton(gb_rectype) rb1.setText(_('Scrambled words')) bg_rectype.addButton(rb1) bg_rectype.setId(rb1, RECOVERY_TYPE_SCRAMBLED_WORDS) hbox_rectype.addWidget(rb1) rb1.setChecked(True) rb2 = QRadioButton(gb_rectype) rb2.setText(_('Matrix')) bg_rectype.addButton(rb2) bg_rectype.setId(rb2, RECOVERY_TYPE_MATRIX) hbox_rectype.addWidget(rb2) else: bg_rectype = None wizard.exec_layout(vbox, next_enabled=next_enabled) if method in [TIM_NEW, TIM_RECOVER]: item = bg_numwords.checkedId() pin = cb_pin.isChecked() recovery_type = bg_rectype.checkedId() if bg_rectype else None else: item = ' '.join(str(clean_text(text)).split()) pin = str(pin.text()) recovery_type = None return (item, name.text(), pin, cb_phrase.isChecked(), recovery_type)
def __init__(self, recipe_model, parent=None): QDialog.__init__(self, parent) self.commit_on_change = True self.previous_urn = None self.setWindowIcon(QIcon(I('scheduler.png'))) self.setWindowTitle(_("Schedule news download")) self.l = l = QGridLayout(self) # Left panel self.h = h = QHBoxLayout() l.addLayout(h, 0, 0, 1, 1) self.search = s = SearchBox2(self) self.search.initialize('scheduler_search_history') self.search.setMinimumContentsLength(15) self.go_button = b = QToolButton(self) b.setText(_("Go")) b.clicked.connect(self.search.do_search) h.addWidget(s), h.addWidget(b) self.recipes = RecipesView(self) l.addWidget(self.recipes, 1, 0, 1, 1) self.recipe_model = recipe_model self.recipe_model.do_refresh() self.recipes.setModel(self.recipe_model) self.recipes.setFocus(Qt.OtherFocusReason) self.count_label = la = QLabel(_('%s news sources') % self.recipe_model.showing_count) la.setAlignment(Qt.AlignCenter) l.addWidget(la, 2, 0, 1, 1) self.search.search.connect(self.recipe_model.search) self.recipe_model.searched.connect(self.search.search_done, type=Qt.QueuedConnection) self.recipe_model.searched.connect(self.search_done) # Right Panel self.scroll_area_contents = sac = QWidget(self) self.l.addWidget(sac, 0, 1, 2, 1) sac.v = v = QVBoxLayout(sac) v.setContentsMargins(0, 0, 0, 0) self.detail_box = QTabWidget(self) self.detail_box.setVisible(False) self.detail_box.setCurrentIndex(0) v.addWidget(self.detail_box) v.addItem(QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)) # First Tab (scheduling) self.tab = QWidget() self.detail_box.addTab(self.tab, _("&Schedule")) self.tab.v = vt = QVBoxLayout(self.tab) vt.setContentsMargins(0, 0, 0, 0) self.blurb = la = QLabel('blurb') la.setWordWrap(True), la.setOpenExternalLinks(True) vt.addWidget(la) self.frame = f = QFrame(self.tab) vt.addWidget(f) f.setFrameShape(f.StyledPanel) f.setFrameShadow(f.Raised) f.v = vf = QVBoxLayout(f) self.schedule = s = QCheckBox(_("&Schedule for download:"), f) self.schedule.stateChanged[int].connect(self.toggle_schedule_info) vf.addWidget(s) f.h = h = QHBoxLayout() vf.addLayout(h) self.days_of_week = QRadioButton(_("&Days of week"), f) self.days_of_month = QRadioButton(_("Da&ys of month"), f) self.every_x_days = QRadioButton(_("Every &x days"), f) self.days_of_week.setChecked(True) h.addWidget(self.days_of_week), h.addWidget(self.days_of_month), h.addWidget(self.every_x_days) self.schedule_stack = ss = QStackedWidget(f) self.schedule_widgets = [] for key in reversed(self.SCHEDULE_TYPES): self.schedule_widgets.insert(0, self.SCHEDULE_TYPES[key](self)) self.schedule_stack.insertWidget(0, self.schedule_widgets[0]) vf.addWidget(ss) self.last_downloaded = la = QLabel(f) la.setWordWrap(True) vf.addWidget(la) self.account = acc = QGroupBox(self.tab) acc.setTitle(_("&Account")) vt.addWidget(acc) acc.g = g = QGridLayout(acc) acc.unla = la = QLabel(_("&Username:"******"&Password:"******"&Show password"), self.account) spw.stateChanged[int].connect(self.set_pw_echo_mode) g.addWidget(spw, 2, 0, 1, 2) self.rla = la = QLabel(_("For the scheduling to work, you must leave calibre running.")) vt.addWidget(la) for b, c in iteritems(self.SCHEDULE_TYPES): b = getattr(self, b) b.toggled.connect(self.schedule_type_selected) b.setToolTip(textwrap.dedent(c.HELP)) # Second tab (advanced settings) self.tab2 = t2 = QWidget() self.detail_box.addTab(self.tab2, _("&Advanced")) self.tab2.g = g = QGridLayout(t2) g.setContentsMargins(0, 0, 0, 0) self.add_title_tag = tt = QCheckBox(_("Add &title as tag"), t2) g.addWidget(tt, 0, 0, 1, 2) t2.la = la = QLabel(_("&Extra tags:")) self.custom_tags = ct = QLineEdit(self) la.setBuddy(ct) g.addWidget(la), g.addWidget(ct, 1, 1) t2.la2 = la = QLabel(_("&Keep at most:")) la.setToolTip(_("Maximum number of copies (issues) of this recipe to keep. Set to 0 to keep all (disable).")) self.keep_issues = ki = QSpinBox(t2) tt.toggled['bool'].connect(self.keep_issues.setEnabled) ki.setMaximum(100000), la.setBuddy(ki) ki.setToolTip(_( "<p>When set, this option will cause calibre to keep, at most, the specified number of issues" " of this periodical. Every time a new issue is downloaded, the oldest one is deleted, if the" " total is larger than this number.\n<p>Note that this feature only works if you have the" " option to add the title as tag checked, above.\n<p>Also, the setting for deleting periodicals" " older than a number of days, below, takes priority over this setting.")) ki.setSpecialValueText(_("all issues")), ki.setSuffix(_(" issues")) g.addWidget(la), g.addWidget(ki, 2, 1) si = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) g.addItem(si, 3, 1, 1, 1) # Bottom area self.hb = h = QHBoxLayout() self.l.addLayout(h, 2, 1, 1, 1) self.labt = la = QLabel(_("Delete downloaded &news older than:")) self.old_news = on = QSpinBox(self) on.setToolTip(_( "<p>Delete downloaded news older than the specified number of days. Set to zero to disable.\n" "<p>You can also control the maximum number of issues of a specific periodical that are kept" " by clicking the Advanced tab for that periodical above.")) on.setSpecialValueText(_("never delete")), on.setSuffix(_(" days")) on.setMaximum(1000), la.setBuddy(on) on.setValue(gconf['oldest_news']) h.addWidget(la), h.addWidget(on) self.download_all_button = b = QPushButton(QIcon(I('news.png')), _("Download &all scheduled"), self) b.setToolTip(_("Download all scheduled news sources at once")) b.clicked.connect(self.download_all_clicked) self.l.addWidget(b, 3, 0, 1, 1) self.bb = bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self) bb.accepted.connect(self.accept), bb.rejected.connect(self.reject) self.download_button = b = bb.addButton(_('&Download now'), bb.ActionRole) b.setIcon(QIcon(I('arrow-down.png'))), b.setVisible(False) b.clicked.connect(self.download_clicked) self.l.addWidget(bb, 3, 1, 1, 1) geom = gprefs.get('scheduler_dialog_geometry') if geom is not None: QApplication.instance().safe_restore_geometry(self, geom)
def __init__(self, plugin): DefaultConfigWidget.__init__(self, plugin) c = plugin_prefs[STORE_NAME] other_group_box = QGroupBox('Other options', self) self.l.addWidget(other_group_box, self.l.rowCount(), 0, 1, 2) other_group_box_layout = QGridLayout() other_group_box.setLayout(other_group_box_layout) # Guess Series guess_series_label = QLabel( 'Guess Series and Series Index from Title:', self) guess_series_label.setToolTip( 'DNB only rarely provides data about a book\'s series.\n' 'This plugin can try to extract series and series_index from the book title.\n' ) other_group_box_layout.addWidget(guess_series_label, 0, 0, 1, 1) self.guess_series_checkbox = QCheckBox(self) self.guess_series_checkbox.setChecked( c.get(KEY_GUESS_SERIES, DEFAULT_STORE_VALUES[KEY_GUESS_SERIES])) other_group_box_layout.addWidget(self.guess_series_checkbox, 0, 1, 1, 1) # Append Edition to Title append_edition_to_title_label = QLabel('Append Edition to Title:', self) append_edition_to_title_label.setToolTip( 'For some books DNB has information about the edition.\n' 'This plugin can fetch this information and append it to the book\'s title,\n' 'e.g. "Mord am Tegernsee : Ein Bayern-Krimi : 2. Aufl.".\n' 'Of course this only works reliable if you search for a book with a known unique identifier such as dnb-idn or ISBN.' ) other_group_box_layout.addWidget(append_edition_to_title_label, 1, 0, 1, 1) self.append_edition_to_title_checkbox = QCheckBox(self) self.append_edition_to_title_checkbox.setChecked( c.get(KEY_APPEND_EDITION_TO_TITLE, DEFAULT_STORE_VALUES[KEY_APPEND_EDITION_TO_TITLE])) other_group_box_layout.addWidget(self.append_edition_to_title_checkbox, 1, 1, 1, 1) # Fetch Subjects fetch_subjects_label = QLabel('Fetch Subjects:', self) fetch_subjects_label.setToolTip( 'DNB provides several types of subjects:\n' ' - Standardized subjects according to the GND\n' ' - Subjects delivered by the publisher\n' 'You can choose which ones to fetch.') other_group_box_layout.addWidget(fetch_subjects_label, 2, 0, 1, 1) self.fetch_subjects_radios_group = QButtonGroup(other_group_box) titles = [ 'only GND subjects', 'GND subjects if available, otherwise non-GND subjects', 'GND and non-GND subjects', 'non-GND subjects if available, otherwise GND subjects', 'only non-GND subjects', 'none' ] self.fetch_subjects_radios = [QRadioButton(title) for title in titles] for i, radio in enumerate(self.fetch_subjects_radios): if i == c.get(KEY_FETCH_SUBJECTS, DEFAULT_STORE_VALUES[KEY_FETCH_SUBJECTS]): radio.setChecked(True) self.fetch_subjects_radios_group.addButton(radio, i) other_group_box_layout.addWidget(radio, 2 + i, 1, 1, 1)
def __init__(self, gui, do_user_config, selected_book_ids, is_sync_selected): QWidget.__init__(self, gui) api.build_request('/limits') self.logger = Logger( path.join(gui.current_db.library_path, 'bookfusion_sync.log')) self.logger.info( 'Open sync dialog: selected_book_ids={}; is_sync_selected={}'. format(selected_book_ids, is_sync_selected)) if len(selected_book_ids) == 0: is_sync_selected = False self.worker_thread = None self.do_user_config = do_user_config self.db = gui.current_db.new_api self.selected_book_ids = selected_book_ids self.l = QVBoxLayout() self.l.setContentsMargins(0, 0, 0, 0) self.setLayout(self.l) self.radio_layout = QVBoxLayout() self.l.addLayout(self.radio_layout) self.sync_all_radio = QRadioButton('Sync all books') self.sync_all_radio.setChecked(not is_sync_selected) self.radio_layout.addWidget(self.sync_all_radio) sync_selected_radio_label = 'Sync selected books' if len(selected_book_ids) > 0: sync_selected_radio_label = 'Sync {} selected {}'.format( len(selected_book_ids), 'book' if len(selected_book_ids) == 1 else 'books') self.sync_selected_radio = QRadioButton(sync_selected_radio_label) self.sync_selected_radio.toggled.connect(self.toggle_sync_selected) self.sync_selected_radio.setChecked(is_sync_selected) self.sync_selected_radio.setEnabled(len(selected_book_ids) > 0) self.radio_layout.addWidget(self.sync_selected_radio) self.reupload_possible = len(selected_book_ids) > 0 and len( selected_book_ids) <= 100 if self.reupload_possible: for book_id in selected_book_ids: identifiers = self.db.get_proxy_metadata(book_id).identifiers if not identifiers.get('bookfusion'): self.reupload_possible = False self.reupload_checkbox = QCheckBox('Re-upload book files', self) self.reupload_checkbox.setVisible(is_sync_selected and self.reupload_possible) self.radio_layout.addWidget(self.reupload_checkbox) self.btn_layout = QHBoxLayout() self.l.addLayout(self.btn_layout) self.config_btn = QPushButton('Configure') self.config_btn.clicked.connect(self.config) self.btn_layout.addWidget(self.config_btn) self.btn_layout.addStretch() self.start_btn = QPushButton('Start') self.start_btn.clicked.connect(self.start) self.btn_layout.addWidget(self.start_btn) self.cancel_btn = QPushButton('Cancel') self.cancel_btn.clicked.connect(self.cancel) self.cancel_btn.hide() self.btn_layout.addWidget(self.cancel_btn) self.info = QHBoxLayout() self.info.setContentsMargins(0, 0, 0, 0) self.l.addLayout(self.info) self.msg = QLabel() self.info.addWidget(self.msg) self.info.addStretch() self.log_btn = QLabel('<a href="#">Log</a>') self.log_btn.linkActivated.connect(self.toggle_log) self.log_btn.hide() self.info.addWidget(self.log_btn) self.log = QTableWidget(0, 2) self.log.setHorizontalHeaderLabels(['Book', 'Message']) self.log.horizontalHeader().setStretchLastSection(True) self.log.hide() self.l.addWidget(self.log) self.apply_config()
def _set_middle_frame_ui(self): middle_frame = QFrame() self.middle_layout = QHBoxLayout(middle_frame) middle_left_frame = QFrame() # middle_left_frame.setMinimumWidth(self.main_ui.window.geometry().width() / 2 - 20) middle_right_frame = QFrame() # middle_right_frame.setMinimumWidth(self.main_ui.window.geometry().width() / 2 - 20) self.middle_left_layout = QGridLayout(middle_left_frame) self.middle_right_layout = QGridLayout(middle_right_frame) self.middle_layout.addWidget(middle_left_frame) self.middle_layout.addWidget(middle_right_frame) self.layout.addWidget(middle_frame) row = 0 self.checkbox_outline = QRadioButton('OutLine') self.checkbox_gray = QRadioButton('Gray') self.checkbox_gray.hide() self.btn_load_img = QPushButton('LoadImage') self.checkbox_outline.toggle() self.isOutlineMode = True self.checkbox_outline.setDisabled(True) self.middle_left_layout.addWidget(self.checkbox_outline, row, 0) self.middle_left_layout.addWidget(self.checkbox_gray, row, 1) self.middle_left_layout.addWidget(self.btn_load_img, row, 2) row += 1 label_x_home = QLabel('x_home:') self.slider_x_home = QSlider(QtCore.Qt.Horizontal) self.slider_x_home.setMinimum(0) self.slider_x_home.setMaximum(2000) self.slider_x_home.setValue(1500) self.spinbox_x_home = QDoubleSpinBox() self.spinbox_x_home.setDecimals(1) self.spinbox_x_home.setSingleStep(0.1) self.spinbox_x_home.setMinimum(0.0) self.spinbox_x_home.setMaximum(200.0) self.spinbox_x_home.setValue(150.0) self.slider_x_home.mouseReleaseEvent = functools.partial( self.mouseReleaseEvent, source=self.slider_x_home.mouseReleaseEvent) self.spinbox_x_home.focusOutEvent = functools.partial( self.focusOutEvent, source=self.spinbox_x_home.focusOutEvent) self.middle_left_layout.addWidget(label_x_home, row, 0) self.middle_left_layout.addWidget(self.slider_x_home, row, 1) self.middle_left_layout.addWidget(self.spinbox_x_home, row, 2) row += 1 label_y_home = QLabel('y_home:') self.slider_y_home = QSlider(QtCore.Qt.Horizontal) self.slider_y_home.setMinimum(-1500) self.slider_y_home.setMaximum(1500) self.slider_y_home.setValue(0) self.spinbox_y_home = QDoubleSpinBox() self.spinbox_y_home.setDecimals(1) self.spinbox_y_home.setSingleStep(0.1) self.spinbox_y_home.setMinimum(-150.0) self.spinbox_y_home.setMaximum(150.0) self.spinbox_y_home.setValue(0.0) self.slider_y_home.mouseReleaseEvent = functools.partial( self.mouseReleaseEvent, source=self.slider_y_home.mouseReleaseEvent) self.spinbox_y_home.focusOutEvent = functools.partial( self.focusOutEvent, source=self.spinbox_y_home.focusOutEvent) self.middle_left_layout.addWidget(label_y_home, row, 0) self.middle_left_layout.addWidget(self.slider_y_home, row, 1) self.middle_left_layout.addWidget(self.spinbox_y_home, row, 2) row += 1 label_z_home = QLabel('z_home:') self.slider_z_home = QSlider(QtCore.Qt.Horizontal) self.slider_z_home.setMinimum(0) self.slider_z_home.setMaximum(1500) self.slider_z_home.setValue(900) self.spinbox_z_home = QDoubleSpinBox() self.spinbox_z_home.setDecimals(1) self.spinbox_z_home.setSingleStep(0.1) self.spinbox_z_home.setMinimum(0.0) self.spinbox_z_home.setMaximum(150.0) self.spinbox_z_home.setValue(90.0) self.slider_z_home.mouseReleaseEvent = functools.partial( self.mouseReleaseEvent, source=self.slider_z_home.mouseReleaseEvent) self.spinbox_z_home.focusOutEvent = functools.partial( self.focusOutEvent, source=self.spinbox_z_home.focusOutEvent) self.middle_left_layout.addWidget(label_z_home, row, 0) self.middle_left_layout.addWidget(self.slider_z_home, row, 1) self.middle_left_layout.addWidget(self.spinbox_z_home, row, 2) row += 1 label_x_offset = QLabel('x_offset:') self.slider_x_offset = QSlider(QtCore.Qt.Horizontal) self.slider_x_offset.setMinimum(-5000) self.slider_x_offset.setMaximum(5000) self.slider_x_offset.setValue(0) self.spinbox_x_offset = QDoubleSpinBox() self.spinbox_x_offset.setSingleStep(0.1) self.spinbox_x_offset.setDecimals(1) self.spinbox_x_offset.setMinimum(-500.0) self.spinbox_x_offset.setMaximum(500.0) self.spinbox_x_offset.setValue(0.0) self.slider_x_offset.mouseReleaseEvent = functools.partial( self.mouseReleaseEvent, source=self.slider_x_offset.mouseReleaseEvent) self.spinbox_x_offset.focusOutEvent = functools.partial( self.focusOutEvent, source=self.spinbox_x_offset.focusOutEvent) self.middle_left_layout.addWidget(label_x_offset, row, 0) self.middle_left_layout.addWidget(self.slider_x_offset, row, 1) self.middle_left_layout.addWidget(self.spinbox_x_offset, row, 2) row += 1 label_y_offset = QLabel('y_offset:') self.slider_y_offset = QSlider(QtCore.Qt.Horizontal) self.slider_y_offset.setMinimum(-5000) self.slider_y_offset.setMaximum(5000) self.slider_y_offset.setValue(0) self.spinbox_y_offset = QDoubleSpinBox() self.spinbox_y_offset.setDecimals(1) self.spinbox_y_offset.setSingleStep(0.1) self.spinbox_y_offset.setMinimum(-500.0) self.spinbox_y_offset.setMaximum(500.0) self.spinbox_y_offset.setValue(0.0) self.slider_y_offset.mouseReleaseEvent = functools.partial( self.mouseReleaseEvent, source=self.slider_y_offset.mouseReleaseEvent) self.spinbox_y_offset.focusOutEvent = functools.partial( self.focusOutEvent, source=self.spinbox_y_offset.focusOutEvent) self.middle_left_layout.addWidget(label_y_offset, row, 0) self.middle_left_layout.addWidget(self.slider_y_offset, row, 1) self.middle_left_layout.addWidget(self.spinbox_y_offset, row, 2) row += 1 label_z_offset = QLabel('z_offset:') self.slider_z_offset = QSlider(QtCore.Qt.Horizontal) self.slider_z_offset.setMinimum(-1000) self.slider_z_offset.setMaximum(1500) self.slider_z_offset.setValue(900) self.spinbox_z_offset = QDoubleSpinBox() self.spinbox_z_offset.setDecimals(1) self.spinbox_z_offset.setSingleStep(0.1) self.spinbox_z_offset.setMinimum(-100.0) self.spinbox_z_offset.setMaximum(150.0) self.spinbox_z_offset.setValue(90.0) self.slider_z_offset.mouseReleaseEvent = functools.partial( self.mouseReleaseEvent, source=self.slider_z_offset.mouseReleaseEvent) self.spinbox_z_offset.focusOutEvent = functools.partial( self.focusOutEvent, source=self.spinbox_z_offset.focusOutEvent) self.middle_left_layout.addWidget(label_z_offset, row, 0) self.middle_left_layout.addWidget(self.slider_z_offset, row, 1) self.middle_left_layout.addWidget(self.spinbox_z_offset, row, 2) row += 1 label_pen_up = QLabel('pen_up:') self.slider_pen_up = QSlider(QtCore.Qt.Horizontal) self.slider_pen_up.setMinimum(0) self.slider_pen_up.setMaximum(500) self.slider_pen_up.setValue(200) self.spinbox_pen_up = QDoubleSpinBox() self.spinbox_pen_up.setDecimals(1) self.spinbox_pen_up.setSingleStep(0.1) self.spinbox_pen_up.setMinimum(0.0) self.spinbox_pen_up.setMaximum(50.0) self.spinbox_pen_up.setValue(20.0) self.slider_pen_up.mouseReleaseEvent = functools.partial( self.mouseReleaseEvent, source=self.slider_pen_up.mouseReleaseEvent) self.spinbox_pen_up.focusOutEvent = functools.partial( self.focusOutEvent, source=self.spinbox_pen_up.focusOutEvent) self.slider_pen_up.setDisabled(True) self.spinbox_pen_up.setDisabled(True) self.middle_left_layout.addWidget(label_pen_up, row, 0) self.middle_left_layout.addWidget(self.slider_pen_up, row, 1) self.middle_left_layout.addWidget(self.spinbox_pen_up, row, 2) row = 0 self.checkbox_laser = QRadioButton('Laser') self.checkbox_pen = QRadioButton('Pen') self.checkbox_laser.toggle() self.isLaserMode = True self.middle_right_layout.addWidget(self.checkbox_laser, row, 0) self.middle_right_layout.addWidget(self.checkbox_pen, row, 1) row += 1 label_drawing_feedrate = QLabel('drawing_feedrate:') self.slider_drawing_feedrate = QSlider(QtCore.Qt.Horizontal) self.slider_drawing_feedrate.setMinimum(5) self.slider_drawing_feedrate.setMaximum(1000) self.slider_drawing_feedrate.setValue(100) self.spinbox_drawing_feedrate = QSpinBox() self.spinbox_drawing_feedrate.setMinimum(5) self.spinbox_drawing_feedrate.setMaximum(1000) self.spinbox_drawing_feedrate.setValue(100) self.slider_drawing_feedrate.mouseReleaseEvent = functools.partial( self.mouseReleaseEvent, source=self.slider_drawing_feedrate.mouseReleaseEvent) self.spinbox_drawing_feedrate.focusOutEvent = functools.partial( self.focusOutEvent, source=self.spinbox_drawing_feedrate.focusOutEvent) self.middle_right_layout.addWidget(label_drawing_feedrate, row, 0) self.middle_right_layout.addWidget(self.slider_drawing_feedrate, row, 1) self.middle_right_layout.addWidget(self.spinbox_drawing_feedrate, row, 2) row += 1 label_moving_feedrate = QLabel('moving_feedrate:') self.slider_moving_feedrate = QSlider(QtCore.Qt.Horizontal) self.slider_moving_feedrate.setMinimum(5) self.slider_moving_feedrate.setMaximum(20000) self.slider_moving_feedrate.setValue(100) self.spinbox_moving_feedrate = QSpinBox() self.spinbox_moving_feedrate.setMinimum(5) self.spinbox_moving_feedrate.setMaximum(20000) self.spinbox_moving_feedrate.setValue(100) self.slider_moving_feedrate.mouseReleaseEvent = functools.partial( self.mouseReleaseEvent, source=self.slider_moving_feedrate.mouseReleaseEvent) self.spinbox_moving_feedrate.focusOutEvent = functools.partial( self.focusOutEvent, source=self.spinbox_moving_feedrate.focusOutEvent) self.middle_right_layout.addWidget(label_moving_feedrate, row, 0) self.middle_right_layout.addWidget(self.slider_moving_feedrate, row, 1) self.middle_right_layout.addWidget(self.spinbox_moving_feedrate, row, 2) row += 1 label_scale = QLabel('scale:') self.slider_scale = QSlider(QtCore.Qt.Horizontal) self.slider_scale.setMinimum(1) self.slider_scale.setMaximum(100) self.slider_scale.setValue(10) self.spinbox_scale = QDoubleSpinBox() self.spinbox_scale.setDecimals(1) self.spinbox_scale.setSingleStep(0.1) self.spinbox_scale.setMinimum(0.1) self.spinbox_scale.setMaximum(10.0) self.spinbox_scale.setValue(1.0) # self.slider_scale.setDisabled(True) # self.spinbox_scale.setDisabled(True) self.slider_scale.mouseReleaseEvent = functools.partial( self.mouseReleaseEvent, source=self.slider_scale.mouseReleaseEvent) self.spinbox_scale.focusOutEvent = functools.partial( self.focusOutEvent, source=self.spinbox_scale.focusOutEvent) self.middle_right_layout.addWidget(label_scale, row, 0) self.middle_right_layout.addWidget(self.slider_scale, row, 1) self.middle_right_layout.addWidget(self.spinbox_scale, row, 2) row += 1 label_resolution = QLabel('resolution:') self.slider_resolution = QSlider(QtCore.Qt.Horizontal) self.slider_resolution.setMinimum(1) self.slider_resolution.setMaximum(100) self.slider_resolution.setValue(10) self.spinbox_resolution = QDoubleSpinBox() self.spinbox_resolution.setMinimum(0.1) self.spinbox_resolution.setMaximum(10.0) self.spinbox_resolution.setSingleStep(0.1) self.spinbox_resolution.setDecimals(1) self.spinbox_resolution.setValue(1.0) self.slider_resolution.setDisabled(True) self.spinbox_resolution.setDisabled(True) self.middle_right_layout.addWidget(label_resolution, row, 0) self.middle_right_layout.addWidget(self.slider_resolution, row, 1) self.middle_right_layout.addWidget(self.spinbox_resolution, row, 2) row += 1 self.btn_generate_gcode = QPushButton('Generate_Gcode') self.middle_right_layout.addWidget(self.btn_generate_gcode, row, 0) row += 1 self.label_x_min = QLabel('') self.label_x_max = QLabel('') self.middle_right_layout.addWidget(self.label_x_min, row, 0) self.middle_right_layout.addWidget(self.label_x_max, row, 1) row += 1 self.label_y_min = QLabel('') self.label_y_max = QLabel('') self.middle_right_layout.addWidget(self.label_y_min, row, 0) self.middle_right_layout.addWidget(self.label_y_max, row, 1)
def setup_ui(self): # {{{ self._g = g = QHBoxLayout(self) self.setLayout(g) self._l = l = QVBoxLayout() g.addLayout(l) fmts = sorted(x.upper() for x in self.fmts) self.fmt_choice_box = QGroupBox(_('Choose the format to unpack:'), self) self._fl = fl = QHBoxLayout() self.fmt_choice_box.setLayout(self._fl) self.fmt_choice_buttons = [QRadioButton(y, self) for y in fmts] for x in self.fmt_choice_buttons: fl.addWidget(x, stretch=10 if x is self.fmt_choice_buttons[-1] else 0) l.addWidget(self.fmt_choice_box) self.fmt_choice_box.setVisible(len(fmts) > 1) self.help_label = QLabel( _('''\ <h2>About Unpack book</h2> <p>Unpack book allows you to fine tune the appearance of an e-book by making small changes to its internals. In order to use Unpack book, you need to know a little bit about HTML and CSS, technologies that are used in e-books. Follow the steps:</p> <br> <ol> <li>Click "Explode book": This will "explode" the book into its individual internal components.<br></li> <li>Right click on any individual file and select "Open with..." to edit it in your favorite text editor.<br></li> <li>When you are done: <b>close the file browser window and the editor windows you used to make your tweaks</b>. Then click the "Rebuild book" button, to update the book in your calibre library.</li> </ol>''')) self.help_label.setWordWrap(True) self._fr = QFrame() self._fr.setFrameShape(QFrame.VLine) g.addWidget(self._fr) g.addWidget(self.help_label) self._b = b = QGridLayout() left, top, right, bottom = b.getContentsMargins() top += top b.setContentsMargins(left, top, right, bottom) l.addLayout(b, stretch=10) self.explode_button = QPushButton(QIcon(I('wizard.png')), _('&Explode book')) self.preview_button = QPushButton(QIcon(I('view.png')), _('&Preview book')) self.cancel_button = QPushButton(QIcon(I('window-close.png')), _('&Cancel')) self.rebuild_button = QPushButton(QIcon(I('exec.png')), _('&Rebuild book')) self.explode_button.setToolTip( _('Explode the book to edit its components')) self.preview_button.setToolTip(_('Preview the result of your changes')) self.cancel_button.setToolTip(_('Abort without saving any changes')) self.rebuild_button.setToolTip( _('Save your changes and update the book in the calibre library')) a = b.addWidget a(self.explode_button, 0, 0, 1, 1) a(self.preview_button, 0, 1, 1, 1) a(self.cancel_button, 1, 0, 1, 1) a(self.rebuild_button, 1, 1, 1, 1) for x in ('explode', 'preview', 'cancel', 'rebuild'): getattr(self, x + '_button').clicked.connect(getattr(self, x)) self.msg = QLabel('dummy', self) self.msg.setVisible(False) self.msg.setStyleSheet(''' QLabel { text-align: center; background-color: white; color: black; border-width: 1px; border-style: solid; border-radius: 20px; font-size: x-large; font-weight: bold; } ''') self.resize(self.sizeHint() + QSize(40, 10))
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("Convert sources to 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="Output FITS file", default_suffix="fits", file_types="FITS files (*.fits *.FITS)", file_mode=QFileDialog.ExistingFile) lo.addWidget(self.wfile) # reference frequency lo1 = QHBoxLayout() lo.addLayout(lo1) lo1.setContentsMargins(0, 0, 0, 0) label = QLabel("Frequency, MHz:", self) lo1.addWidget(label) tip = """<P>If your sky model contains spectral information (such as spectral indices), then a brick may be generated for a specific frequency. If a frequency is not specified here, the reference frequency of the model sources will be assumed.</P>""" self.wfreq = QLineEdit(self) self.wfreq.setValidator(QDoubleValidator(self)) label.setToolTip(tip) self.wfreq.setToolTip(tip) lo1.addWidget(self.wfreq) # beam gain lo1 = QHBoxLayout() lo.addLayout(lo1) lo1.setContentsMargins(0, 0, 0, 0) self.wpb_apply = QCheckBox("Apply primary beam expression:", self) self.wpb_apply.setChecked(True) lo1.addWidget(self.wpb_apply) tip = """<P>If this option is specified, a primary power beam gain will be applied to the sources before inserting them into the brick. This can be any valid Python expression making use of the variables 'r' (corresponding to distance from field centre, in radians) and 'fq' (corresponding to frequency.)</P>""" self.wpb_exp = QLineEdit(self) self.wpb_apply.setToolTip(tip) self.wpb_exp.setToolTip(tip) lo1.addWidget(self.wpb_exp) # overwrite or add mode lo1 = QHBoxLayout() lo.addLayout(lo1) lo1.setContentsMargins(0, 0, 0, 0) self.woverwrite = QRadioButton("overwrite image", self) self.woverwrite.setChecked(True) lo1.addWidget(self.woverwrite) self.waddinto = QRadioButton("add into image", self) lo1.addWidget(self.waddinto) # add to model self.wadd = QCheckBox( "Add resulting brick to sky model as a FITS image component", self) lo.addWidget(self.wadd) lo1 = QHBoxLayout() lo.addLayout(lo1) lo1.setContentsMargins(0, 0, 0, 0) self.wpad = QLineEdit(self) self.wpad.setValidator(QDoubleValidator(self)) self.wpad.setText("1.1") lab = QLabel("...with padding factor:", self) lab.setToolTip( """<P>The padding factor determines the amount of null padding inserted around the image during the prediction stage. Padding alleviates the effects of tapering and detapering in the uv-brick, which can show up towards the edges of the image. For a factor of N, the image will be padded out to N times its original size. This increases memory use, so if you have no flux at the edges of the image anyway, then a pad factor of 1 is perfectly fine.</P>""") self.wpad.setToolTip(lab.toolTip()) self.wadd.toggled[bool].connect(self.wpad.setEnabled) self.wadd.toggled[bool].connect(lab.setEnabled) self.wpad.setEnabled(False) lab.setEnabled(False) lo1.addStretch(1) lo1.addWidget(lab, 0) lo1.addWidget(self.wpad, 1) self.wdel = QCheckBox( "Remove from the sky model sources that go into the brick", self) lo.addWidget(self.wdel) # 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.filenameSelected.connect(self._fileSelected) # internal state self.qerrmsg = QErrorMessage(self)