本文整理汇总了Python中PyQt4.QtGui.QStackedLayout.count方法的典型用法代码示例。如果您正苦于以下问题:Python QStackedLayout.count方法的具体用法?Python QStackedLayout.count怎么用?Python QStackedLayout.count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QStackedLayout
的用法示例。
在下文中一共展示了QStackedLayout.count方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ComboEditor
# 需要导入模块: from PyQt4.QtGui import QStackedLayout [as 别名]
# 或者: from PyQt4.QtGui.QStackedLayout import count [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 count [as 别名]
#.........这里部分代码省略.........
def _file_has_been_modified(self, neditable):
val = QMessageBox.No
fileName = neditable.file_path
val = QMessageBox.question(self, translations.TR_FILE_HAS_BEEN_MODIFIED,
"%s%s" % (fileName, translations.TR_FILE_MODIFIED_OUTSIDE),
QMessageBox.Yes | QMessageBox.No)
if val == QMessageBox.Yes:
neditable.reload_file()
def _run_file(self, path):
self._main_container.run_file(path)
def _add_to_project(self, path):
self._main_container._add_to_project(path)
def set_current(self, neditable):
if neditable:
self.bar.set_current_file(neditable)
def _set_current(self, neditable, index):
if neditable:
self.stacked.setCurrentIndex(index)
editor = self.stacked.currentWidget()
self._update_cursor_position(ignore_sender=True)
editor.setFocus()
self._main_container.current_editor_changed(
neditable.file_path)
self._load_symbols(neditable)
neditable.update_checkers_display()
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)
def _set_current_symbol(self, line, 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:
index = bisect.bisect(self._symbols_index, line)
if (index >= len(self._symbols_index) or
self._symbols_index[index] > (line + 1)):
index -= 1
self.bar.set_current_symbol(index)
def _editor_modified(self, value):
obj = self.sender()
neditable = obj.neditable
if value:
text = "%s (*)" % neditable.display_name
self.bar.update_item_text(neditable, text)
else:
self.bar.update_item_text(neditable, neditable.display_name)
示例3: _MainContainer
# 需要导入模块: from PyQt4.QtGui import QStackedLayout [as 别名]
# 或者: from PyQt4.QtGui.QStackedLayout import count [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)
示例4: ProjectTreeColumn
# 需要导入模块: from PyQt4.QtGui import QStackedLayout [as 别名]
# 或者: from PyQt4.QtGui.QStackedLayout import count [as 别名]
#.........这里部分代码省略.........
project that contains it (i.e. if the same file is
included in multiple open projects, the path will be
expanded for the first project only).
Note: This slot is connected to the main container's
"showFileInExplorer(QString)" signal.'''
for project in self.projects:
index = project.model().index(path)
if index.isValid():
# Show the explorer if it is currently hidden
central = IDE.get_service('central_container')
if central and not central.is_lateral_panel_visible():
central.change_lateral_visibility()
# This highlights the index in the tree for us
project.setCurrentIndex(index)
# Loop through the parents to expand the tree
# all the way up to the selected index.
while index.isValid():
project.expand(index)
index = index.parent()
break
def add_project(self, project):
if project not in self.projects:
self._combo_project.addItem(project.name)
ptree = TreeProjectsWidget(project)
self._projects_area.addWidget(ptree)
self.connect(ptree, SIGNAL("closeProject(PyQt_PyObject)"),
self._close_project)
pmodel = project.model
ptree.setModel(pmodel)
pindex = pmodel.index(pmodel.rootPath())
ptree.setRootIndex(pindex)
self.projects.append(ptree)
current_index = self._projects_area.count()
self._projects_area.setCurrentIndex(current_index - 1)
self._combo_project.setCurrentIndex(current_index - 1)
def _close_project(self, widget):
"""Close the project related to the tree widget."""
index = self._projects_area.currentIndex()
self.projects.remove(widget)
self._projects_area.takeAt(index)
self._combo_project.removeItem(index)
index = self._combo_project.currentIndex()
self._projects_area.setCurrentIndex(index)
ninjaide = IDE.get_service('ide')
ninjaide.filesystem.close_project(widget.project.path)
widget.deleteLater()
def _change_current_project(self, index):
self._projects_area.setCurrentIndex(index)
def close_opened_projects(self):
for project in reversed(self.projects):
self._close_project(project)
def save_project(self):
"""Save all the opened files that belongs to the actual project."""
if self._active_project:
path = self._projects_area.currentWidget().project.path
main_container = IDE.get_service('main_container')
if path and main_container:
main_container.save_project(path)
def create_new_project(self):
wizard = new_project_manager.NewProjectManager(self)
示例5: ComboEditor
# 需要导入模块: from PyQt4.QtGui import QStackedLayout [as 别名]
# 或者: from PyQt4.QtGui.QStackedLayout import count [as 别名]
#.........这里部分代码省略.........
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)
elif val == QMessageBox.Yes:
self._main_container.save_file(neditable.editor)
neditable.nfile.close()
def _run_file(self, path):
self._main_container.run_file(path)
def _add_to_project(self, path):
self._main_container._add_to_project(path)
def set_current(self, neditable):
if neditable:
self.stacked.setCurrentWidget(neditable.editor)
self._update_cursor_position(ignore_sender=True)
neditable.editor.setFocus()
self._main_container.current_editor_changed(
neditable.file_path)
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)
def _set_current_symbol(self, line, 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:
index = bisect.bisect(self._symbols_index, line)
if self._symbols_index[index] > line:
index -= 1
self.bar.set_current_symbol(index)
def _go_to_symbol(self, index):
line = self._symbols_index[index]
editor = self.stacked.currentWidget()
editor.go_to_line(line)
def _update_symbols(self, neditable):
editor = self.stacked.currentWidget()
# Check if it's current to avoid signals from other splits.
if editor == neditable.editor:
self._load_symbols(neditable)
def _load_symbols(self, neditable):
symbols_handler = settings.get_symbols_handler('py')
source = neditable.editor.toPlainText()
source = source.encode(neditable.editor.encoding)
symbols = symbols_handler.get_symbols_simplified(source)
self._symbols_index = sorted(symbols.keys())
symbols = sorted(list(symbols.items()), key=lambda x: x[0])
self.bar.add_symbols(symbols)
line = neditable.editor.textCursor().blockNumber()
self._set_current_symbol(line, True)
def _show_notification_icon(self, neditable):
checkers = neditable.sorted_checkers
icon = QIcon()
for items in checkers:
checker, color, _ = items
if checker.checks:
if isinstance(checker.checker_icon, int):
icon = self.style().standardIcon(checker.checker_icon)
elif isinstance(checker.checker_icon, str):
icon = QIcon(checker.checker_icon)
break
self.bar.update_item_icon(neditable, icon)
示例6: BarraConversa
# 需要导入模块: from PyQt4.QtGui import QStackedLayout [as 别名]
# 或者: from PyQt4.QtGui.QStackedLayout import count [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)