Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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))
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
 def open_window(self, action=None):
     """open a top-level window, a TopLevelFreeLayout instance, to hold a
     free-layout in addition to the one in the outline's main window"""
     ns = NestedSplitter(root=self.root)
     window = NestedSplitterTopLevel(owner=self.root,
                                     window_title=ns.get_title(action))
     hbox = QtWidgets.QHBoxLayout()
     window.setLayout(hbox)
     hbox.setContentsMargins(0, 0, 0, 0)
     window.resize(400, 300)
     hbox.addWidget(ns)
     # NestedSplitters must have two widgets so the handle carrying
     # the all important context menu exists
     ns.addWidget(NestedSplitterChoice(ns))
     button = NestedSplitterChoice(ns)
     ns.addWidget(button)
     if action == '_move_marked_there':
         ns.replace_widget(button, ns.root.marked[3])
     elif action is not None:
         ns.place_provided(action, 1)
     ns.setSizes([0, 1])  # but hide one initially
     self.root.windows.append(window)
     # copy the main main window's stylesheet to new window
     w = self.root  # this is a Qt Widget, class NestedSplitter
     sheets = []
     while w:
         s = w.styleSheet()
         if s:
             sheets.append(str(s))
         w = w.parent()
     sheets.reverse()
     ns.setStyleSheet('\n'.join(sheets))
     window.show()
Ejemplo n.º 7
0
 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)
Ejemplo n.º 8
0
 def __init__(self, parent, c):
     super().__init__(parent)
     hBox = QtWidgets.QHBoxLayout()
     self.setLayout(hBox)
     self.textEdit = PyInterp(self, c)
     # this is how you pass in locals to the interpreter
     self.textEdit.initInterpreter(locals())
     hBox.addWidget(self.textEdit)
     hBox.setContentsMargins(0, 0, 0, 0)
     hBox.setSpacing(0)
    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()
Ejemplo n.º 10
0
    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 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
Ejemplo n.º 12
0
    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
Ejemplo n.º 13
0
    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)
Ejemplo n.º 14
0
    def __init__ (self, c):

        self.c = c
        c.attribEditor = self

        self.pname = "_attrib_edit_frame"  # used to tag out panel

        active = c.config.getData('attrib_edit_active_modes') or []

        self.getsetters = []
        for i in AttributeGetter.implementations:
            s = i(c)
            self.getsetters.append([s, (s.name() in active) ])
        if not active:
            self.getsetters[0][1] = True  # turn on the first one

        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)
Ejemplo n.º 15
0
    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