本文整理汇总了Python中PySide2.QtWidgets.QTabWidget方法的典型用法代码示例。如果您正苦于以下问题:Python QtWidgets.QTabWidget方法的具体用法?Python QtWidgets.QTabWidget怎么用?Python QtWidgets.QTabWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide2.QtWidgets
的用法示例。
在下文中一共展示了QtWidgets.QTabWidget方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QTabWidget [as 别名]
def __init__(self, node: NetworkNode):
super().__init__()
self.network = node.network
self.node = node
self.layout = QGridLayout()
self.setLayout(self.layout)
self.tabs = QTabWidget()
self.layout.addWidget(self.tabs)
self.tab_dialogs = []
for node_tab in node_tabs[self.network]:
tab_dialog = node_tab['class'](self.node)
self.tabs.addTab(tab_dialog, node_tab['title'])
示例2: setLang
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QTabWidget [as 别名]
def setLang(self, langName):
uiList_lang_read = self.memoData['lang'][langName]
for ui_name in uiList_lang_read:
ui_element = self.uiList[ui_name]
if type(ui_element) in [ QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox ]:
# uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
if uiList_lang_read[ui_name] != "":
ui_element.setText(uiList_lang_read[ui_name])
elif type(ui_element) in [ QtWidgets.QGroupBox, QtWidgets.QMenu ]:
# uiType: QMenu, QGroupBox
if uiList_lang_read[ui_name] != "":
ui_element.setTitle(uiList_lang_read[ui_name])
elif type(ui_element) in [ QtWidgets.QTabWidget]:
# uiType: QTabWidget
tabCnt = ui_element.count()
if uiList_lang_read[ui_name] != "":
tabNameList = uiList_lang_read[ui_name].split(';')
if len(tabNameList) == tabCnt:
for i in range(tabCnt):
if tabNameList[i] != "":
ui_element.setTabText(i,tabNameList[i])
elif type(ui_element) == str:
# uiType: string for msg
if uiList_lang_read[ui_name] != "":
self.uiList[ui_name] = uiList_lang_read[ui_name]
示例3: __init__
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QTabWidget [as 别名]
def __init__(self, node_set: NodeSet, system_tray):
# noinspection PyUnresolvedReferences
super().__init__(
f=Qt.WindowMinimizeButtonHint|Qt.WindowMaximizeButtonHint|Qt.WindowCloseButtonHint
)
# Dialog properties
self.setWindowTitle('Manage Nodes')
self.setMinimumSize(1200, 800)
self.layout = QVBoxLayout()
self.setLayout(self.layout)
# Locally storing provided parameters
self.node_set = node_set
self.system_tray = system_tray
# Initializing the main tabs widget
self.tabs = QTabWidget()
self.layout.addWidget(self.tabs)
# Initializing tor tab
self.tor_tab = NodeManageDialog(self.node_set.tor_node)
self.tabs.addTab(self.tor_tab, 'Tor')
# Initializing bitcoind tab
self.bitcoind_tab = NodeManageDialog(self.node_set.bitcoind_node)
self.tabs.addTab(self.bitcoind_tab, 'Bitcoind')
# Initializing lnd tab
self.lnd_tab = NodeManageDialog(self.node_set.lnd_node)
self.tabs.addTab(self.lnd_tab, 'Lnd')
示例4: setLang
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QTabWidget [as 别名]
def setLang(self, langName):
lang_data = self.memoData['lang'][langName]
for ui_name in lang_data.keys():
if ui_name in self.uiList.keys() and lang_data[ui_name] != '':
ui_element = self.uiList[ui_name]
# '' means no translation availdanle in that data file
if isinstance(ui_element, (QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox) ):
# uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
ui_element.setText(lang_data[ui_name])
elif isinstance(ui_element, (QtWidgets.QGroupBox, QtWidgets.QMenu) ):
# uiType: QMenu, QGroupBox
ui_element.setTitle(lang_data[ui_name])
elif isinstance(ui_element, QtWidgets.QTabWidget):
# uiType: QTabWidget
tabCnt = ui_element.count()
tabNameList = lang_data[ui_name].split(';')
if len(tabNameList) == tabCnt:
for i in range(tabCnt):
if tabNameList[i] != '':
ui_element.setTabText(i,tabNameList[i])
elif isinstance(ui_element, QtWidgets.QComboBox):
# uiType: QComboBox
itemCnt = ui_element.count()
itemNameList = lang_data[ui_name].split(';')
ui_element.clear()
ui_element.addItems(itemNameList)
elif isinstance(ui_element, QtWidgets.QTreeWidget):
# uiType: QTreeWidget
labelCnt = ui_element.headerItem().columnCount()
labelList = lang_data[ui_name].split(';')
ui_element.setHeaderLabels(labelList)
elif isinstance(ui_element, QtWidgets.QTableWidget):
# uiType: QTableWidget
colCnt = ui_element.columnCount()
headerList = lang_data[ui_name].split(';')
cur_table.setHorizontalHeaderLabels( headerList )
elif isinstance(ui_element, (str, unicode) ):
# uiType: string for msg
self.uiList[ui_name] = lang_data[ui_name]
示例5: quickTabUI
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QTabWidget [as 别名]
def quickTabUI(self, name, tab_list, tab_names):
self.uiList[name]=QtWidgets.QTabWidget()
self.uiList[name].setStyleSheet("QTabWidget::tab-bar{alignment:center;}QTabBar::tab { min-width: 100px; }")
for i in range( len(tab_list) ):
each_tab = tab_list[i]
each_name = tab_names[i]
if isinstance(each_tab, QtWidgets.QWidget):
self.uiList[name].addTab(each_tab, each_name)
else:
tmp_holder = QtWidgets.QWidget()
tmp_holder.setLayout(each_tab)
self.uiList[name].addTab(tmp_holder, each_name)
return self.uiList[name]
示例6: qui
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QTabWidget [as 别名]
def qui(self, ui_list_string, parentObject_string='', opt=''):
# pre-defined user short name syntax
type_dict = {
'vbox': 'QVBoxLayout','hbox':'QHBoxLayout','grid':'QGridLayout', 'form':'QFormLayout',
'split': 'QSplitter', 'grp':'QGroupBox', 'tab':'QTabWidget',
'btn':'QPushButton', 'btnMsg':'QPushButton', 'label':'QLabel', 'input':'QLineEdit', 'check':'QCheckBox', 'choice':'QComboBox',
'txtEdit': 'LNTextEdit', 'txt': 'QTextEdit',
'tree': 'QTreeWidget', 'table': 'QTableWidget',
'space': 'QSpacerItem',
}
# get ui_list, creation or existing ui object
ui_list = [x.strip() for x in ui_list_string.split('|')]
for i in range(len(ui_list)):
if ui_list[i] in self.uiList:
# - exisiting object
ui_list[i] = self.uiList[ui_list[i]]
else:
# - string creation:
# get part info
partInfo = ui_list[i].split(';',1)
uiName = partInfo[0].split('@')[0]
uiType = uiName.rsplit('_',1)[-1]
if uiType in type_dict:
uiType = type_dict[uiType]
# set quickUI string format
ui_list[i] = partInfo[0]+';'+uiType
if len(partInfo)==1:
# give empty button and label a place holder name
if uiType in ('btn', 'btnMsg', 'QPushButton','label', 'QLabel'):
ui_list[i] = partInfo[0]+';'+uiType + ';'+uiName
elif len(partInfo)==2:
ui_list[i]=ui_list[i]+";"+partInfo[1]
# get parentObject or exisiting object
parentObject = parentObject_string
if parentObject in self.uiList:
parentObject = self.uiList[parentObject]
# process quickUI
self.quickUI(ui_list, parentObject, opt)
示例7: loadLang
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QTabWidget [as 别名]
def loadLang(self):
self.quickMenu(['language_menu;&Language'])
cur_menu = self.uiList['language_menu']
self.quickMenuAction('langDefault_atnLang', 'Default','','langDefault.png', cur_menu)
cur_menu.addSeparator()
self.uiList['langDefault_atnLang'].triggered.connect(partial(self.setLang,'default'))
# store default language
self.memoData['lang']={}
self.memoData['lang']['default']={}
for ui_name in self.uiList:
ui_element = self.uiList[ui_name]
if type(ui_element) in [ QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox ]:
# uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
self.memoData['lang']['default'][ui_name] = str(ui_element.text())
elif type(ui_element) in [ QtWidgets.QGroupBox, QtWidgets.QMenu ]:
# uiType: QMenu, QGroupBox
self.memoData['lang']['default'][ui_name] = str(ui_element.title())
elif type(ui_element) in [ QtWidgets.QTabWidget]:
# uiType: QTabWidget
tabCnt = ui_element.count()
tabNameList = []
for i in range(tabCnt):
tabNameList.append(str(ui_element.tabText(i)))
self.memoData['lang']['default'][ui_name]=';'.join(tabNameList)
elif type(ui_element) == str:
# uiType: string for msg
self.memoData['lang']['default'][ui_name] = self.uiList[ui_name]
# try load other language
lang_path = os.path.dirname(self.location) # better in packed than(os.path.abspath(__file__))
baseName = os.path.splitext( os.path.basename(self.location) )[0]
for fileName in os.listdir(lang_path):
if fileName.startswith(baseName+"_lang_"):
langName = fileName.replace(baseName+"_lang_","").split('.')[0].replace(" ","")
self.memoData['lang'][ langName ] = self.readRawFile( os.path.join(lang_path,fileName) )
self.quickMenuAction(langName+'_atnLang', langName.upper(),'',langName + '.png', cur_menu)
self.uiList[langName+'_atnLang'].triggered.connect(partial(self.setLang,langName))
# if no language file detected, add export default language option
if len(self.memoData['lang']) == 1:
self.quickMenuAction('langExport_atnLang', 'Export Default Language','','langExport.png', cur_menu)
self.uiList['langExport_atnLang'].triggered.connect(self.exportLang)
示例8: qui
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QTabWidget [as 别名]
def qui(self, ui_list_string, parentObject_string='', opt=''):
# pre-defined user short name syntax
type_dict = {
'vbox': 'QVBoxLayout','hbox':'QHBoxLayout','grid':'QGridLayout', 'form':'QFormLayout',
'split': 'QSplitter', 'grp':'QGroupBox', 'tab':'QTabWidget',
'btn':'QPushButton', 'btnMsg':'QPushButton', 'label':'QLabel', 'input':'QLineEdit', 'check':'QCheckBox', 'choice':'QComboBox',
'txt': 'QTextEdit',
'list': 'QListWidget', 'tree': 'QTreeWidget', 'table': 'QTableWidget',
'space': 'QSpacerItem',
}
# get ui_list, creation or existing ui object
ui_list = [x.strip() for x in ui_list_string.split('|')]
for i in range(len(ui_list)):
if ui_list[i] in self.uiList:
# - exisiting object
ui_list[i] = self.uiList[ui_list[i]]
else:
# - string creation:
# get part info
partInfo = ui_list[i].split(';',1)
uiName = partInfo[0].split('@')[0]
uiType = uiName.rsplit('_',1)[-1]
if uiType in type_dict:
uiType = type_dict[uiType]
# set quickUI string format
ui_list[i] = partInfo[0]+';'+uiType
if len(partInfo)==1:
# give empty button and label a place holder name
if uiType in ('btn', 'btnMsg', 'QPushButton','label', 'QLabel'):
ui_list[i] = partInfo[0]+';'+uiType + ';'+uiName
elif len(partInfo)==2:
ui_list[i]=ui_list[i]+";"+partInfo[1]
# get parentObject or exisiting object
parentObject = parentObject_string
if parentObject in self.uiList:
parentObject = self.uiList[parentObject]
# process quickUI
self.quickUI(ui_list, parentObject, opt)
示例9: __init__
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QTabWidget [as 别名]
def __init__(self, parent=None, mode=0):
super_class.__init__(self, parent)
#------------------------------
# class variables
#------------------------------
self.version="0.1"
self.help = "How to Use:\n1. Put source info in\n2. Click Process button\n3. Check result output\n4. Save memory info into a file."
self.uiList={} # for ui obj storage
self.memoData = {} # key based variable data storage
self.location = ""
if getattr(sys, 'frozen', False):
# frozen - cx_freeze
self.location = sys.executable
else:
# unfrozen
self.location = os.path.realpath(sys.modules[self.__class__.__module__].__file__)
self.name = self.__class__.__name__
self.iconPath = os.path.join(os.path.dirname(self.location),'icons',self.name+'.png')
self.iconPix = QtGui.QPixmap(self.iconPath)
self.icon = QtGui.QIcon(self.iconPath)
self.fileType='.{0}_EXT'.format(self.name)
#------------------------------
# core function variable
#------------------------------
self.qui_core_dict = {
'vbox': 'QVBoxLayout','hbox':'QHBoxLayout','grid':'QGridLayout', 'form':'QFormLayout',
'split': 'QSplitter', 'grp':'QGroupBox', 'tab':'QTabWidget',
'btn':'QPushButton', 'btnMsg':'QPushButton', 'label':'QLabel', 'input':'QLineEdit', 'check':'QCheckBox', 'choice':'QComboBox',
'txt': 'QTextEdit',
'list': 'QListWidget', 'tree': 'QTreeWidget', 'table': 'QTableWidget',
'space': 'QSpacerItem',
}
self.qui_user_dict = {}
#------------------------------