class BarTitle(QWidget): # {{{ def __init__(self, parent=None): QWidget.__init__(self, parent) self._layout = QHBoxLayout() self.setLayout(self._layout) self._layout.addStretch(10) self.icon = QLabel('') self._layout.addWidget(self.icon) self.title = QLabel('') self.title.setStyleSheet('QLabel { font-weight: bold }') self.title.setAlignment(Qt.AlignLeft | Qt.AlignCenter) self._layout.addWidget(self.title) self._layout.addStretch(10) def show_plugin(self, plugin): self.pmap = QPixmap(plugin.icon).scaled(ICON_SIZE, ICON_SIZE, Qt.KeepAspectRatio, Qt.SmoothTransformation) self.icon.setPixmap(self.pmap) self.title.setText(plugin.gui_name) tt = plugin.description self.setStatusTip(tt) tt = textwrap.fill(tt) self.setToolTip(tt) self.setWhatsThis(tt)
def __init__(self, parent, config_name=None, buttons=[], *args): """Creates dialog. 'config_name' is used to get/set default window size from Config object 'buttons' can be a list of names or (QPixmapWrapper,name[,tooltip]) tuples to provide custom buttons at the bottom of the dialog. When a button is clicked, the dialog emits SIGNAL("name"). A "Close" button is always provided, this simply hides the dialog. """ QDialog.__init__(self, parent, *args) self.setModal(False) lo = QVBoxLayout(self) # create viewer self.label = QLabel(self) self.label.setMargin(5) self.label.setWordWrap(True) lo.addWidget(self.label) self.label.hide() self.viewer = QTextBrowser(self) lo.addWidget(self.viewer) # self.viewer.setReadOnly(True) self.viewer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) QObject.connect(self.viewer, SIGNAL("anchorClicked(const QUrl &)"), self._urlClicked) self._source = None lo.addSpacing(5) # create button bar btnfr = QFrame(self) btnfr.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) # btnfr.setMargin(5) lo.addWidget(btnfr) lo.addSpacing(5) btnfr_lo = QHBoxLayout(btnfr) btnfr_lo.setMargin(5) # add user buttons self._user_buttons = {} for name in buttons: if isinstance(name, str): btn = QPushButton(name, btnfr) elif isinstance(name, (list, tuple)): if len(name) < 3: pixmap, name = name tip = None else: pixmap, name, tip = name btn = QPushButton(pixmap.icon(), name, btnfr) if tip: btn.setToolTip(tip) self._user_buttons[name] = btn btn._clicked = Kittens.utils.curry(self.emit, SIGNAL(name)) self.connect(btn, SIGNAL("clicked()"), btn._clicked) btnfr_lo.addWidget(btn, 1) # add a Close button btnfr_lo.addStretch(100) closebtn = QPushButton(pixmaps.grey_round_cross.icon(), "Close", btnfr) self.connect(closebtn, SIGNAL("clicked()"), self.hide) btnfr_lo.addWidget(closebtn, 1) # resize selves self.config_name = config_name or "html-viewer" width = Config.getint('%s-width' % self.config_name, 512) height = Config.getint('%s-height' % self.config_name, 512) self.resize(QSize(width, height))
def setup_ui(self, parent): cm = self.col_metadata self.make_widgets(parent, DateTimeEdit) self.widgets.append(QLabel('')) w = QWidget(parent) self.widgets.append(w) l = QHBoxLayout() l.setContentsMargins(0, 0, 0, 0) w.setLayout(l) l.addStretch(1) self.today_button = QPushButton(_('Set \'%s\' to today')%cm['name'], parent) l.addWidget(self.today_button) self.clear_button = QPushButton(_('Clear \'%s\'')%cm['name'], parent) l.addWidget(self.clear_button) l.addStretch(2) w = self.main_widget format = cm['display'].get('date_format','') if not format: format = 'dd MMM yyyy' w.setDisplayFormat(format) w.setCalendarPopup(True) w.setMinimumDateTime(UNDEFINED_QDATETIME) w.setSpecialValueText(_('Undefined')) self.today_button.clicked.connect(w.set_to_today) self.clear_button.clicked.connect(w.set_to_clear)
def make_widgets(self, parent, main_widget_class, extra_label_text=''): w = QWidget(parent) self.widgets = [QLabel('&'+self.col_metadata['name']+':', w), w] l = QHBoxLayout() l.setContentsMargins(0, 0, 0, 0) w.setLayout(l) self.main_widget = main_widget_class(w) l.addWidget(self.main_widget) l.setStretchFactor(self.main_widget, 10) self.a_c_checkbox = QCheckBox(_('Apply changes'), w) l.addWidget(self.a_c_checkbox) self.ignore_change_signals = True # connect to the various changed signals so we can auto-update the # apply changes checkbox if hasattr(self.main_widget, 'editTextChanged'): # editable combobox widgets self.main_widget.editTextChanged.connect(self.a_c_checkbox_changed) if hasattr(self.main_widget, 'textChanged'): # lineEdit widgets self.main_widget.textChanged.connect(self.a_c_checkbox_changed) if hasattr(self.main_widget, 'currentIndexChanged'): # combobox widgets self.main_widget.currentIndexChanged[int].connect(self.a_c_checkbox_changed) if hasattr(self.main_widget, 'valueChanged'): # spinbox widgets self.main_widget.valueChanged.connect(self.a_c_checkbox_changed) if hasattr(self.main_widget, 'dateTimeChanged'): # dateEdit widgets self.main_widget.dateTimeChanged.connect(self.a_c_checkbox_changed)
def __init__(self, *args): QWidget.__init__(self, *args) lo = QHBoxLayout(self) lo.setContentsMargins(0, 0, 0, 0) lo.setSpacing(5) # type selector self.wtypesel = QComboBox(self) for i, tp in enumerate(self.ValueTypes): self.wtypesel.addItem(tp.__name__) QObject.connect(self.wtypesel, SIGNAL("activated(int)"), self._selectTypeNum) typesel_lab = QLabel("&Type:", self) typesel_lab.setBuddy(self.wtypesel) lo.addWidget(typesel_lab, 0) lo.addWidget(self.wtypesel, 0) self.wvalue = QLineEdit(self) self.wvalue_lab = QLabel("&Value:", self) self.wvalue_lab.setBuddy(self.wvalue) self.wbool = QComboBox(self) self.wbool.addItems(["false", "true"]) self.wbool.setCurrentIndex(1) lo.addWidget(self.wvalue_lab, 0) lo.addWidget(self.wvalue, 1) lo.addWidget(self.wbool, 1) self.wvalue.hide() # make input validators self._validators = {int: QIntValidator(self), float: QDoubleValidator(self)} # select bool type initially self._selectTypeNum(0)
def __init__(self, parent=None,): QDialog.__init__(self, parent) self.parent = parent self.setWindowTitle(u"{0} {1}: Add New Mobipocket PID".format(PLUGIN_NAME, PLUGIN_VERSION)) layout = QVBoxLayout(self) self.setLayout(layout) data_group_box = QGroupBox(u"", self) layout.addWidget(data_group_box) data_group_box_layout = QVBoxLayout() data_group_box.setLayout(data_group_box_layout) key_group = QHBoxLayout() data_group_box_layout.addLayout(key_group) key_group.addWidget(QLabel(u"PID:", self)) self.key_ledit = QLineEdit("", self) self.key_ledit.setToolTip(u"Enter a Mobipocket PID. Mobipocket PIDs are 8 or 10 characters long. Mobipocket PIDs are case-sensitive, so be sure to enter the upper and lower case letters unchanged.") key_group.addWidget(self.key_ledit) key_label = QLabel(_(''), self) key_label.setAlignment(Qt.AlignHCenter) data_group_box_layout.addWidget(key_label) self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.button_box.accepted.connect(self.accept) self.button_box.rejected.connect(self.reject) layout.addWidget(self.button_box) self.resize(self.sizeHint())
def makeControlWidgets(self, parent, gridlayout, row, column): toprow = QWidget(parent) gridlayout.addWidget(toprow, row * 2, column) top_lo = QHBoxLayout(toprow) top_lo.setContentsMargins(0, 0, 0, 0) self._wlabel = QLabel(self.format % (self.name, self.value), toprow) top_lo.addWidget(self._wlabel) self._wreset = QToolButton(toprow) self._wreset.setText("reset") self._wreset.setToolButtonStyle(Qt.ToolButtonTextOnly) self._wreset.setAutoRaise(True) self._wreset.setEnabled(self.value != self._default) QObject.connect(self._wreset, SIGNAL("clicked()"), self._resetValue) top_lo.addWidget(self._wreset) self._wslider = QwtSlider(parent) # This works around a stupid bug in QwtSliders -- see comments on histogram zoom wheel above self._wslider_timer = QTimer(parent) self._wslider_timer.setSingleShot(True) self._wslider_timer.setInterval(500) QObject.connect(self._wslider_timer, SIGNAL("timeout()"), self.setValue) gridlayout.addWidget(self._wslider, row * 2 + 1, column) self._wslider.setRange(self.minval, self.maxval) self._wslider.setStep(self.step) self._wslider.setValue(self.value) self._wslider.setTracking(False) QObject.connect(self._wslider, SIGNAL("valueChanged(double)"), self.setValue) QObject.connect(self._wslider, SIGNAL("sliderMoved(double)"), self._previewValue)
def __init__(self, show_strength=True, parent=None): super(PinMatrixWidget, self).__init__(parent) self.password = QLineEdit() self.password.setValidator(QRegExpValidator(QRegExp('[1-9]+'), None)) self.password.setEchoMode(QLineEdit.Password) QObject.connect(self.password, SIGNAL('textChanged(QString)'), self._password_changed) self.strength = QLabel() self.strength.setMinimumWidth(75) self.strength.setAlignment(Qt.AlignCenter) self._set_strength(0) grid = QGridLayout() grid.setSpacing(0) for y in range(3)[::-1]: for x in range(3): button = PinButton(self.password, x + y * 3 + 1) button.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) button.setFocusPolicy(Qt.NoFocus) grid.addWidget(button, 3 - y, x) hbox = QHBoxLayout() hbox.addWidget(self.password) if show_strength: hbox.addWidget(self.strength) vbox = QVBoxLayout() vbox.addLayout(grid) vbox.addLayout(hbox) self.setLayout(vbox)
class CursorPositionWidget(QWidget): # {{{ def __init__(self, parent): QWidget.__init__(self, parent) self.l = QHBoxLayout(self) self.setLayout(self.l) self.la = QLabel('') self.l.addWidget(self.la) self.l.setContentsMargins(0, 0, 0, 0) f = self.la.font() f.setBold(False) self.la.setFont(f) def update_position(self, line=None, col=None, character=None): if line is None: self.la.setText('') else: try: name = unicodedata.name(character, None) if character else None except Exception: name = None text = _('Line: {0} : {1}').format(line, col) if name: text = name + ' : ' + text self.la.setText(text)
def __init__(self, script="", parent=None): super(QTextEditCS, self).__init__(parent) self.resize(800, 600) self.script = script self.edit = QtGui.QTextEdit(self) # met une police de caractère même largeur pour tous les caractères font = QtGui.QFont() font.setFamily(u"DejaVu Sans Mono") # police de Qt4 font.setStyleHint(QtGui.QFont.Courier) # si la police est indisponible font.setPointSize(10) self.edit.setFont(font) # met en place la coloration syntaxique self.colorSyntax = ColorSyntax(self.edit.document()) # affiche le script colorisé self.setText(self.script) # positionne le QTextEdit dans la fenêtre layout = QHBoxLayout(self) layout.setMargin(0) layout.setSpacing(0) self.number_bar = self.NumberBar() self.number_bar.setTextEdit(self.edit) layout.addWidget(self.number_bar) layout.addWidget(self.edit) self.setLayout(layout) self.edit.installEventFilter(self) self.edit.viewport().installEventFilter(self)
def _init_controls(self): layout = QVBoxLayout(self) self.setLayout(layout) ml = QHBoxLayout() layout.addLayout(ml, 1) self.keys_list = QListWidget(self) self.keys_list.setSelectionMode(QAbstractItemView.SingleSelection) self.keys_list.setFixedWidth(150) self.keys_list.setAlternatingRowColors(True) ml.addWidget(self.keys_list) self.value_text = QTextEdit(self) self.value_text.setTabStopWidth(24) self.value_text.setReadOnly(False) ml.addWidget(self.value_text, 1) button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) button_box.accepted.connect(self._apply_changes) button_box.rejected.connect(self.reject) self.clear_button = button_box.addButton('Clear', QDialogButtonBox.ResetRole) self.clear_button.setIcon(get_icon('trash.png')) self.clear_button.setToolTip('Clear all settings for this plugin') self.clear_button.clicked.connect(self._clear_settings) layout.addWidget(button_box)
def __init__(self, parent, modal=True, flags=Qt.WindowFlags(), caption="Select Tags", ok_button="Select"): QDialog.__init__(self, parent, flags) self.setModal(modal) self.setWindowTitle(caption) lo = QVBoxLayout(self) lo.setMargin(10) lo.setSpacing(5) # tag selector self.wtagsel = QListWidget(self) lo.addWidget(self.wtagsel) # self.wtagsel.setColumnMode(QListBox.FitToWidth) self.wtagsel.setSelectionMode(QListWidget.MultiSelection) QObject.connect(self.wtagsel, SIGNAL("itemSelectionChanged()"), self._check_tag) # buttons lo.addSpacing(10) lo2 = QHBoxLayout() lo.addLayout(lo2) lo2.setContentsMargins(0, 0, 0, 0) lo2.setMargin(5) self.wokbtn = QPushButton(ok_button, self) self.wokbtn.setMinimumWidth(128) QObject.connect(self.wokbtn, SIGNAL("clicked()"), self.accept) self.wokbtn.setEnabled(False) cancelbtn = QPushButton("Cancel", self) cancelbtn.setMinimumWidth(128) QObject.connect(cancelbtn, SIGNAL("clicked()"), self.reject) lo2.addWidget(self.wokbtn) lo2.addStretch(1) lo2.addWidget(cancelbtn) self.setMinimumWidth(384) self._tagnames = []
def __init__(self, parent=None,): QDialog.__init__(self, parent) self.parent = parent self.setWindowTitle(u"{0} {1}: Add New EInk Kindle Serial Number".format(PLUGIN_NAME, PLUGIN_VERSION)) layout = QVBoxLayout(self) self.setLayout(layout) data_group_box = QGroupBox(u"", self) layout.addWidget(data_group_box) data_group_box_layout = QVBoxLayout() data_group_box.setLayout(data_group_box_layout) key_group = QHBoxLayout() data_group_box_layout.addLayout(key_group) key_group.addWidget(QLabel(u"EInk Kindle Serial Number:", self)) self.key_ledit = QLineEdit("", self) self.key_ledit.setToolTip(u"Enter an eInk Kindle serial number. EInk Kindle serial numbers are 16 characters long and usually start with a 'B' or a '9'. Kindle Serial Numbers are case-sensitive, so be sure to enter the upper and lower case letters unchanged.") key_group.addWidget(self.key_ledit) key_label = QLabel(_(''), self) key_label.setAlignment(Qt.AlignHCenter) data_group_box_layout.addWidget(key_label) self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.button_box.accepted.connect(self.accept) self.button_box.rejected.connect(self.reject) layout.addWidget(self.button_box) self.resize(self.sizeHint())
def set_viewer_group(self): ''' 1. Load Items from viewer factory ''' view_fact = ViewerPluginFactory() self.viewer_stack = QtGui.QStackedWidget() self.viewer_cbox = self.builder.combobox(self.groupb_viewer, [], self.set_cb_changed_event_view) self.set_start_button = self.builder.pushbutton(self.groupb_viewer, 'Start Simulation', self.create_aut_env) self.set_start_button.setFixedWidth(200) self.set_start_button.setFixedHeight(25) for viewer_plugin in view_fact.createable_objects(): view = view_fact.make(viewer_plugin) if view != None: view.set_monitor(self.monitor) self.viewer_stack.addWidget(view.get_widget(self)) self.viewer_cbox.addItem(view.get_combobox_name()) ''' layout ''' v_layout = QVBoxLayout() self.viewer_cbox.setFixedHeight(25) v_layout.addWidget(self.viewer_stack) hl = QHBoxLayout() hl.addWidget(self.viewer_cbox) hl.addWidget(self.set_start_button) v_layout.addLayout(hl) self.groupb_viewer.setLayout(v_layout)
class CursorPositionWidget(QWidget): # {{{ def __init__(self, parent): QWidget.__init__(self, parent) self.l = QHBoxLayout(self) self.setLayout(self.l) self.la = QLabel('') self.l.addWidget(self.la) self.l.setContentsMargins(0, 0, 0, 0) f = self.la.font() f.setBold(False) self.la.setFont(f) def update_position(self, line=None, col=None, character=None): if line is None: self.la.setText('') else: try: name = character_name(character) if character and tprefs['editor_show_char_under_cursor'] else None except Exception: name = None text = _('Line: {0} : {1}').format(line, col) if not name: name = {'\t':'TAB'}.get(character, None) if name and tprefs['editor_show_char_under_cursor']: text = name + ' : ' + text self.la.setText(text)
def __init__(self, parent, flags=Qt.WindowFlags()): QDialog.__init__(self, parent, flags) self.setModal(False) self.setWindowTitle("Select sources by...") lo = QVBoxLayout(self) lo.setMargin(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) QObject.connect(self.wselby, SIGNAL("activated(const QString &)"), self._setup_selection_by) # under/over self.wgele = QComboBox(self) lo1.addWidget(self.wgele, 0) self.wgele.addItems([">", ">=", "<=", "<", "sum<=", "sum>"]) QObject.connect(self.wgele, SIGNAL("activated(const QString &)"), self._select_threshold) # threshold value self.wthreshold = QLineEdit(self) QObject.connect(self.wthreshold, SIGNAL("editingFinished()"), 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) QObject.connect(self.wpercent, SIGNAL("valueChanged(int)"), self._select_percentile) QObject.connect(self.wpercent, SIGNAL("sliderMoved(int)"), 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,SIGNAL("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 create_color_button(key, text): b = ColorButton(data, key, text, self) b.changed.connect(self.changed), l.addWidget(b) bc = QToolButton(self) bc.setIcon(QIcon(I('clear_left.png'))) bc.setToolTip(_('Remove color')) bc.clicked.connect(b.clear) h = QHBoxLayout() h.addWidget(b), h.addWidget(bc) return h
def _createHeader(self, iconPath, title): """ Creates the Property Manager header, which contains an icon (a QLabel with a pixmap) and white text (a QLabel with text). @param iconPath: The relative path for the icon (PNG image) that appears in the header. @type iconPath: str @param title: The title that appears in the header. @type title: str """ # Heading frame (dark gray), which contains # a pixmap and (white) heading text. self.headerFrame = QFrame(self) self.headerFrame.setFrameShape(QFrame.NoFrame) self.headerFrame.setFrameShadow(QFrame.Plain) self.headerFrame.setPalette(QPalette(pmHeaderFrameColor)) self.headerFrame.setAutoFillBackground(True) # HBox layout for heading frame, containing the pixmap # and label (title). HeaderFrameHLayout = QHBoxLayout(self.headerFrame) # 2 pixels around edges -- HeaderFrameHLayout.setMargin(PM_HEADER_FRAME_MARGIN) # 5 pixel between pixmap and label. -- HeaderFrameHLayout.setSpacing(PM_HEADER_FRAME_SPACING) # PropMgr icon. Set image by calling setHeaderIcon(). self.headerIcon = QLabel(self.headerFrame) self.headerIcon.setSizePolicy( QSizePolicy(QSizePolicy.Policy(QSizePolicy.Fixed), QSizePolicy.Policy(QSizePolicy.Fixed))) self.headerIcon.setScaledContents(True) HeaderFrameHLayout.addWidget(self.headerIcon) # PropMgr header title text (a QLabel). self.headerTitle = QLabel(self.headerFrame) headerTitlePalette = self._getHeaderTitlePalette() self.headerTitle.setPalette(headerTitlePalette) self.headerTitle.setAlignment(PM_LABEL_LEFT_ALIGNMENT) # Assign header title font. self.headerTitle.setFont(self._getHeaderFont()) HeaderFrameHLayout.addWidget(self.headerTitle) self.vBoxLayout.addWidget(self.headerFrame) # Set header icon and title text. self.setHeaderIcon(iconPath) self.setHeaderTitle(title)
class Dialog(QDialog): def __init__(self, title, widget=None, closeButton=True, keySequence=None, isDialog=False, icon=None): QDialog.__init__(self, ctx.mainScreen) self.setObjectName("dialog") self.isDialog = isDialog self.layout = QVBoxLayout() self.setLayout(self.layout) self.wlayout= QHBoxLayout() if icon: self.setStyleSheet("""QDialog QLabel{ margin-left:16px;margin-right:10px} QDialog#dialog {background-image:url(':/images/%s.png'); background-repeat:no-repeat; background-position: top left; padding-left:500px;} """ % icon) self.windowTitle = windowTitle(self, closeButton) self.setTitle(title) self.layout.setMargin(0) self.layout.addWidget(self.windowTitle) if widget: self.addWidget(widget) QObject.connect(widget, SIGNAL("finished(int)"), self.reject) QObject.connect(widget, SIGNAL("resizeDialog(int,int)"), self.resize) if closeButton: QObject.connect(self.windowTitle.pushButton, SIGNAL("clicked()"), self.reject) if keySequence: shortCut = QShortcut(keySequence, self) QObject.connect(shortCut, SIGNAL("activated()"), self.reject) QMetaObject.connectSlotsByName(self) self.resize(10,10) def setTitle(self, title): self.windowTitle.label.setText(title) def addWidget(self, widget): self.content = widget self.wlayout.addWidget(self.content) if self.isDialog: widget.setStyleSheet("QMessageBox { background:none }") self.layout.addItem(QSpacerItem(10, 10, QSizePolicy.Fixed, QSizePolicy.MinimumExpanding)) self.layout.setContentsMargins(0, 0, 0, 8) self.layout.addLayout(self.wlayout) def setCentered(self): self.move(ctx.mainScreen.width()/2 - self.width()/2, ctx.mainScreen.height()/2 - self.height()/2) def exec_(self): QTimer.singleShot(0, self.setCentered) return QDialog.exec_(self)
def __init__(self, parent=None,): QDialog.__init__(self, parent) self.parent = parent self.setWindowTitle(u"{0} {1}: Getting Default Kindle for Mac/PC Key".format(PLUGIN_NAME, PLUGIN_VERSION)) layout = QVBoxLayout(self) self.setLayout(layout) try: if iswindows or isosx: from calibre_plugins.dedrm.kindlekey import kindlekeys defaultkeys = kindlekeys() else: # linux from wineutils import WineGetKeys scriptpath = os.path.join(parent.parent.alfdir,u"kindlekey.py") defaultkeys = WineGetKeys(scriptpath, u".k4i",parent.getwineprefix()) self.default_key = defaultkeys[0] except: traceback.print_exc() self.default_key = u"" self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) if len(self.default_key)>0: data_group_box = QGroupBox(u"", self) layout.addWidget(data_group_box) data_group_box_layout = QVBoxLayout() data_group_box.setLayout(data_group_box_layout) key_group = QHBoxLayout() data_group_box_layout.addLayout(key_group) key_group.addWidget(QLabel(u"Unique Key Name:", self)) self.key_ledit = QLineEdit(u"default_key", self) self.key_ledit.setToolTip(u"<p>Enter an identifying name for the current default Kindle for Mac/PC key.") key_group.addWidget(self.key_ledit) key_label = QLabel(_(''), self) key_label.setAlignment(Qt.AlignHCenter) data_group_box_layout.addWidget(key_label) self.button_box.accepted.connect(self.accept) else: default_key_error = QLabel(u"The default encryption key for Kindle for Mac/PC could not be found.", self) default_key_error.setAlignment(Qt.AlignHCenter) layout.addWidget(default_key_error) # if no default, bot buttons do the same self.button_box.accepted.connect(self.reject) self.button_box.rejected.connect(self.reject) layout.addWidget(self.button_box) self.resize(self.sizeHint())
def __init__(self, parent): QWidget.__init__(self, parent) layout = QHBoxLayout() layout.setSpacing(5) layout.setContentsMargins(0, 0, 0, 0) self.tags_box = EditWithComplete(parent) layout.addWidget(self.tags_box, stretch=1000) self.editor_button = QToolButton(self) self.editor_button.setToolTip(_('Open Item Editor')) self.editor_button.setIcon(QIcon(I('chapters.png'))) layout.addWidget(self.editor_button) self.setLayout(layout)
def create_widgets(self): ''' Create Widgets''' self.builder.set_props(self, False, 1200, 740) self.desc_label = self.builder.label(self, "Description: \nEdit an existing Timing Mapping Parameter Set or create a new one") self.desc_label.setFixedHeight(50) self.set_cb = self.builder.combobox(self, [], self.set_cb_selection_changed) self.set_cb.setFixedHeight(22) self.set_plus_pb = self.builder.pushbutton(self, "Add", self.add_hit, os.getcwd() +r'/icons/add.png') self.set_plus_pb.setFixedWidth(100) self.set_plus_pb.setFixedHeight(30) self.elem_tab = self.builder.table(self, 0, 5, ["Affiliation", "Timing Variable", "Type", "Value", "Condition"]) self.elem_tab.cellDoubleClicked.connect(self._cell_double_clicked) ''' Save and Exit Buttons ''' self.space = self.builder.label(self, "") # self.space.setFixedWidth(300) self.ok_pb = self.builder.pushbutton(self, "Ok", self.ok_hit) self.ok_pb.setFixedHeight(30) self.ok_pb.setFixedWidth(140) self.apply_pb = self.builder.pushbutton(self, "Apply", self.apply_hit) self.apply_pb.setFixedHeight(30) self.apply_pb.setFixedWidth(140) self.cancel_pb = self.builder.pushbutton(self, "Cancel", self.cancel_hit) self.cancel_pb.setFixedHeight(30) self.cancel_pb.setFixedWidth(140) ''' Layout ''' v_lay = QVBoxLayout() v_lay.addWidget(self.desc_label) hl = QHBoxLayout() hl.addWidget(self.set_plus_pb) hl.addWidget(self.set_cb) v_lay.addLayout(hl) v_lay.addWidget(self.elem_tab) hl = QHBoxLayout() hl.addWidget(self.space) hl.addWidget(self.ok_pb) hl.addWidget(self.cancel_pb) hl.addWidget(self.apply_pb) v_lay.addLayout(hl) self.setLayout(v_lay)
def __init__(self, parent, values): QWidget.__init__(self, parent) layout = QHBoxLayout() layout.setSpacing(5) layout.setContentsMargins(0, 0, 0, 0) self.tags_box = EditWithComplete(parent) self.tags_box.update_items_cache(values) layout.addWidget(self.tags_box, stretch=3) self.checkbox = QCheckBox(_('Remove all tags'), parent) layout.addWidget(self.checkbox) layout.addStretch(1) self.setLayout(layout) self.connect(self.checkbox, SIGNAL('stateChanged(int)'), self.box_touched)
class ConfigWidget(QWidget): 'Configuration widget' def __init__(self): QWidget.__init__(self) self.layout = QHBoxLayout() self.setLayout(self.layout) self.key_label = QLabel('&api key:') self.layout.addWidget(self.key_label) self.key_msg = QLineEdit(self) self.key_msg.setText(PREFS['api_key']) self.layout.addWidget(self.key_msg) self.key_label.setBuddy(self.key_msg) self.threads_label = QLabel('&worker_threads:') self.layout.addWidget(self.threads_label) self.threads_msg = QLineEdit(self) self.threads_msg.setText(str(PREFS['worker_threads'])) self.layout.addWidget(self.threads_msg) self.key_label.setBuddy(self.key_msg) def save_settings(self): 'Apply new settings value' PREFS['api_key'] = unicode(self.key_msg.text()) PREFS['worker_threads'] = int(self.threads_msg.text()) pycomicvine.api_key = PREFS['api_key']
def setup_ui(self, parent): self.make_widgets(parent, EditWithComplete) values = self.all_values = list(self.db.all_custom(num=self.col_id)) values.sort(key=sort_key) self.main_widget.setSizeAdjustPolicy(self.main_widget.AdjustToMinimumContentsLengthWithIcon) self.main_widget.setMinimumContentsLength(25) self.widgets.append(QLabel('', parent)) w = QWidget(parent) layout = QHBoxLayout(w) layout.setContentsMargins(0, 0, 0, 0) self.remove_series = QCheckBox(parent) self.remove_series.setText(_('Remove series')) layout.addWidget(self.remove_series) self.idx_widget = QCheckBox(parent) self.idx_widget.setText(_('Automatically number books')) layout.addWidget(self.idx_widget) self.force_number = QCheckBox(parent) self.force_number.setText(_('Force numbers to start with ')) layout.addWidget(self.force_number) self.series_start_number = QSpinBox(parent) self.series_start_number.setMinimum(1) self.series_start_number.setMaximum(9999999) self.series_start_number.setProperty("value", 1) layout.addWidget(self.series_start_number) layout.addItem(QSpacerItem(20, 10, QSizePolicy.Expanding, QSizePolicy.Minimum)) self.widgets.append(w) self.idx_widget.stateChanged.connect(self.check_changed_checkbox) self.force_number.stateChanged.connect(self.check_changed_checkbox) self.series_start_number.valueChanged.connect(self.check_changed_checkbox) self.remove_series.stateChanged.connect(self.check_changed_checkbox) self.ignore_change_signals = False
class DaysOfWeek(Base): HELP = _('''\ Download this periodical every week on the specified days after the specified time. For example, if you choose: Monday after 9:00 AM, then the periodical will be download every Monday as soon after 9:00 AM as possible. ''') def __init__(self, parent=None): Base.__init__(self, parent) self.days = [QCheckBox(force_unicode(calendar.day_abbr[d]), self) for d in xrange(7)] for i, cb in enumerate(self.days): row = i % 2 col = i // 2 self.l.addWidget(cb, row, col, 1, 1) self.time = QTimeEdit(self) self.time.setDisplayFormat('hh:mm AP') if canonicalize_lang(get_lang()) in {'deu', 'nds'}: self.time.setDisplayFormat('HH:mm') self.hl = QHBoxLayout() self.l1 = QLabel(_('&Download after:')) self.l1.setBuddy(self.time) self.hl.addWidget(self.l1) self.hl.addWidget(self.time) self.l.addLayout(self.hl, 1, 3, 1, 1) self.initialize() def initialize(self, typ=None, val=None): if typ is None: typ = 'day/time' val = (-1, 6, 0) if typ == 'day/time': val = convert_day_time_schedule(val) days_of_week, hour, minute = val for i, d in enumerate(self.days): d.setChecked(i in days_of_week) self.time.setTime(QTime(hour, minute)) @property def schedule(self): days_of_week = tuple([i for i, d in enumerate(self.days) if d.isChecked()]) t = self.time.time() hour, minute = t.hour(), t.minute() return 'days_of_week', (days_of_week, int(hour), int(minute))
class ConfigWidget(QWidget): def __init__(self): QWidget.__init__(self) self.l = QHBoxLayout() self.setLayout(self.l) self.oldest_articlel = QLabel('Oldest article:') self.l.addWidget(self.oldest_articlel) self.oldest_article_msg = QLineEdit(self) self.oldest_article_msg.setText(prefs['oldest_article']) self.l.addWidget(self.oldest_article_msg) self.oldest_articlel.setBuddy(self.oldest_article_msg) self.max_articlesl = QLabel('Max articles:') self.l.addWidget(self.max_articlesl) self.max_articles_msg = QLineEdit(self) self.max_articles_msg.setText(prefs['max_articles']) self.l.addWidget(self.max_articles_msg) self.max_articlesl.setBuddy(self.max_articles_msg) def save_settings(self): prefs['oldest_article'] = unicode(self.oldest_article_msg.text()) prefs['max_articles'] = unicode(self.max_articles_msg.text())
def __init__(self, *args): QtGui.QFrame.__init__(self, *args) self.edit = Editor() self.pyFile = "" self.number_bar = NumberBar(self.edit) hbox = QHBoxLayout(self) # Pack the number bar, then pack the editor hbox.setSpacing(10) hbox.setContentsMargins(10,0,0,0) hbox.addWidget(self.number_bar) hbox.addWidget(self.edit) self.edit.blockCountChanged.connect(self.number_bar.adjustWidth) self.edit.updateRequest.connect(self.number_bar.updateContents)
def create_row2(row, widget, button=None, front_button=None): row += 1 ql = BuddyLabel(widget) if front_button: ltl = QHBoxLayout() ltl.addWidget(front_button) ltl.addWidget(ql) l.addLayout(ltl, row, 0, 1, 1) else: l.addWidget(ql, row, 0, 1, 1) l.addWidget(widget, row, 1, 1, 2 if button is None else 1) if button is not None: l.addWidget(button, row, 2, 1, 1) if button is not None: sto(widget, button)
def __init__(self, *args): QFrame.__init__(self, *args) self.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken) self.edit = self.PlainTextEdit() self.number_bar = self.NumberBar(self.edit) hbox = QHBoxLayout(self) hbox.setSpacing(0) hbox.setMargin(0) hbox.addWidget(self.number_bar) hbox.addWidget(self.edit) self.edit.blockCountChanged.connect(self.number_bar.adjustWidth) self.edit.updateRequest.connect(self.number_bar.updateContents)
class CursorPositionWidget(QWidget): def __init__(self, parent): QWidget.__init__(self, parent) self.l = QHBoxLayout(self) self.setLayout(self.l) self.la = QLabel('') self.l.addWidget(self.la) self.l.setContentsMargins(0, 0, 0, 0) f = self.la.font() f.setBold(False) self.la.setFont(f) def update_position(self, line=None, col=None): if line is None: self.la.setText('') else: self.la.setText(_('Line: {0} : {1}').format(line, col))
class ConfigWidget(QWidget): def __init__(self): QWidget.__init__(self) self.l = QVBoxLayout() self.setLayout(self.l) self.ll = QHBoxLayout() self.server_label = QLabel('Gphoto2 server address:') self.ll.addWidget(self.server_label) self.gphoto2_server = QLineEdit(self) self.gphoto2_server.setText(prefs['gphoto2_server']) self.ll.addWidget(self.gphoto2_server) self.server_label.setBuddy(self.gphoto2_server) self.l.addLayout(self.ll) def save_settings(self): prefs['gphoto2_server'] = self.gphoto2_server.text()
def _initialize_controls(self): self.setWindowTitle(_('User plugins')) self.setWindowIcon(QIcon(I('plugins/plugin_updater.png'))) layout = QVBoxLayout(self) self.setLayout(layout) title_layout = ImageTitleLayout(self, 'plugins/plugin_updater.png', _('User Plugins')) layout.addLayout(title_layout) header_layout = QHBoxLayout() layout.addLayout(header_layout) self.filter_combo = PluginFilterComboBox(self) self.filter_combo.setMinimumContentsLength(20) self.filter_combo.currentIndexChanged[int].connect(self._filter_combo_changed) header_layout.addWidget(QLabel(_('Filter list of plugins')+':', self)) header_layout.addWidget(self.filter_combo) header_layout.addStretch(10) self.plugin_view = QTableView(self) self.plugin_view.horizontalHeader().setStretchLastSection(True) self.plugin_view.setSelectionBehavior(QAbstractItemView.SelectRows) self.plugin_view.setSelectionMode(QAbstractItemView.SingleSelection) self.plugin_view.setAlternatingRowColors(True) self.plugin_view.setSortingEnabled(True) self.plugin_view.setIconSize(QSize(28, 28)) layout.addWidget(self.plugin_view) details_layout = QHBoxLayout() layout.addLayout(details_layout) forum_label = QLabel('<a href="http://www.foo.com/">Plugin Forum Thread</a>', self) forum_label.setTextInteractionFlags(Qt.LinksAccessibleByMouse | Qt.LinksAccessibleByKeyboard) forum_label.linkActivated.connect(self._forum_label_activated) details_layout.addWidget(QLabel(_('Description')+':', self), 0, Qt.AlignLeft) details_layout.addWidget(forum_label, 1, Qt.AlignRight) self.description = QLabel(self) self.description.setFrameStyle(QFrame.Panel | QFrame.Sunken) self.description.setAlignment(Qt.AlignTop | Qt.AlignLeft) self.description.setMinimumHeight(40) self.description.setWordWrap(True) layout.addWidget(self.description) self.button_box = QDialogButtonBox(QDialogButtonBox.Close) self.button_box.rejected.connect(self.reject) self.finished.connect(self._finished) self.install_button = self.button_box.addButton(_('&Install'), QDialogButtonBox.AcceptRole) self.install_button.setToolTip(_('Install the selected plugin')) self.install_button.clicked.connect(self._install_clicked) self.install_button.setEnabled(False) self.configure_button = self.button_box.addButton(' '+_('&Customize plugin ')+' ', QDialogButtonBox.ResetRole) self.configure_button.setToolTip(_('Customize the options for this plugin')) self.configure_button.clicked.connect(self._configure_clicked) self.configure_button.setEnabled(False) layout.addWidget(self.button_box)
def __init__(self, parent, *args): QWidget.__init__(self, parent, *args) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) lo = QVBoxLayout(self) lo.setContentsMargins(0, 0, 0, 0) lo1 = QHBoxLayout() lo.addLayout(lo1) lo1.setContentsMargins(0, 0, 0, 0) lbl = QLabel(QString("<nobr><b>Source groupings:</b></nobr>"), self) lo1.addWidget(lbl, 0) lo1.addStretch(1) # add show/hide button self._showattrbtn = QPushButton(self) self._showattrbtn.setMinimumWidth(256) lo1.addWidget(self._showattrbtn, 0) lo1.addStretch() QObject.connect(self._showattrbtn, SIGNAL("clicked()"), self._togglePlotControlsVisibility) # add table self.table = QTableWidget(self) lo.addWidget(self.table) QObject.connect(self.table, SIGNAL("cellChanged(int,int)"), self._valueChanged) self.table.setSelectionMode(QTableWidget.NoSelection) # setup basic columns self.table.setColumnCount(6 + len(self.EditableAttrs)) for i, label in enumerate( ("grouping", "total", "selection", "list", "plot", "style")): self.table.setHorizontalHeaderItem(i, QTableWidgetItem(label)) self.table.horizontalHeader().setSectionHidden(self.ColApply, True) # setup columns for editable grouping attributes for i, attr in self.AttrByCol.items(): self.table.setHorizontalHeaderItem( i, QTableWidgetItem(PlotStyles.StyleAttributeLabels[attr])) self.table.horizontalHeader().setSectionHidden(i, True) self.table.verticalHeader().hide() # other internal init self._attrs_shown = False self._togglePlotControlsVisibility() self.model = None self._setting_model = False self._currier = PersistentCurrier() # row of 'selected' grouping self._irow_selgroup = 0
def setup_ui(self): self.block_show = False self.properties = [] self.l = l = QVBoxLayout(self) self.setLayout(l) h = QHBoxLayout() l.addLayout(h) self.la = la = QLabel(_('&Edit theme:')) h.addWidget(la) self.theme = t = QComboBox(self) la.setBuddy(t) t.addItems(sorted(custom_theme_names())) t.setMinimumWidth(200) if t.count() > 0: t.setCurrentIndex(0) t.currentIndexChanged[int].connect(self.show_theme) h.addWidget(t) self.add_button = b = QPushButton(QIcon(I('plus.png')), _('Add &new theme'), self) b.clicked.connect(self.create_new_theme) h.addWidget(b) self.remove_button = b = QPushButton(QIcon(I('minus.png')), _('&Remove theme'), self) b.clicked.connect(self.remove_theme) h.addWidget(b) h.addStretch(1) self.scroll = s = QScrollArea(self) self.w = w = QWidget(self) s.setWidget(w), s.setWidgetResizable(True) self.cl = cl = QVBoxLayout() w.setLayout(cl) from calibre.gui2.tweak_book.editor.text import TextEdit self.preview = p = TextEdit(self, expected_geometry=(73, 50)) p.load_text(HELP_TEXT.format( *['<b>%s</b>' % x for x in ( 'Normal', 'Visual', 'CursorLine', 'LineNr', 'MatchParen', 'Function', 'Type', 'Statement', 'Constant', 'SpecialCharacter', 'Error', 'SpellError', 'Comment' )] )) p.setMaximumWidth(p.size_hint.width() + 5) s.setMinimumWidth(600) self.splitter = sp = QSplitter(self) l.addWidget(sp) sp.addWidget(s), sp.addWidget(p) self.bb.clear() self.bb.addButton(self.bb.Close) l.addWidget(self.bb) if self.theme.count() > 0: self.show_theme()
class ShortcutConfig(QWidget): def __init__(self, model, parent=None): QWidget.__init__(self, parent) self._layout = QHBoxLayout() self.setLayout(self._layout) self.view = QListView(self) self._layout.addWidget(self.view) self.view.setModel(model) self.delegate = Delegate() self.view.setItemDelegate(self.delegate) self.delegate.sizeHintChanged.connect(self.scrollTo, type=Qt.QueuedConnection) def scrollTo(self, index): self.view.scrollTo(index, self.view.EnsureVisible) @property def is_editing(self): return self.view.state() == self.view.EditingState
def __init__(self, *args): QFrame.__init__(self, *args) self.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken) self.edit = self.PlainTextEdit() self.number_bar = self.NumberBar(self.edit) hbox = QHBoxLayout(self) hbox.setSpacing(0) hbox.setMargin(0) hbox.addWidget(self.number_bar) hbox.addWidget(self.edit) # self.edit.blockCountChanged.connect(self.number_bar.adjustWidth) # self.edit.updateRequest.connect(self.number_bar.updateContents) # self.edit.textChanged.connect(self.number_bar.updateContents) self.edit.zoomed.connect(self.update_numbar_zoom)
def pmAddHeader(propMgr): """Creates the Property Manager header, which contains a pixmap and white text label. """ # Heading frame (dark gray), which contains # a pixmap and (white) heading text. propMgr.header_frame = QFrame(propMgr) propMgr.header_frame.setFrameShape(QFrame.NoFrame) propMgr.header_frame.setFrameShadow(QFrame.Plain) header_frame_palette = propMgr.getPropMgrTitleFramePalette() propMgr.header_frame.setPalette(header_frame_palette) propMgr.header_frame.setAutoFillBackground(True) # HBox layout for heading frame, containing the pixmap # and label (title). HeaderFrameHLayout = QHBoxLayout(propMgr.header_frame) HeaderFrameHLayout.setMargin(pmHeaderFrameMargin) # 2 pixels around edges. HeaderFrameHLayout.setSpacing( pmHeaderFrameSpacing) # 5 pixel between pixmap and label. # PropMgr icon. Set image by calling setPropMgrIcon() at any time. propMgr.header_pixmap = QLabel(propMgr.header_frame) propMgr.header_pixmap.setSizePolicy( QSizePolicy(QSizePolicy.Policy(QSizePolicy.Fixed), QSizePolicy.Policy(QSizePolicy.Fixed))) propMgr.header_pixmap.setScaledContents(True) HeaderFrameHLayout.addWidget(propMgr.header_pixmap) # PropMgr title label propMgr.header_label = QLabel(propMgr.header_frame) header_label_palette = propMgr.getPropMgrTitleLabelPalette() propMgr.header_label.setPalette(header_label_palette) propMgr.header_label.setAlignment(pmLabelLeftAlignment) # PropMgr heading font (for label). propMgr.header_label.setFont(getHeaderFont()) HeaderFrameHLayout.addWidget(propMgr.header_label) propMgr.pmVBoxLayout.addWidget(propMgr.header_frame)
def __init__(self, main, interpreterLocals, ventana_interprete, *args): QFrame.__init__(self, *args) self.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken) self.editor = WidgetEditor(self, interpreterLocals, ventana_interprete) self.editor.setFrameStyle(QFrame.NoFrame) self.editor.setAcceptRichText(False) self.number_bar = self.NumberBar() self.number_bar.setTextEdit(self.editor) hbox = QHBoxLayout(self) hbox.setSpacing(0) hbox.setMargin(0) hbox.addWidget(self.number_bar) hbox.addWidget(self.editor) self.editor.installEventFilter(self) self.editor.viewport().installEventFilter(self)
def __init__(self, *args): QFrame.__init__(self, *args) self.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken) self.edit = QTextEdit() self.edit.setFrameStyle(QFrame.NoFrame) self.edit.setAcceptRichText(False) self.number_bar = NumberBar() self.number_bar.setTextEdit(self.edit) hbox = QHBoxLayout(self) hbox.setSpacing(0) hbox.setMargin(0) hbox.addWidget(self.number_bar) hbox.addWidget(self.edit) self.edit.installEventFilter(self) self.edit.viewport().installEventFilter(self)
def __init__(self, name, data, parent=None): QWidget.__init__(self, parent) self.l = l = QHBoxLayout(self) self.setLayout(l) self.label = QLabel(name) l.addWidget(self.label) self.data = data def create_color_button(key, text): b = ColorButton(data, key, text, self) b.changed.connect(self.changed), l.addWidget(b) bc = QToolButton(self) bc.setIcon(QIcon(I('clear_left.png'))) bc.setToolTip(_('Remove color')) bc.clicked.connect(b.clear) h = QHBoxLayout() h.addWidget(b), h.addWidget(bc) return h for k, text in (('fg', _('&Foreground')), ('bg', _('&Background'))): h = create_color_button(k, text) l.addLayout(h) for k, text in (('bold', _('B&old')), ('italic', _('&Italic'))): w = Bool(data, k, text, self) w.changed.connect(self.changed) l.addWidget(w) self.underline = us = QComboBox(self) us.addItems(sorted(tuple(underline_styles) + ('',))) idx = us.findText(data.get('underline', '') or '') us.setCurrentIndex(max(idx, 0)) us.currentIndexChanged.connect(self.us_changed) self.la = la = QLabel(_('&Underline:')) la.setBuddy(us) h = QHBoxLayout() h.addWidget(la), h.addWidget(us), l.addLayout(h) h = create_color_button('underline_color', _('Color')) l.addLayout(h) l.addStretch(1)
def _init_controls(self): layout = QVBoxLayout(self) self.setLayout(layout) ml = QHBoxLayout() layout.addLayout(ml, 1) self.keys_list = QListWidget(self) self.keys_list.setSelectionMode(QAbstractItemView.SingleSelection) self.keys_list.setFixedWidth(150) self.keys_list.setAlternatingRowColors(True) ml.addWidget(self.keys_list) self.value_text = QTextEdit(self) self.value_text.setTabStopWidth(24) self.value_text.setReadOnly(True) ml.addWidget(self.value_text, 1) button_box = QDialogButtonBox(QDialogButtonBox.Ok) button_box.accepted.connect(self.accept) button_box.setCenterButtons(True) layout.addWidget(button_box)
def __init__(self, parent=None, name=None, modal=0, fl=None): if fl is None: fl = Qt.Dialog | Qt.WindowTitleHint QDialog.__init__(self, parent, Qt.Dialog | Qt.WindowTitleHint) self.setModal(modal) image0 = pixmaps.tigger_logo.pm() # self.setSizeGripEnabled(0) LayoutWidget = QWidget(self) LayoutWidget.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) lo_top = QVBoxLayout(LayoutWidget) lo_title = QHBoxLayout(None) self.title_icon = QLabel(LayoutWidget) self.title_icon.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.title_icon.setPixmap(image0) self.title_icon.setAlignment(Qt.AlignCenter) lo_title.addWidget(self.title_icon) self.title_label = QLabel(LayoutWidget) self.title_label.setWordWrap(True) lo_title.addWidget(self.title_label) lo_top.addLayout(lo_title) lo_logos = QHBoxLayout(None) lo_top.addLayout(lo_logos) # for logo in ("astron",): # icon = QLabel(LayoutWidget) # icon.setSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed) # icon.setPixmap(getattr(pixmaps,logo+"_logo").pm()) # icon.setAlignment(Qt.AlignCenter) # lo_logos.addWidget(icon) lo_mainbtn = QHBoxLayout(None) lo_mainbtn.addItem( QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)) lo_top.addLayout(lo_mainbtn) self.btn_ok = QPushButton(LayoutWidget) self.btn_ok.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.btn_ok.setMinimumSize(QSize(60, 0)) self.btn_ok.setAutoDefault(1) self.btn_ok.setDefault(1) lo_mainbtn.addWidget(self.btn_ok) lo_mainbtn.addItem( QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)) self.languageChange() LayoutWidget.adjustSize() # LayoutWidget.resize(QSize(489,330).expandedTo(LayoutWidget.minimumSizeHint())) # self.resize(QSize(489,330).expandedTo(self.minimumSizeHint())) # self.clearWState(Qt.WState_Polished) self.connect(self.btn_ok, SIGNAL("clicked()"), self.accept)
def __init__(self, parent, label, filename=None, dialog_label=None, file_types=None, default_suffix=None, file_mode=QFileDialog.AnyFile): QWidget.__init__(self, parent) lo = QHBoxLayout(self) lo.setContentsMargins(0, 0, 0, 0) lo.setSpacing(5) # label lab = QLabel(label, self) lo.addWidget(lab, 0) # text field self.wfname = QLineEdit(self) self.wfname.setReadOnly(True) self.setFilename(filename) lo.addWidget(self.wfname, 1) # selector wsel = QToolButton(self) wsel.setText("Choose...") QObject.connect(wsel, SIGNAL("clicked()"), self._chooseFile) lo.addWidget(wsel, 0) # other init self._file_dialog = None self._dialog_label = dialog_label or label self._file_types = file_types or "All files (*)" self._file_mode = file_mode self._default_suffix = default_suffix self._dir = None
def __init__(self, parent, modal=True, flags=Qt.WindowFlags()): QDialog.__init__(self, parent, flags) self.setModal(modal) self.setWindowTitle("Export Karma annotations") lo = QVBoxLayout(self) lo.setMargin(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(0, 0, 0, 0) lo2.setMargin(5) self.wokbtn = QPushButton("OK", self) self.wokbtn.setMinimumWidth(128) QObject.connect(self.wokbtn, SIGNAL("clicked()"), self.accept) self.wokbtn.setEnabled(False) cancelbtn = QPushButton("Cancel", self) cancelbtn.setMinimumWidth(128) QObject.connect(cancelbtn, SIGNAL("clicked()"), self.reject) lo2.addWidget(self.wokbtn) lo2.addStretch(1) lo2.addWidget(cancelbtn) self.setMinimumWidth(384) # signals QObject.connect(self.wfile, SIGNAL("valid"), self.wokbtn.setEnabled) # internal state self.qerrmsg = QErrorMessage(self) self._model_filename = None
def set_cb_changed_event_view(self, e): # check which items are selected and show all of them try: # clear all try: for ky in self.wid_to_idx: self.wid_to_idx[ky].setParent(None) except: ECULogger().log_traceback() # get checked items checked_idx = [] for cnt in range(self.viewer_cbox.count()): item = self.viewer_cbox.model().item(cnt, 0) if item.checkState(): checked_idx.append(cnt) row_nr = int(self.arrange_rows.text()) col_nr = int(self.arrange_cols.text()) if row_nr * col_nr < len(checked_idx): row_nr = ceil(float(len(checked_idx)) / col_nr) self.arrange_rows.setText(str(row_nr)) # arrange cnt = 0 for r in range(row_nr): hlay = QHBoxLayout() for c in range(col_nr): try: wid = self.wid_to_idx[checked_idx[cnt]]; cnt += 1 hlay.addWidget(wid) except: pass try: self.main_v_layout.addLayout(hlay) except: pass except: pass
def __init__(self, parent, label, extra_widgets=[], style=QFrame.HLine + QFrame.Raised, offset=16): QWidget.__init__(self, parent) lo = QHBoxLayout(self) lo.setContentsMargins(0, 0, 0, 0) lo.setSpacing(4) if offset: frame = QFrame(self) frame.setFrameStyle(style) frame.setMinimumWidth(offset) lo.addWidget(frame, 0) lo.addWidget(QLabel(label, self), 0) frame = QFrame(self) frame.setFrameStyle(style) lo.addWidget(frame, 1) for w in extra_widgets: lo.addWidget(w, 0)
def set_viewer_group(self): ''' 1. Load Items from viewer factory ''' self.wid_to_idx = {} self.viewer_cbox = self.builder.checkable_combobox(self.groupb_viewer, [], self.set_cb_changed_event_view) self.save_but = self.builder.pushbutton(self.groupb_viewer, "Save", self._save_hit) self.save_but.setFixedWidth(100) # field to enter arrangement [lay_r, self.arrange_rows] = self.builder.label_text(self.groupb_viewer, "rows:", 25, 40, self.set_cb_changed_event_view) self.arrange_rows.setText('2') [lay_c, self.arrange_cols] = self.builder.label_text(self.groupb_viewer, "columns:", 40, 40, self.set_cb_changed_event_view) self.arrange_cols.setText('2') cnt = 0 for view in self.view_plugins: if view != None: self.viewer_cbox.addItem(view.get_combobox_name()) item = self.viewer_cbox.model().item(cnt, 0) item.setCheckState(QtCore.Qt.Checked) self.wid_to_idx[cnt] = view.get_widget(self) cnt += 1 ''' Layout ''' self.main_v_layout = QVBoxLayout() self.viewer_cbox.setFixedHeight(25) hl = QHBoxLayout() hl.addWidget(self.viewer_cbox) hl.addLayout(lay_r) hl.addLayout(lay_c) hl.addWidget(self.save_but) self.main_v_layout.addLayout(hl) self.groupb_viewer.setLayout(self.main_v_layout) self.set_cb_changed_event_view(None)
def _create_widget(self): self.builder.set_props(self, False, 820, 300) self.setWindowIcon(QtGui.QIcon( os.getcwd() +r'/icons/tumcreatelogo2.png')) self.tit_label = self.builder.label(self, "Description: \nEdit the Database request and the conditions") self.left_label = self.builder.label(self, "Database request:") self.db_textbox = QtGui.QTextEdit() self.cond_label = self.builder.label(self, "Conditions for Database with ID:") self.condition_tab = self.builder.table(self, len(self.condition), 6, ["ID", 'Lookup DB', "Var Name", "Var Config", "Type", "Value"], False) self.condition_tab.verticalHeader().hide() self.condition_tab.setColumnWidth(2, 250) self.add_pb = self.builder.pushbutton(self, "Add Item", self.add_hit, icon_path = os.getcwd() +r'/icons/add.png') self.add_pb.setFixedHeight(30) self.add_pb.setFixedWidth(200) self.del_pb = self.builder.pushbutton(self, "Delete Item", self.delete_hit, icon_path = os.getcwd() +r'/icons/delete.png') self.del_pb.setFixedHeight(30) self.del_pb.setFixedWidth(200) self.space = self.builder.label(self, "") self.ok_pb = self.builder.pushbutton(self, "Ok", self.ok_hit) self.ok_pb.setFixedHeight(30) self.ok_pb.setFixedWidth(140) self.cancel_pb = self.builder.pushbutton(self, "Cancel", self.cancel_hit) self.cancel_pb.setFixedHeight(30) self.cancel_pb.setFixedWidth(140) ''' Layout ''' v_lay = QVBoxLayout() v_lay.addWidget(self.tit_label) v_lay.addWidget(self.left_label) v_lay.addWidget(self.db_textbox) v_lay.addWidget(self.cond_label) v_lay.addWidget(self.condition_tab) hl = QHBoxLayout() hl.addWidget(self.add_pb) hl.addWidget(self.del_pb) hl.addWidget(self.space) hl.addWidget(self.ok_pb) hl.addWidget(self.cancel_pb) v_lay.addLayout(hl) self.setLayout(v_lay)
def __init__( self, parent=None, ): QDialog.__init__(self, parent) self.parent = parent self.setWindowTitle( u"{0} {1}: Add New EInk Kindle Serial Number".format( PLUGIN_NAME, PLUGIN_VERSION)) layout = QVBoxLayout(self) self.setLayout(layout) data_group_box = QGroupBox(u"", self) layout.addWidget(data_group_box) data_group_box_layout = QVBoxLayout() data_group_box.setLayout(data_group_box_layout) key_group = QHBoxLayout() data_group_box_layout.addLayout(key_group) key_group.addWidget(QLabel(u"EInk Kindle Serial Number:", self)) self.key_ledit = QLineEdit("", self) self.key_ledit.setToolTip( u"Enter an eInk Kindle serial number. EInk Kindle serial numbers are 16 characters long and usually start with a 'B' or a '9'. Kindle Serial Numbers are case-sensitive, so be sure to enter the upper and lower case letters unchanged." ) key_group.addWidget(self.key_ledit) key_label = QLabel(_(''), self) key_label.setAlignment(Qt.AlignHCenter) data_group_box_layout.addWidget(key_label) self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.button_box.accepted.connect(self.accept) self.button_box.rejected.connect(self.reject) layout.addWidget(self.button_box) self.resize(self.sizeHint())
def __init__(self, parent, modal=True, flags=Qt.WindowFlags()): QDialog.__init__(self, parent, flags) self.setModal(modal) self.setWindowTitle("Add Tag") lo = QVBoxLayout(self) lo.setMargin(10) lo.setSpacing(5) # tag selector lo1 = QHBoxLayout() lo.addLayout(lo1) lo1.setSpacing(5) self.wtagsel = QComboBox(self) self.wtagsel.setEditable(True) wtagsel_lbl = QLabel("&Tag:", self) wtagsel_lbl.setBuddy(self.wtagsel) lo1.addWidget(wtagsel_lbl, 0) lo1.addWidget(self.wtagsel, 1) QObject.connect(self.wtagsel, SIGNAL("activated(int)"), self._check_tag) QObject.connect(self.wtagsel, SIGNAL("editTextChanged(const QString &)"), self._check_tag_text) # value editor self.valedit = ValueTypeEditor(self) lo.addWidget(self.valedit) # buttons lo.addSpacing(10) lo2 = QHBoxLayout() lo.addLayout(lo2) lo2.setContentsMargins(0, 0, 0, 0) lo2.setMargin(5) self.wokbtn = QPushButton("OK", self) self.wokbtn.setMinimumWidth(128) QObject.connect(self.wokbtn, SIGNAL("clicked()"), self.accept) self.wokbtn.setEnabled(False) cancelbtn = QPushButton("Cancel", self) cancelbtn.setMinimumWidth(128) QObject.connect(cancelbtn, SIGNAL("clicked()"), self.reject) lo2.addWidget(self.wokbtn) lo2.addStretch(1) lo2.addWidget(cancelbtn) self.setMinimumWidth(384)
def pmAddTopRowButtons(propMgr, showFlags=pmAllButtons): """Creates the OK, Cancel, Preview, and What's This buttons row at the top of the Property Manager <propMgr>. <showFlags> is an enum that can be used to show only certain Property Manager buttons, where: pmDoneButton = 1 pmCancelButton = 2 pmRestoreDefaultsButton = 4 pmPreviewButton = 8 pmWhatsThisButton = 16 pmAllButtons = 31 These flags are defined in PropMgr_Constants.py. This subroutine is used by the following Property Managers (which are still not using the PropMgrBaseClass): - Build Atoms - Build Crystal - Extrude - Move - Movie Player - Fuse Chunks Note: This subrouting is temporary. It will be removed after the PropMgrs in this list are converted to the PropMgrBaseClass. Mark 2007-06-24 """ # The Top Buttons Row includes the following widgets: # # - propMgr.pmTopRowBtns (Hbox Layout containing everything:) # # - frame # - hbox layout "frameHboxLO" (margin=2, spacing=2) # - Done (OK) button # - Abort (Cancel) button # - Restore Defaults button # - Preview button # - What's This button # - right spacer (10x10) # Main "button group" widget (but it is not a QButtonGroup). propMgr.pmTopRowBtns = QHBoxLayout() # Horizontal spacer HSpacer = QSpacerItem(1, 1, QSizePolicy.Expanding, QSizePolicy.Minimum) # Frame containing all the buttons. propMgr.TopRowBtnsFrame = QFrame() propMgr.TopRowBtnsFrame.setFrameShape(QFrame.NoFrame) propMgr.TopRowBtnsFrame.setFrameShadow(QFrame.Plain) # Create Hbox layout for main frame. TopRowBtnsHLayout = QHBoxLayout(propMgr.TopRowBtnsFrame) TopRowBtnsHLayout.setMargin(pmTopRowBtnsMargin) TopRowBtnsHLayout.setSpacing(pmTopRowBtnsSpacing) TopRowBtnsHLayout.addItem(HSpacer) # Set button type. buttonType = QToolButton # May want to use QToolButton.setAutoRaise(1) below. Mark 2007-05-29 # OK (Done) button. propMgr.done_btn = buttonType(propMgr.TopRowBtnsFrame) propMgr.done_btn.setIcon(geticon("ui/actions/Properties Manager/Done.png")) propMgr.done_btn.setIconSize(QSize(22, 22)) propMgr.connect(propMgr.done_btn, SIGNAL("clicked()"), propMgr.ok_btn_clicked) propMgr.done_btn.setToolTip("Done") TopRowBtnsHLayout.addWidget(propMgr.done_btn) # Cancel (Abort) button. propMgr.abort_btn = buttonType(propMgr.TopRowBtnsFrame) propMgr.abort_btn.setIcon( geticon("ui/actions/Properties Manager/Abort.png")) propMgr.abort_btn.setIconSize(QSize(22, 22)) propMgr.connect(propMgr.abort_btn, SIGNAL("clicked()"), propMgr.abort_btn_clicked) propMgr.abort_btn.setToolTip("Cancel") TopRowBtnsHLayout.addWidget(propMgr.abort_btn) # Restore Defaults button. propMgr.restore_defaults_btn = buttonType(propMgr.TopRowBtnsFrame) propMgr.restore_defaults_btn.setIcon( geticon("ui/actions/Properties Manager/Restore.png")) propMgr.restore_defaults_btn.setIconSize(QSize(22, 22)) propMgr.connect(propMgr.restore_defaults_btn, SIGNAL("clicked()"), propMgr.restore_defaults_btn_clicked) propMgr.restore_defaults_btn.setToolTip("Restore Defaults") TopRowBtnsHLayout.addWidget(propMgr.restore_defaults_btn) # Preview (glasses) button. propMgr.preview_btn = buttonType(propMgr.TopRowBtnsFrame) propMgr.preview_btn.setIcon( geticon("ui/actions/Properties Manager/Preview.png")) propMgr.preview_btn.setIconSize(QSize(22, 22)) propMgr.connect(propMgr.preview_btn, SIGNAL("clicked()"), propMgr.preview_btn_clicked) propMgr.preview_btn.setToolTip("Preview") TopRowBtnsHLayout.addWidget(propMgr.preview_btn) # What's This (?) button. propMgr.whatsthis_btn = buttonType(propMgr.TopRowBtnsFrame) propMgr.whatsthis_btn.setIcon( geticon("ui/actions/Properties Manager/WhatsThis.png")) propMgr.whatsthis_btn.setIconSize(QSize(22, 22)) propMgr.connect(propMgr.whatsthis_btn, SIGNAL("clicked()"), QWhatsThis.enterWhatsThisMode) propMgr.whatsthis_btn.setToolTip("What\'s This Help") TopRowBtnsHLayout.addWidget(propMgr.whatsthis_btn) TopRowBtnsHLayout.addItem(HSpacer) # Create Button Row propMgr.pmTopRowBtns.addWidget(propMgr.TopRowBtnsFrame) propMgr.pmVBoxLayout.addLayout(propMgr.pmTopRowBtns) # Add What's This for buttons. propMgr.done_btn.setWhatsThis("""<b>Done</b> <p><img source=\"ui/actions/Properties Manager/Done.png\"><br> Completes and/or exits the current command.</p>""") propMgr.abort_btn.setWhatsThis("""<b>Cancel</b> <p><img source=\"ui/actions/Properties Manager/Abort.png\"><br> Cancels the current command.</p>""") propMgr.restore_defaults_btn.setWhatsThis("""<b>Restore Defaults</b> <p><img source=\"ui/actions/Properties Manager/Restore.png\"><br> Restores the defaut values of the Property Manager.</p>""") propMgr.preview_btn.setWhatsThis("""<b>Preview</b> <p><img source=\"ui/actions/Properties Manager/Preview.png\"><br> Preview the structure based on current Property Manager settings.</p>""" ) propMgr.whatsthis_btn.setWhatsThis("""<b>What's This</b> <p><img source=\"ui/actions/Properties Manager/WhatsThis.png\"><br> Click this option to invoke a small question mark that is attached to the mouse pointer, then click on an object which you would like more information about. A pop-up box appears with information about the object you selected.</p>""" ) # Hide the buttons that shouldn't be displayed base on <showFlags>. if not showFlags & pmDoneButton: propMgr.done_btn.hide() if not showFlags & pmCancelButton: propMgr.abort_btn.hide() if not showFlags & pmRestoreDefaultsButton: propMgr.restore_defaults_btn.hide() if not showFlags & pmPreviewButton: propMgr.preview_btn.hide() if not showFlags & pmWhatsThisButton: propMgr.whatsthis_btn.hide() return
def __init__(self, parent=None): BasicSettings.__init__(self, parent) self.dictionaries_changed = False self.l = l = QFormLayout(self) self.setLayout(l) fc = FontFamilyChooser(self) self('editor_font_family', widget=fc, getter=attrgetter('font_family'), setter=lambda x, val: setattr(x, 'font_family', val)) fc.family_changed.connect(self.emit_changed) l.addRow(_('Editor font &family:'), fc) fs = self('editor_font_size') fs.setMinimum(8), fs.setSuffix(' pt'), fs.setMaximum(50) l.addRow(_('Editor font &size:'), fs) choices = self.theme_choices() theme = self.choices_widget('editor_theme', choices, 'auto', 'auto') self.custom_theme_button = b = QPushButton( _('Create/edit &custom color schemes')) b.clicked.connect(self.custom_theme) h = QHBoxLayout() h.addWidget(theme), h.addWidget(b) l.addRow(_('&Color scheme:'), h) l.labelForField(h).setBuddy(theme) tw = self('editor_tab_stop_width') tw.setMinimum(2), tw.setSuffix(_(' characters')), tw.setMaximum(20) l.addRow(_('Width of &tabs:'), tw) lw = self('editor_line_wrap') lw.setText(_('&Wrap long lines in the editor')) l.addRow(lw) lw = self('replace_entities_as_typed') lw.setText(_('&Replace HTML entities as they are typed')) lw.setToolTip('<p>' + _( 'With this option, every time you type in a complete html entity, such as &hellip;' ' it is automatically replaced by its corresponding character. The replacement' ' happens only when the trailing semi-colon is typed.')) l.addRow(lw) lw = self('editor_show_char_under_cursor') lw.setText( _('Show the name of the current character before the cursor along with the line and column number' )) l.addRow(lw) lw = self('pretty_print_on_open') lw.setText( _('Beautify individual files automatically when they are opened')) lw.setToolTip('<p>' + _( 'This will cause the beautify current file action to be performed automatically every' ' time you open a HTML/CSS/etc. file for editing.')) l.addRow(lw) lw = self('inline_spell_check') lw.setText(_('Show misspelled words underlined in the code view')) lw.setToolTip('<p>' + _( 'This will cause spelling errors to be highlighted in the code view' ' for easy correction as you type.')) l.addRow(lw) self.dictionaries = d = QPushButton(_('Manage &spelling dictionaries'), self) d.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) d.clicked.connect(self.manage_dictionaries) l.addRow(d)
def __init__(self, parent=None, desc=None, name=None, modal=0, fl=0, env=None, type="QDialog"): if env is None: import foundation.env as env # this is a little weird... probably it'll be ok, and logically it seems correct. self.desc = desc self.typ = type if type == "QDialog": QDialog.__init__(self, parent, name, modal, fl) elif type == "QTextEdit": QTextEdit.__init__(self, parent, name) elif type == "QFrame": QFrame.__init__(self, parent, name) else: print "don't know about type == %r" % (type, ) self.image1 = QPixmap() self.image1.loadFromData(image1_data, "PNG") # should be: title_icon #### self.image3 = QPixmap() self.image3.loadFromData(image3_data, "PNG") self.image4 = QPixmap() self.image4.loadFromData(image4_data, "PNG") self.image5 = QPixmap() self.image5.loadFromData(image5_data, "PNG") self.image6 = QPixmap() self.image6.loadFromData(image6_data, "PNG") self.image7 = QPixmap() self.image7.loadFromData(image7_data, "PNG") self.image0 = QPixmap(image0_data) # should be: border_icon #### self.image2 = QPixmap(image2_data) # should be: sponsor_pixmap #### try: ####@@@@ title_icon_name = self.desc.options.get('title_icon') border_icon_name = self.desc.options.get('border_icon') if title_icon_name: self.image1 = imagename_to_pixmap( title_icon_name) ###@@@ pass icon_path ###@@@ import imagename_to_pixmap or use env function # or let that func itself be an arg, or have an env arg for it ###e rename it icon_name_to_pixmap, or find_icon? (the latter only if it's ok if it returns an iconset) ###e use iconset instead? if border_icon_name: self.image0 = imagename_to_pixmap(border_icon_name) except: print_compact_traceback( "bug in icon-setting code, using fallback icons: ") pass if not name: self.setName("parameter_dialog_or_frame") ### ###k guess this will need: if type == 'QDialog' self.setIcon(self.image0) # should be: border_icon #### nanotube_dialogLayout = QVBoxLayout(self, 0, 0, "nanotube_dialogLayout") self.heading_frame = QFrame(self, "heading_frame") self.heading_frame.setPaletteBackgroundColor(QColor(122, 122, 122)) self.heading_frame.setFrameShape(QFrame.NoFrame) self.heading_frame.setFrameShadow(QFrame.Plain) heading_frameLayout = QHBoxLayout(self.heading_frame, 0, 3, "heading_frameLayout") self.heading_pixmap = QLabel(self.heading_frame, "heading_pixmap") self.heading_pixmap.setSizePolicy( QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed, 0, 0, self.heading_pixmap.sizePolicy().hasHeightForWidth())) self.heading_pixmap.setPixmap( self.image1) # should be: title_icon #### self.heading_pixmap.setScaledContents(1) heading_frameLayout.addWidget(self.heading_pixmap) self.heading_label = QLabel(self.heading_frame, "heading_label") self.heading_label.setPaletteForegroundColor(QColor(255, 255, 255)) heading_label_font = QFont(self.heading_label.font()) heading_label_font.setPointSize(12) heading_label_font.setBold(1) self.heading_label.setFont(heading_label_font) heading_frameLayout.addWidget(self.heading_label) nanotube_dialogLayout.addWidget(self.heading_frame) self.body_frame = QFrame(self, "body_frame") self.body_frame.setFrameShape(QFrame.StyledPanel) self.body_frame.setFrameShadow(QFrame.Raised) body_frameLayout = QVBoxLayout(self.body_frame, 3, 3, "body_frameLayout") self.sponsor_frame = QFrame(self.body_frame, "sponsor_frame") self.sponsor_frame.setPaletteBackgroundColor(QColor(255, 255, 255)) self.sponsor_frame.setFrameShape(QFrame.StyledPanel) self.sponsor_frame.setFrameShadow(QFrame.Raised) sponsor_frameLayout = QHBoxLayout(self.sponsor_frame, 0, 0, "sponsor_frameLayout") self.sponsor_btn = QPushButton(self.sponsor_frame, "sponsor_btn") self.sponsor_btn.setAutoDefault(0) #bruce 060703 bugfix self.sponsor_btn.setSizePolicy( QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred, 0, 0, self.sponsor_btn.sizePolicy().hasHeightForWidth())) self.sponsor_btn.setPaletteBackgroundColor(QColor(255, 255, 255)) self.sponsor_btn.setPixmap( self.image2 ) # should be: sponsor_pixmap #### [also we'll need to support >1 sponsor] self.sponsor_btn.setFlat(1) sponsor_frameLayout.addWidget(self.sponsor_btn) body_frameLayout.addWidget(self.sponsor_frame) layout59 = QHBoxLayout(None, 0, 6, "layout59") left_spacer = QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) layout59.addItem(left_spacer) self.done_btn = QToolButton(self.body_frame, "done_btn") self.done_btn.setIcon(QIcon(self.image3)) layout59.addWidget(self.done_btn) self.abort_btn = QToolButton(self.body_frame, "abort_btn") self.abort_btn.setIcon(QIcon(self.image4)) layout59.addWidget(self.abort_btn) self.preview_btn = QToolButton(self.body_frame, "preview_btn") self.preview_btn.setIcon(QIcon(self.image5)) layout59.addWidget(self.preview_btn) self.whatsthis_btn = QToolButton(self.body_frame, "whatsthis_btn") self.whatsthis_btn.setIcon(QIcon(self.image6)) layout59.addWidget(self.whatsthis_btn) right_spacer = QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) layout59.addItem(right_spacer) body_frameLayout.addLayout(layout59) self.groups = [] self.param_getters = { } # map from param name to get-function (which gets current value out of its widget or controller) for group_desc in self.desc.kids('group'): # == start parameters_grpbox ### this will differ for Windows style header_refs = [ ] # keep python refcounted refs to all objects we make (at least the ones pyuic stored in self attrs) self.parameters_grpbox = QGroupBox(self.body_frame, "parameters_grpbox") self.parameters_grpbox.setFrameShape(QGroupBox.StyledPanel) self.parameters_grpbox.setFrameShadow(QGroupBox.Sunken) self.parameters_grpbox.setMargin(0) self.parameters_grpbox.setColumnLayout(0, Qt.Vertical) self.parameters_grpbox.layout().setSpacing(1) self.parameters_grpbox.layout().setMargin(4) parameters_grpboxLayout = QVBoxLayout( self.parameters_grpbox.layout()) parameters_grpboxLayout.setAlignment(Qt.AlignTop) layout20 = QHBoxLayout(None, 0, 6, "layout20") self.nt_parameters_grpbtn = QPushButton(self.parameters_grpbox, "nt_parameters_grpbtn") self.nt_parameters_grpbtn.setSizePolicy( QSizePolicy( QSizePolicy.Minimum, QSizePolicy.Fixed, 0, 0, self.nt_parameters_grpbtn.sizePolicy().hasHeightForWidth()) ) self.nt_parameters_grpbtn.setMaximumSize(QSize(16, 16)) self.nt_parameters_grpbtn.setAutoDefault(0) self.nt_parameters_grpbtn.setIcon(QIcon( self.image7)) ### not always right, but doesn't matter self.nt_parameters_grpbtn.setFlat(1) layout20.addWidget(self.nt_parameters_grpbtn) self.parameters_grpbox_label = QLabel(self.parameters_grpbox, "parameters_grpbox_label") self.parameters_grpbox_label.setSizePolicy( QSizePolicy( QSizePolicy.Preferred, QSizePolicy.Minimum, 0, 0, self.parameters_grpbox_label.sizePolicy(). hasHeightForWidth())) self.parameters_grpbox_label.setAlignment(QLabel.AlignVCenter) layout20.addWidget(self.parameters_grpbox_label) gbx_spacer1 = QSpacerItem(67, 16, QSizePolicy.Expanding, QSizePolicy.Minimum) layout20.addItem(gbx_spacer1) parameters_grpboxLayout.addLayout(layout20) nt_parameters_body_layout = QGridLayout( None, 1, 1, 0, 6, "nt_parameters_body_layout" ) ### what is 6 -- is it related to number of items??? # is it 6 in all the ones we got, but that could be a designer error so i better look it up sometime. # == start its kids # will use from above: self.parameters_grpbox, nt_parameters_body_layout nextrow = 0 # which row of the QGridLayout to start filling next (loop variable) hidethese = [ ] # set of objects to hide or show, when this group is closed or opened for param in group_desc.kids('parameter'): # param (a group subobj desc) is always a parameter, but we already plan to extend this beyond that, # so we redundantly test for this here. getter = None paramname = None # set these for use by uniform code at the end (e.g. for tooltips) editfield = None label = None if param.isa('parameter'): label = QLabel(self.parameters_grpbox, "members_label") label.setAlignment(QLabel.AlignVCenter | QLabel.AlignRight) nt_parameters_body_layout.addWidget(label, nextrow, 0) hidethese.append(label) thisrow = nextrow nextrow += 1 #e following should be known in a place that knows the input language, not here paramname = param.options.get('name') or ( param.args and param.args[0]) or "?" paramlabel = param.options.get( 'label' ) or paramname ##e wrong, label "" or none ought to be possible # QtGui.QApplication.translate(self.__class__.__name__, "xyz") label.setText( QtGui.QApplication.translate(self.__class__.__name__, paramlabel)) if param.isa('parameter', widget='combobox', type=('str', None)): self.members_combox = QComboBox( 0, self.parameters_grpbox, "members_combox") ###k what's 0? editfield = self.members_combox #### it probably needs a handler class, and then that could do this setup self.members_combox.clear() default = param.options.get( 'default', None) # None is not equal to any string thewidgetkid = param.kids( 'widget' )[-1] # kluge; need to think what the desc method for this should be for item in thewidgetkid.kids('item'): itemval = item.args[0] itemtext = itemval self.members_combox.insertItem( QtGui.QApplication.translate( self.__class__.__name__, itemtext)) #k __tr ok?? if itemval == default: #k or itemtext? pass ##k i find no setItem in our py code, so not sure yet what to do for this. nt_parameters_body_layout.addWidget( self.members_combox, thisrow, 1) hidethese.append(self.members_combox) getter = (lambda combobox=self.members_combox: str( combobox.currentText())) ##e due to __tr or non-str values, it might be better to use currentIndex and look it up in a table # (though whether __tr is good here might depend on what it's used for) elif param.isa('parameter', widget=('lineedit', None), type=('str', None)): # this covers explicit str|lineedit, and 3 default cases str, lineedit, neither. # (i.e. if you say parameter and nothing else, it's str lineedit by default.) self.length_linedit = QLineEdit(self.parameters_grpbox, "length_linedit") editfield = self.length_linedit nt_parameters_body_layout.addWidget( self.length_linedit, thisrow, 1) hidethese.append(self.length_linedit) default = str(param.options.get('default', "")) self.length_linedit.setText( QtGui.QApplication.translate(self.__class__.__name__, default)) # __tr ok? getter = (lambda lineedit=self.length_linedit: str( lineedit.text())) elif param.isa('parameter', widget=('lineedit', None), type='float'): self.length_linedit = QLineEdit(self.parameters_grpbox, "length_linedit") editfield = self.length_linedit nt_parameters_body_layout.addWidget( self.length_linedit, thisrow, 1) hidethese.append(self.length_linedit) controller = FloatLineeditController_Qt( self, param, self.length_linedit) header_refs.append(controller) getter = controller.get_value elif param.isa('parameter', widget = ('spinbox', None), type = 'int') or \ param.isa('parameter', widget = ('spinbox'), type = None): self.chirality_N_spinbox = QSpinBox( self.parameters_grpbox, "chirality_N_spinbox" ) # was chirality_m_spinbox, now chirality_N_spinbox editfield = self.chirality_N_spinbox ### seems like Qt defaults for min and max are 0,100 -- way too small a range! if param.options.has_key('min') or 1: self.chirality_N_spinbox.setMinimum( param.options.get('min', -999999999)) # was 0 if param.options.has_key('max') or 1: self.chirality_N_spinbox.setMaximum( param.options.get( 'max', +999999999)) # wasn't in egcode, but needed self.chirality_N_spinbox.setValue( param.options.get('default', 0)) # was 5 ##e note: i suspect this default 0 should come from something that knows this desc grammar. suffix = param.options.get('suffix', '') if suffix: self.chirality_N_spinbox.setSuffix( QtGui.QApplication.translate( self.__class__.__name__, suffix)) else: self.chirality_N_spinbox.setSuffix( QString.null) # probably not needed nt_parameters_body_layout.addWidget( self.chirality_N_spinbox, thisrow, 1) hidethese.append(self.chirality_N_spinbox) getter = self.chirality_N_spinbox.value # note: it also has .text, which includes suffix else: print "didn't match:", param ###e improve this # things done the same way for all kinds of param-editing widgets if 1: #bruce 060703 moved this down here, as bugfix # set tooltip (same one for editfield and label) tooltip = param.options.get('tooltip', '') ###e do it for more kinds of params; share the code somehow; do it in controller, or setup-aid? ###k QToolTip appropriateness; tooltip option might be entirely untested if tooltip and label: QToolTip.add( label, QtGui.QApplication.translate( self.__class__.__name__, tooltip)) if tooltip and editfield: QToolTip.add( editfield, QtGui.QApplication.translate( self.__class__.__name__, tooltip) ) ##k ok?? review once not all params have same-row labels. if getter and paramname and paramname != '?': self.param_getters[paramname] = getter ### also bind these params to actions... continue # next param header_refs.extend([ self.parameters_grpbox, self.nt_parameters_grpbtn, self.parameters_grpbox_label ]) # now create the logic/control object for the group group = CollapsibleGroupController_Qt(self, group_desc, header_refs, hidethese, self.nt_parameters_grpbtn) ### maybe ask env for the class to use for this? self.groups.append( group ) ### needed?? only for scanning the params, AFAIK -- oh, and to maintain a python refcount. # from languageChange: if 1: # i don't know if these are needed: self.parameters_grpbox.setTitle(QString.null) self.nt_parameters_grpbtn.setText(QString.null) self.parameters_grpbox_label.setText( QtGui.QApplication.translate( self.__class__.__name__, group_desc.args[0])) # was "Nanotube Parameters" ##e note that it's questionable in the syntax design for this property of a group (overall group label) # to be in that position (desc arg 0). # == end its kids parameters_grpboxLayout.addLayout(nt_parameters_body_layout) body_frameLayout.addWidget(self.parameters_grpbox) # == end parameters groupbox continue # next group nanotube_dialogLayout.addWidget(self.body_frame) spacer14 = QSpacerItem(20, 20, QSizePolicy.Minimum, QSizePolicy.Expanding) nanotube_dialogLayout.addItem(spacer14) layout42 = QHBoxLayout(None, 4, 6, "layout42") btm_spacer = QSpacerItem(59, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) layout42.addItem(btm_spacer) self.cancel_btn = QPushButton(self, "cancel_btn") self.cancel_btn.setAutoDefault(0) #bruce 060703 bugfix layout42.addWidget(self.cancel_btn) self.ok_btn = QPushButton(self, "ok_btn") self.ok_btn.setAutoDefault(0) #bruce 060703 bugfix layout42.addWidget(self.ok_btn) nanotube_dialogLayout.addLayout(layout42) self.languageChange() self.resize( QSize(246, 618).expandedTo(self.minimumSizeHint()) ) ### this size will need to be adjusted (guess -- it's only place overall size is set) qt4todo('self.clearWState(Qt.WState_Polished)') ## self.connect(self.nt_parameters_grpbtn,SIGNAL("clicked()"),self.toggle_nt_parameters_grpbtn) #### # new: for button, methodname in ( (self.sponsor_btn, 'do_sponsor_btn'), #e generalize to more than one sponsor button (self.done_btn, 'do_done_btn'), (self.abort_btn, 'do_abort_btn'), (self.preview_btn, 'do_preview_btn'), (self.whatsthis_btn, 'do_whatsthis_btn'), (self.cancel_btn, 'do_cancel_btn'), (self.ok_btn, 'do_ok_btn')): if hasattr(self, methodname): self.connect(button, SIGNAL("clicked()"), getattr(self, methodname)) return
def __init__( self, parent=None, ): QDialog.__init__(self, parent) self.parent = parent self.setWindowTitle(u"{0} {1}: Create New eReader Key".format( PLUGIN_NAME, PLUGIN_VERSION)) layout = QVBoxLayout(self) self.setLayout(layout) data_group_box = QGroupBox(u"", self) layout.addWidget(data_group_box) data_group_box_layout = QVBoxLayout() data_group_box.setLayout(data_group_box_layout) key_group = QHBoxLayout() data_group_box_layout.addLayout(key_group) key_group.addWidget(QLabel(u"Unique Key Name:", self)) self.key_ledit = QLineEdit("", self) self.key_ledit.setToolTip( u"<p>Enter an identifying name for this new key.\nIt should be something that will help you remember what personal information was used to create it." ) key_group.addWidget(self.key_ledit) key_label = QLabel(_(''), self) key_label.setAlignment(Qt.AlignHCenter) data_group_box_layout.addWidget(key_label) name_group = QHBoxLayout() data_group_box_layout.addLayout(name_group) name_group.addWidget(QLabel(u"Your Name:", self)) self.name_ledit = QLineEdit(u"", self) self.name_ledit.setToolTip( u"Enter the name for this eReader key, usually the name on your credit card.\nIt will only be used to generate this one-time key and won\'t be stored anywhere in calibre or on your computer.\n(ex: Mr Jonathan Q Smith)" ) name_group.addWidget(self.name_ledit) name_disclaimer_label = QLabel( _(u"(Will not be saved in configuration data)"), self) name_disclaimer_label.setAlignment(Qt.AlignHCenter) data_group_box_layout.addWidget(name_disclaimer_label) ccn_group = QHBoxLayout() data_group_box_layout.addLayout(ccn_group) ccn_group.addWidget(QLabel(u"Credit Card#:", self)) self.cc_ledit = QLineEdit(u"", self) self.cc_ledit.setToolTip( u"<p>Enter the last 8 digits of credit card number for this eReader key.\nThey will only be used to generate this one-time key and won\'t be stored anywhere in calibre or on your computer." ) ccn_group.addWidget(self.cc_ledit) ccn_disclaimer_label = QLabel( _('(Will not be saved in configuration data)'), self) ccn_disclaimer_label.setAlignment(Qt.AlignHCenter) data_group_box_layout.addWidget(ccn_disclaimer_label) layout.addSpacing(10) self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.button_box.accepted.connect(self.accept) self.button_box.rejected.connect(self.reject) layout.addWidget(self.button_box) self.resize(self.sizeHint())
def __init__( self, parent=None, ): QDialog.__init__(self, parent) self.parent = parent self.setWindowTitle(u"{0} {1}: Create New Barnes & Noble Key".format( PLUGIN_NAME, PLUGIN_VERSION)) layout = QVBoxLayout(self) self.setLayout(layout) data_group_box = QGroupBox(u"", self) layout.addWidget(data_group_box) data_group_box_layout = QVBoxLayout() data_group_box.setLayout(data_group_box_layout) key_group = QHBoxLayout() data_group_box_layout.addLayout(key_group) key_group.addWidget(QLabel(u"Unique Key Name:", self)) self.key_ledit = QLineEdit("", self) self.key_ledit.setToolTip( _(u"<p>Enter an identifying name for this new key.</p>" + u"<p>It should be something that will help you remember " + u"what personal information was used to create it.")) key_group.addWidget(self.key_ledit) key_label = QLabel(_(''), self) key_label.setAlignment(Qt.AlignHCenter) data_group_box_layout.addWidget(key_label) name_group = QHBoxLayout() data_group_box_layout.addLayout(name_group) name_group.addWidget(QLabel(u"Your Name:", self)) self.name_ledit = QLineEdit(u"", self) self.name_ledit.setToolTip( _(u"<p>Enter your name as it appears in your B&N " + u"account or on your credit card.</p>" + u"<p>It will only be used to generate this " + u"one-time key and won\'t be stored anywhere " + u"in calibre or on your computer.</p>" + u"<p>(ex: Jonathan Smith)")) name_group.addWidget(self.name_ledit) name_disclaimer_label = QLabel( _(u"(Will not be saved in configuration data)"), self) name_disclaimer_label.setAlignment(Qt.AlignHCenter) data_group_box_layout.addWidget(name_disclaimer_label) ccn_group = QHBoxLayout() data_group_box_layout.addLayout(ccn_group) ccn_group.addWidget(QLabel(u"Credit Card#:", self)) self.cc_ledit = QLineEdit(u"", self) self.cc_ledit.setToolTip( _(u"<p>Enter the full credit card number on record " + u"in your B&N account.</p>" + u"<p>No spaces or dashes... just the numbers. " + u"This number will only be used to generate this " + u"one-time key and won\'t be stored anywhere in " + u"calibre or on your computer.")) ccn_group.addWidget(self.cc_ledit) ccn_disclaimer_label = QLabel( _('(Will not be saved in configuration data)'), self) ccn_disclaimer_label.setAlignment(Qt.AlignHCenter) data_group_box_layout.addWidget(ccn_disclaimer_label) layout.addSpacing(10) self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.button_box.accepted.connect(self.accept) self.button_box.rejected.connect(self.reject) layout.addWidget(self.button_box) self.resize(self.sizeHint())
def __init__(self, parent, key_type_name, plugin_keys, create_key, keyfile_ext=u""): QDialog.__init__(self, parent) self.parent = parent self.key_type_name = key_type_name self.plugin_keys = plugin_keys self.create_key = create_key self.keyfile_ext = keyfile_ext self.import_key = (keyfile_ext != u"") self.binary_file = (key_type_name == u"Adobe Digital Editions Key") self.json_file = (key_type_name == u"Kindle for Mac and PC Key") self.setWindowTitle("{0} {1}: Manage {2}s".format( PLUGIN_NAME, PLUGIN_VERSION, self.key_type_name)) # Start Qt Gui dialog layout layout = QVBoxLayout(self) self.setLayout(layout) help_layout = QHBoxLayout() layout.addLayout(help_layout) # Add hyperlink to a help file at the right. We will replace the correct name when it is clicked. help_label = QLabel('<a href="http://www.foo.com/">Help</a>', self) help_label.setTextInteractionFlags(Qt.LinksAccessibleByMouse | Qt.LinksAccessibleByKeyboard) help_label.setAlignment(Qt.AlignRight) help_label.linkActivated.connect(self.help_link_activated) help_layout.addWidget(help_label) keys_group_box = QGroupBox(_(u"{0}s".format(self.key_type_name)), self) layout.addWidget(keys_group_box) keys_group_box_layout = QHBoxLayout() keys_group_box.setLayout(keys_group_box_layout) self.listy = QListWidget(self) self.listy.setToolTip( u"{0}s that will be used to decrypt ebooks".format( self.key_type_name)) self.listy.setSelectionMode(QAbstractItemView.SingleSelection) self.populate_list() keys_group_box_layout.addWidget(self.listy) button_layout = QVBoxLayout() keys_group_box_layout.addLayout(button_layout) self._add_key_button = QtGui.QToolButton(self) self._add_key_button.setToolTip(u"Create new {0}".format( self.key_type_name)) self._add_key_button.setIcon(QIcon(I('plus.png'))) self._add_key_button.clicked.connect(self.add_key) button_layout.addWidget(self._add_key_button) self._delete_key_button = QtGui.QToolButton(self) self._delete_key_button.setToolTip(_(u"Delete highlighted key")) self._delete_key_button.setIcon(QIcon(I('list_remove.png'))) self._delete_key_button.clicked.connect(self.delete_key) button_layout.addWidget(self._delete_key_button) if type(self.plugin_keys) == dict: self._rename_key_button = QtGui.QToolButton(self) self._rename_key_button.setToolTip(_(u"Rename highlighted key")) self._rename_key_button.setIcon(QIcon(I('edit-select-all.png'))) self._rename_key_button.clicked.connect(self.rename_key) button_layout.addWidget(self._rename_key_button) self.export_key_button = QtGui.QToolButton(self) self.export_key_button.setToolTip( u"Save highlighted key to a .{0} file".format( self.keyfile_ext)) self.export_key_button.setIcon(QIcon(I('save.png'))) self.export_key_button.clicked.connect(self.export_key) button_layout.addWidget(self.export_key_button) spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) button_layout.addItem(spacerItem) layout.addSpacing(5) migrate_layout = QHBoxLayout() layout.addLayout(migrate_layout) if self.import_key: migrate_layout.setAlignment(Qt.AlignJustify) self.migrate_btn = QPushButton(u"Import Existing Keyfiles", self) self.migrate_btn.setToolTip( u"Import *.{0} files (created using other tools).".format( self.keyfile_ext)) self.migrate_btn.clicked.connect(self.migrate_wrapper) migrate_layout.addWidget(self.migrate_btn) migrate_layout.addStretch() self.button_box = QDialogButtonBox(QDialogButtonBox.Close) self.button_box.rejected.connect(self.close) migrate_layout.addWidget(self.button_box) self.resize(self.sizeHint())
def __init__(self, plugin): DefaultConfigWidget.__init__(self, plugin) c = plugin_prefs[STORE_NAME] all_tags = get_current_db().all_tags() self.gb.setMaximumHeight(80) genre_group_box = QGroupBox('Shelfari genre to calibre tag mappings', self) self.l.addWidget(genre_group_box, self.l.rowCount(), 0, 1, 2) genre_group_box_layout = QVBoxLayout() genre_group_box.setLayout(genre_group_box_layout) tags_layout = QHBoxLayout() genre_group_box_layout.addLayout(tags_layout) self.edit_table = GenreTagMappingsTableWidget(self, all_tags) tags_layout.addWidget(self.edit_table) button_layout = QVBoxLayout() tags_layout.addLayout(button_layout) add_mapping_button = QtGui.QToolButton(self) add_mapping_button.setToolTip('Add genre mapping') add_mapping_button.setIcon(QIcon(I('plus.png'))) add_mapping_button.clicked.connect(self.add_mapping) button_layout.addWidget(add_mapping_button) spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) button_layout.addItem(spacerItem1) remove_mapping_button = QtGui.QToolButton(self) remove_mapping_button.setToolTip('Delete genre mapping') remove_mapping_button.setIcon(QIcon(I('minus.png'))) remove_mapping_button.clicked.connect(self.delete_mapping) button_layout.addWidget(remove_mapping_button) spacerItem3 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) button_layout.addItem(spacerItem3) rename_genre_button = QtGui.QToolButton(self) rename_genre_button.setToolTip('Rename Goodreads genre') rename_genre_button.setIcon(QIcon(I('edit-undo.png'))) rename_genre_button.clicked.connect(self.rename_genre) button_layout.addWidget(rename_genre_button) spacerItem2 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) button_layout.addItem(spacerItem2) reset_defaults_button = QtGui.QToolButton(self) reset_defaults_button.setToolTip('Reset to plugin default mappings') reset_defaults_button.setIcon(QIcon(I('clear_left.png'))) reset_defaults_button.clicked.connect(self.reset_to_defaults) button_layout.addWidget(reset_defaults_button) self.l.setRowStretch(self.l.rowCount()-1, 2) other_group_box = QGroupBox('Other options', self) self.l.addWidget(other_group_box, self.l.rowCount(), 0, 1, 2) other_group_box_layout = QVBoxLayout() other_group_box.setLayout(other_group_box_layout) self.get_editions_checkbox = QCheckBox('Scan multiple editions for title/author searches (slower)', self) self.get_editions_checkbox.setToolTip('When checked will perform an additional search to scan the top ranked\n' 'Shelfari editions (if available) to exclude audiobook editions.\n' 'Without this enabled you will get a faster search, using the "best".\n' 'edition ranked by Shelfari which can in some cases be an audiobook.') self.get_editions_checkbox.setChecked(c[KEY_GET_EDITIONS]) other_group_box_layout.addWidget(self.get_editions_checkbox) self.all_authors_checkbox = QCheckBox('Get all contributing authors (e.g. illustrators, series editors etc)', self) self.all_authors_checkbox.setToolTip('Shelfari for some books will list all of the contributing authors and\n' 'the type of contribution like (Editor), (Illustrator) etc.\n\n' 'When this option is checked, all contributing authors are retrieved.\n\n' 'When unchecked (default) only the primary author(s) are returned which\n' 'are those that either have no contribution type specified, or have the\n' 'value of (Shelfari Author).\n\n' 'If there is no primary author then only those with the same contribution\n' 'type as the first author are returned.\n' 'e.g. "A, B (Illustrator)" will return author A\n' 'e.g. "A (Shelfari Author)" will return author A\n' 'e.g. "A (Editor), B (Editor), C (Illustrator)" will return authors A & B\n' 'e.g. "A (Editor), B (Series Editor)" will return author A\n') self.all_authors_checkbox.setChecked(c[KEY_GET_ALL_AUTHORS]) other_group_box_layout.addWidget(self.all_authors_checkbox) self.edit_table.populate_table(c[KEY_GENRE_MAPPINGS])
def __init__(self, parent, modal=True, flags=Qt.WindowFlags()): QDialog.__init__(self, parent, flags) self.setModal(modal) self.setWindowTitle("Convert sources to FITS brick") lo = QVBoxLayout(self) lo.setMargin(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()) QObject.connect(self.wadd, SIGNAL("toggled(bool)"), self.wpad.setEnabled) QObject.connect(self.wadd, SIGNAL("toggled(bool)"), 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(0, 0, 0, 0) lo2.setMargin(5) self.wokbtn = QPushButton("OK", self) self.wokbtn.setMinimumWidth(128) QObject.connect(self.wokbtn, SIGNAL("clicked()"), self.accept) self.wokbtn.setEnabled(False) cancelbtn = QPushButton("Cancel", self) cancelbtn.setMinimumWidth(128) QObject.connect(cancelbtn, SIGNAL("clicked()"), self.reject) lo2.addWidget(self.wokbtn) lo2.addStretch(1) lo2.addWidget(cancelbtn) self.setMinimumWidth(384) # signals QObject.connect(self.wfile, SIGNAL("filenameSelected"), self._fileSelected) # internal state self.qerrmsg = QErrorMessage(self)