当前位置: 首页>>代码示例>>Python>>正文


Python QStackedLayout.currentIndex方法代码示例

本文整理汇总了Python中PyQt4.QtGui.QStackedLayout.currentIndex方法的典型用法代码示例。如果您正苦于以下问题:Python QStackedLayout.currentIndex方法的具体用法?Python QStackedLayout.currentIndex怎么用?Python QStackedLayout.currentIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtGui.QStackedLayout的用法示例。


在下文中一共展示了QStackedLayout.currentIndex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _MainContainer

# 需要导入模块: from PyQt4.QtGui import QStackedLayout [as 别名]
# 或者: from PyQt4.QtGui.QStackedLayout import currentIndex [as 别名]

#.........这里部分代码省略.........

    def add_status_bar(self, status):
        self._vbox.addWidget(status)

    @property
    def combo_header_size(self):
        return self.combo_area.bar.height()

    def add_widget(self, widget):
        self.stack.addWidget(widget)

    def remove_widget(self, widget):
        self.stack.removeWidget(widget)

    def _close_dialog(self, widget):
        self.emit(SIGNAL("closeDialog(PyQt_PyObject)"), widget)
        self.disconnect(widget, SIGNAL("finished(int)"),
                        lambda: self._close_dialog(widget))

    def show_dialog(self, widget):
        self._opening_dialog = True
        self.connect(widget, SIGNAL("finished(int)"),
                     lambda: self._close_dialog(widget))
        self.setVisible(True)
        self.stack.addWidget(widget)
        self.show_selector()

    def show_selector(self):
        if self.selector != self.stack.currentWidget():
            temp_dir = os.path.join(QDir.tempPath(), "ninja-ide")
            if not os.path.exists(temp_dir):
                os.mkdir(temp_dir)
            collected_data = []
            current = self.stack.currentIndex()
            for index in range(self.stack.count()):
                widget = self.stack.widget(index)
                if widget == self.selector:
                    continue
                closable = True
                if widget == self.splitter:
                    closable = False
                pixmap = QPixmap.grabWidget(widget, widget.rect())
                path = os.path.join(temp_dir, "screen%s.png" % index)
                pixmap.save(path)
                if index == current:
                    self.selector.set_preview(index, path)
                    collected_data.insert(0, (index, path, closable))
                else:
                    collected_data.append((index, path, closable))
            self.selector.set_model(collected_data)
        else:
            self.selector.close_selector()

    def _selector_ready(self):
        self.stack.setCurrentWidget(self.selector)
        self.selector.start_animation()

    def _selector_animation_completed(self):
        if self._opening_dialog:
            # We choose the last one with -2, -1 (for last one) +
            # -1 for the hidden selector widget which is in the stacked too.
            self.selector.open_item(self.stack.count() - 2)
        self._opening_dialog = False

    def _change_current_stack(self, index):
        self.stack.setCurrentIndex(index)
开发者ID:adamscieszko,项目名称:ninja-ide,代码行数:70,代码来源:main_container.py

示例2: ComboEditor

# 需要导入模块: from PyQt4.QtGui import QStackedLayout [as 别名]
# 或者: from PyQt4.QtGui.QStackedLayout import currentIndex [as 别名]
class ComboEditor(QDialog):

    def __init__(self, original=False):
        super(ComboEditor, self).__init__(None, Qt.WindowStaysOnTopHint)
        self.__original = original
        self.__undocked = []
        self._symbols_index = []
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)

        self.bar = ActionBar(main_combo=original)
        vbox.addWidget(self.bar)

        self.stacked = QStackedLayout()
        vbox.addLayout(self.stacked)

        self._main_container = IDE.get_service('main_container')

        if not self.__original:
            self.connect(self._main_container, SIGNAL("fileOpened(QString)"),
                self._file_opened_by_main)

        self.connect(self.bar, SIGNAL("changeCurrent(PyQt_PyObject, int)"),
            self._set_current)
        self.connect(self.bar, SIGNAL("splitEditor(bool)"), self.split_editor)
        self.connect(self.bar, SIGNAL("runFile(QString)"),
            self._run_file)
        self.connect(self.bar, SIGNAL("closeSplit()"),
            lambda: self.emit(SIGNAL("closeSplit(PyQt_PyObject)"), self))
        self.connect(self.bar, SIGNAL("addToProject(QString)"),
            self._add_to_project)
        self.connect(self.bar, SIGNAL("goToSymbol(int)"),
            self._go_to_symbol)
        self.connect(self.bar, SIGNAL("undockEditor()"),
            self.undock_editor)
        self.connect(self.bar, SIGNAL("reopenTab(QString)"),
            lambda path: self._main_container.open_file(path))
        self.connect(self.bar, SIGNAL("recentTabsModified()"),
            lambda: self._main_container.recent_files_changed())
        self.connect(self.bar.code_navigator.btnPrevious, SIGNAL("clicked()"),
            lambda: self._navigate_code(False))
        self.connect(self.bar.code_navigator.btnNext, SIGNAL("clicked()"),
            lambda: self._navigate_code(True))

    def _navigate_code(self, val):
        op = self.bar.code_navigator.operation
        self._main_container.navigate_code_history(val, op)

    def currentWidget(self):
        return self.stacked.currentWidget()

    def setFocus(self):
        super(ComboEditor, self).setFocus()
        self.stacked.currentWidget().setFocus()
        self._editor_with_focus()

    def _file_opened_by_main(self, path):
        index = self.stacked.currentIndex()
        ninjaide = IDE.get_service('ide')
        editable = ninjaide.get_or_create_editable(path)
        self.add_editor(editable)
        self.bar.set_current_by_index(index)

    def add_editor(self, neditable):
        """Add Editor Widget to the UI area."""
        if neditable.editor:
            if self.__original:
                editor = neditable.editor
            else:
                editor = self._main_container.create_editor_from_editable(
                    neditable)
            self.stacked.addWidget(editor)
            self.bar.add_item(neditable.display_name, neditable)

            # Editor Signals
            self.connect(editor, SIGNAL("cursorPositionChanged()"),
                self._update_cursor_position)
            self.connect(editor, SIGNAL("editorFocusObtained()"),
                self._editor_with_focus)
            self.connect(editor, SIGNAL("currentLineChanged(int)"),
                self._set_current_symbol)
            self.connect(editor, SIGNAL("modificationChanged(bool)"),
                self._editor_modified)
            self.connect(neditable, SIGNAL("checkersUpdated(PyQt_PyObject)"),
                self._show_notification_icon)
            self.connect(neditable, SIGNAL("fileSaved(PyQt_PyObject)"),
                self._update_symbols)
            self.connect(neditable, SIGNAL("fileSaved(PyQt_PyObject)"),
                self._update_combo_info)

            # Connect file system signals only in the original
            self.connect(neditable, SIGNAL("fileClosing(PyQt_PyObject)"),
                self._close_file)
            if self.__original:
                self.connect(neditable,
                    SIGNAL("neverSavedFileClosing(PyQt_PyObject)"),
                    self._ask_for_save)
                self.connect(neditable, SIGNAL("fileChanged(PyQt_PyObject)"),
                    self._file_has_been_modified)
