本文整理汇总了Python中PyQt5.QtWidgets.QStackedLayout.count方法的典型用法代码示例。如果您正苦于以下问题:Python QStackedLayout.count方法的具体用法?Python QStackedLayout.count怎么用?Python QStackedLayout.count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QStackedLayout
的用法示例。
在下文中一共展示了QStackedLayout.count方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _MainContainer
# 需要导入模块: from PyQt5.QtWidgets import QStackedLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QStackedLayout import count [as 别名]
#.........这里部分代码省略.........
def add_widget(self, widget):
i = self.stack.addWidget(widget)
#if not isinstance(widget, start_page.StartPage):
self.tryMakeImagePreview(i)
def remove_widget(self, widget):
#self.toRemovePreview.emit(self.stack.widget(widget))
self.stack.removeWidget(widget)
def _close_dialog(self, widget):
self.closeDialog.emit(widget)
widget.finished[int].disconnect()#lambda i: self._close_dialog(widget))
def show_dialog(self, widget):
print("\n\nshow_dialog", self.isVisible())
self._opening_dialog = True
widget.finished[int].connect(lambda i: self._close_dialog(widget))
widget.setVisible(True)
self.show_selector()
def show_selector(self):
print("\n\nshow_selector::", self.selector, self.stack.currentWidget())
if self.selector != self.stack.currentWidget():
_dir = self.Successful_Tmp()
if not _dir:
print("failed!")
return
# 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
# path = os.path.join(temp_dir, "screen%s.png" % index)
#ff = QFile(_dir, "screen%s.png" % index)
path = _dir.absolutePath()+"/screen%s.png" % index
pixmap = widget.grab()#widget.rect())
pixmap.save(path)
#path = path.replace("\\", '/')
#print("path::", path, QFileInfo(path).exists())
path = "file:///"+path
if index == current:
self.selector.set_preview(index, path)#QUrl(path)
collected_data.insert(0, (index, path, closable))
else:
collected_data.append((index, path, closable))
self.selector.set_model(collected_data)
print("self.selector.set_model()", collected_data)
self.stack.setCurrentWidget(self.selector)
else:
print("\n\n_selector_Close()")
self._selector_Close()
def Successful_Tmp(self):# CheckTmpDir, StateTmpDir
failed = lambda: not self.tdir or not self.tdir.isValid()
if failed():# not successfully
self.tdir = QTemporaryDir()
if failed():
QMessageBox.critical(self, "Unexpected Failurer", "The application has detected a problem trying to\nCreate or Access a Temporary File!.")
示例2: ComboEditor
# 需要导入模块: from PyQt5.QtWidgets import QStackedLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QStackedLayout import count [as 别名]
#.........这里部分代码省略.........
if not self.bar.isVisible():
self.bar.setVisible(True)
if keep_index:
self.bar.set_current_by_index(current_index)
# Connections
neditable.fileClosing.connect(self._close_file)
neditable.fileSaved.connect(self._update_symbols)
editor.editorFocusObtained.connect(self._editor_with_focus)
editor.modificationChanged.connect(self._editor_modified)
editor.cursor_position_changed[int, int].connect(
self._update_cursor_position)
editor.current_line_changed[int].connect(self._set_current_symbol)
if neditable._swap_file.dirty:
self._editor_modified(True, sender=editor)
neditable.checkersUpdated.connect(self._show_notification_icon)
# Connect file system signals only in the original
if self.__original:
neditable.askForSaveFileClosing.connect(self._ask_for_save)
neditable.fileChanged.connect(self._file_has_been_modified)
# Load Symbols
self._load_symbols(neditable)
def show_combo_file(self):
self.bar.combo.showPopup()
def show_combo_symbol(self):
self.bar.symbols_combo.showPopup()
def show_combo_set_language(self):
self.bar.set_language_combo.showPopup()
def unlink_editors(self):
for index in range(self.stacked.count()):
widget = self.stacked.widget(index)
# widget.setDocument(QsciDocument())
def clone(self):
combo = ComboEditor()
for neditable in self.bar.get_editables():
combo.add_editor(neditable)
return combo
def split_editor(self, orientation):
new_combo = self.clone()
self.splitEditor.emit(self, new_combo, orientation)
def undock_editor(self):
new_combo = ComboEditor()
for neditable in self.bar.get_editables():
new_combo.add_editor(neditable)
self.__undocked.append(new_combo)
new_combo.setWindowTitle("NINJA-IDE")
editor = self.current_editor()
new_combo.set_current(editor.neditable)
new_combo.resize(700, 500)
new_combo.about_to_close_combo_editor.connect(self._remove_undock)
new_combo.show()
def _remove_undock(self):
widget = self.sender()
self.__undocked.remove(widget)
def close_current_file(self):
self.bar.about_to_close_file()
示例3: ProjectTreeColumn
# 需要导入模块: from PyQt5.QtWidgets import QStackedLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QStackedLayout import count [as 别名]
#.........这里部分代码省略.........
return
logger.debug("Opening %s" % folderName)
for p in self.projects:
if p.project.path == folderName:
QMessageBox.information(
self,
translations.TR_PROJECT_PATH_ALREADY_EXIST_TITLE,
translations.TR_PROJECT_PATH_ALREADY_EXIST
% folderName)
return
self._open_project_folder(folderName)
def _open_project_folder(self, folderName):
ninjaide = IDE.get_service("ide")
# TODO: handle exception when .nja file is empty
project = NProject(folderName)
qfsm = ninjaide.filesystem.open_project(project)
if qfsm:
self.add_project(project)
self.save_recent_projects(folderName)
# FIXME: show editor area?
# main_container = IDE.get_service('main_container')
# if main_container:
# main_container.show_editor_area()
if len(self.projects) > 1:
title = "%s (%s)" % (
translations.TR_TAB_PROJECTS, len(self.projects))
else:
title = translations.TR_TAB_PROJECTS
self.changeTitle.emit(self, title)
def _add_file_to_project(self, path):
"""Add the file for 'path' in the project the user choose here."""
if self._projects_area.count() > 0:
path_project = [self.current_project]
_add_to_project = add_to_project.AddToProject(path_project, self)
_add_to_project.exec_()
if not _add_to_project.path_selected:
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,
translations.TR_FILENAME + ": ")[0]
if not name:
QMessageBox.information(
self,
translations.TR_INVALID_FILENAME,
translations.TR_INVALID_FILENAME_ENTER_A_FILENAME)
return
else:
name = file_manager.get_basename(editorWidget.file_path)
new_path = file_manager.create_path(
_add_to_project.path_selected, name)
ide_srv = IDE.get_service("ide")
old_file = ide_srv.get_or_create_nfile(path)
new_file = old_file.save(editorWidget.text(), new_path)
# FIXME: Make this file replace the original in the open tab
else:
pass
# Message about no project
示例4: ComboEditor
# 需要导入模块: from PyQt5.QtWidgets import QStackedLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QStackedLayout import count [as 别名]
#.........这里部分代码省略.........
neditable)
index = self.stacked.currentIndex()
self.stacked.addWidget(editor)
self.bar.add_item(neditable.display_name, neditable)
if keep_index:
self.bar.set_current_by_index(index)
# Editor Signals
editor.cursorPositionChanged[int, int].connect(self._update_cursor_position)
editor.editorFocusObtained.connect(self._editor_with_focus)
editor.currentLineChanged.connect(self._set_current_symbol)
editor.modificationChanged['bool'].connect(self._editor_modified)
neditable.checkersUpdated.connect(self._show_notification_icon)
neditable.fileSaved.connect(self._update_symbols)
neditable.fileSaved.connect(self._update_combo_info)
# Connect file system signals only in the original
neditable.fileClosing.connect(self._close_file)
if self.__original:
neditable.askForSaveFileClosing.connect(self._ask_for_save)
neditable.fileChanged.connect(self._file_has_been_modified)
# Load Symbols
self._load_symbols(neditable)
def show_combo_file(self):
print("show_combo_file")
self.bar.combo.showPopup()
def show_combo_symbol(self):
self.bar.symbols_combo.showPopup()
def unlink_editors(self):
for index in range(self.stacked.count()):
widget = self.stacked.widget(index)
widget.setDocument(QsciDocument())
def split_editor(self, orientationVertical):
new_widget = ComboEditor()
for neditable in self.bar.get_editables():
print("\nsplit_editor", neditable, new_widget)
new_widget.add_editor(neditable)
self.splitEditor.emit(self, new_widget, orientationVertical)
def undock_editor(self):
new_combo = ComboEditor()
new_combo.setWindowTitle("NINJA-IDE")
self.__undocked.append(new_combo)
for neditable in self.bar.get_editables():
print("undock_editor", neditable)
new_combo.add_editor(neditable)
new_combo.resize(500, 500)
new_combo.aboutToCloseComboEditor.connect(self._remove_undock)
new_combo.show()
def _remove_undock(self):
widget = self.sender()
self.__undocked.remove(widget)
def close_current_file(self):
self.bar.about_to_close_file()
def _close_file(self, neditable):
index = self.bar.close_file(neditable)
layoutItem = self.stacked.takeAt(index)
#neditable.editor.completer.cc.unload_module()
示例5: ProjectTreeColumn
# 需要导入模块: from PyQt5.QtWidgets import QStackedLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QStackedLayout import count [as 别名]
class ProjectTreeColumn(QDialog):
dockWidget = pyqtSignal("QObject*")
undockWidget = pyqtSignal()
changeTitle = pyqtSignal("QObject*", str)
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._combo_project.currentIndexChanged[int].connect(self._change_current_project)
self._combo_project.customContextMenuRequested['const QPoint &'].connect(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.getInstance()
ui_tools.install_shortcuts(self, actions.PROJECTS_TREE_ACTIONS, ide)
ide.goingDown.connect(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):
print("open_project_folder", folderName)
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.save_recent_projects(folderName)
main_container = IDE.get_service('main_container')
if main_container:
main_container.show_editor_area()
if len(self.projects) > 1:
title = "%s (%s)" % (
translations.TR_TAB_PROJECTS, len(self.projects))
else:
title = translations.TR_TAB_PROJECTS
self.changeTitle.emit(self, title)
def _add_file_to_project(self, path):
"""Add the file for 'path' in the project the user choose here."""
if self._projects_area.count() > 0:
pathProject = [self.current_project]
addToProject = add_to_project.AddToProject(pathProject, self)
addToProject.exec_()
if not addToProject.pathSelected:
return
#.........这里部分代码省略.........