def make_widgets(self): w = self # Init the window's attributes. w.setStyleSheet(f"background: {self.background_color}") w.setGeometry(0, 0, self._width, self._height) # The non-full-screen sizes. # Create the picture area. w.picture = QtWidgets.QLabel('picture', self) w.picture.keyPressEvent = w.keyPressEvent # Create the scroll area. w.scroll_area = area = QtWidgets.QScrollArea() area.setWidget(self.picture) AlignmentFlag = QtCore.Qt if isQt5 else QtCore.Qt.AlignmentFlag area.setAlignment(AlignmentFlag.AlignHCenter | AlignmentFlag.AlignVCenter) # pylint: disable=no-member # Disable scrollbars. ScrollBarPolicy = QtCore.Qt if isQt5 else QtCore.Qt.ScrollBarPolicy area.setHorizontalScrollBarPolicy( ScrollBarPolicy.ScrollBarAlwaysOff) # pylint: disable=no-member area.setVerticalScrollBarPolicy(ScrollBarPolicy.ScrollBarAlwaysOff) # pylint: disable=no-member # Init the layout. layout = QtWidgets.QVBoxLayout() layout.addWidget(self.scroll_area) w.setLayout(layout)
def button_menu(self, event, bm, but, up=False): """button_menu - handle a button being right-clicked :Parameters: - `event`: QPushButton event - `bm`: Bookmark associated with button - `but`: button widget """ menu = QtWidgets.QMenu() actions = [ ("Link bookmark to this node", self.update_bookmark), ("Re-name bookmark", self.rename_bookmark), ("Edit bookmark in tree", self.edit_bookmark), ("Delete bookmark", self.delete_bookmark), ("Add this node as child bookmark", self.add_child_bookmark), ] for action in actions: # pylint: disable=cell-var-from-loop act = QtWidgets.QAction(action[0], menu) act.triggered.connect(lambda checked, bm=bm, f=action[1]: f(bm)) menu.addAction(act) def follow(checked, bm=bm, manager=self): manager.current = bm.v manager.second = True manager.upwards = False manager.show_list(manager.get_list(), up=False) act = QtWidgets.QAction("Show child bookmarks", menu) act.triggered.connect(follow) menu.addAction(act) menu.exec_(but.mapToGlobal(event.pos()))
def create_ui(self): self.w = w = QtWidgets.QWidget() w.setWindowTitle("Leo search") lay = QtWidgets.QVBoxLayout() self.web = web = QtWebKitWidgets.QWebView(w) self.web.linkClicked.connect(self._lnk_handler) self.led = led = QtWidgets.QLineEdit(w) led.returnPressed.connect(self.docmd) lay.addWidget(led) lay.addWidget(web) self.lc = lc = LeoConnector() web.page().mainFrame().addToJavaScriptWindowObject("leo",lc) web.page().setLinkDelegationPolicy(QtWebKitWidgets.QWebPage.DelegateAllLinks) w.setLayout(lay) #web.load(QUrl("http://google.fi")) self.show_help() # w.show() def help_handler(tgt,qs): if qs == "help": self.show_help() return True return False self.add_cmd_handler(help_handler) self.led.setFocus()
def build(self, n=3, columns=3, year=None, month=None): self.calendars = [] if year is None: year = datetime.date.today().year if month is None: month = datetime.date.today().month layout = QtWidgets.QGridLayout() while self.layout().count(): self.layout().removeItem(self.layout().itemAt(0)) self.layout().addLayout(layout) size = self.minimumSizeHint() x, y = size.width(), size.height() x *= min(n, columns) y *= 1 + ((n - 1) // columns) self.setMinimumSize(QtCore.QSize(x, y)) for i in range(n): calendar = QtWidgets.QCalendarWidget() calendar.i = i calendar.setCurrentPage(year, month) month += 1 if month == 13: year += 1 month = 1 calendar.currentPageChanged.connect( lambda year, month, cal=calendar: self.currentPageChanged( year, month, cal)) calendar.clicked.connect(self.return_result) calendar.activated.connect(self.return_result) self.calendars.append(calendar) layout.addWidget(calendar, i // columns, i % columns)
def main(): app = QtWidgets.QApplication(sys.argv) win = QtWidgets.QWidget() l = QtWidgets.QVBoxLayout() win.setLayout(l) w = QtWidgets.QDateEdit() w.setCalendarPopup(True) l.addWidget(w) l.addWidget(QNDateEdit()) l.addWidget(QNDateEdit(n=6)) l.addWidget(QNDateEdit(n=1)) l.addWidget(QNDateEdit(n=2)) l.addWidget(QNDateEdit(n=6, columns=2)) l.addWidget(QNDateEdit(n=6, columns=4)) l.addWidget(QNDateEdit(n=12, columns=4)) l.addWidget(QNDateEdit(columns=1)) last = QNDateEdit() l.addWidget(last) last.calendarWidget().build(5, 4) win.show() if isQt6: sys.exit(app.exec()) else: sys.exit(app.exec_())
def make_image(path, src, fail_ok=False): """relative to path (if needed), make a QGraphicsPixmapItem for the image named in src, returning None if not available, or an 'No Image' image if fail_ok == False""" if '//' not in src or src.startswith('file://'): testpath = src if '//' in testpath: testpath = testpath.split('//', 1)[-1] # # file on local file system testpath = g.os_path_finalize_join(path, testpath) if g.os_path_exists(testpath): return QtWidgets.QGraphicsPixmapItem(QtGui.QPixmap(testpath)) # # explicit file://, but no such file exists if src.startswith('file://'): return None if fail_ok else GetImage._no_image() # # no explict file://, so try other protocols testpath = src if '//' in src else 'http://%s' % (src) data = GetImage.get_url(testpath) if data: img = QtGui.QPixmap() if img.loadFromData(data): return QtWidgets.QGraphicsPixmapItem(img) return None if fail_ok else GetImage._no_image()
def __init__(self, c, v=None): self.c = c c._bookmarks = self # self.v - where the bookmarks for c are kept, may not be in c if v is None: v = self.v = c.p.v else: self.v = v self.current = None # current (last used) bookmark self.previous = None # position in outline, for outline / bookmarks switch self.levels = c.config.getInt('bookmarks-levels') or 1 # levels to show in hierarchical display self.second = False # second click of current bookmark? self.upwards = False # moving upwards through hierarchy self.w = QtWidgets.QWidget() self.reloadSettings() # stuff for pane persistence self.w._ns_id = '_leo_bookmarks_show:' # v might not be in this outline c.db['_leo_bookmarks_show'] = v.context.vnode2position(v).get_UNL() # else: # c.frame.log.createTab(c.p.h[:10]) # tabWidget = c.frame.log.tabWidget # self.w = tabWidget.widget(tabWidget.count()-1) self.w.setObjectName('show_bookmarks') self.w.setMinimumSize(10, 10) self.w.setLayout(QtWidgets.QVBoxLayout()) self.w.layout().setContentsMargins(0, 0, 0, 0) self.current_list = self.get_list() self.show_list(self.current_list) g.registerHandler('select1', self.update)
def misc_menu(self): """build menu on Action button""" # info needed to separate edit and view widgets in self.widget_classes name_test_current = [ ("Editor", lambda x: x.lep_type == 'EDITOR', self.edit_widget.__class__), ("Viewer", lambda x: x.lep_type != 'EDITOR', self.view_widget.__class__), ] menu = QtWidgets.QMenu() for name, is_one, current in name_test_current: # list Editor widgets, then Viewer widgets for widget_class in [i for i in self.widget_classes if is_one(i)]: def cb(checked, widget_class=widget_class): self.set_widget(widget_class=widget_class) act = QtWidgets.QAction( "%s: %s" % (name, widget_class.lep_name), self) act.setCheckable(True) act.setChecked(widget_class == current) act.triggered.connect(cb) menu.addAction(act) menu.exec_(self.mapToGlobal(self.control_menu_button.pos()))
def __init__(self, c): self.c = c c.attribEditor = self self.pname = "_attrib_edit_frame" # used to tag out panel self.reloadSettings() self.attrPaths = set() # set of tuples (getter-class, path) self.handlers = [ ('select3', self.updateEditor), ] for i in self.handlers: g.registerHandler(i[0], i[1]) # 'body' or 'tab' mode # self.guiMode = c.config.getString('attrib_edit_placement') or 'tab' self.guiMode = 'tab' # body mode in not compatible with nested_splitter, causes hard crash if self.guiMode == 'body': self.holder = QtWidgets.QSplitter(QtCore.Qt.Vertical) self.holder.setMinimumWidth(300) parent = c.frame.top.leo_body_frame.parent() self.holder.addWidget(c.frame.top.leo_body_frame) parent.addWidget(self.holder) self.parent = self.holder elif self.guiMode == 'tab': self.parent = QtWidgets.QFrame() self.holder = QtWidgets.QHBoxLayout() self.parent.setLayout(self.holder) c.frame.log.createTab('Attribs', widget=self.parent)
def _add_checkbox(self, text, state_changed, tooltip, checked=True, enabled=True, button_label=True): """ _add_checkbox - helper to add a checkbox :param str text: Text for label :param function state_changed: callback for state_changed signal :param bool checked: initially checked? :param bool enabled: initially enabled? :param bool button_label: label should be a button for single shot use :return: QCheckBox """ cbox = QtWidgets.QCheckBox('' if button_label else text, self) self.control.layout().addWidget(cbox) btn = None if button_label: btn = QtWidgets.QPushButton(text, self) self.control.layout().addWidget(btn) def cb(checked, cbox=cbox, state_changed=state_changed): state_changed(cbox.isChecked(), one_shot=True) btn.clicked.connect(cb) btn.setToolTip(tooltip) cbox.setChecked(checked) cbox.setEnabled(enabled) cbox.stateChanged.connect(state_changed) cbox.setToolTip(tooltip) self.control.layout().addItem(QtWidgets.QSpacerItem(20, 0)) return cbox
def __init__(self, glue, hierarchyLink=False, *args, **kargs): """:Parameters: - `glue`: glue object owning this pass glue object and let it key nodeItems to leo nodes """ self.glue = glue QtWidgets.QGraphicsItemGroup.__init__(self) self.line = QtWidgets.QGraphicsLineItem(*args) pen = QtGui.QPen() self.line.setZValue(0) if not hierarchyLink: self.setZValue(1) pen.setWidth(2) else: self.setZValue(0) pen.setColor(QtGui.QColor(240, 240, 240)) pen.setWidth(2) # (0.5) self.line.setPen(pen) self.addToGroup(self.line) self.head = QtWidgets.QGraphicsPolygonItem() if hierarchyLink: self.head.setBrush(QtGui.QBrush(QtGui.QColor(180, 180, 180))) else: self.head.setBrush(QtGui.QBrush(QtGui.QColor(0, 0, 0))) self.head.setPen(QtGui.QPen(QtConst.NoPen)) self.addToGroup(self.head)
def update_graphics_script(self, s, keywords): '''Update the graphics script in the vr pane.''' pc = self; c = pc.c force = keywords.get('force') if pc.gs and not force: return if not pc.gs: splitter = c.free_layout.get_top_splitter() # Careful: we may be unit testing. if not splitter: g.trace('no splitter') return # Create the widgets. pc.gs = QtWidgets.QGraphicsScene(splitter) pc.gv = QtWidgets.QGraphicsView(pc.gs) w = pc.gv.viewport() # A QWidget # Embed the widgets. def delete_callback(): for w in (pc.gs, pc.gv): w.deleteLater() pc.gs = pc.gv = None pc.embed_widget(w, delete_callback=delete_callback) c.executeScript( script=s, namespace={'gs': pc.gs, 'gv': pc.gv})
def create_widgets(self): '''Create the big-text buttons and text warning area.''' c = self.c self.active_flag = True warning = self.warning_message() self.old_w.setPlainText(self.p.b) # essential. self.w = w = QtWidgets.QWidget() # No parent needed. layout = QtWidgets.QVBoxLayout() # No parent needed. w.setLayout(layout) w.text = tw = QtWidgets.QTextBrowser() tw.setText(warning) tw.setObjectName('bigtextwarning') self.widgets['bigtextwarning'] = tw layout.addWidget(tw) table = [ ('remove', 'Remove These Buttons', self.remove), ('load_nc', 'Load Text With @killcolor', self.load_nc), ('more', 'Double limit for this session', self.more), ('copy', 'Copy body to clipboard', self.copy), ] if self.s.startswith('@killcolor'): del table[1] for key, label, func in table: self.widgets[key] = button = QtWidgets.QPushButton(label) layout.addWidget(button) def button_callback(checked, func=func): func() button.clicked.connect(button_callback) # layout.addItem(QtWidgets.QSpacerItem( # 10, 10, vPolicy=QtWidgets.QSizePolicy.Expanding)) self.layout.addWidget(w) w.show()
def __init__(self, *args, **kwargs): QtWidgets.QWidget.__init__(self, *args, **kwargs) self.textedit = QtWidgets.QTextEdit(*args, **kwargs) # need to call focusin/out set on parent by FocusingPlaintextEdit / mknote self.textedit.focusInEvent = self._call_old_first( self.textedit.focusInEvent, self.focusin) self.textedit.focusOutEvent = self._call_old_first( self.textedit.focusOutEvent, self.focusout) self.searchbox = QtWidgets.QLineEdit() self.searchbox.focusInEvent = self._call_old_first( self.searchbox.focusInEvent, self.focusin) self.searchbox.focusOutEvent = self._call_old_first( self.searchbox.focusOutEvent, self.focusout) # invoke find when return pressed self.searchbox.returnPressed.connect(self.search) layout = QtWidgets.QVBoxLayout() self.setLayout(layout) layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.textedit) hlayout = QtWidgets.QHBoxLayout() hlayout.setContentsMargins(0, 0, 0, 0) hlayout.addWidget(QtWidgets.QLabel("Find:")) hlayout.addWidget(self.searchbox) layout.addLayout(hlayout)
def __init__(self, glue, hierarchyLink=False, *args, **kargs): """:Parameters: - `glue`: glue object owning this pass glue object and let it key nodeItems to leo nodes """ # pylint: disable=keyword-arg-before-vararg # putting *args first is invalid in Python 2.x. self.glue = glue super().__init__() self.line = QtWidgets.QGraphicsLineItem(*args) pen = QtGui.QPen() self.line.setZValue(0) if not hierarchyLink: self.setZValue(1) pen.setWidth(2) else: self.setZValue(0) pen.setColor(QtGui.QColor(240, 240, 240)) pen.setWidth(2) # (0.5) self.line.setPen(pen) self.addToGroup(self.line) self.head = QtWidgets.QGraphicsPolygonItem() if hierarchyLink: self.head.setBrush(QtGui.QBrush(QtGui.QColor(180, 180, 180))) else: self.head.setBrush(QtGui.QBrush(QtGui.QColor(0, 0, 0))) self.head.setPen(QtGui.QPen(QtConst.NoPen)) self.addToGroup(self.head)
def addParentMatches(self, parent_list): lineMatchHits = 0 for parent_key, parent_value in parent_list.items(): if g.isString(parent_key): it = QtWidgets.QListWidgetItem(parent_key, self.lw) else: it = QtWidgets.QListWidgetItem(parent_key.h, self.lw) f = it.font() f.setItalic(True) it.setFont(f) self.its[id(it)] = (parent_key, None) for p in parent_value: it = QtWidgets.QListWidgetItem(" " + p.h, self.lw) f = it.font() f.setBold(True) it.setFont(f) self.its[id(it)] = (p, None) if hasattr(p, "matchiter"): #p might be not have body matches ms = matchlines(p.b, p.matchiter) for ml, pos in ms: lineMatchHits += 1 it = QtWidgets.QListWidgetItem(" " + " " + ml, self.lw) self.its[id(it)] = (p, pos) return lineMatchHits
def addParentMatches(self, parent_list): lineMatchHits = 0 for parent_key, parent_value in parent_list.items(): if g.isString(parent_key): v = self.c.fileCommands.gnxDict.get(parent_key) h = v.h if v else parent_key it = QtWidgets.QListWidgetItem(h, self.lw) else: it = QtWidgets.QListWidgetItem(parent_key.h, self.lw) f = it.font() f.setItalic(True) it.setFont(f) if self.addItem(it, (parent_key, None)): return lineMatchHits for p in parent_value: it = QtWidgets.QListWidgetItem(" " + p.h, self.lw) f = it.font() f.setBold(True) it.setFont(f) if self.addItem(it, (p, None)): return lineMatchHits if hasattr(p, "matchiter"): #p might be not have body matches ms = matchlines(p.b, p.matchiter) for ml, pos in ms: lineMatchHits += 1 it = QtWidgets.QListWidgetItem(" " + " " + ml, self.lw) if self.addItem(it, (p, pos)): return lineMatchHits return lineMatchHits
def create_buttons(self, layout): """Create two rows of buttons.""" vlayout = QtWidgets.QVBoxLayout() table1 = ( ('start', self.debug_xdb), ('quit', self.debug_quit), ('help', self.debug_help), ('list', self.debug_list), ('where', self.debug_where), ) table2 = ( ('break', self.debug_break), ('continue', self.debug_continue), ('next', self.debug_next), ('step', self.debug_step), ('return', self.debug_return), ) for table in (table1, table2): hlayout = QtWidgets.QHBoxLayout() for name, func in table: w = QtWidgets.QPushButton() w.setText(name) w.clicked.connect(func) hlayout.addWidget(w) vlayout.addLayout(hlayout) layout.addLayout(vlayout)
def main(): # stupid test a = QtWidgets.QApplication([]) b = QtWidgets.QPushButton("Say hello", None) g.procs.add(['ls', '/tmp']) g.procs.add(['ls', '-la']) #a.setMainWidget(b) b.show() a.exec_()
def __init__(self, parent, title, text, entries): self.entries = entries QtWidgets.QDialog.__init__(self, parent) vbox = QtWidgets.QVBoxLayout() sa = QtWidgets.QScrollArea() salo = QtWidgets.QVBoxLayout() frame = QtWidgets.QFrame() frame.setLayout(salo) self.buttons = [] for entry in entries: hbox = QtWidgets.QHBoxLayout() cb = QtWidgets.QCheckBox(entry[0]) self.buttons.append(cb) if entry[1]: cb.setCheckState(QtCore.Qt.Checked) hbox.addWidget(cb) salo.addLayout(hbox) sa.setWidget(frame) vbox.addWidget(sa) hbox = QtWidgets.QHBoxLayout() ok = QtWidgets.QPushButton("Ok") cancel = QtWidgets.QPushButton("Cancel") ok.clicked.connect(self.writeBack) cancel.clicked.connect(self.reject) # QtCore.QObject.connect(ok, QtCore.SIGNAL('clicked(bool)'), self.writeBack) # QtCore.QObject.connect(cancel, QtCore.SIGNAL('clicked(bool)'), self.reject) hbox.addWidget(ok) hbox.addWidget(cancel) vbox.addLayout(hbox) self.setLayout(vbox)
def _build_gui(self): self.w = w = QtWidgets.QWidget() w.setObjectName('show_livecode') w.setLayout(QtWidgets.QVBoxLayout()) self.status = QtWidgets.QLabel() w.layout().addWidget(self.status) self.text = QtWidgets.QTextBrowser() w.layout().addWidget(self.text) h = QtWidgets.QHBoxLayout() w.layout().addLayout(h) self.activate = QtWidgets.QPushButton("Stop") self.activate.setToolTip("Start / stop live code display") h.addWidget(self.activate) self.activate.clicked.connect(lambda checked: self.toggle_active()) b = QtWidgets.QPushButton("Run here") b.setToolTip("Show live code for this node") h.addWidget(b) b.clicked.connect(lambda checked: self.run_here()) b = QtWidgets.QPushButton("Go to node") b.setToolTip("Jump to node where live code is shown") h.addWidget(b) b.clicked.connect(lambda checked: self.goto_node()) b = QtWidgets.QPushButton("Dump") b.setToolTip("AST dump to stdout (devel. option)") h.addWidget(b) b.clicked.connect( lambda checked, self=self: setattr(self, 'dump', True))
def _add_frame(self): """_add_frame - add a widget with a layout as a hiding target. i.e. a container we can hide / show easily""" w = QtWidgets.QWidget(self) self.layout().addWidget(w) w.setSizePolicy(Policy.Expanding, Policy.Maximum) w.setLayout(QtWidgets.QHBoxLayout()) w.layout().setContentsMargins(0, 0, 0, 0) w.layout().setSpacing(0) return w
def __init__(self, parent=None): """ctor for NestedSplitterChoice class.""" super().__init__(parent) self.setLayout(QtWidgets.QVBoxLayout()) button = QtWidgets.QPushButton("Action", self) # EKR: 2011/03/15 self.layout().addWidget(button) button.setContextMenuPolicy(QtConst.CustomContextMenu) button.customContextMenuRequested.connect(lambda pnt: self.parent( ).choice_menu(self, button.mapToParent(pnt))) button.clicked.connect( lambda: self.parent().choice_menu(self, button.pos()))
def __init__(self, canvas, num): '''Ctor for the LeoFigureManagerQt class.''' self.c = c = g.app.log.c # g.trace('LeoFigureManagerQT', c) FigureManagerBase.__init__(self, canvas, num) self.canvas = canvas # New code for Leo: embed the canvas in the viewrendered area. self.vr_controller = vc = vr.controllers.get(c.hash()) self.splitter = c.free_layout.get_top_splitter() self.frame = w = QtWidgets.QFrame() w.setLayout(QtWidgets.QVBoxLayout()) w.layout().addWidget(self.canvas) vc.embed_widget(w) class DummyWindow: def __init__(self, c): self.c = c self._destroying = None def windowTitle(self): return self.c.p.h self.window = DummyWindow(c) # See comments in the base class ctor, in backend_qt5.py. self.canvas.setFocusPolicy(QtCore.Qt.StrongFocus) self.canvas.setFocus() self.canvas._destroying = False self.toolbar = self._get_toolbar(self.canvas, self.frame) if self.toolbar is not None: # The toolbar is a backend_qt5.NavigationToolbar2QT. layout = self.frame.layout() layout.addWidget(self.toolbar) # add text label to status bar self.statusbar_label = QtWidgets.QLabel() layout.addWidget(self.statusbar_label) # pylint: disable=no-member if isQt5: pass # The status bar doesn't work yet. else: self.toolbar.message.connect(self._show_message) self.canvas.draw_idle() def notify_axes_change(fig): # This will be called whenever the current axes is changed if self.toolbar is not None: self.toolbar.update() self.canvas.figure.add_axobserver(notify_axes_change)
def create_frame(self, filename, filenames, window): QLabel = QtWidgets.QLabel # Create the frame. frame = QtWidgets.QFrame(parent=window) # Create the vertical layout. layout = QtWidgets.QVBoxLayout() frame.setLayout(layout) # Set the font. font = QtGui.QFont() font.setBold(True) font.setPointSize(12) # Create the labels.. ctime = time.ctime(os.path.getctime(filename)) struct_time = time.strptime(ctime) creation_time = time.strftime('%Y %m %d', struct_time) file_label = QLabel(text=filename, parent=frame) file_label.setFont(font) layout.addWidget(file_label) size = os.path.getsize(filename) / 1000 info_label = QLabel(text=f"size: {size} KB date: {creation_time}") info_label.setFont(font) layout.addWidget(info_label) # Create the delete button, centered. button_layout = QtWidgets.QHBoxLayout() button_layout.addStretch() delete_button = QtWidgets.QPushButton(text='Delete', parent=frame) button_layout.addWidget(delete_button) button_layout.addStretch() layout.addLayout(button_layout) # Set the button action. def delete_action(arg): self.delete_file(filename) delete_button.clicked.connect(delete_action) # Create the picture area. picture = QtWidgets.QLabel('picture', parent=frame) layout.addWidget(picture) # Display the picture. pixmap = QtGui.QPixmap(filename) try: TransformationMode = QtCore.Qt if isQt5 else QtCore.Qt.TransformationMode image = pixmap.scaledToHeight( self.window_height, TransformationMode.SmoothTransformation) # pylint: disable=no-member picture.setPixmap(image) picture.adjustSize() return frame except Exception: g.trace('Bad image') g.es_exception() return None
def initUI(self): # create GUI components ## this code is atrocious... don't look too closely self.setObjectName("LeoTagWidget") # verticalLayout_2: contains # verticalLayout self.verticalLayout_2 = QtWidgets.QVBoxLayout(self) self.verticalLayout_2.setContentsMargins(0, 1, 0, 1) self.verticalLayout_2.setObjectName("nodetags-verticalLayout_2") # horizontalLayout: contains # "Refresh" button # comboBox self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setContentsMargins(0, 0, 0, 0) self.horizontalLayout.setObjectName("nodetags-horizontalLayout") # horizontalLayout2: contains # label2 # not much by default -- it's a place to add buttons for current tags self.horizontalLayout2 = QtWidgets.QHBoxLayout() self.horizontalLayout2.setContentsMargins(0, 0, 0, 0) self.horizontalLayout2.setObjectName("nodetags-horizontalLayout2") label2 = QtWidgets.QLabel(self) label2.setObjectName("nodetags-label2") label2.setText("Tags for current node:") self.horizontalLayout2.addWidget(label2) # verticalLayout: contains # horizontalLayout # listWidget # horizontalLayout2 # label self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setObjectName("nodetags-verticalLayout") self.comboBox = QtWidgets.QComboBox(self) self.comboBox.setObjectName("nodetags-comboBox") self.comboBox.setEditable(True) self.horizontalLayout.addWidget(self.comboBox) self.pushButton = QtWidgets.QPushButton("+", self) self.pushButton.setObjectName("nodetags-pushButton") self.pushButton.setMinimumSize(24, 24) self.pushButton.setMaximumSize(24, 24) self.horizontalLayout.addWidget(self.pushButton) self.verticalLayout.addLayout(self.horizontalLayout) self.listWidget = QtWidgets.QListWidget(self) self.listWidget.setObjectName("nodetags-listWidget") self.verticalLayout.addWidget(self.listWidget) self.verticalLayout.addLayout(self.horizontalLayout2) self.label = QtWidgets.QLabel(self) self.label.setObjectName("nodetags-label") self.label.setText("Total: 0 items") self.verticalLayout.addWidget(self.label) self.verticalLayout_2.addLayout(self.verticalLayout) QtCore.QMetaObject.connectSlotsByName(self)
def createTrayIcon(): g.trayIconMenu = QtWidgets.QMenu() def new_note(): c = g.app.commanders()[0] c.k.simulateCommand('stickynote-new') g.trayIconMenu.addAction("New note", new_note) g.trayIcon = QtWidgets.QSystemTrayIcon() g.trayIcon.setContextMenu(g.trayIconMenu) g.trayIcon.setIcon(QtGui.QIcon(g.app.leoDir + "/Icons/leoapp32.png")) g.trayIcon.setVisible(True)
def makeButtons(self): ib_w = self.c.frame.iconBar.w if not ib_w: return # EKR: can be None when unit testing. icon_l = ib_w.style().standardIcon(QtWidgets.QStyle.SP_ArrowLeft) icon_r = ib_w.style().standardIcon(QtWidgets.QStyle.SP_ArrowRight) act_l = QtWidgets.QAction(icon_l, 'prev', ib_w) act_r = QtWidgets.QAction(icon_r, 'next', ib_w) # act_l.connect(act_l, QtCore.SIGNAL("triggered()"), self.clickPrev) # act_r.connect(act_r, QtCore.SIGNAL("triggered()"), self.clickNext) act_l.triggered.connect(self.clickPrev) act_r.triggered.connect(self.clickNext) self.c.frame.iconBar.add(qaction=act_l, command=self.clickPrev) self.c.frame.iconBar.add(qaction=act_r, command=self.clickNext)
def mode_menu(self): """build menu on Action button""" menu = QtWidgets.QMenu() for mode in 'edit', 'view', 'split': act = QtWidgets.QAction(mode.title(), self) def cb(checked, self=self, mode=mode): self.set_mode(mode) act.triggered.connect(cb) act.setCheckable(True) act.setChecked(mode == self.mode) menu.addAction(act) menu.exec_(self.mapToGlobal(self.btn_mode.pos()))
def make_ui(self): """make_ui - build up UI""" ui = type('CSVEditUI', (), {}) self.setLayout(QtWidgets.QVBoxLayout()) buttons = QtWidgets.QHBoxLayout() self.layout().addLayout(buttons) def mkbuttons(what, function): list_ = [ ('go-first', "%s column left", QtWidgets.QStyle.SP_ArrowLeft), ('go-last', "%s column right", QtWidgets.QStyle.SP_ArrowRight), ('go-top', "%s row above", QtWidgets.QStyle.SP_ArrowUp), ('go-bottom', "%s row below", QtWidgets.QStyle.SP_ArrowDown), ] buttons.addWidget(QtWidgets.QLabel(what+": ")) for name, tip, fallback in list_: button = QtWidgets.QPushButton() button.setIcon(QtGui.QIcon.fromTheme(name, QtWidgets.QApplication.style().standardIcon(fallback))) button.setToolTip(tip % what) button.clicked.connect(lambda checked, name=name: function(name)) buttons.addWidget(button) mkbuttons("Move", self.move) mkbuttons("Insert", self.insert) for text, function in [ ("Del row", lambda clicked: self.delete_col(row=True)), ("Del col.", lambda clicked: self.delete_col()), ("Prev", lambda clicked: self.prev_tbl()), ("Next", lambda clicked: self.prev_tbl(next=True)), ]: btn = QtWidgets.QPushButton(text) buttons.addWidget(btn) btn.clicked.connect(function) ui.min_rows = QtWidgets.QSpinBox() buttons.addWidget(ui.min_rows) ui.min_rows.setMinimum(1) ui.min_rows.setPrefix("tbl with ") ui.min_rows.setSuffix(" rows") ui.min_rows.setValue(4) buttons.addStretch(1) ui.table = QtWidgets.QTableView() self.layout().addWidget(ui.table) return ui