Example #1
0
 def __init__(self, parent=None):
     super(IDE, self).__init__(parent)
     self.setLayout(QtWidgets.QHBoxLayout(self))
     self.layout().setContentsMargins(0, 0, 0, 0)
     self.setObjectName('IDE')
     self.setWindowTitle('Python Editor')
     self.buildUI()
Example #2
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)
Example #3
0
    def __init__(self, parent=None):
        super(TabEditor, self).__init__(parent)
        if parent is not None:
            self.setParent(parent)

        self.setLayout(QtWidgets.QVBoxLayout(self))
        self.layout().setContentsMargins(0, 0, 0, 0)

        self.tab_widget = QtWidgets.QWidget()
        twl = QtWidgets.QHBoxLayout(self.tab_widget)
        self.tab_widget_layout = twl
        self.tab_widget_layout.setContentsMargins(0, 0, 0, 0)
        self.tabs = Tabs()
        self.tab_widget_layout.addWidget(self.tabs)

        # add corner buttons
        tb = QtWidgets.QToolButton()
        self.tab_list_button = tb
        tb.setArrowType(QtCore.Qt.DownArrow)
        tb.setToolTip('Click for a list of tabs.')
        tb.setAutoRaise(True)
        tb.setFixedSize(24, 24)
        self.tab_list_button.clicked.connect(self.show_tab_menu)

        nb = QtWidgets.QToolButton()
        self.new_tab_button = nb
        nb.setToolTip('Click to add a new tab.')
        nb.setText('+')
        nb.setAutoRaise(True)
        self.new_tab_button.clicked.connect(self.new_tab)

        for button in [self.new_tab_button, self.tab_list_button]:
            self.tab_widget_layout.addWidget(button)

        self.editor = editor.Editor(handle_shortcuts=False)

        for widget in self.tab_widget, self.editor:
            self.layout().addWidget(widget)

        # Give the autosave a chance to load all
        # tabs before connecting signals between
        # tabs and editor.
        QtCore.QTimer.singleShot(0, self.connect_signals)
Example #4
0
    def __init__(self):
        super(SingleTab, self).__init__()
        l = LoaderList()
        self.l = l
        root, subscripts = autosavexml.parsexml('subscript')
        for s in subscripts:
            name = s.attrib.get('name')
            a = s.attrib.copy()
            a['text'] = s.text
            l[name] = a

        self.t = edittabs.EditTabs()
        self.l.emit_tab.connect(self.receive_tab)

        self._layout = QtWidgets.QHBoxLayout(self)
        self.splitter = QtWidgets.QSplitter(self)
        self._layout.addWidget(self.splitter)
        self.setLayout(self._layout)

        self.splitter.addWidget(self.l)
        self.splitter.addWidget(self.t)
Example #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
        )