コード例 #1
0
    def show_popup_bar(self):
        #editor = _ide.python_editor.editor
        #layout = _ide.python_editor.tabeditor.layout()
        
        editor = self.editor
        layout = self.tabeditor.layout()

        # first remove any previous widgets
        name = 'Document out of sync warning'
        for i in range(layout.count()):
            item = layout.itemAt(i)
            if item is None:
                continue
            widget = item.widget()
            if widget.objectName() != name:
                continue
            layout.removeItem(item)
            widget.deleteLater()

        popup_bar = QtWidgets.QWidget()
        popup_bar.setObjectName('Document out of sync warning')
        bar_layout = QtWidgets.QHBoxLayout(popup_bar)

        l = QtWidgets.QLabel()
        l.setText('This tab is out of sync with the autosave.')
        new_button     = QtWidgets.QPushButton('Load into New Tab')
        save_button    = QtWidgets.QPushButton('Save This Version')
        update_button  = QtWidgets.QPushButton('Update From Autosave')
        diff_button    = QtWidgets.QPushButton('Show Diff')

        stylesheet = """
        QPushButton { background-color: #444; }
        QPushButton:hover { background-color: orange; }
        """

        for b in new_button, save_button, update_button, diff_button:
            #b.setFlat(True)
            b.setStyleSheet(stylesheet)

        for b in l, new_button, save_button, update_button, diff_button:
            bar_layout.addWidget(b)

        layout.insertWidget(1, popup_bar)
        popup_bar.setMaximumHeight(0)

        #print popup_bar.maximumHeight()
        #popup_bar.setMaximumHeight(46)
        def anim_popup_bar(popup_bar):
            anim = QtCore.QPropertyAnimation(
                popup_bar, 
                'maximumHeight'
            )
            anim.setStartValue(0)
            anim.setEndValue(46)
            anim.setDuration(400)
            anim.start()
            anim_popup_bar.anim = anim

        anim_popup_bar(popup_bar)
コード例 #2
0
ファイル: menubar.py プロジェクト: franklinvfx/PythonEditor
 def show_about_dialog(self):
     """
     Shows an about dialog with version information.
     TODO: Make it a borderless splash screen, centred, nice text,
     major and minor version numbers set in one place in the
     project.
     """
     msg = 'Python Editor version {0} by Max Last'.format(__version__)
     self.about_dialog = QtWidgets.QLabel(msg)
     self.about_dialog.show()
コード例 #3
0
ファイル: preferences.py プロジェクト: plasmax/PythonEditor
    def build_layout(self):

        # external editor path
        self.edit_path = QtWidgets.QLineEdit()
        self.external_editor_label = QtWidgets.QLabel('External Editor Path')
        self.external_editor_label.setBuddy(self.edit_path)
        self.layout.addWidget(self.external_editor_label)
        self.layout.addWidget(self.edit_path)

        # # change editor colours
        self.choose_colour_button = QtWidgets.QPushButton('Choose Colour')
        self.colour_dialog = QtWidgets.QColorDialog()
        self.choose_colour_button.clicked.connect(self.colour_dialog.show)
        self.layout.addWidget(self.choose_colour_button)

        # change editor font
        self.font_size = QtWidgets.QSpinBox()
        self.font_size.setValue(9)
        self.font_size_label = QtWidgets.QLabel('Choose Font Size')
        self.font_size_label.setBuddy(self.font_size)
        self.layout.addWidget(self.font_size_label)
        self.layout.addWidget(self.font_size)
コード例 #4
0
 def new_button(self):
     i = self.currentIndex() + 1
     e = Editor()
     self.insertTab(i, e, '')
     b = QtWidgets.QToolButton()
     b.editor = e
     b.clicked.connect(self.close_tab)
     self.tabs.append(b)
     b.setText('x')
     l = QtWidgets.QLabel('Widget')
     self.tabs.append(l)
     tb = self.tabBar()
     tb.setTabButton(i, QtWidgets.QTabBar.RightSide, b)
     tb.setTabButton(i, QtWidgets.QTabBar.LeftSide, l)
コード例 #5
0
    def show_diff_text_popup(self, subscript):
        popup_bar = QtWidgets.QWidget()
        self.popup_bar = popup_bar
        name = 'Document out of sync warning'
        popup_bar.setObjectName(name)
        popup_bar.setLayout(
            QtWidgets.QHBoxLayout(popup_bar)
        )

        label = QtWidgets.QLabel()
        label.setText(
            'This tab is out of sync\n'\
            'with the autosave.'
        )
        popup_bar.layout().addWidget(label)

        B = QtWidgets.QPushButton
        new_button    = B('Load into New Tab')
        new_button.setToolTip(
            'Click to load the text inside '\
            'the editor into a fresh tab, '\
            'updating the autosaved version '\
            'into the previous tab.'
        )
        save_button   = B('Save This Version')
        save_button.setToolTip(
            'Click to choose this version '\
            'as the version to save.'
        )
        update_button = B('Update From Autosave')
        update_button.setToolTip(
            'Load the version from the '\
            'autosave into this tab.'
        )

        diff_button   = B('Show Diff')
        diff_button.setToolTip(
            'Show the difference between the two.'
        )

        remove = partial(
            self.remove_existing_popups,
            name
        )

        layout = self.tabeditor.layout()
        layout.insertWidget(1, popup_bar)

        stylesheet = """
        QPushButton { background-color: #444; }
        QPushButton:hover { background-color: orange; }
        """
        buttons = (
            new_button,
            save_button,
            update_button,
            diff_button
        )
        for b in buttons:
            popup_bar.layout().addWidget(b)
            b.setStyleSheet(stylesheet)

        # wire signals into buttons
        new = partial(
            self.load_into_new_tab,
            subscript
        )
        new_button.clicked.connect(new)
        new_button.clicked.connect(remove)
        save = partial(
            self.save_this_version,
            subscript
        )
        save_button.clicked.connect(save)
        save_button.clicked.connect(remove)
        update = partial(
            self.update_from_autosave,
            subscript
        )
        update_button.clicked.connect(update)
        update_button.clicked.connect(remove)

        show_diff = partial(
            self.show_diff_text,
            subscript.text
        )
        diff_button.clicked.connect(show_diff)

        self.editor.modificationChanged.connect(
            self.check_diff_modified
        )