本文整理汇总了Python中PyQt5.QtWidgets.QStackedLayout.widget方法的典型用法代码示例。如果您正苦于以下问题:Python QStackedLayout.widget方法的具体用法?Python QStackedLayout.widget怎么用?Python QStackedLayout.widget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QStackedLayout
的用法示例。
在下文中一共展示了QStackedLayout.widget方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _MainContainer
# 需要导入模块: from PyQt5.QtWidgets import QStackedLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QStackedLayout import widget [as 别名]
#.........这里部分代码省略.........
self.__bookmarksFile = ''
self.__bookmarksPos = -1
self.__breakpointsFile = ''
self.__breakpointsPos = -1
self.__operations = {
0: self._navigate_code_jumps,
1: self._navigate_bookmarks,
2: self._navigate_breakpoints}
self.locateFunction.connect(self.locate_function)
IDE.register_service('main_container', self)
#Register signals connections
connections = (
{'target': 'menu_file',
'signal_name': 'openFile',#(QString)
'slot': self.open_file},
{'target': 'explorer_container',
'signal_name': 'goToDefinition',#(int)
'slot': self.editor_go_to_line},
{'target': 'explorer_container',
'signal_name': 'pep8Activated',#(bool)
'slot': self.reset_pep8_warnings},
{'target': 'explorer_container',
'signal_name': 'lintActivated',#(bool)
'slot': self.reset_lint_warnings},
)
IDE.register_signals('main_container', connections)
self.selector = main_selector.MainSelector(self)
self._opening_dialog = False
self.add_widget(self.selector)
if settings.SHOW_START_PAGE:
self.show_start_page()
self.selector.changeCurrent[int].connect(self._change_current_stack)
self.selector.removeWidget[int].connect(self._remove_item_from_stack)
self.selector.ready.connect(self._selector_ready)
self.selector.closePreviewer.connect(self._selector_Close)
self.selector.animationCompleted.connect(self._selector_animation_completed)
self.closeDialog.connect(self.remove_widget)
self.stack.widgetRemoved[int].connect(lambda i:print("widgetRemoved._-", i))
def install(self):
ide = IDE.getInstance()
ide.place_me_on("main_container", self, "central", top=True)
self.combo_area = combo_editor.ComboEditor(original=True)
self.combo_area.allFilesClosed.connect(self._files_closed)
self.splitter.add_widget(self.combo_area)
self.add_widget(self.splitter)
self.current_widget = self.combo_area
ui_tools.install_shortcuts(self, actions.ACTIONS, ide)
def add_status_bar(self, status):
self._vbox.addWidget(status)
@property
def combo_header_size(self):
return self.combo_area.bar.height()
示例2: _MainContainer
# 需要导入模块: from PyQt5.QtWidgets import QStackedLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QStackedLayout import widget [as 别名]
class _MainContainer(QWidget):
currentEditorChanged = pyqtSignal(str)
fileOpened = pyqtSignal(str)
beforeFileSaved = pyqtSignal(str)
fileSaved = pyqtSignal(str)
runFile = pyqtSignal(str)
showFileInExplorer = pyqtSignal(str)
addToProject = pyqtSignal(str)
allFilesClosed = pyqtSignal()
def __init__(self, parent=None):
super().__init__(parent)
self.setAcceptDrops(True)
self._vbox = QVBoxLayout(self)
self._vbox.setContentsMargins(0, 0, 0, 0)
self._vbox.setSpacing(0)
self.stack = QStackedLayout()
self.stack.setStackingMode(QStackedLayout.StackAll)
self._vbox.addLayout(self.stack)
self.splitter = dynamic_splitter.DynamicSplitter()
self._files_handler = files_handler.FilesHandler(self)
# Code Navigation
self.__code_back = []
self.__code_forward = []
self.__operations = {
0: self._navigate_code_jumps,
1: self._navigate_bookmarks
}
# Recent files list
self.__last_opened_files = []
# QML UI
self._add_file_folder = add_file_folder.AddFileFolderWidget(self)
if settings.SHOW_START_PAGE:
self.show_start_page()
IDE.register_service("main_container", self)
# Register signals connections
connections = (
# {
# "target": "main_container",
# "signal_name": "updateLocator",
# "slot": self._explore_code
# },
{
"target": "filesystem",
"signal_name": "projectOpened",
"slot": self._explore_code
},
# {
# "target": "projects_explore",
# "signal_name": "updateLocator",
# "slot": self._explore_code
# }
{
"target": "filesystem",
"signal_name": "projectClosed",
"slot": self._explore_code
}
)
IDE.register_signals("main_container", connections)
fhandler_short = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Tab), self)
fhandler_short.activated.connect(self.show_files_handler)
# Added for set language
# self._setter_language = set_language.SetLanguageFile()
def install(self):
ninjaide = IDE.get_service("ide")
ninjaide.place_me_on("main_container", self, "central", top=True)
self.combo_area = combo_editor.ComboEditor(original=True)
self.combo_area.allFilesClosed.connect(self._files_closed)
self.combo_area.allFilesClosed.connect(
lambda: self.allFilesClosed.emit())
self.combo_area.fileClosed.connect(self._add_to_last_opened)
self.splitter.add_widget(self.combo_area)
self.add_widget(self.splitter)
# self.current_widget = self.combo_area
# Code Locator
self._code_locator = locator_widget.LocatorWidget(ninjaide)
data_settings = IDE.data_settings()
recent_files = data_settings.value("lastSession/recentFiles")
if recent_files is not None:
self.__last_opened_files = recent_files
ui_tools.install_shortcuts(self, actions.ACTIONS, ninjaide)
# self.fileSaved.connect(self._show_message_about_saved)
def run_file(self, filepath):
self.runFile.emit(filepath)
def _show_file_in_explorer(self, filepath):
self.showFileInExplorer.emit(filepath)
def _add_to_project(self, filepath):
self.addToProject.emit(filepath)
#.........这里部分代码省略.........
示例3: ComboEditor
# 需要导入模块: from PyQt5.QtWidgets import QStackedLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QStackedLayout import widget [as 别名]
class ComboEditor(QWidget):
# Signals
closeSplit = pyqtSignal('PyQt_PyObject')
splitEditor = pyqtSignal(
'PyQt_PyObject', 'PyQt_PyObject', Qt.Orientation)
allFilesClosed = pyqtSignal()
about_to_close_combo_editor = pyqtSignal()
fileClosed = pyqtSignal("PyQt_PyObject")
def __init__(self, original=False):
super(ComboEditor, self).__init__(None)
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)
# Info bar
# self.info_bar = InfoBar(self)
# self.info_bar.setVisible(False)
# vbox.addWidget(self.info_bar)
self.stacked = QStackedLayout()
vbox.addLayout(self.stacked)
self._main_container = IDE.get_service('main_container')
if not self.__original:
self._main_container.fileOpened['QString'].connect(
self._file_opened_by_main)
self.bar.combo_files.showComboSelector.connect(
self._main_container.show_files_handler)
self.bar.combo_files.hideComboSelector.connect(
self._main_container.hide_files_handler)
self.bar.change_current['PyQt_PyObject',
int].connect(self._set_current)
self.bar.splitEditor[bool].connect(self.split_editor)
self.bar.runFile['QString'].connect(self._run_file)
self.bar.closeSplit.connect(lambda: self.closeSplit.emit(self))
self.bar.addToProject['QString'].connect(self._add_to_project)
self.bar.showFileInExplorer['QString'].connect(
self._show_file_in_explorer)
self.bar.goToSymbol[int].connect(self._go_to_symbol)
self.bar.undockEditor.connect(self.undock_editor)
self.bar.reopenTab['QString'].connect(
lambda path: self._main_container.open_file(path))
self.bar.closeImageViewer.connect(self._close_image)
self.bar.code_navigator.previousPressed.connect(self._navigate_code)
self.bar.code_navigator.nextPressed.connect(self._navigate_code)
# 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, operation, forward=True):
self._main_container.navigate_code_history(operation, forward)
# op = self.bar.code_navigator.operation
# self._main_container.navigate_code_history(val, op)
def current_editor(self):
return self.stacked.currentWidget()
def setFocus(self):
super(ComboEditor, self).setFocus()
self.current_editor().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)
if index == -1:
self.bar.set_current_by_index(0)
def add_image_viewer(self, viewer):
"""Add Image Viewer widget to the UI area"""
self.stacked.addWidget(viewer)
viewer.scaleFactorChanged.connect(
self.bar.image_viewer_controls.update_scale_label)
viewer.imageSizeChanged.connect(
self.bar.image_viewer_controls.update_size_label)
self.bar.add_item(viewer.display_name(), None)
viewer.create_scene()
if not self.bar.isVisible():
self.bar.setVisible(True)
def add_editor(self, neditable, keep_index=False):
"""Add Editor Widget to the UI area."""
if neditable.editor:
#.........这里部分代码省略.........
示例4: ComboEditor
# 需要导入模块: from PyQt5.QtWidgets import QStackedLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QStackedLayout import widget [as 别名]
#.........这里部分代码省略.........
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()
self._add_to_last_opened(neditable.file_path)