def __init__(self, document, setting, setnsproxy): """Initialise button, passing document, setting, and parent widget.""" qt4.QWidget.__init__(self) self.setFocusPolicy(qt4.Qt.StrongFocus) self.document = document self.connect(document, qt4.SIGNAL('sigModified'), self.slotDocModified) self.setting = setting self.setnsproxy = setnsproxy self.layout = qt4.QHBoxLayout(self) self.layout.setMargin(2) if setting.usertext: text = setting.usertext else: text = setting.name self.labelicon = qt4.QLabel(text) self.layout.addWidget(self.labelicon) self.iconlabel = qt4.QLabel() self.layout.addWidget(self.iconlabel) self.connect(self, qt4.SIGNAL('clicked'), self.settingMenu) self.infocus = False self.inmouse = False self.inmenu = False # initialise settings self.slotDocModified()
def makeSplashLogo(): '''Make a splash screen logo.''' splash = qt4.QSplashScreen() splash.setStyleSheet("background-color:whitesmoke;") # draw logo on pixmap layout = qt4.QVBoxLayout(splash) pm = utils.getPixmap('logo.png') logo = qt4.QLabel() logo.setPixmap(pm) logo.setAlignment(qt4.Qt.AlignCenter) layout.addWidget(logo) # add copyright text message = qt4.QLabel() message.setText(splashcopyr % utils.version()) message.setAlignment(qt4.Qt.AlignCenter) # increase size of font font = message.font() font.setPointSize(font.pointSize() * 1.5) message.setFont(font) layout.addWidget(message) h = qt4.QFontMetrics(font).height() layout.setContentsMargins(h, h, h, h) # Center the spash screen splash.setGeometry(5, 5, 100, 100) screen = qt4.QDesktopWidget().screenGeometry() splash.move((screen.width() - layout.sizeHint().width()) / 2, (screen.height() - layout.sizeHint().height()) / 2) return splash
def __init__(self, thedocument, *args): qt4.QDockWidget.__init__(self, *args) self.setWindowTitle(_("Console - Veusz")) self.setObjectName("veuszconsolewindow") # arrange sub-widgets in a vbox self.vbox = qt4.QWidget() self.setWidget(self.vbox) vlayout = qt4.QVBoxLayout(self.vbox) vlayout.setMargin(vlayout.margin() / 4) vlayout.setSpacing(vlayout.spacing() / 4) # start an interpreter instance to the document self.interpreter = document.CommandInterpreter(thedocument) self.document = thedocument # output from the interpreter goes to self.output_stdxxx self.con_stdout = _Writer(self.output_stdout) self.con_stderr = _Writer(self.output_stderr) self.interpreter.setOutputs(self.con_stdout, self.con_stderr) self.stdoutbuffer = "" self.stderrbuffer = "" # (mostly) hidden notification self._hiddennotify = qt4.QLabel() vlayout.addWidget(self._hiddennotify) self._hiddennotify.hide() # the output from the console goes here self._outputdisplay = qt4.QTextEdit() self._outputdisplay.setReadOnly(True) self._outputdisplay.insertHtml(introtext) vlayout.addWidget(self._outputdisplay) self._hbox = qt4.QWidget() hlayout = qt4.QHBoxLayout(self._hbox) hlayout.setMargin(0) vlayout.addWidget(self._hbox) self._prompt = qt4.QLabel(">>>") hlayout.addWidget(self._prompt) # where commands are typed in self._inputedit = _CommandEdit() hlayout.addWidget(self._inputedit) self._inputedit.setFocus() # keep track of multiple line commands self.command_build = '' # get called if enter is pressed in the input control self.connect(self._inputedit, qt4.SIGNAL("sigEnter"), self.slotEnter) # called if document logs something self.connect(thedocument, qt4.SIGNAL("sigLog"), self.slotDocumentLog)
def makeControl(self, doc, currentwidget): default = self.default if default == '': default = currentwidget l = qt4.QLabel(self.descr) c = _WidgetCombo(doc, self.widgettypes, default) return (l, c)
def makeControl(self, doc, currentwidget): l = qt4.QLabel(self.descr) c = qt4.QComboBox() c.addItems(self.items) c.setEditable(bool(self.editable)) if self.default: self.setControlVal((l, c), self.default) return (l, c)
def makeSplash(app): '''Make a splash screen logo.''' splash = qt.QSplashScreen() splash.setStyleSheet("background-color:white; color: black;") # draw logo on pixmap layout = qt.QVBoxLayout(splash) logo = qt.QLabel() logo.setPixmap(utils.getPixmap('logo.png')) logo.setAlignment(qt.Qt.AlignCenter) layout.addWidget(logo) # add copyright text message = qt.QLabel() message.setText(splashcopyr % utils.version()) message.setAlignment(qt.Qt.AlignCenter) # increase size of font font = message.font() font.setPointSizeF(font.pointSize()*1.5) message.setFont(font) layout.addWidget(message) h = qt.QFontMetrics(font).height() layout.setContentsMargins(h,h,h,h) # Center the spash screen splash.setGeometry(5, 5, 100, 100) screen = qt.QDesktopWidget().screenGeometry() splash.move( (screen.width()-layout.sizeHint().width())//2, (screen.height()-layout.sizeHint().height())//2 ) # make sure dialog goes away - avoid problem if a message box pops # up before it is removed qt.QTimer.singleShot(2000, splash.hide) return splash
def makeControl(self, doc, currentwidget): """Use setting makeControl method to make control.""" self.setn.parent = self # setting looks to parent for document self.setn.set(self.default) self.document = doc l = qt4.QLabel(self.descr) c = self.setn.makeControl(None) def updateval(cntrl, setn, val): setn.set(val) # if control changes setting, update setting c.connect(c, qt4.SIGNAL('settingChanged'), updateval) return (l, c)
def setupColorTab(self): """Initialise color tab this makes a grid of controls for each color consisting of label, isdefault check and change color button.""" self.chosencolors = {} self.colorbutton = {} self.colordefaultcheck = {} layout = qt4.QGridLayout() setdb = setting.settingdb for row, colname in enumerate(setdb.colors): isdefault, colval = setting.settingdb['color_%s' % colname] self.chosencolors[colname] = qt4.QColor(colval) # label name, tooltip = color_names[colname] label = qt4.QLabel(name) label.setToolTip(tooltip) layout.addWidget(label, row, 0) # is default check defcheck = qt4.QCheckBox(_("Default")) defcheck.setToolTip( _("Use the default color instead of the one chosen here")) layout.addWidget(defcheck, row, 1) self.colordefaultcheck[colname] = defcheck defcheck.setChecked(isdefault) # button button = qt4.QPushButton() # connect button to method to change color def clicked(color=colname): self.colorButtonClickedSlot(color) self.connect(button, qt4.SIGNAL('clicked()'), clicked) layout.addWidget(button, row, 2) self.colorbutton[colname] = button self.colorGroup.setLayout(layout) self.updateButtonColors()
def __init__(self, mainwin): tb = mainwin.formatdock.tabwidget.tabBar() label = qt4.QLabel(" ") tb.setTabButton(1, qt4.QTabBar.LeftSide, label) TutorialStep.__init__(self, _(''' <p>Different types of formatting properties are grouped under separate tables. The options for drawing the function line are grouped under the flashing Line tab (%s).</p> <p class="usercmd">Click on the Line tab to continue.</p> ''') % utils.pixmapAsHtml(utils.getPixmap('settings_plotline.png')), mainwin, flash=label, disablenext=True, nextstep=FunctionLineFormatting) self.connect(tb, qt4.SIGNAL('currentChanged(int)'), self.slotCurrentChanged)
def _addActions(self, setnsproxy, row): """Add a list of actions.""" for action in setnsproxy.actionsList(): text = action.name if action.usertext: text = action.usertext lab = qt4.QLabel(text) self.layout.addWidget(lab, row, 0) self.childlist.append(lab) button = qt4.QPushButton(text) button.setToolTip(action.descr) # need to save reference to caller object button.caller = utils.BoundCaller(setnsproxy.onAction, action, self.getConsole()) self.connect(button, qt4.SIGNAL('clicked()'), button.caller) self.layout.addWidget(button, row, 1) self.childlist.append(button) row += 1 return row
def updateProperties(self, setnsproxy, title=None, showformatting=True, onlyformatting=False): """Update the list of controls with new ones for the SettingsProxy.""" # keep a reference to keep it alive self._setnsproxy = setnsproxy # delete all child widgets self.setUpdatesEnabled(False) while len(self.childlist) > 0: c = self.childlist.pop() self.layout.removeWidget(c) c.deleteLater() del c if setnsproxy is None: self.setUpdatesEnabled(True) return row = 0 self.setncntrls = {} self.layout.setEnabled(False) # add a title if requested if title is not None: lab = qt4.QLabel(title[0], frameShape=qt4.QFrame.Panel, frameShadow=qt4.QFrame.Sunken, toolTip=title[1]) self.layout.addWidget(lab, row, 0, 1, -1) row += 1 # add actions if parent is widget if setnsproxy.actionsList() and not showformatting: row = self._addActions(setnsproxy, row) if setnsproxy.settingsProxyList() and self.showformatsettings: # if we have subsettings, use tabs tabbed = TabbedFormatting(self.document, setnsproxy) self.layout.addWidget(tabbed, row, 1, 1, 2) row += 1 self.childlist.append(tabbed) else: # else add settings proper as a list for setn in setnsproxy.childProxyList(): # add setting # only add if formatting setting and formatting allowed # and not formatting and not formatting not allowed if ( isinstance(setn, setting.Setting) and ( (setn.formatting and (showformatting or onlyformatting)) or (not setn.formatting and not onlyformatting)) and not setn.hidden ): row = self._addControl(setnsproxy, setn, row) elif ( isinstance(setn, SettingsProxy) and setn.setnsmode() == 'groupedsetting' and not onlyformatting ): row = self._addGroupedSettingsControl(setn, row) # add empty widget to take rest of space w = qt4.QWidget( sizePolicy=qt4.QSizePolicy( qt4.QSizePolicy.Maximum, qt4.QSizePolicy.MinimumExpanding) ) self.layout.addWidget(w, row, 0) self.childlist.append(w) self.setUpdatesEnabled(True) self.layout.setEnabled(True)
def makeControl(self, doc, currentwidget): l = qt4.QLabel(self.descr) e = qt4.QLineEdit() if self.default: e.setText(self.default) return (l, e)
def __init__(self, thedocument, mainwin, parent, readonly=False, filterdims=None, filterdtype=None): """Initialise widget: thedocument: document to show mainwin: main window of application (or None if readonly) parent: parent of widget. readonly: for choosing datasets only filterdims: if set, only show datasets with dimensions given filterdtype: if set, only show datasets with type given """ qt4.QWidget.__init__(self, parent) self.layout = qt4.QVBoxLayout() self.setLayout(self.layout) # options for navigator are in this layout self.optslayout = qt4.QHBoxLayout() # grouping options - use a menu to choose the grouping self.grpbutton = qt4.QPushButton(_("Group")) self.grpmenu = qt4.QMenu() self.grouping = setting.settingdb.get("navtree_grouping", "filename") self.grpact = qt4.QActionGroup(self) self.grpact.setExclusive(True) for name in self.grpnames: a = self.grpmenu.addAction(self.grpentries[name]) a.grpname = name a.setCheckable(True) if name == self.grouping: a.setChecked(True) self.grpact.addAction(a) self.connect(self.grpact, qt4.SIGNAL("triggered(QAction*)"), self.slotGrpChanged) self.grpbutton.setMenu(self.grpmenu) self.grpbutton.setToolTip(_("Group datasets with property given")) self.optslayout.addWidget(self.grpbutton) # filtering by entering text self.optslayout.addWidget(qt4.QLabel(_("Filter"))) self.filteredit = LineEditWithClear() self.filteredit.setToolTip(_("Enter text here to filter datasets")) self.connect(self.filteredit, qt4.SIGNAL("textChanged(const QString&)"), self.slotFilterChanged) self.optslayout.addWidget(self.filteredit) self.layout.addLayout(self.optslayout) # the actual widget tree self.navtree = DatasetsNavigatorTree(thedocument, mainwin, self.grouping, None, readonly=readonly, filterdims=filterdims, filterdtype=filterdtype) self.layout.addWidget(self.navtree)