def setupGUI(self): layout = QGridLayout() self.widget = QWidget() self.widget.setLayout(layout) self.setCentralWidget(self.widget) self.setWindowTitle("Nutch Job Service") # create active job list active_label = QLabel("Active Hadoop Jobs") layout.addWidget(active_label, 0, 0) self.lv = QListView() layout.addWidget(self.lv, 1, 0, 3, 1) # Create buttons self.stop_button = QPushButton("Stop") self.refresh_button = QPushButton("Refresh") button_layout = QVBoxLayout() button_layout.addWidget(self.stop_button) button_layout.addWidget(self.refresh_button) layout.addLayout(button_layout, 1, 1) # Start Button self.new_job_layout = QHBoxLayout() self.new_job_combo = QComboBox() self.new_job_combo.addItems(["Inject", "Generate", "Fetch", "Parse", "Solr"]) self.new_job_button = QPushButton("Start New Job") self.new_job_layout.addWidget(self.new_job_combo) self.new_job_layout.addWidget(self.new_job_button) layout.addLayout(self.new_job_layout, 5, 0) # self.statusBar() self.connectSlots()
def __init__(self, parent=None): super(SessionEditor, self).__init__(parent) self.setWindowModality(Qt.WindowModal) layout = QVBoxLayout() self.setLayout(layout) grid = QGridLayout() layout.addLayout(grid) self.name = QLineEdit() self.nameLabel = l = QLabel() l.setBuddy(self.name) grid.addWidget(l, 0, 0) grid.addWidget(self.name, 0, 1) self.autosave = QCheckBox() grid.addWidget(self.autosave, 1, 1) self.basedir = widgets.urlrequester.UrlRequester() self.basedirLabel = l = QLabel() l.setBuddy(self.basedir) grid.addWidget(l, 2, 0) grid.addWidget(self.basedir, 2, 1) layout.addWidget(widgets.Separator()) self.buttons = b = QDialogButtonBox(self) layout.addWidget(b) b.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) b.accepted.connect(self.accept) b.rejected.connect(self.reject) help.addButton(b, "sessions") app.translateUI(self)
def __init__(self, options, title, text, resultReceiver): QDialog.__init__(self) self.options = options self.resultReceiver = resultReceiver self.resize(250, 60) self.setWindowTitle(title) self.setModal(True) self.setSizeGripEnabled(False) label = QLabel(text) grid = QGridLayout() grid.setSpacing(10) grid.addWidget(label, 0, 0, 1, len(options)) position = 0 for option in options: button = QPushButton(option) receiver = lambda item = option: self.chooseOption(item) self.connect(button, SIGNAL('clicked()'), receiver) grid.addWidget(button, 1, position) position += 1 self.setLayout(grid) self.show()
class AboutDialog(QDialog): """ Common About Dialog for the Freeseer Project. This should be used for the about dialog when including one in GUIs. Grid Layout: Logo | About Infos ------|------------- | Close Button """ def __init__(self, parent=None): QWidget.__init__(self, parent) self.aboutWidget = AboutWidget() icon = QIcon() icon.addPixmap(QPixmap(_fromUtf8(":/freeseer/logo.png")), QIcon.Normal, QIcon.Off) self.setWindowIcon(icon) self.layout = QGridLayout() self.setLayout(self.layout) self.layout.addWidget(self.aboutWidget) # Right Bottom corner of grid, Close Button self.buttonBox = QDialogButtonBox() self.closeButton = self.buttonBox.addButton("Close", QDialogButtonBox.AcceptRole) self.layout.addWidget(self.buttonBox, 1, 1) self.connect(self.closeButton, SIGNAL("clicked()"), self.close) self.setWindowTitle("About Freeseer")
def __init__(self, width, height, parent=None): super(ResizeDlg, self).__init__(parent) widthLabel = QLabel("&Width:") self.widthSpinBox = QSpinBox() widthLabel.setBuddy(self.widthSpinBox) self.widthSpinBox.setAlignment(Qt.AlignRight|Qt.AlignVCenter) self.widthSpinBox.setRange(4, width * 4) self.widthSpinBox.setValue(width) heightLabel = QLabel("&Height:") self.heightSpinBox = QSpinBox() heightLabel.setBuddy(self.heightSpinBox) self.heightSpinBox.setAlignment(Qt.AlignRight| Qt.AlignVCenter) self.heightSpinBox.setRange(4, height * 4) self.heightSpinBox.setValue(height) buttonBox = QDialogButtonBox(QDialogButtonBox.Ok| QDialogButtonBox.Cancel) layout = QGridLayout() layout.addWidget(widthLabel, 0, 0) layout.addWidget(self.widthSpinBox, 0, 1) layout.addWidget(heightLabel, 1, 0) layout.addWidget(self.heightSpinBox, 1, 1) layout.addWidget(buttonBox, 2, 0, 1, 2) self.setLayout(layout) self.connect(buttonBox, SIGNAL("accepted()"), self.accept) self.connect(buttonBox, SIGNAL("rejected()"), self.reject) self.setWindowTitle("Image Changer - Resize")
def createKeypadPage(self): self.keypad_page = QWidget() self.keypad_page.setObjectName("keypad_page") self.keypad_page.setToolTip(QApplication.translate("option", "<b>Connect the keypad keys with custom actions</b>" "<p>Enter the text in the spaces to connect the correspondent key " "in order to use as a shortcut to send the text to the server.</p>")) page_layout = QGridLayout(self.keypad_page) page_layout.setSpacing(7) page_layout.setContentsMargins(10, 20, 0, 10) page_layout.setColumnMinimumWidth(0, 80) self.label_conn_keypad = QLabel() self.list_conn_keypad = QComboBox() self.createConnSection(page_layout, self.label_conn_keypad, self.list_conn_keypad, 1) page_layout.addWidget(self.createKeyPad(), 3, 0, 1, 1, Qt.AlignRight) self.addVerticalStretch(page_layout) self.save_keypad = QPushButton() self.save_keypad.setFixedHeight(28) self.save_keypad.setIcon(QIcon(":/images/button-save.png")) self.save_keypad.setText(QApplication.translate("option", "Save")) page_layout.addWidget(self.save_keypad, 4, 0, 1, 1, Qt.AlignRight) self.label_conn_keypad.setText(QApplication.translate("option", "Connection")) return self.keypad_page
class ViewAnimationForm(QWidget): def __init__(self, visualization, parent_widget = None): QWidget.__init__(self, parent_widget) self.inGui = False self.visualization = visualization size = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.widgetLayout = QGridLayout(self) self.setSizePolicy(size) self.scroll = QScrollArea() file_path = self.visualization.get_file_path() self.label = QLabel() movie = QMovie(QString(file_path), QByteArray(), self) movie.setCacheMode(QMovie.CacheAll) self.label.setMovie(movie) movie.start() self.scroll.setWidget(self.label) self.widgetLayout.addWidget(self.scroll) self.tabIcon = QIcon(":/Images/Images/map.png") self.tabLabel = visualization.table_name def removeElement(self): return True
def __init__(self, table_p, obj, parent, *args, **kwargs): QDialog.__init__(self, parent, *args, **kwargs) self.setWindowTitle("Confirmation de le suppression") self.title = FPageTitle("Voulez vous vraiment le supprimer?") self.obj = obj self.table_p = table_p self.parent = parent # self.title.setAlignment(Qt.AlignHCenter) title_hbox = QHBoxLayout() title_hbox.addWidget(self.title) report_hbox = QGridLayout() report_hbox.addWidget(FLabel(obj.display_name()), 0, 0) # delete and cancel hbox Button_hbox = QHBoxLayout() # Delete Button widget. delete_but = Button("Supprimer") Button_hbox.addWidget(delete_but) delete_but.clicked.connect(self.delete) # Cancel Button widget. cancel_but = Button("Annuler") Button_hbox.addWidget(cancel_but) cancel_but.clicked.connect(self.cancel) # Create the QVBoxLayout contenaire. vbox = QVBoxLayout() vbox.addLayout(title_hbox) vbox.addLayout(report_hbox) vbox.addLayout(Button_hbox) self.setLayout(vbox)
def __init__(self, page): super(Browser, self).__init__(page) layout = QGridLayout() self.setLayout(layout) self.languagesLabel = QLabel() self.languages = QComboBox(currentIndexChanged=self.changed) layout.addWidget(self.languagesLabel, 0, 0) layout.addWidget(self.languages, 0, 1) items = ['', ''] items.extend(language_names.languageName(l, l) for l in lilydoc.translations) self.languages.addItems(items) self.fontLabel = QLabel() self.fontChooser = QFontComboBox(currentFontChanged=self.changed) self.fontSize = QSpinBox(valueChanged=self.changed) self.fontSize.setRange(6, 32) self.fontSize.setSingleStep(1) layout.addWidget(self.fontLabel, 1, 0) layout.addWidget(self.fontChooser, 1, 1) layout.addWidget(self.fontSize, 1, 2) app.translateUI(self)
def __init__(self, manager): super(EditorDialog, self).__init__(manager.mainwin) self.mainwin = manager.mainwin self.sm = manager self.setButtons(KDialog.ButtonCode( KDialog.Help | KDialog.Ok | KDialog.Cancel)) self.setFaceType(KPageDialog.List) self.setHelp("sessions") # First page with name and auto-save option page = QWidget(self) item = self.firstPage = self.addPage(page, i18n("Session")) item.setHeader(i18n("Properties of this session")) item.setIcon(KIcon("configure")) layout = QGridLayout(page) l = QLabel(i18n("Name:")) self.name = QLineEdit() l.setBuddy(self.name) layout.addWidget(l, 0, 0) layout.addWidget(self.name, 0, 1) self.autosave = QCheckBox(i18n( "Always save the list of documents in this session")) layout.addWidget(self.autosave, 1, 1) l = QLabel(i18n("Base directory:")) self.basedir = KUrlRequester() self.basedir.setMode(KFile.Mode( KFile.Directory | KFile.ExistingOnly | KFile.LocalOnly)) l.setBuddy(self.basedir) layout.addWidget(l, 2, 0) layout.addWidget(self.basedir, 2, 1)
def createElectricalSimulationSettingsTab(self): widget = QWidget() layout = QtGui.QGridLayout() widget.setLayout(layout) layout.addWidget(QLabel('Simulation dt'), 0, 0) layout.addWidget(self.electricalSimulationDt, 0, 1) layout.addWidget(QLabel('Plot Update Interval'), 2, 0) layout.addWidget(self.electricalPlotUpdateInterval, 2, 1) layout.addWidget(QLabel('GUI Update Interval'), 3, 0) layout.addWidget(self.electricalGuiUpdateInterval, 3, 1) # layout.addWidget(QLabel('Default Runtime'), 4, 0) # layout.addWidget(self.electricalDefaultSimulationRuntime, 4, 1) # layout.addWidget(QLabel('Solver'), 5, 0) index = 0 for solver in self.electricalSolvers: # layout.addWidget(self.electricalSolvers[solver], 5 + index, 1) self.electricalSolver.addButton(self.electricalSolvers[solver], index) self.electricalSolvers[solver].setFocusPolicy(PyQt4.QtCore.Qt.NoFocus) index += 1 self.electricalSolver.setExclusive(True) buttonLayout = QGridLayout() layout.addLayout(buttonLayout, 5 + index, 1) buttonLayout.addWidget(self.electricalSimulationCancel, 0, 0, Qt.Qt.AlignRight) buttonLayout.addWidget(self.electricalSimulationApply, 0, 1, Qt.Qt.AlignLeft) return widget
def _build_field(self): #build option if self.option.is_compound: #make container container = QGroupBox(self.title, self.parent) container.setToolTip(self.option.formatted_desc) layout = QGridLayout(container) self._addRow(container, self.parent.layout()) #make option if not self.option.is_poly or self.value_required or self.field is not None: field = dict((opt.name, Field(opt, container)) for opt in self.option.options) self._add_or_set('container', container) self._add_or_set('field', field) #add +/- buttons if poly-option if self.option.is_poly: new_row = layout.rowCount() if self.field is not None and len(self.field) > int(self.value_required): del_button = QPushButton('-', container) del_button.setToolTip('Delete this %s' % self.title) del_option_gui = trigger(self._del_instance, self.field[-1], self.container[-1]) del_button.clicked.connect(del_option_gui) layout.addWidget(del_button, new_row, 0) add_button = QPushButton('+', container) add_button.setToolTip('Add another %s' % self.title) add_button.clicked.connect(self._add_instance) layout.addWidget(add_button, new_row, 1) else: field = self._make_simple_field(self.option, self.parent) self._add_or_set('field', field)
def __init__(self, modelRoot): super(NeuroKitVisualizer, self).__init__() layout = QGridLayout() self.toolbar = self.createToolbar() self.textEdit = self.createTextEdit() layout.addWidget(self.toolbar, 0, 0, 1, -1) layout.addWidget(self.textEdit, 1, 0, -1, -1)
class QuadHistogram(QWidget): '''A class which uses ColorHistogram to draw the 4 histograms of an image. R, G, B, and Value. The 4 histograms are layout out in a grid, and can be specified horizontal or vertical, and in which order ie. ['R', 'G', 'B', 'V'] ''' def __init__(self, img, layout='vertical', order=['R', 'G', 'B', 'V']): QWidget.__init__(self) r, g, b, v = histograms(img, 100) self.r_hist = ColorHistogram(r, (255, 0, 0)) self.g_hist = ColorHistogram(g, (0, 255, 0)) self.b_hist = ColorHistogram(b, (0, 0, 255)) self.v_hist = ColorHistogram(v, (0, 0, 0)) self.layout = QGridLayout(self) order_map = {'R': self.r_hist, 'G': self.g_hist, 'B': self.b_hist, 'V': self.v_hist} if layout=='vertical': for i in range(len(order)): self.layout.addWidget(order_map[order[i]], i, 0) elif layout=='horizontal': for i in range(len(order)): self.layout.addWidget(order_map[order[i]], 0, i) def update_hists(self, img): r, g, b, v = histograms(img, 100) self.r_hist.update_hist(r, (255, 0, 0)) self.g_hist.update_hist(g, (0, 255, 0)) self.b_hist.update_hist(b, (0, 0, 255)) self.v_hist.update_hist(v, (0, 0, 0))
def __init__(self, master): super(SmoothingControlItems, self).__init__() master.button_nosmooth = QPushButton('No Smoothing') master.button_lowsmooth = QPushButton('Low Smoothing') master.button_midsmooth = QPushButton('Medium Smoothing') master.button_highsmooth = QPushButton('High Smoothing') master.slider_xsmooth = QSlider(Qt.Horizontal) master.slider_ysmooth = QSlider(Qt.Horizontal) master.slider_zsmooth = QSlider(Qt.Horizontal) master.label_xsmooth = QLabel('') master.label_ysmooth = QLabel('') master.label_zsmooth = QLabel('') layout = QGridLayout() for index, button in enumerate((master.button_nosmooth, master.button_lowsmooth, master.button_midsmooth, master.button_highsmooth)): layout.addWidget(button, 1, index) layout.addWidget(master.label_xsmooth,0,index+1) layout.addWidget(master.label_ysmooth,0,index+2) layout.addWidget(master.label_zsmooth,0,index+3) layout.addWidget(master.slider_xsmooth,1,index+1) layout.addWidget(master.slider_ysmooth,1,index+2) layout.addWidget(master.slider_zsmooth,1,index+3) layout.setMargin(5) self.setLayout(layout)
def _clicked(self, point, button): if self.iface.activeLayer() is None: self.raise_message("no_active_layer") return # Prüfe, ob Punkt innerhalb des Features for feature in self.iface.activeLayer().getFeatures(): #Falls Punkt in Features if feature.geometry().contains(point): #hole gml_id try: gml_id = feature.attribute('gml_id') except KeyError: self.raise_message("no_gml_id_found") return break # ids = tuple(str(feature.attribute('gml_id')) for feature in selected_features) result = self._get_fsn_from_gml_id(gml_id) html = self._build_html(result[0]['flsnr']) parent = QDialog() parent.setWindowTitle(u"Eigentümerinformationen") parent.setParent(self.iface.mainWindow()) parent.setWindowFlags(QtCore.Qt.Window) textview = QTextEdit() textview.setReadOnly(True) textview.setText(html) layout = QGridLayout(parent) layout.addWidget(textview) parent.resize(500, 600) parent.show()
def __init__(self, master): super(ViewControlItems, self).__init__() nbuttons = 10 master.button_view = [QPushButton() for i in range(nbuttons)] self.label_view = QLabel("View") self.label_roll = QLabel("Roll") buttontext = ["XY", "YZ", "ZX", "-XY", "-YZ", "-ZX", "0", "90", "180", "270"] layout = QGridLayout() for index in range(nbuttons): master.button_view[index].setText(buttontext[index]) master.button_view[index].setObjectName('button_view%d' % index) layout.addWidget(master.button_view[index], 1, index) layout.addWidget(self.label_view,0,0) layout.addWidget(self.label_roll,0,6) layout.setMargin(5) layout.setHorizontalSpacing(5) layout.setVerticalSpacing(0) self.setLayout(layout)
def __init__( self, wizard, title, fields ): ## construct a new QWizardPage QWizardPage.__init__( self, wizard ) self.wizard = wizard ## this will store widgets created from fields self.widgets = {} self.setTitle( title ) layout = QGridLayout( self ) self.setLayout( layout ) ## create and add widget for each field at this page ## for each field we add a label with it's name and the widget ## describing the field ## @sa Field i = 0 for field in fields: item = Field( self, field.name, field.value, field.extra ) self.widgets[field.name] = item self.widgets[field.name].id = i if not callable( field.value ): label = QLabel( field.name.replace( '_', ' ' ) ) layout.addWidget( label, i , 0 ) layout.addWidget( self.widgets[field.name].widget, i, 1 ) i+=1
class StrokesWatcher(QWidget): """Main module's widget""" def __init__(self, path): super(StrokesWatcher, self).__init__() self.path = path self.strokes_order, letters = get_letters(path) self.setup_ui() self.stroke_list = StrokeList(letters, self.strokes_order, self.display) self.letter_selector.setModel(self.stroke_list.keys_model) self.list_view.setModel(self.stroke_list) self.letter_selector.currentIndexChanged.connect(self.select_letter) self.set_letter_btn.clicked.connect(self.change_letter) def change_letter(self): new_key = str(self.letter_edt.text()) indexes = self.list_view.selectedIndexes() if new_key and indexes: new_key = new_key[0] self.stroke_list.change_stroke_key(indexes[0], new_key, self.path) def select_letter(self): # set stroke_list key_letter to the one # choosen by letter_selector new_letter = self.letter_selector.currentText() self.stroke_list.set_key_letter(new_letter) def setup_ui(self): self.resize(800, 480) self.grid = QGridLayout(self) self.display = pg.PlotWidget(name='st', background='w') add_circles(self.display, (1, 2)) self.grid.addWidget(self.display, 0, 0, 2, 2) self.display.getViewBox().setXRange(-np.pi, np.pi) self.display.getViewBox().setYRange(-np.pi / 2, np.pi / 2) self.display.getViewBox().setAspectLocked() self.list_view = QListView(self) self.grid.addWidget(self.list_view, 0, 2, 1, 2) self.letter_selector = QComboBox(self) self.grid.addWidget(self.letter_selector, 1, 2, 1, 2) self.letter_edt = QLineEdit(self) self.grid.addWidget(self.letter_edt, 2, 2, 1, 1) self.set_letter_btn = QPushButton(self) self.set_letter_btn.setText('Set') self.grid.addWidget(self.set_letter_btn, 2, 3, 1, 1)
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)
def __init__(self, address=None, parent=None): super(Dialog, self).__init__(parent) self.street = LabelledLineEdit("&Street:") self.city = LabelledLineEdit("&City:") self.state = LabelledLineEdit("St&ate:") self.zipcode = LabelledLineEdit("&Zipcode:") self.notes = LabelledTextEdit("&Notes:", ABOVE) if address is not None: self.street.lineEdit.setText(address.get("street", QString())) self.city.lineEdit.setText(address.get("city", QString())) self.state.lineEdit.setText(address.get("state", QString())) self.zipcode.lineEdit.setText(address.get("zipcode", QString())) self.notes.textEdit.setPlainText(address.get("notes", QString())) buttonBox = QDialogButtonBox(QDialogButtonBox.Ok| QDialogButtonBox.Cancel) grid = QGridLayout() grid.addWidget(self.street, 0, 0) grid.addWidget(self.city, 0, 1) grid.addWidget(self.state, 1, 0) grid.addWidget(self.zipcode, 1, 1) grid.addWidget(self.notes, 2, 0, 1, 2) layout = QVBoxLayout() layout.addLayout(grid) layout.addWidget(buttonBox) self.setLayout(layout) self.connect(buttonBox, SIGNAL("accepted()"), self.accept) self.connect(buttonBox, SIGNAL("rejected()"), self.reject) self.setWindowTitle("Labelled Widgets")
def __init__(self, parent): self.parent = parent self.parent.setAttribute(Qt.WA_DeleteOnClose) text = QPlainTextEdit(self.parent) lineNumbers = QPlainTextEdit(self.parent) lineNumbers.setMaximumWidth(20) lineNumbers.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) lineNumbers.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) lineNumbers.setFrameShape(QFrame.StyledPanel) lineNumbers.setFrameShadow(QFrame.Plain) lineNumbers.setEnabled(False) grid = QGridLayout(self.parent) grid.addWidget(lineNumbers, 0, 0, 1, 1) grid.addWidget(text, 0, 1, 1, 1) text.blockCountChanged.connect(self.parent.setLineNumbers) text.updateRequest.connect(self.parent.scrollLineNumbers) text.cursorPositionChanged.connect(self.parent.highlightCurrentLine) text.document().contentsChanged.connect(self.parent.documentModified) self.parent.text = text self.parent.lineNumbers = lineNumbers
def __init__(self, parent=None): super(CreditCard, self).__init__(parent) fileLabel = QLabel("Excel files:") self.fileList = FileList(self) self.connect(self.fileList, QtCore.SIGNAL("dropped"), self.fileDrop) self.cashdepo = QPushButton("&Cash Depo") self.cashdepo.show() self.crediCard = QPushButton("C&redit Card") self.crediCard.show() self.cashdepo.clicked.connect(self.getCashDepo) self.crediCard.clicked.connect(self.getCreditCard) buttonLayout1 = QVBoxLayout() buttonLayout1.addWidget(self.cashdepo, QtCore.Qt.AlignTop) buttonLayout1.addWidget(self.crediCard) buttonLayout1.addStretch() mainLayout = QGridLayout() mainLayout.addWidget(fileLabel, 0, 0) mainLayout.addWidget(self.fileList, 1, 0) mainLayout.addLayout(buttonLayout1, 1, 1) self.setLayout(mainLayout) self.setWindowTitle("Credit Card & Cash Depo XL")
def main(): """Main function to run the example.""" app = QApplication([]) default_value_parameter = DefaultValueParameter() default_value_parameter.name = 'Value parameter' default_value_parameter.help_text = 'Help text' default_value_parameter.description = 'Description' default_value_parameter.labels = [ 'Setting', 'Do not report', 'Custom'] default_value_parameter.options = [0, 1, None] parameters = [ default_value_parameter ] extra_parameters = [ (DefaultValueParameter, DefaultValueParameterWidget) ] parameter_container = ParameterContainer( parameters, extra_parameters=extra_parameters) parameter_container.setup_ui() widget = QWidget() layout = QGridLayout() layout.addWidget(parameter_container) widget.setLayout(layout) widget.setGeometry(0, 0, 500, 500) widget.show() sys.exit(app.exec_())
def __init__(self, client, parent): ScrollArea.__init__(self) self.client = client self.mainwindow = parent self._modified = False self.error_message = '' self.config = None frame = QFrame(self) layout = QGridLayout(frame) title = QLabel(u'<H1>%s</H1>' % tr('Contact Configuration')) layout.addWidget(title, 0, 0) self.admin_mail = self.buildAdminMail(layout, 1, 0) self.sender_mail = self.buildSenderMail(layout, 2, 0) self.smarthost_group, self.use_smarthost, self.mail_relay = \ self.buildOutgoing(layout, 3, 0) self.language = self.buildChooseLanguage(layout, 4, 0) self.buildTestMail(layout, 5, 0) layout.setRowStretch(6, 15) self.setWidget(frame) self.setWidgetResizable(True) self.resetConf() self.mainwindow.addToInfoArea(tr('Contact interface enabled'))
def add_color_legend(self, legend, show_option=None): """ Create a legend on the right of the plots with colors and names. :param sequence legend: List of (color, text) tuples, where `color` is a Qt color name (e.g. '#ff0000') and `text` is the corresponding text to display in the legend. :param bool show_option: Determines whether a toggle for the legend will be shown (if the parameter is not ``None``) and if the legend is visible initially (``True``/``False``). """ widget = QWidget(self) layout = QGridLayout(widget) widget.setLayout(layout) for l in legend: label = QtGui.QLabel(self) label.setStyleSheet('background-color:' + str(l[0])) label.setFrameShape(QFrame.StyledPanel) label.setMaximumWidth(80) label.setMaximumHeight(12) layout.addWidget(label, layout.rowCount(), 0, 1, 1) label = QtGui.QLabel(self) label.setText(l[1]) layout.addWidget(label, layout.rowCount()-1, 1, 1, 1) self.plot_layout.addWidget(widget, 0, self.plot_layout.columnCount(), -1, 1) if show_option is not None: widget.setVisible(show_option) self.add_option('Show legend sidebar', lambda w,s : widget.setVisible(s), show_option)
def __init__(self, strip, parent=None): super(LEDDialog,self).__init__(parent) self.strip = strip self.buttons = [] layout = QVBoxLayout() btnlayout = QGridLayout() self.btnmapper = QSignalMapper() for i in xrange(int(self.strip.config['nleds'])): p = QPushButton() p.setFixedWidth(40) p.setFlat(True) p.setAutoFillBackground(True) self.btnmapper.setMapping( p, i) p.clicked.connect( self.btnmapper.map) self.buttons += [[p,QColor()]] btnlayout.addWidget(p, i/self.rowwidth, i%self.rowwidth) self.btnmapper.mapped['int'].connect(self.chooseColor) layout.addLayout(btnlayout) ctrllayout = QHBoxLayout() p = QPushButton("Refresh") p.clicked.connect(self.refresh) ctrllayout.addWidget(p) p = QPushButton("Set") p.clicked.connect(self.set) ctrllayout.addWidget(p) p = QPushButton("Close") p.clicked.connect(self.close) ctrllayout.addWidget(p) layout.addLayout(ctrllayout) self.setLayout( layout) self.refresh()
class EditPane(QWidget): def __init__(self, model): QWidget.__init__(self) self._setupUi() self.model = model self.model.view = self self.normalButton.clicked.connect(partial(self.model.app.change_state_of_selected, ElementState.Normal)) self.titleButton.clicked.connect(partial(self.model.app.change_state_of_selected, ElementState.Title)) self.footnoteButton.clicked.connect(partial(self.model.app.change_state_of_selected, ElementState.Footnote)) self.ignoreButton.clicked.connect(partial(self.model.app.change_state_of_selected, ElementState.Ignored)) self.tofixButton.clicked.connect(partial(self.model.app.change_state_of_selected, ElementState.ToFix)) self.hideIgnoredCheckBox.stateChanged.connect(self.hideIgnoredCheckBoxStateChanged) self.textEdit.textChanged.connect(self.textEditTextChanged) self.saveEditsButton.clicked.connect(self.model.save_edits) self.cancelEditsButton.clicked.connect(self.model.cancel_edits) def _setupUi(self): self.mainLayout = QVBoxLayout(self) self.buttonLayout = QGridLayout() self.normalButton = QPushButton("Normal") self.buttonLayout.addWidget(self.normalButton, 0, 0) self.titleButton = QPushButton("Title") self.buttonLayout.addWidget(self.titleButton, 1, 0) self.footnoteButton = QPushButton("Footnote") self.buttonLayout.addWidget(self.footnoteButton, 2, 0) self.ignoreButton = QPushButton("Ignore") self.buttonLayout.addWidget(self.ignoreButton, 0, 1) self.tofixButton = QPushButton("To Fix") self.buttonLayout.addWidget(self.tofixButton, 1, 1) self.mainLayout.addLayout(self.buttonLayout) self.rightLayout = QVBoxLayout() self.hideIgnoredCheckBox = QCheckBox("Hide Ignored Elements") self.rightLayout.addWidget(self.hideIgnoredCheckBox) self.textEdit = QTextEdit() self.textEdit.setAcceptRichText(False) self.rightLayout.addWidget(self.textEdit) self.editButtonLayout = QHBoxLayout() self.editButtonLayout.addItem(horizontalSpacer()) self.saveEditsButton = QPushButton("Save") self.editButtonLayout.addWidget(self.saveEditsButton) self.cancelEditsButton = QPushButton("Cancel") self.editButtonLayout.addWidget(self.cancelEditsButton) self.rightLayout.addLayout(self.editButtonLayout) self.mainLayout.addLayout(self.rightLayout) #--- Signals def hideIgnoredCheckBoxStateChanged(self, state): self.model.app.hide_ignored = state == Qt.Checked def textEditTextChanged(self): self.model.edit_text = self.textEdit.toPlainText() #--- model -> view def refresh_edit_text(self): self.textEdit.setText(self.model.edit_text) self.textEdit.setEnabled(self.model.edit_enabled) self.saveEditsButton.setEnabled(self.model.edit_enabled) self.cancelEditsButton.setEnabled(self.model.edit_enabled)
def __init__(self, path, parent=None): super(LineEditDialog, self).__init__(parent) self.path = path # newPage/newSubpage if parent.objectName() in ["mikiWindow", "notesTree"]: editorLabel = QLabel("Page Name:") self.extNames = [".md", ".markdown", ".mkd"] # Copy Image to notesEdit elif parent.objectName() == "notesEdit": editorLabel = QLabel("File Name:") self.extNames = ["", ".jpg"] else: return self.editor = QLineEdit() editorLabel.setBuddy(self.editor) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) layout = QGridLayout() layout.addWidget(editorLabel, 0, 0) layout.addWidget(self.editor, 0, 1) layout.addWidget(self.buttonBox, 1, 1) self.setLayout(layout) self.editor.textEdited.connect(self.updateUi) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject)
def set_layouts(self): assert object_thread( self ) self._vlayout = QVBoxLayout() self._vlayout.setSpacing(0) self._vlayout.setContentsMargins(0,0,0,0) # needed in case we have a widget that changes the size # of the widget and can be hidden # this prevents the ChangeObjects dialog from being scaleable, # therefor commented out #self._vlayout.setSizeConstraint(QLayout.SetFixedSize) banner_layout = QGridLayout() banner_layout.setColumnStretch(0, 1) banner_layout.addWidget(QLabel(), 0, 1, Qt.AlignRight) banner_layout.addLayout(QVBoxLayout(), 0, 0) # TODO: allow banner widget to be supplied banner_widget = QWidget() banner_widget.setLayout(banner_layout) self._vlayout.addWidget(banner_widget) self._vlayout.addWidget(HSeparator()) self._vlayout.addWidget(QFrame(), 1) self._vlayout.addWidget(HSeparator()) self._vlayout.addWidget(QWidget()) self.setLayout(self._vlayout)
def __init__(self, mainwindow): super(Dialog, self).__init__(mainwindow) self._document = None layout = QGridLayout() self.setLayout(layout) self.versionLabel = QLabel() self.lilyChooser = lilychooser.LilyChooser() self.outputLabel = QLabel() self.outputCombo = QComboBox() self.resolutionLabel = QLabel() self.resolutionCombo = QComboBox(editable=True) self.antialiasLabel = QLabel() self.antialiasSpin = QSpinBox(minimum=1, maximum=128, value=1) self.modeLabel = QLabel() self.modeCombo = QComboBox() self.englishCheck = QCheckBox() self.deleteCheck = QCheckBox() self.commandLineLabel = QLabel() self.commandLine = QTextEdit(acceptRichText=False) self.buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.buttons.button(QDialogButtonBox.Ok).setIcon( icons.get("lilypond-run")) userguide.addButton(self.buttons, "engrave_custom") self.resolutionCombo.addItems(['100', '200', '300', '600', '1200']) self.resolutionCombo.setCurrentIndex(2) self.modeCombo.addItems(['preview', 'publish', 'debug']) layout.addWidget(self.versionLabel, 0, 0) layout.addWidget(self.lilyChooser, 0, 1, 1, 3) layout.addWidget(self.outputLabel, 1, 0) layout.addWidget(self.outputCombo, 1, 1, 1, 3) layout.addWidget(self.resolutionLabel, 2, 0) layout.addWidget(self.resolutionCombo, 2, 1) layout.addWidget(self.antialiasLabel, 2, 2, Qt.AlignRight) layout.addWidget(self.antialiasSpin, 2, 3) layout.addWidget(self.modeLabel, 3, 0) layout.addWidget(self.modeCombo, 3, 1, 1, 3) layout.addWidget(self.englishCheck, 4, 0, 1, 4) layout.addWidget(self.deleteCheck, 5, 0, 1, 4) layout.addWidget(self.commandLineLabel, 6, 0, 1, 4) layout.addWidget(self.commandLine, 7, 0, 1, 4) layout.addWidget(widgets.Separator(), 8, 0, 1, 4) layout.addWidget(self.buttons, 9, 0, 1, 4) app.translateUI(self) qutil.saveDialogSize(self, "engrave/custom/dialog/size", QSize(480, 260)) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) model = listmodel.ListModel(formats, display=lambda f: f.title(), icon=lambda f: icons.file_type(f.type)) self.outputCombo.setModel(model) s = QSettings() s.beginGroup("lilypond_settings") self.englishCheck.setChecked(s.value("no_translation", False, bool)) self.deleteCheck.setChecked( s.value("delete_intermediate_files", True, bool)) if s.value("default_output_target", "pdf", type("")) == "svg": self.outputCombo.setCurrentIndex(3) app.jobFinished.connect(self.slotJobFinished) self.outputCombo.currentIndexChanged.connect(self.makeCommandLine) self.modeCombo.currentIndexChanged.connect(self.makeCommandLine) self.deleteCheck.toggled.connect(self.makeCommandLine) self.resolutionCombo.editTextChanged.connect(self.makeCommandLine) self.antialiasSpin.valueChanged.connect(self.makeCommandLine) self.makeCommandLine() panelmanager.manager( mainwindow).layoutcontrol.widget().optionsChanged.connect( self.makeCommandLine)
def __init__(self, parent, enable_replace=False): QWidget.__init__(self, parent) self.enable_replace = enable_replace self.editor = None glayout = QGridLayout() glayout.setContentsMargins(0, 0, 0, 0) self.setLayout(glayout) self.close_button = create_toolbutton( self, triggered=self.hide, icon=get_std_icon("DialogCloseButton")) glayout.addWidget(self.close_button, 0, 0) # Find layout self.search_text = PatternComboBox(self, tip=self.tr("Search string"), adjust_to_minimum=False) self.connect(self.search_text, SIGNAL("editTextChanged(QString)"), self.text_has_changed) self.previous_button = create_toolbutton( self, text=self.tr("Previous"), triggered=self.find_previous, icon=get_std_icon("ArrowBack")) self.next_button = create_toolbutton(self, text=self.tr("Next"), triggered=self.find_next, icon=get_std_icon("ArrowForward")) self.connect(self.next_button, SIGNAL('clicked()'), self.update_search_combo) self.connect(self.previous_button, SIGNAL('clicked()'), self.update_search_combo) self.case_check = QCheckBox(self.tr("Case Sensitive")) self.connect(self.case_check, SIGNAL("stateChanged(int)"), self.find) self.words_check = QCheckBox(self.tr("Whole words")) self.connect(self.words_check, SIGNAL("stateChanged(int)"), self.find) hlayout = QHBoxLayout() self.widgets = [ self.close_button, self.search_text, self.previous_button, self.next_button, self.case_check, self.words_check ] for widget in self.widgets[1:]: hlayout.addWidget(widget) glayout.addLayout(hlayout, 0, 1) # Replace layout replace_with1 = QLabel(self.tr("Replace")) replace_with2 = QLabel() font = replace_with2.font() font.setBold(True) replace_with2.setFont(font) replace_with3 = QLabel(self.tr("with:")) self.replace_text = PatternComboBox(self, adjust_to_minimum=False, tip=self.tr("Replace string")) self.replace_button = create_toolbutton( self, text=self.tr("Replace/find"), triggered=self.replace_find, icon=get_std_icon("DialogApplyButton")) self.connect(self.replace_button, SIGNAL('clicked()'), self.update_replace_combo) self.connect(self.replace_button, SIGNAL('clicked()'), self.update_search_combo) self.all_check = QCheckBox(self.tr("Replace all")) self.replace_layout = QHBoxLayout() widgets = [ replace_with1, replace_with2, replace_with3, self.replace_text, self.replace_button, self.all_check ] for widget in widgets: self.replace_layout.addWidget(widget) self.connect(self.search_text, SIGNAL("editTextChanged(QString)"), replace_with2, SLOT("setText(QString)")) glayout.addLayout(self.replace_layout, 1, 1) self.widgets.extend(widgets) self.replace_widgets = widgets self.hide_replace() self.search_text.setTabOrder(self.search_text, self.replace_text) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
def __init__(self, parent): super(InstrumentNames, self).__init__(parent, checkable=True, checked=True) grid = QGridLayout() self.setLayout(grid) self.firstSystemLabel = QLabel() self.firstSystem = QComboBox() self.firstSystemLabel.setBuddy(self.firstSystem) self.otherSystemsLabel = QLabel() self.otherSystems = QComboBox() self.otherSystemsLabel.setBuddy(self.otherSystems) self.languageLabel = QLabel() self.language = QComboBox() self.languageLabel.setBuddy(self.language) self.firstSystem.setModel( listmodel.ListModel((lambda: _("Long"), lambda: _("Short")), self.firstSystem, display=listmodel.translate)) self.otherSystems.setModel( listmodel.ListModel( (lambda: _("Long"), lambda: _("Short"), lambda: _("None")), self.otherSystems, display=listmodel.translate)) self._langs = l = ['', 'C'] l.extend(sorted(po.available())) def display(lang): if lang == 'C': return _("English (untranslated)") elif not lang: return _("Default") return language_names.languageName(lang, po.setup.current()) self.language.setModel( listmodel.ListModel(l, self.language, display=display)) grid.addWidget(self.firstSystemLabel, 0, 0) grid.addWidget(self.firstSystem, 0, 1) grid.addWidget(self.otherSystemsLabel, 1, 0) grid.addWidget(self.otherSystems, 1, 1) grid.addWidget(self.languageLabel, 2, 0) grid.addWidget(self.language, 2, 1) app.translateUI(self) self.loadSettings() self.window().finished.connect(self.saveSettings)
def main(): """Main function to run the example.""" app = QApplication([]) options = OrderedDict([ (DO_NOT_USE, { 'label': 'Do not use', 'value': None, 'type': STATIC, 'constraint': {} }), (GLOBAL_DEFAULT, { 'label': 'Global default', 'value': 0.5, 'type': STATIC, 'constraint': {} }), ( CUSTOM_VALUE, { 'label': 'Custom', 'value': 0.7, # Taken from keywords / recent value 'type': SINGLE_DYNAMIC, 'constraint': { 'min': 0, 'max': 1 } }), ( FIELDS, { 'label': 'Ratio fields', 'value': ['field A', 'field B', 'field C'], # Taken from keywords 'type': MULTIPLE_DYNAMIC, 'constraint': {} }) ]) default_value_parameter = GroupSelectParameter() default_value_parameter.name = 'Group Select parameter' default_value_parameter.help_text = 'Help text' default_value_parameter.description = 'Description' default_value_parameter.options = options default_value_parameter.selected = 'ratio fields' parameters = [default_value_parameter] extra_parameters = [(GroupSelectParameter, GroupSelectParameterWidget)] parameter_container = ParameterContainer(parameters, extra_parameters=extra_parameters) parameter_container.setup_ui() widget = QWidget() layout = QGridLayout() layout.addWidget(parameter_container) widget.setLayout(layout) widget.setGeometry(0, 0, 500, 500) widget.show() sys.exit(app.exec_())
def __init__(self, dockwidget): super(Widget, self).__init__(dockwidget) self._document = None self._midiin = midiinput.MidiIn(self) self._dockwidget = weakref.ref(dockwidget) signals = list() self._labelmidichannel = QLabel() self._midichannel = QComboBox() signals.append(self._midichannel.currentIndexChanged) self._labelkeysignature = QLabel() self._keysignature = QComboBox() signals.append(self._keysignature.currentIndexChanged) self._labelaccidentals = QLabel() self._accidentalssharps = QRadioButton() signals.append(self._accidentalssharps.clicked) self._accidentalsflats = QRadioButton() signals.append(self._accidentalsflats.clicked) self._groupaccidentals = QGroupBox() self._groupaccidentals.setFlat(True) hbox = QHBoxLayout() self._groupaccidentals.setLayout(hbox) hbox.addWidget(self._accidentalssharps) hbox.addWidget(self._accidentalsflats) self._accidentalssharps.setChecked(True) self._chordmode = QCheckBox() signals.append(self._chordmode.clicked) self._relativemode = QCheckBox() signals.append(self._relativemode.clicked) self._labeldamper = QLabel() self._damper = QComboBox() self._labelsostenuto = QLabel() self._sostenuto = QComboBox() self._labelsoft = QLabel() self._soft = QComboBox() ac = self.parentWidget().actionCollection self._capture = QToolButton() self._capture.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self._capture.setDefaultAction(ac.capture_start) self._notemode = QLabel() layout = QVBoxLayout() self.setLayout(layout) grid = QGridLayout(spacing=0) layout.addLayout(grid) grid.addWidget(self._labelmidichannel, 0, 0) grid.addWidget(self._midichannel, 0, 1) grid.addWidget(self._labelkeysignature, 1, 0) grid.addWidget(self._keysignature, 1, 1) grid.addWidget(self._labelaccidentals, 2, 0) grid.addWidget(self._groupaccidentals, 2, 1) grid.addWidget(self._chordmode, 3, 0) grid.addWidget(self._relativemode, 3, 1) grid.addWidget(self._labeldamper, 4, 0) grid.addWidget(self._damper, 4, 1) grid.addWidget(self._labelsostenuto, 5, 0) grid.addWidget(self._sostenuto, 5, 1) grid.addWidget(self._labelsoft, 6, 0) grid.addWidget(self._soft, 6, 1) hbox = QHBoxLayout() layout.addLayout(hbox) hbox.addWidget(self._capture) hbox.addStretch() app.translateUI(self) self.loadsettings() for s in signals: s.connect(self.savesettings)