示例#1
0
文件: miow.py 项目: jleahred/miow
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        self.setMinimumWidth(400)
        self.setMinimumHeight(400)

        # create widgets
        self._main_tab = QTabWidget(self)
        # self._main_tab.setTabsClosable(True)
        self._main_tab.setMovable(True)
        self.v_splitter = QSplitter(Qt.Vertical, self)
        self.v_splitter.addWidget(self._main_tab)
        layout = QVBoxLayout(self)
        layout.addWidget(self.v_splitter)
        layout.setMargin(0)
        self.setLayout(layout)

        self.command_window = CommandWindow(self)
        self.command_window.event_selected_command += self.cw_selected_command

        import shutil

        shutil.rmtree("/tmp/miow/", True)
        os.makedirs("/tmp/miow/")
示例#2
0
文件: miow.py 项目: jleahred/miow
class MainWindow(QWidget):
    """Miow main window
    """

    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        self.setMinimumWidth(400)
        self.setMinimumHeight(400)

        # create widgets
        self._main_tab = QTabWidget(self)
        # self._main_tab.setTabsClosable(True)
        self._main_tab.setMovable(True)
        self.v_splitter = QSplitter(Qt.Vertical, self)
        self.v_splitter.addWidget(self._main_tab)
        layout = QVBoxLayout(self)
        layout.addWidget(self.v_splitter)
        layout.setMargin(0)
        self.setLayout(layout)

        self.command_window = CommandWindow(self)
        self.command_window.event_selected_command += self.cw_selected_command

        import shutil

        shutil.rmtree("/tmp/miow/", True)
        os.makedirs("/tmp/miow/")

    def cw_selected_command(self, command):
        exec(command)

    def get_current_widget(self):
        return self.main_tab.currentWidget()

    def show_command_window(self, context=None):
        self.command_window.show_hide(context)

    def get_command_list(self, context=None):
        if context == None:
            command_list = copy(COMMAND_LIST)
            if self.get_current_widget():
                self.get_current_widget().bw_add_command_list(command_list)
        else:
            command_list = []
            EVENT_REQUEST_COMMAND_CONTEXT(context, command_list)
        return command_list

    @property
    def main_tab(self):
        return self._main_tab

    def _add_widget(self, widget_class, params):
        """Add any kind of widget"""
        widget = widget_class(params, self.main_tab)
        self.main_tab.addTab(widget, "?")
        self.main_tab.setCurrentIndex(self.main_tab.count() - 1)
        if self.main_tab.count() == 1:
            # self.v_splitter.setStretchFactor(0, 10)
            # self.v_splitter.setStretchFactor(1, 3)
            total_size = sum(self.v_splitter.sizes())
            self.v_splitter.setSizes([total_size / 100 * 70, total_size / 100 * 30])
        widget.setFocus()
        core.InterpreterEditor.CURRENT_WIDGET = widget