本文整理汇总了Python中PyQt4.QtGui.QStackedLayout.setCurrentIndex方法的典型用法代码示例。如果您正苦于以下问题:Python QStackedLayout.setCurrentIndex方法的具体用法?Python QStackedLayout.setCurrentIndex怎么用?Python QStackedLayout.setCurrentIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QStackedLayout
的用法示例。
在下文中一共展示了QStackedLayout.setCurrentIndex方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EkdConfigBox
# 需要导入模块: from PyQt4.QtGui import QStackedLayout [as 别名]
# 或者: from PyQt4.QtGui.QStackedLayout import setCurrentIndex [as 别名]
#.........这里部分代码省略.........
scroll = QScrollArea()
frame = QFrame()
frame.setMinimumSize(self.w-50, self.h/2) # Ajouté le 10/12/2009 Pour que la partie réglage prenne toute la place dispo.
frame.setMaximumSize(self.w, self.h)
linelayout = QGridLayout(frame)
linelayout.setSizeConstraint(QLayout.SetMinAndMaxSize)
row = 0
## Insertion des propriété de la section en fonction de son type
allkeys = allprops.keys()
found = False
for prop in allkeys :
if not prop in EkdConfig.PROPERTIES_MASK :
if prop in EkdConfig.PATH_PROPERTIES :
self.propWidget.append( EkdPathPropertie(prop, EkdConfig.PROPERTIES[prop], allprops[prop], section=section) )
linelayout.addWidget(self.propWidget[wid].label, row, 0)
linelayout.addWidget(self.propWidget[wid].widget, row, 1)
wid += 1
found = True
row += 1
for prop in allkeys :
if not prop in EkdConfig.PROPERTIES_MASK :
if prop in EkdConfig.STYLE_PROPERTIES :
self.propWidget.append( EkdStylePropertie(prop, EkdConfig.PROPERTIES[prop], allprops[prop], EkdConfig.STYLE_PROPERTIES[prop], section=section ) )
linelayout.addWidget(self.propWidget[wid].label, row, 0)
linelayout.addWidget(self.propWidget[wid].widget, row, 1)
wid += 1
found = True
row += 1
for prop in allkeys :
if not prop in EkdConfig.PROPERTIES_MASK :
if prop in EkdConfig.CODEC_PROPERTIES :
self.propWidget.append( EkdCodecPropertie(prop, EkdConfig.PROPERTIES[prop], allprops[prop], EkdConfig.CODEC_PROPERTIES[prop], section=section ) )
linelayout.addWidget(self.propWidget[wid].label, row, 0)
linelayout.addWidget(self.propWidget[wid].widget, row, 1)
wid += 1
found = True
row += 1
for prop in allkeys :
if not prop in EkdConfig.PROPERTIES_MASK :
if prop in EkdConfig.BOOLEAN_PROPERTIES :
self.propWidget.append( EkdBoolPropertie(prop, EkdConfig.PROPERTIES[prop], allprops[prop], section=section) )
linelayout.addWidget(self.propWidget[wid].widget, row, 0, 1, 2)
wid += 1
found = True
row += 1
for prop in allkeys :
if not prop in EkdConfig.PROPERTIES_MASK :
if prop in EkdConfig.NUM_PROPERTIES :
self.propWidget.append( EkdNumPropertie(prop, EkdConfig.PROPERTIES[prop], allprops[prop], section=section) )
linelayout.addWidget(self.propWidget[wid].label, row, 0)
linelayout.addWidget(self.propWidget[wid].widget, row, 1)
wid += 1
found = True
row += 1
for prop in allkeys :
if not prop in EkdConfig.PROPERTIES_MASK :
if prop in EkdConfig.TIME_PROPERTIES :
self.propWidget.append( EkdTimePropertie(prop, EkdConfig.PROPERTIES[prop], allprops[prop], section=section) )
linelayout.addWidget(self.propWidget[wid].label, row, 0)
linelayout.addWidget(self.propWidget[wid].widget, row, 1)
wid += 1
found = True
row += 1
for prop in allkeys :
if not prop in EkdConfig.PROPERTIES_MASK :
if prop in EkdConfig.COLOR_PROPERTIES :
self.propWidget.append( EkdColorPropertie(prop, EkdConfig.PROPERTIES[prop], allprops[prop], section=section) )
linelayout.addWidget(self.propWidget[wid].label, row, 0)
linelayout.addWidget(self.propWidget[wid].widget, row, 1)
wid += 1
found = True
elif not found:
line = QLineEdit(allprops[prop])
linelayout.addWidget(QLabel(prop), row, 0)
linelayout.addWidget(line, row, 1)
row += 1
frame.setLineWidth(0)
scroll.setWidget(frame)
self.leftpart.addWidget(scroll)
self.menu.setAlternatingRowColors(True)
# Define the size of the list depending of its content
self.menu.setFixedHeight(( self.menu.sizeHintForRow(0) + self.menu.verticalStepsPerItem() + 1)* self.menu.count())
self.menu.updateGeometries()
## Boutton pour fermer la boite de dialogue
self.fermer = QPushButton(_(u"Fermer"))
self.layout.addWidget(self.fermer)
## Lorsqu'on clique sur fermer, la fenêtre se ferme
self.connect(self.fermer, SIGNAL("clicked()"), self.close)
## Lorsqu'on selectionne un élément du menu, on met à jour la partie droite du menu
self.connect(self.menu, SIGNAL("currentItemChanged(QListWidgetItem *,QListWidgetItem *)"), self.updateMenu)
def updateMenu(self):
propriete = self.menu.currentRow()
self.leftpart.setCurrentIndex(propriete)
示例2: ComboEditor
# 需要导入模块: from PyQt4.QtGui import QStackedLayout [as 别名]
# 或者: from PyQt4.QtGui.QStackedLayout import setCurrentIndex [as 别名]
#.........这里部分代码省略.........
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 _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)):
示例3: CMainWindow
# 需要导入模块: from PyQt4.QtGui import QStackedLayout [as 别名]
# 或者: from PyQt4.QtGui.QStackedLayout import setCurrentIndex [as 别名]
class CMainWindow(QFrame):
def __init__(self):
QMainWindow.__init__(self)
layout = QGridLayout(self)
layout.setMargin(2)
btnFiles = QPushButton(u'Файлы', self)
btnVideo = QPushButton(u'Видео', self)
btnPlay = QPushButton(u'Play/Pause', self)
btnStop = QPushButton(u'Stop', self)
btnMute = QPushButton(u'Mute', self)
btnMute.setCheckable(True)
btnMainMenu = QPushButton(u'Main', self)
self.sldVolume = QSlider(Qt.Vertical, self)
self.sldPosition = QSlider(Qt.Horizontal, self)
self.layMain = QStackedLayout()
btnFiles.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
btnVideo.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
btnPlay.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
btnStop.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
btnMute.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
btnMainMenu.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
self.sldVolume.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)
self.sldPosition.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
layout.addWidget(btnFiles, 0, 0)
layout.addWidget(btnVideo, 0, 1)
layout.addWidget(btnPlay, 0, 3)
layout.addWidget(btnStop, 0, 4)
layout.addWidget(btnMute, 0, 5)
layout.addWidget(btnMainMenu, 2, 5)
layout.addWidget(self.sldVolume, 1, 5)
layout.addWidget(self.sldPosition, 2, 0, 1, 5)
layout.addLayout(self.layMain, 1, 0, 1, 5)
fileBrowser = CFileBrowser(self)
self.videoWidget = QWidget(self)
self.exitMenu = CExitMenu(self)
self.mplayer = MPlayerControl(self, self.videoWidget)
fileBrowser.chosen.connect(self.startPlay)
btnFiles.clicked.connect(lambda: self.selectMode(0))
btnVideo.clicked.connect(lambda: self.selectMode(1))
btnMainMenu.clicked.connect(lambda: self.selectMode(2))
self.sldPosition.valueChanged.connect(self.mplayer.seek)
self.sldVolume.valueChanged.connect(self.mplayer.setvol)
btnMute.clicked.connect(lambda: self.mplayer.mute(btnMute.isChecked()))
btnPlay.clicked.connect(self.mplayer.play)
btnStop.clicked.connect(self.mplayer.stop)
self.sldVolume.setValue(QtGui.qApp.settings['volume'])
self.mplayer.percent_position.connect(self.on_mplayer_position)
self.layMain.addWidget(fileBrowser)
self.layMain.addWidget(self.videoWidget)
self.layMain.addWidget(self.exitMenu)
@pyqtSlot(int)
def on_mplayer_position(self, pos):
self.sldPosition.blockSignals(True)
self.sldPosition.setValue(pos)
self.sldPosition.blockSignals(False)
@pyqtSlot(int)
def selectMode(self, mode):
self.layMain.setCurrentIndex(mode)
@pyqtSlot(str)
def startPlay(self, path):
self.selectMode(1)
self.mplayer.play(path)
def closeEvent(self, event):
self.mplayer.quit()
QFrame.closeEvent(self, event)
示例4: _MainContainer
# 需要导入模块: from PyQt4.QtGui import QStackedLayout [as 别名]
# 或者: from PyQt4.QtGui.QStackedLayout import setCurrentIndex [as 别名]
#.........这里部分代码省略.........
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)
def _remove_item_from_stack(self, index):
widget = self.stack.takeAt(index)
del widget
def show_editor_area(self):
self.stack.setCurrentWidget(self.splitter)
def _files_closed(self):
if settings.SHOW_START_PAGE:
self.show_start_page()
def change_visibility(self):
"""Show/Hide the Main Container area."""
if self.isVisible():
self.hide()
else:
self.show()
def expand_symbol_combo(self):
self.stack.setCurrentWidget(self.splitter)
self.current_widget.show_combo_symbol()
def expand_file_combo(self):
self.stack.setCurrentWidget(self.splitter)
self.current_widget.show_combo_file()
def locate_function(self, function, filePath, isVariable):
"""Move the cursor to the proper position in the navigate stack."""
editorWidget = self.get_current_editor()
if editorWidget:
self.__codeBack.append((editorWidget.file_path,
示例5: ProjectTreeColumn
# 需要导入模块: from PyQt4.QtGui import QStackedLayout [as 别名]
# 或者: from PyQt4.QtGui.QStackedLayout import setCurrentIndex [as 别名]
#.........这里部分代码省略.........
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(addToProject.pathSelected, name)
ide_srv = IDE.get_service("ide")
old_file = ide_srv.get_or_create_nfile(path)
new_file = old_file.save(editorWidget.get_text(), new_path)
#FIXME: Make this file replace the original in the open tab
else:
pass
# Message about no project
def _show_file_in_explorer(self, path):
'''Iterate through the list of available projects and show
the current file in the explorer view for the first
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')
示例6: Preferences
# 需要导入模块: from PyQt4.QtGui import QStackedLayout [as 别名]
# 或者: from PyQt4.QtGui.QStackedLayout import setCurrentIndex [as 别名]
class Preferences(QDialog):
configuration = {}
weight = 0
def __init__(self, parent=None):
super(Preferences, self).__init__(parent, Qt.Dialog)
self.setWindowTitle(translations.TR_PREFERENCES_TITLE)
self.setMinimumSize(QSize(800, 600))
self.setMaximumSize(QSize(0, 0))
vbox = QVBoxLayout(self)
hbox = QHBoxLayout()
vbox.setContentsMargins(0, 0, 5, 5)
hbox.setContentsMargins(0, 0, 0, 0)
self.tree = QTreeWidget()
self.tree.header().setHidden(True)
self.tree.setSelectionMode(QTreeWidget.SingleSelection)
self.tree.setAnimated(True)
self.tree.header().setHorizontalScrollMode(
QAbstractItemView.ScrollPerPixel)
self.tree.header().setResizeMode(0, QHeaderView.ResizeToContents)
self.tree.header().setStretchLastSection(False)
self.tree.setFixedWidth(200)
self.stacked = QStackedLayout()
hbox.addWidget(self.tree)
hbox.addLayout(self.stacked)
vbox.addLayout(hbox)
hbox_footer = QHBoxLayout()
self._btnSave = QPushButton(translations.TR_SAVE)
self._btnCancel = QPushButton(translations.TR_CANCEL)
hbox_footer.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding))
hbox_footer.addWidget(self._btnCancel)
hbox_footer.addWidget(self._btnSave)
vbox.addLayout(hbox_footer)
self.connect(self.tree, SIGNAL("itemSelectionChanged()"),
self._change_current)
self.connect(self._btnCancel, SIGNAL("clicked()"), self.close)
self.connect(self._btnSave, SIGNAL("clicked()"),
self._save_preferences)
self.load_ui()
self.tree.setCurrentItem(self.tree.topLevelItem(0))
def _save_preferences(self):
self.emit(SIGNAL("savePreferences()"))
self.close()
def load_ui(self):
sections = sorted(list(Preferences.configuration.keys()),
key=lambda item: Preferences.configuration[item]['weight'])
for section in sections:
text = Preferences.configuration[section]['text']
Widget = Preferences.configuration[section]['widget']
widget = Widget(self)
area = QScrollArea()
area.setWidgetResizable(True)
area.setWidget(widget)
index = self.stacked.addWidget(area)
item = QTreeWidgetItem([text])
item.setData(0, Qt.UserRole, index)
self.tree.addTopLevelItem(item)
#Sort Item Children
subcontent = Preferences.configuration[section].get(
'subsections', {})
subsections = sorted(list(subcontent.keys()),
key=lambda item: subcontent[item]['weight'])
for sub in subsections:
text = subcontent[sub]['text']
Widget = subcontent[sub]['widget']
widget = Widget(self)
area = QScrollArea()
area.setWidgetResizable(True)
area.setWidget(widget)
index = self.stacked.addWidget(area)
subitem = QTreeWidgetItem([text])
subitem.setData(0, Qt.UserRole, index)
item.addChild(subitem)
self.tree.expandAll()
def _change_current(self):
item = self.tree.currentItem()
index = item.data(0, Qt.UserRole)
self.stacked.setCurrentIndex(index)
@classmethod
def register_configuration(cls, section, widget, text, weight=None,
subsection=None):
if weight is None:
Preferences.weight += 1
weight = Preferences.weight
if not subsection:
Preferences.configuration[section] = {'widget': widget,
'weight': weight, 'text': text}
else:
config = Preferences.configuration.get(section, {})
#.........这里部分代码省略.........
示例7: LoginView
# 需要导入模块: from PyQt4.QtGui import QStackedLayout [as 别名]
# 或者: from PyQt4.QtGui.QStackedLayout import setCurrentIndex [as 别名]
#.........这里部分代码省略.........
#Stack em up vertically
self._mainLayout_ = QVBoxLayout()
self._mainLayout_.addStretch()
self._mainLayout_.addWidget(self._logoLabel_,0,Qt.AlignCenter)
self._mainLayout_.addWidget(self._usernameWidget_)
self._mainLayout_.addWidget(self._passWidget_)
self._mainLayout_.addWidget(self._rememberWidget_)
self._mainLayout_.addLayout(self._buttonsWidget_)
self._mainLayout_.addLayout(myBloopSiteLinkLayout)
self._mainLayout_.addStretch()
#Add another layout to show while we wait
#put all this on a QStackedLayout
self._passwordLineEdit_.setStyleSheet("border-style: outset; border-width: 1px; border-radius: 3px; border-color: gray; padding: 3px;")
self._usernameLineEdit_.setStyleSheet("border-style: outset; border-width: 1px; border-radius: 3px; border-color: gray; padding: 3px;")
self._waitLayout_ = QVBoxLayout()
self._waitLayout_.setAlignment(Qt.AlignHCenter)
self._waitLabel_ = QLabel()
pixmap = QPixmap(os.path.join('i18n','images','us_en','loading.png'))
self._waitLabel_.setPixmap(pixmap)
self._waitLayout_.addWidget(self._waitLabel_)
self._waitLayout_.addStretch()
self._stackedLayout_ = QStackedLayout()
waitWidget = QWidget()
waitWidget.setLayout(self._waitLayout_)
mainWidget = QWidget()
mainWidget.setLayout(self._mainLayout_)
self._stackedLayout_.addWidget(mainWidget)
self._stackedLayout_.addWidget(waitWidget)
self._stackedLayout_.setCurrentIndex(0) #main layout
self.fillBackground()
loginLayout = QVBoxLayout()
loginLayout.addLayout(self._stackedLayout_)
self.setLayout(loginLayout)
def getLineEditUsername(self):
return self._usernameLineEdit_
def getLineEditPassword(self):
return self._passwordLineEdit_
def getUsernameLabel(self):
return self._usernameLabel_
def getPasswordLabel(self):
return self._passwordLabel_
def getButtonLogin(self):
return self._loginButton_
def getButtonRegister(self):
return self._registerButton_
def getLabelMyBloopSiteLink(self):
'''Returns a QLabel object.
This QLabel contains one or more links to MyBloop.com pages.
It's the responsability of the controller to catch the linkActivated(QString)
signal to open a browser for the user. The String passed contains the URL'''
return self._myBloopSiteLink_
def getRememberCheckbox(self):
return self._rememberCheckbox_
def wantsToBeRemembered(self):
return self._rememberCheckbox_.checkState() == Qt.Checked
def fillBackground(self):
"""Fills the background with a solid white"""
self.palette().setColor(QPalette.Background, QColor(255,255,255))
self.setAutoFillBackground(True)
def showForm(self):
self._stackedLayout_.setCurrentIndex(0)
def showWaiting(self):
self._stackedLayout_.setCurrentIndex(1)
def createMenubar(self):
self._menuBar_ = QMenuBar(None)
#Create File Menu
self._fileMenu_ = QMenu(self)
am = ActionManager.getInstance()
#todo add actions from ActionManager
for action in am.getBloopFileMenuActions():
print "MainView.createMenuBar() adding action to file menu", action
print self._fileMenu_.addAction(action)
#Create Help Menu
self._menuBar_.addMenu(self._fileMenu_)
#self.setMenuWidget(self._menuBar_)
#self._menuBar_.setVisible(True)
示例8: Ui_option
# 需要导入模块: from PyQt4.QtGui import QStackedLayout [as 别名]
# 或者: from PyQt4.QtGui.QStackedLayout import setCurrentIndex [as 别名]
#.........这里部分代码省略.........
def addItem(label, icon_pixmap, width, height):
item = QListWidgetItem(list_option)
item.setText(label)
item.setTextAlignment(Qt.AlignHCenter)
item.setIcon(QIcon(icon_pixmap))
item.setSizeHint(QSize(width, height))
list_option = QListWidget()
list_option.setAutoFillBackground(True)
list_option.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
list_option.setTextElideMode(Qt.ElideNone)
list_option.setMovement(QListView.Static)
list_option.setFlow(QListView.TopToBottom)
list_option.setProperty("isWrapping", QVariant(False))
list_option.setSpacing(3)
list_option.setViewMode(QListView.IconMode)
items = []
items.append((QApplication.translate("option", "Connections"), "connections.png"))
items.append((QApplication.translate("option", "Accounts"), "accounts.png"))
items.append((QApplication.translate("option", "Aliases"), "aliases.png"))
items.append((QApplication.translate("option", "Macros"), "macros.png"))
items.append((QApplication.translate("option", "Keypad"), "keypad.png"))
items.append((QApplication.translate("option", "Triggers"), "triggers.png"))
items.append((QApplication.translate("option", "Preferences"), "preferences.png"))
max_width = 0
for label, icon_name in items:
w = list_option.fontMetrics().boundingRect(label).width()
if w > max_width:
max_width = w
# An empiric method to align element in the center of the QListWidget
max_width += 15
total_height = 0
for label, icon_name in items:
icon_pixmap = QPixmap(":/images/" + icon_name)
height = icon_pixmap.height() + list_option.fontMetrics().height() + 3
total_height += height + 5
addItem(label, icon_pixmap, max_width, height)
list_option.setUniformItemSizes(True)
list_option.setFixedWidth(max_width + 10)
list_option.setMinimumHeight(total_height)
return list_option
def setupUi(self, option):
option.setWindowTitle(QApplication.translate("option", "Option"))
main_layout = QGridLayout(option)
main_layout.setSpacing(5)
main_layout.setContentsMargins(10, 10, 10, 10)
main_layout.setColumnStretch(1, 1)
self.list_option = self.createListOption()
main_layout.addWidget(self.list_option, 0, 0)
self.page_container = QStackedLayout()
self.page_container.setContentsMargins(0, 0, 0, 0)
main_layout.addLayout(self.page_container, 0, 1)
self.populatePages()
main_layout.addWidget(self.createLine(), 1, 0, 1, 2)
close_layout = QHBoxLayout()
close_layout.setContentsMargins(0, 0, 5, 0)
close_layout.setSpacing(5)
close_option = QPushButton()
close_option.setText(QApplication.translate("option", "Close"))
option.connect(close_option, QtCore.SIGNAL("clicked()"), option.accept)
close_layout.addWidget(close_option)
main_layout.addLayout(close_layout, 2, 1, 1, 2, Qt.AlignRight)
self.list_option.setCurrentRow(0)
self.page_container.setCurrentIndex(0)
option.setTabOrder(self.list_option, self.list_conn)
option.setTabOrder(self.list_conn, self.name_conn)
option.setTabOrder(self.name_conn, self.host_conn)
option.setTabOrder(self.host_conn, self.port_conn)
option.setTabOrder(self.port_conn, self.save_conn)
option.setTabOrder(self.save_conn, self.delete_conn)
option.setTabOrder(self.delete_conn, self.list_conn_account)
option.setTabOrder(self.list_conn_account, self.list_account)
option.setTabOrder(self.list_account, self.delete_account)
option.setTabOrder(self.delete_account, self.list_conn_alias)
option.setTabOrder(self.list_conn_alias, self.list_alias)
option.setTabOrder(self.list_alias, self.label_alias)
option.setTabOrder(self.label_alias, self.body_alias)
option.setTabOrder(self.body_alias, self.save_alias)
option.setTabOrder(self.save_alias, self.delete_alias)
option.setTabOrder(self.delete_alias, self.list_conn_macro)
option.setTabOrder(self.list_conn_macro, self.list_macro)
option.setTabOrder(self.list_macro, self.register_macro)
option.setTabOrder(self.register_macro, self.keys_macro)
option.setTabOrder(self.keys_macro, self.command_macro)
option.setTabOrder(self.command_macro, self.save_macro)
option.setTabOrder(self.save_macro, self.delete_macro)
option.setTabOrder(self.delete_macro, self.echo_color_button)
option.setTabOrder(self.echo_color_button, self.save_log)
示例9: BarraConversa
# 需要导入模块: from PyQt4.QtGui import QStackedLayout [as 别名]
# 或者: from PyQt4.QtGui.QStackedLayout import setCurrentIndex [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)