#.........这里部分代码省略.........
开发者ID:nelsam,项目名称:ninja-ide,代码行数:103,代码来源:combo_editor.py

示例3: ProjectTreeColumn

# 需要导入模块: from PyQt4.QtGui import QStackedLayout [as 别名]
# 或者: from PyQt4.QtGui.QStackedLayout import currentIndex [as 别名]
class ProjectTreeColumn(QDialog):

    def __init__(self, parent=None):
        super(ProjectTreeColumn, self).__init__(parent,
                                                Qt.WindowStaysOnTopHint)
        vbox = QVBoxLayout(self)
        vbox.setSizeConstraint(QVBoxLayout.SetDefaultConstraint)
        vbox.setContentsMargins(0, 0, 0, 0)
        self._buttons = []

        self._combo_project = QComboBox()
        self._combo_project.setMinimumHeight(30)
        self._combo_project.setContextMenuPolicy(Qt.CustomContextMenu)
        vbox.addWidget(self._combo_project)

        self._projects_area = QStackedLayout()
        logger.debug("This is the projects area")
        logger.debug(self._projects_area)
        vbox.addLayout(self._projects_area)

        self.projects = []

        self.connect(self._combo_project, SIGNAL("currentIndexChanged(int)"),
                     self._change_current_project)
        self.connect(self._combo_project, SIGNAL(
            "customContextMenuRequested(const QPoint &)"),
            self.context_menu_for_root)
        connections = (
            {'target': 'main_container',
             'signal_name': 'addToProject(QString)',
             'slot': self._add_file_to_project},
            {'target': 'main_container',
             'signal_name': 'showFileInExplorer(QString)',
             'slot': self._show_file_in_explorer},
        )
        IDE.register_service('projects_explorer', self)
        IDE.register_signals('projects_explorer', connections)
        ExplorerContainer.register_tab(translations.TR_TAB_PROJECTS, self)

        #FIXME: Should have a ninja settings object that stores tree state
        #FIXME: Or bettter, application data object
        #TODO: check this:
        #self.connect(ide, SIGNAL("goingDown()"),
            #self.tree_projects.shutdown)

        #def close_project_signal():
            #self.emit(SIGNAL("updateLocator()"))

    def install_tab(self):
        ide = IDE.get_service('ide')
        ui_tools.install_shortcuts(self, actions.PROJECTS_TREE_ACTIONS, ide)

        self.connect(ide, SIGNAL("goingDown()"), self.close)

    def load_session_projects(self, projects):
        for project in projects:
            if os.path.exists(project):
                self._open_project_folder(project)

    def open_project_folder(self, folderName=None):
        if settings.WORKSPACE:
            directory = settings.WORKSPACE
        else:
            directory = os.path.expanduser("~")

        if folderName is None:
            folderName = QFileDialog.getExistingDirectory(
                self, translations.TR_OPEN_PROJECT_DIRECTORY, directory)
            logger.debug("Choosing Foldername")
        if folderName:
            logger.debug("Opening %s" % folderName)
            self._open_project_folder(folderName)

    def _open_project_folder(self, folderName):
        ninjaide = IDE.get_service("ide")
        project = NProject(folderName)
        qfsm = ninjaide.filesystem.open_project(project)
        if qfsm:
            self.add_project(project)
            self.emit(SIGNAL("updateLocator()"))
            self.save_recent_projects(folderName)
            main_container = IDE.get_service('main_container')
            if main_container:
                main_container.show_editor_area()

    def _add_file_to_project(self, path):
        """Add the file for 'path' in the project the user choose here."""
        if self._active_project:
            pathProject = [self._active_project.project]
            addToProject = add_to_project.AddToProject(pathProject, self)
            addToProject.exec_()
            if not addToProject.pathSelected:
                return
            main_container = IDE.get_service('main_container')
            if not main_container:
                return
            editorWidget = main_container.get_current_editor()
            if not editorWidget.file_path:
                name = QInputDialog.getText(None,
                                            translations.TR_ADD_FILE_TO_PROJECT,
#.........这里部分代码省略.........
开发者ID:malix0,项目名称:ninja-ide,代码行数:103,代码来源:tree_projects_widget.py


注:本文中的PyQt4.QtGui.QStackedLayout.currentIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。