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 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 __init__(self, *args, **kwargs): self.c = kwargs['c'] del kwargs['c'] super().__init__(*args, **kwargs) # were we opened by an @ rich node? Calling code will set self.at_rich = False # are we being closed by leaving an @ rich node? Calling code will set self.at_rich_close = False # read settings. self.reloadSettings() # load HTML template template_path = g.os_path_join(g.computeLeoDir(), 'plugins', 'cke_template.html') self.template = open(template_path).read() path = g.os_path_join(g.computeLeoDir(), 'external', 'ckeditor') self.template = self.template.replace( '[CKEDITOR]', QtCore.QUrl.fromLocalFile(path).toString()) # make widget containing QWebView self.setLayout(QtWidgets.QVBoxLayout()) self.layout().setSpacing(0) self.layout().setContentsMargins(0, 0, 0, 0) # enable inspector, if this really is QtWebKit if real_webkit: QtWebKit.QWebSettings.globalSettings().setAttribute( QtWebKit.QWebSettings.DeveloperExtrasEnabled, True) self.webview = QtWebKitWidgets.QWebView() self.layout().addWidget(self.webview) g.registerHandler('select3', self.select_node) g.registerHandler('unselect1', self.unselect_node) # load current node self.select_node('', {'c': self.c, 'new_p': self.c.p})
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 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 __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 _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 __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 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 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 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 initUI(self): # create GUI components ## this code is atrocious... don't look too closely self.setObjectName("LeoNodewatchWidget") # verticalLayout_2: contains # verticalLayout self.verticalLayout_2 = QtWidgets.QVBoxLayout(self) self.verticalLayout_2.setContentsMargins(0, 1, 0, 1) self.verticalLayout_2.setObjectName("verticalLayout_2") # horizontalLayout: contains # "Refresh" button # comboBox self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setContentsMargins(0, 0, 0, 0) self.horizontalLayout.setObjectName("horizontalLayout") # verticalLayout: contains # horizontalLayout # listWidget # label self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") self.comboBox = QtWidgets.QComboBox(self) self.comboBox.setObjectName("comboBox") self.horizontalLayout.addWidget(self.comboBox) self.pushButton = QtWidgets.QPushButton("Refresh", self) self.pushButton.setObjectName("pushButton") self.pushButton.setMinimumSize(50, 24) self.pushButton.setMaximumSize(50, 24) self.horizontalLayout.addWidget(self.pushButton) self.verticalLayout.addLayout(self.horizontalLayout) self.listWidget = QtWidgets.QListWidget(self) self.listWidget.setObjectName("listWidget") self.verticalLayout.addWidget(self.listWidget) self.label = QtWidgets.QLabel(self) self.label.setObjectName("label") self.label.setText("Total: 0 items") self.verticalLayout.addWidget(self.label) self.verticalLayout_2.addLayout(self.verticalLayout) QtCore.QMetaObject.connectSlotsByName(self)
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 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 __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(self): """Create the Debug tab in the Log pane.""" c = self.c layout = QtWidgets.QVBoxLayout(self) self.create_buttons(layout) self.create_input_area(layout) if c.config.getBool('use-xdb-pane-output-area', default=True): self.create_output_area(layout) else: self.output_area = None layout.addStretch() self.setLayout(layout)
def __init__(self, *args, **kwargs): self.c = kwargs['c'] del kwargs['c'] QtWidgets.QWidget.__init__(self, *args, **kwargs) # were we opened by an @ rich node? Calling code will set self.at_rich = False # are we being closed by leaving an @ rich node? Calling code will set self.at_rich_close = False # read autosave preference if not hasattr(self.c, '_ckeeditor_autosave'): auto = self.c.config.getBool("richtext_cke_autosave") or False self.c._ckeeditor_autosave = auto if auto: g.es("NOTE: automatic saving of rich text edits") # load HTML template template_path = g.os_path_join( g.computeLeoDir(), 'plugins', 'cke_template.html', ) self.template = open(template_path).read() path = g.os_path_join(g.computeLeoDir(), 'external', 'ckeditor') self.template = self.template.replace( '[CKEDITOR]', QtCore.QUrl.fromLocalFile(path).toString()) # load config self.config = self.c.config.getData("richtext_cke_config") if self.config: self.config = '\n'.join(self.config).strip() # make widget containing QWebView self.setLayout(QtWidgets.QVBoxLayout()) self.layout().setSpacing(0) self.layout().setContentsMargins(0, 0, 0, 0) # enable inspector QtWebKit.QWebSettings.globalSettings().setAttribute( QtWebKit.QWebSettings.DeveloperExtrasEnabled, True) self.webview = QtWebKitWidgets.QWebView() self.layout().addWidget(self.webview) g.registerHandler('select3', self.select_node) g.registerHandler('unselect1', self.unselect_node) # load current node self.select_node('', {'c': self.c, 'new_p': self.c.p})
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
def create_input_area(self, layout): # Create the Label label = QtWidgets.QLabel() label.setText('Debugger command:') # Create the editor. self.line_edit = w = QtWidgets.QLineEdit() w.setStyleSheet('background: white; color: black;') w.returnPressed.connect(self.debug_input) # Add the widgets to a new layout. layout2 = QtWidgets.QVBoxLayout() layout2.addWidget(label) layout2.addWidget(w) layout.addLayout(layout2)
def create_output_area(self, layout): # Create the Label label = QtWidgets.QLabel() label.setText('Debugger outpuit:') # Create the output area. self.output_area = w = QtWidgets.QTextEdit() w.setStyleSheet('background: white; color: black;') w.setHorizontalScrollBarPolicy(ScrollBarPolicy.ScrollBarAsNeeded) w.setWordWrapMode(WrapMode.NoWrap) # Add the widgets to a new layout. vlayout = QtWidgets.QVBoxLayout() vlayout.addWidget(label) vlayout.addWidget(w) layout.addLayout(vlayout)
def create_ui(self): self.w = w = QtWidgets.QWidget() w.setWindowTitle("Leo search") lay = QtWidgets.QVBoxLayout() if (not QtWebKitWidgets # Workaround #1114: https://github.com/leo-editor/leo-editor/issues/1114 or isQt5 and sys.platform.startswith('win') # Workaround #304: https://github.com/leo-editor/leo-editor/issues/304 ): self.web = web = QtWidgets.QTextBrowser(w) else: self.web = web = QtWebKitWidgets.QWebView(w) try: # PyQt4 self.web.linkClicked.connect(self._lnk_handler) # AttributeError: 'QWebEngineView' object has no attribute 'linkClicked' except AttributeError: # PyQt5 pass # Not clear what to do. self.led = led = QtWidgets.QLineEdit(w) led.returnPressed.connect(self.docmd) lay.addWidget(led) lay.addWidget(web) self.lc = lc = LeoConnector() try: web.page().mainFrame().addToJavaScriptWindowObject("leo", lc) web.page().setLinkDelegationPolicy( QtWebKitWidgets.QWebPage.DelegateAllLinks) except AttributeError: # PyQt5 pass # Not clear what to do. 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 create_window(self, filenames): # Create the widget. global gWindow gWindow = window = QtWidgets.QWidget() window.setWindowTitle(f"{len(filenames)} duplicates of {filenames[0]}") window.setMinimumHeight(self.window_height) # Move the window. window.move(50, 50) # Init the layouts. outer_layout = QtWidgets.QVBoxLayout() window.setLayout(outer_layout) button_layout = QtWidgets.QHBoxLayout() frame_layout = QtWidgets.QHBoxLayout() outer_layout.addLayout(button_layout) outer_layout.addLayout(frame_layout) # Set the font. font = QtGui.QFont() font.setBold(True) font.setPointSize(12) # Create the common buttons, left aligned. next_button = QtWidgets.QPushButton(text='Next', parent=window) quit_button = QtWidgets.QPushButton(text='Quit', parent=window) next_button.setFont(font) quit_button.setFont(font) button_layout.addWidget(next_button) button_layout.addWidget(quit_button) button_layout.addStretch() # Create the actions. next_button.clicked.connect(window.close) quit_button.clicked.connect(self.quit) # Create the subframes and add them to the frame_layout. for filename in filenames: frame = self.create_frame(filename, filenames[:], window) if frame: frame_layout.addWidget(frame) # Handle close events. def closeEvent(*args, **kwargs): window.close() self.next_window() window.closeEvent = closeEvent # Show the window. window.show()
def __init__(self, c, parent=None): '''Ctor for ViewRenderedController class.''' self.c = c # Create the widget. QtWidgets.QWidget.__init__(self, parent) self.setObjectName('viewrendered_pane') self.setLayout(QtWidgets.QVBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) # Set the ivars. self.active = False self.badColors = [] self.delete_callback = None self.gnx = None self.graphics_class = QtWidgets.QGraphicsWidget self.gs = None # For @graphics-script: a QGraphicsScene self.gv = None # For @graphics-script: a QGraphicsView self.html_class = QtWebKitWidgets.QWebView # In VR2, this is a WebViewPlus. self.inited = False self.length = 0 # The length of previous p.b. self.locked = False self.scrollbar_pos_dict = { } # Keys are vnodes, values are positions. self.sizes = [] # Saved splitter sizes. self.splitter_index = None # The index of the rendering pane in the splitter. self.svg_class = QtSvg.QSvgWidget self.text_class = QtWidgets.QTextBrowser self.title = None self.vp = None # The present video player. self.w = None # The present widget in the rendering pane. # User-options: self.default_kind = c.config.getString( 'view-rendered-default-kind') or 'rst' self.auto_create = c.config.getBool('view-rendered-auto-create', False) # self.auto_hide = c.config.getBool('view-rendered-auto-hide',False) self.background_color = c.config.getColor( 'rendering-pane-background-color') or 'white' self.node_changed = True # Init. self.create_dispatch_dict() self.activate()
def _build_layout(self, show_head=True, show_control=True, update=True, recurse=False): """build_layout - build layout """ DBG("build layout") self.setLayout(QtWidgets.QVBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) self.layout().setSpacing(0) # header self.header = self._add_frame() self.toggle_ctrl = QtWidgets.QPushButton("-", self) self.header.layout().addWidget(self.toggle_ctrl) self.line_edit = QtWidgets.QLineEdit(self) self.header.layout().addWidget(self.line_edit) self.header.layout().addStretch(1) self.btn_close = QtWidgets.QPushButton("X", self) self.btn_close.clicked.connect(lambda checked: self.close()) self.header.layout().addWidget(self.btn_close) # controls self.control = self._add_frame() # checkboxes txt = ",\ncheck to do this always" self.cb_track = self._add_checkbox( "Track", self.change_track, "Track the node selected in the tree" + txt) self.cb_goto = self._add_checkbox( "Goto", self.change_goto, "Make the tree go to this node" + txt) self.cb_update = self._add_checkbox( "Update", self.change_update, "Update view to match changed node" + txt) self.cb_recurse = self._add_checkbox("Recurse", self.change_recurse, "Recursive view" + txt, checked=recurse) # mode menu btn = self.btn_mode = QtWidgets.QPushButton("Mode", self) self.control.layout().addWidget(btn) btn.setContextMenuPolicy(QtConst.CustomContextMenu) btn.customContextMenuRequested.connect( # right click lambda pnt: self.mode_menu()) btn.clicked.connect( # or left click lambda checked: self.mode_menu()) # misc. menu btn = self.control_menu_button = QtWidgets.QPushButton( "More\u25BE", self) self.control.layout().addWidget(btn) btn.setContextMenuPolicy(QtConst.CustomContextMenu) btn.customContextMenuRequested.connect( # right click lambda pnt: self.misc_menu()) btn.clicked.connect( # or left click lambda checked: self.misc_menu()) # padding self.control.layout().addItem( QtWidgets.QSpacerItem(0, 0, hPolicy=QtWidgets.QSizePolicy.Expanding)) # content self.splitter = ClickySplitter(self) self.splitter.setOrientation(QtCore.Qt.Vertical) self.layout().addWidget(self.splitter) self.edit_frame = self._add_frame() self.splitter.addWidget(self.edit_frame) self.view_frame = self._add_frame() self.splitter.addWidget(self.view_frame) self.control_visible = show_control self.header_visible = show_head self.show() # debug self.line_edit.setText("test") # toggle control visibility self.toggle_ctrl.clicked.connect( lambda checked: self.control.setVisible(not self.control.isVisible( )))
def make_ui(self): """make_ui - build up UI""" ui = type('CSVEditUI', (), {}) # a QVBox containing two QHBoxes self.setLayout(QtWidgets.QVBoxLayout()) buttons = QtWidgets.QHBoxLayout() self.layout().addLayout(buttons) buttons2 = QtWidgets.QHBoxLayout() self.layout().addLayout(buttons2) # make 4 directional 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) # add buttons to move rows / columns mkbuttons("Move", self.move) # add buttons to insert rows / columns mkbuttons("Insert", self.insert) for text, function, layout in [ ("Del row", lambda clicked: self.delete_col(row=True), buttons), ("Del col.", lambda clicked: self.delete_col(), buttons), ("Prev", lambda clicked: self.prev_tbl(), buttons2), ("Next", lambda clicked: self.prev_tbl(next=True), buttons2), ]: btn = QtWidgets.QPushButton(text) layout.addWidget(btn) btn.clicked.connect(function) # input for minimum rows to count as a table ui.min_rows = QtWidgets.QSpinBox() buttons2.addWidget(ui.min_rows) ui.min_rows.setMinimum(1) ui.min_rows.setPrefix("tbl with ") ui.min_rows.setSuffix(" rows") ui.min_rows.setValue(self.state['rows']) # separator text and line start / end text for attr in 'sep', 'start', 'end': buttons2.addWidget(QtWidgets.QLabel(attr.title() + ':')) w = QtWidgets.QLineEdit() w.setText(self.state[attr]) setattr(ui, attr + '_txt', w) # w.textEdited.connect(self.delim_changed) buttons2.addWidget(w) ui.sep_txt.setToolTip("Use Prev/Next to rescan table with new sep") w = QtWidgets.QPushButton('Change') w.setToolTip("Change separator in text") w.clicked.connect(lambda checked: self.delim_changed()) buttons2.addWidget(w) buttons.addStretch(1) buttons2.addStretch(1) ui.table = QtWidgets.QTableView() self.layout().addWidget(ui.table) return ui