Exemplo n.º 1
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)
Exemplo n.º 2
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)
    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
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    def initForm(self):
        """set up self.form, the blank form layout before adding edit widgets"""
        self.editors = []

        w = self.holder

        for i in w.parent().findChildren(QtCore.QObject):
            if i.objectName() == self.pname:
                i.hide()
                i.deleteLater()

        pnl = QtWidgets.QFrame()
        pnl.setObjectName(self.pname)
        self.form = QtWidgets.QFormLayout()
        self.form.setVerticalSpacing(0)
        pnl.setLayout(self.form)
        pnl.setAutoFillBackground(True)
        w.addWidget(pnl)
Exemplo n.º 6
0
 def open_shell_window(self, parent=None):
     '''Open pyzo's file browser.'''
     try:
         if not parent:
             # Create a "large enough" parent window.
             parent = QtWidgets.QFrame()
             parent.setMinimumSize(800, 500)
             # Avoids an error.
             self.widgets.append(parent)
         #@+<< import the shell >>
         #@+node:ekr.20190415182821.1: *4* << import the shell >>
         #
         # Standard prerequisites.
         import pyzo
         import pyzo.core.main as main
         main.loadIcons()
         main.loadFonts()
         from pyzo.core.menu import Menu
         from pyzo.tools.pyzoFileBrowser.tree import Tree
         if 0:  # To keep pyflakes quiet.
             print(pyzo, Menu, Tree)
         #
         # Build the keymapper
         from pyzo.core import menu
         pyzo.keyMapper = menu.KeyMapper()
         #
         # Shell-related...
         import pyzo.core.shellStack as shellStack
         import pyzo.core.shell as shell
         from pyzo.core import kernelbroker
         import pyzo.tools as tools
         from pyzo.core.shellStack import ShellStackWidget
         if 0:  # To keep pyflakes quiet.
             print(shellStack, shell, kernelbroker, tools)
         #@-<< import the shell >>
         ### self.monkey_patch_shell()
         shell_widget = ShellStackWidget(parent=parent)
         self.widgets.append(shell_widget)
         parent.show()
         # Must be done after creating the shell widget.
         return shell_widget
     except Exception:
         g.es_exception()
         return None
Exemplo n.º 7
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)