本文整理汇总了Python中PyQt4.QtGui.QStackedLayout.widget方法的典型用法代码示例。如果您正苦于以下问题:Python QStackedLayout.widget方法的具体用法?Python QStackedLayout.widget怎么用?Python QStackedLayout.widget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QStackedLayout
的用法示例。
在下文中一共展示了QStackedLayout.widget方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ComboEditor
# 需要导入模块: from PyQt4.QtGui import QStackedLayout [as 别名]
# 或者: from PyQt4.QtGui.QStackedLayout import widget [as 别名]
class ComboEditor(QWidget):
def __init__(self, original=False):
super(ComboEditor, self).__init__()
self.__original = original
vbox = QVBoxLayout(self)
vbox.setContentsMargins(0, 0, 0, 0)
self.bar = ActionBar()
self.connect(self.bar, SIGNAL("changeCurrent(PyQt_PyObject)"),
self.set_current)
vbox.addWidget(self.bar)
self.stacked = QStackedLayout()
vbox.addLayout(self.stacked)
def currentWidget(self):
return self.stacked.currentWidget()
def add_editor(self, neditable):
"""Add Editor Widget to the UI area."""
if neditable.editor:
self.stacked.addWidget(neditable.editor)
self.bar.add_item(neditable.display_name, neditable)
# Editor Signals
self.connect(neditable.editor, SIGNAL("cursorPositionChanged()"),
self._update_cursor_position)
# Connect file system signals only in the original
if self.__original:
pass
def set_current(self, neditable):
self.stacked.setCurrentWidget(neditable.editor)
self._update_cursor_position(ignore_sender=True)
neditable.editor.setFocus()
def widget(self, index):
return self.stacked.widget(index)
def count(self):
"""Return the number of editors opened."""
return self.stacked.count()
def _update_cursor_position(self, ignore_sender=False):
obj = self.sender()
editor = self.stacked.currentWidget()
# Check if it's current to avoid signals from other splits.
if ignore_sender or editor == obj:
line = editor.textCursor().blockNumber() + 1
col = editor.textCursor().columnNumber()
self.bar.update_line_col(line, col)
示例2: ComboEditor
# 需要导入模块: from PyQt4.QtGui import QStackedLayout [as 别名]
# 或者: from PyQt4.QtGui.QStackedLayout import widget [as 别名]
#.........这里部分代码省略.........
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)
# 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 split_editor(self, orientationVertical):
new_widget = ComboEditor()
for neditable in self.bar.get_editables():
new_widget.add_editor(neditable)
self.emit(SIGNAL("splitEditor(PyQt_PyObject, PyQt_PyObject, bool)"),
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():
new_combo.add_editor(neditable)
new_combo.resize(500, 500)
self.connect(new_combo, SIGNAL("aboutToCloseComboEditor()"),
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)
layoutItem.widget().deleteLater()
if self.stacked.isEmpty():
self.emit(SIGNAL("allFilesClosed()"))
示例3: _MainContainer
# 需要导入模块: from PyQt4.QtGui import QStackedLayout [as 别名]
# 或者: from PyQt4.QtGui.QStackedLayout import widget [as 别名]
class _MainContainer(QWidget):
###############################################################################
# MainContainer SIGNALS
###############################################################################
"""
newFileOpened(QString)
allTabClosed()
runFile(QString)
addToProject(QString)
showFileInExplorer(QString)
recentTabsModified()
currentEditorChanged(QString)
fileOpened(QString)
---------migrationAnalyzed()
findOcurrences(QString)
---------updateFileMetadata()
editorKeyPressEvent(QEvent)
locateFunction(QString, QString, bool) [functionName, filePath, isVariable]
updateLocator(QString)
beforeFileSaved(QString)
fileSaved(QString)
openPreferences()
--------openProject(QString)
---------dontOpenStartPage()
"""
###############################################################################
def __init__(self, parent=None):
super(_MainContainer, self).__init__(parent)
self._parent = parent
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.setAcceptDrops(True)
self._files_handler = files_handler.FilesHandler(self)
self._add_file_folder = add_file_folder.AddFileFolderWidget(self)
#documentation browser
self.docPage = None
#Code Navigation
self._locator = locator.GoToDefinition()
self.__codeBack = []
self.__codeForward = []
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.connect(self, SIGNAL("locateFunction(QString, QString, bool)"),
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.connect(self.selector, SIGNAL("changeCurrent(int)"),
self._change_current_stack)
self.connect(self.selector, SIGNAL("removeWidget(int)"),
self._remove_item_from_stack)
self.connect(self.selector, SIGNAL("ready()"),
self._selector_ready)
self.connect(self.selector, SIGNAL("animationCompleted()"),
self._selector_animation_completed)
self.connect(self, SIGNAL("closeDialog(PyQt_PyObject)"),
self.remove_widget)
#.........这里部分代码省略.........
示例4: ComboEditor
# 需要导入模块: from PyQt4.QtGui import QStackedLayout [as 别名]
# 或者: from PyQt4.QtGui.QStackedLayout import widget [as 别名]
class ComboEditor(QWidget):
def __init__(self, original=False):
super(ComboEditor, self).__init__()
self.__original = original
self._symbols_index = []
vbox = QVBoxLayout(self)
vbox.setContentsMargins(0, 0, 0, 0)
vbox.setSpacing(0)
self.bar = ActionBar()
vbox.addWidget(self.bar)
self.stacked = QStackedLayout()
vbox.addLayout(self.stacked)
self._main_container = IDE.get_service('main_container')
self.connect(self.bar, SIGNAL("changeCurrent(PyQt_PyObject)"),
self.set_current)
self.connect(self.bar, SIGNAL("runFile(QString)"),
self._run_file)
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("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 add_editor(self, neditable):
"""Add Editor Widget to the UI area."""
if neditable.editor:
self.stacked.addWidget(neditable.editor)
self.bar.add_item(neditable.display_name, neditable)
# Editor Signals
self.connect(neditable.editor, SIGNAL("cursorPositionChanged()"),
self._update_cursor_position)
self.connect(neditable.editor, SIGNAL("currentLineChanged(int)"),
self._set_current_symbol)
self.connect(neditable, SIGNAL("checkersUpdated(PyQt_PyObject)"),
self._show_notification_icon)
self.connect(neditable, SIGNAL("fileSaved(PyQt_PyObject)"),
self._update_symbols)
# 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)
# Load Symbols
self._load_symbols(neditable)
def show_combo_file(self):
self.bar.combo.showPopup()
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)
layoutItem.widget().deleteLater()
def _add_to_last_opened(self, path):
if path not in settings.LAST_OPENED_FILES:
settings.LAST_OPENED_FILES.append(path)
if len(settings.LAST_OPENED_FILES) > settings.MAX_REMEMBER_TABS:
self.__lastOpened = self.__lastOpened[1:]
self.emit(SIGNAL("recentTabsModified()"))
def _ask_for_save(self, neditable):
val = QMessageBox.No
fileName = neditable.file_path
val = QMessageBox.question(
self, (self.tr('The file %s was not saved') %
fileName),
self.tr("Do you want to save before closing?"),
QMessageBox.Yes | QMessageBox.No |
QMessageBox.Cancel)
if val == QMessageBox.No:
neditable.nfile.close(force_close=True)
#.........这里部分代码省略.........
示例5: BarraConversa
# 需要导入模块: from PyQt4.QtGui import QStackedLayout [as 别名]
# 或者: from PyQt4.QtGui.QStackedLayout import widget [as 别名]
class BarraConversa(QWidget):
conversasNaoVisualizadas = pyqtSignal(Usuario, int)
def __init__(self, servico, parent=None):
super().__init__(parent)
self._configurarGui()
self._servico = servico
self._servico.dadosUsuarioAtualizado.connect(self._atualizarUsuario)
self._servico.conversaRecebida.connect(self._receberConversa)
self._servico.informacaoTipoValorRecebida.connect(self._receberSituacao)
def _configurarGui(self):
self._stackedLayout = QStackedLayout(self)
self._stackedLayout.setMargin(0)
self.setLayout(self._stackedLayout)
self._mostrarTelaInicial()
def _setNumConversasNaoVisualizadas(self, barraConversaUsuario, numConversasNaoVisualizadas):
barraConversaUsuario.setNumConversasNaoVisualizadas(numConversasNaoVisualizadas)
self.conversasNaoVisualizadas.emit(barraConversaUsuario.getUsuario(), numConversasNaoVisualizadas)
def _receberConversa(self, de, inf):
usuario = Usuario(nome=NOME_DEFAULT, ip=de)
barraConversaUsuario = self._getOrCreateBarraConversaUsuario(usuario)
barraConversaUsuario.receberTexto(inf)
if self._stackedLayout.currentWidget() != barraConversaUsuario:
numConversasNaoVisualizadasAtual = barraConversaUsuario.getNumConversasNaoVisualizadas() + 1
self._setNumConversasNaoVisualizadas(barraConversaUsuario, numConversasNaoVisualizadasAtual)
def _receberSituacao(self, de, tipo, valor):
if tipo == ServicoClienteMensageiro.INFORMACAO:
usuario = Usuario(nome=NOME_DEFAULT, ip=de)
self._getOrCreateBarraConversaUsuario(usuario).atualizarSituacao(valor['informacao'])
def _atualizarUsuario(self, usuario):
self._getOrCreateBarraConversaUsuario(usuario).setUsuario(usuario)
def _mostrarTelaInicial(self):
lbl = QLabel("<- Selecione o Usuário")
self._stackedLayout.insertWidget(0, lbl)
self._stackedLayout.setCurrentIndex(0)
def _setConversaUsuarioAtual(self, barraConversaUsuario):
ind = self._indexWidgetConversa(barraConversaUsuario.getUsuario())
self._stackedLayout.setCurrentIndex(ind)
def _indexWidgetConversa(self, usuario):
for i in range(1, self._stackedLayout.count()):
if self._stackedLayout.widget(i).getUsuario().getIP() == usuario.getIP():
return i
return -1
def _getOrCreateBarraConversaUsuario(self, usuario):
ind = self._indexWidgetConversa(usuario)
if ind != -1:
return self._stackedLayout.widget(ind)
else:
barraConversaUsuario = BarraConversaUsuario(self._servico, usuario)
self._stackedLayout.addWidget(barraConversaUsuario)
return barraConversaUsuario
def setUsuarioAtual(self, usuario):
"""Altera a conversa visível para a conversa do usuário
e reinicia a contagem de conversas não visualizadas."""
barraConversaUsuario = self._getOrCreateBarraConversaUsuario(usuario)
barraConversaUsuario.setUsuario(usuario)
self._setNumConversasNaoVisualizadas(barraConversaUsuario, 0)
self._setConversaUsuarioAtual(barraConversaUsuario)