我们从Python开源项目中,提取了以下49个代码示例,用于说明如何使用PyQt4.QtGui.QTabWidget()。
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 [ QtGui.QLabel, QtGui.QPushButton, QtGui.QAction, QtGui.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 [ QtGui.QGroupBox, QtGui.QMenu ]: # uiType: QMenu, QGroupBox if uiList_lang_read[ui_name] != "": ui_element.setTitle(uiList_lang_read[ui_name]) elif type(ui_element) in [ QtGui.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]
def addTab(self, webview_tab=None): """ Creates a new tab and add to QTabWidget applysettings() must be called after adding each tab""" if not webview_tab: webview_tab = webkit.MyWebView(self.tabWidget, networkmanager) webview_tab.windowCreated.connect(self.addTab) webview_tab.loadStarted.connect(self.onLoadStart) webview_tab.loadFinished.connect(self.onLoadFinish) webview_tab.loadProgress.connect(self.onProgress) webview_tab.urlChanged.connect(self.onUrlChange) webview_tab.titleChanged.connect(self.onTitleChange) webview_tab.iconChanged.connect(self.onIconChange) webview_tab.page().printRequested.connect(self.printpage) webview_tab.page().downloadRequested.connect(self.download_requested_file) webview_tab.page().unsupportedContent.connect(self.handleUnsupportedContent) webview_tab.page().linkHovered.connect(self.onLinkHover) webview_tab.page().windowCloseRequested.connect(self.closeRequestedTab) self.tabWidget.addTab(webview_tab, "( Untitled )") if self.tabWidget.count()==1: self.tabWidget.tabBar().hide() else: self.tabWidget.tabBar().show() self.tabWidget.setCurrentIndex(self.tabWidget.count()-1)
def __init__(self): QtGui.QApplication.__init__(self, sys.argv) self.window = QtGui.QWidget() self.window.setGeometry(100, 100, 800, 600) self.window.setWindowTitle("Open Browser") self.grid = QtGui.QGridLayout() self.window.setLayout(self.grid) self.tab_stack = CQTabWidget() self.tab_stack.setTabShape(QtGui.QTabWidget.TabShape(QtGui.QTabWidget.Triangular)) self.tab_stack.connect(self.tab_stack, QtCore.SIGNAL("currentChanged(int)"), self.add_tab) self.tab_stack.connect(self.tab_stack, QtCore.SIGNAL("RELOAD_PAGE"), lambda: self.tabs[self.tab_stack.currentIndex()][2].reload()) self.tabs = [[QtGui.QWidget(), QtGui.QGridLayout()], [QtGui.QWidget(), QtGui.QGridLayout()]] self.tab_stack.addTab(self.tabs[0][0], '') self.tab_stack.addTab(self.tabs[1][0], '+') self.current_links = [] self.visited = [] self.bookmarks = Bookmarks() QtWebKit.QWebSettings.globalSettings().setAttribute(QtWebKit.QWebSettings.PluginsEnabled, True) QtWebKit.QWebSettings.globalSettings().setAttribute(QtWebKit.QWebSettings.JavascriptEnabled, True) self.create_widgets() self.current_index = 0 self.window.showMaximized() sys.exit(self.exec_())
def __init__( self, core ) : # Inherit all attributes of an instance of "QTabWidget". super( widget_mom, self ).__init__( ) # Store the Janus core. self.core = core # Intialize this widget's sub-widgets and add them as tabs. self.wdg_ctrl = widget_mom_ctrl( self.core ) self.wdg_res = widget_mom_res( self.core ) self.addTab( self.wdg_ctrl, 'Moment' ) self.addTab( self.wdg_res , 'Results' )
def __init__( self, core ) : # Inherit all attributes of an instance of "QTabWidget". super( widget_mfi, self ).__init__( ) # Store the Janus core. self.core = core # Intialize this widget's sub-widgets and add them as tabs. self.wdg_lin_plot = widget_mfi_lin_plot( self.core ) self.wdg_lon_plot = widget_mfi_lon_plot( self.core ) self.wdg_colat_plot = widget_mfi_colat_plot( self.core ) self.wdg_info = widget_mfi_info( self.core ) self.addTab( self.wdg_lin_plot, 'MFI' ) self.addTab( self.wdg_lon_plot, u'?' ) self.addTab( self.wdg_colat_plot, u'?' ) self.addTab( self.wdg_info, '<B>' )
def __init__( self, core ) : # Inherit all attributes of an instance of "QTabWidget". super( widget_nln, self ).__init__( ) # Store the Janus core. self.core = core # Intialize this widget's sub-widgets and add them as tabs. self.wdg_spc = widget_nln_spc( self.core ) self.wdg_pop = widget_nln_pop( self.core ) self.wdg_set = widget_nln_set( self.core ) self.wdg_gss = widget_nln_gss( self.core ) self.wdg_res = widget_nln_res( self.core ) self.addTab( self.wdg_spc, 'Non-Linear Ions' ) self.addTab( self.wdg_pop, 'Populations' ) self.addTab( self.wdg_set, 'Settings' ) self.addTab( self.wdg_gss, 'Initial Guess' ) self.addTab( self.wdg_res, 'Results' )
def __init__( self, core, n_plt_x=None, n_plt_y=None ) : # Inherit all attributes of an instance of "QTabWidget". super( widget_fc, self ).__init__( ) # Store the Janus core. self.core = core # Create two instances of "widget_fc_cup" (one for each Faraday # cup) and add each as a tab. self.wdg_fc1 = widget_fc_cup( core=self.core, cup=1, n_plt_x=n_plt_x, n_plt_y=n_plt_y ) self.wdg_fc2 = widget_fc_cup( core=self.core, cup=2, n_plt_x=n_plt_x, n_plt_y=n_plt_y ) self.addTab( self.wdg_fc1, 'Faraday Cup 1' ) self.addTab( self.wdg_fc2, 'Faraday Cup 2' )
def initUI(self) : self.main_Vlayout = QtGui.QVBoxLayout(self) # top section self.top_Hlayout = QtGui.QHBoxLayout() self.top_left_Vlayout = QtGui.QVBoxLayout() self.label_info = QtGui.QLabel("") self.table_info = QtGui.QTableWidget() self.table_info.doubleClicked.connect(self.table_mouse_event) self.boxplot_frame = MplCanva() self.tab_genes = QtGui.QTabWidget(self) self.top_left_Vlayout.addWidget(self.label_info) self.top_left_Vlayout.addWidget(self.table_info) self.top_Hlayout.addLayout(self.top_left_Vlayout) self.top_Hlayout.addWidget(self.boxplot_frame) self.main_Vlayout.addLayout(self.top_Hlayout) self.main_Vlayout.addWidget(self.tab_genes)
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]
def initUI(self): #print "ArrayGui.initUI(self)" #mainFrame = QtGui.QFrame(self);self.setCentralWidget(mainFrame) mainVbox = QtGui.QVBoxLayout(); #mainFrame.setLayout(mainbox) self.setLayout(mainVbox) #self.chBox = QtGui.QHBoxLayout(); mainVbox.addLayout(self.chBox) #self.chBox.addWidget(QtGui.QLabel('Channels:')) #self.chWidget = QtGui.QWidget() #chBox.addWidget(self.chWidget) #channelBox = QtGui.QHBoxLayout(); self.chWidget.setLayout(channelBox) arrayBox = QtGui.QHBoxLayout(); mainVbox.addLayout(arrayBox) self.arrayTabs = QtGui.QTabWidget(self); arrayBox.addWidget(self.arrayTabs) mainVbox.addWidget(QtGui.QLabel('NOTICE:')) self.statusCtrl = QtGui.QLabel('') mainVbox.addWidget(self.statusCtrl) #mainVbox.addStretch(1)
def __init__(self, segywidgets=None, parent=None): QWidget.__init__(self, parent) """ :type segywidgets: list[segyviewlib.SegyViewWidget] :type parent: QObject """ self._context = None self._segywidgets = segywidgets if segywidgets else [] self._tab_widget = QTabWidget() self.initialize()
def __init__(self, parent=None): super(dbxIngration, self).__init__(parent) self.dbx_tabWidget = QtGui.QTabWidget(self) self.createWidgets()
def __init__(self, options, conditions, rows, cols, entry_options, Lang): self.mainWidget = QtGui.QTabWidget() self.options = [] self.createTabs('Options', options, rows, cols, entry_options) self.createTabs('Conditions', conditions, rows, cols, entry_options) super(OptionsDialog, self).__init__(Lang) self.setWindowTitle(Lang.value('MI_Options'))
def initUI(self) : self.main_widget = QtGui.QWidget(self) self.layout = QtGui.QVBoxLayout(self.main_widget) self.layout_top_right = QtGui.QHBoxLayout() self.layout_top = QtGui.QHBoxLayout() # Search bar with auto completer model = QtGui.QStringListModel() model.setStringList(self.genes.keys()) self.completer = QtGui.QCompleter() self.completer.setModel(model) self.search_bar = QtGui.QLineEdit("Search gene") self.search_bar.keyPressEvent = self.search_bar_key_event self.search_bar.mousePressEvent = self.search_bar_mouse_event self.search_bar.setCompleter(self.completer) self.af_bar = QtGui.QLineEdit("Set af bar") self.af_bar.keyPressEvent = self.af_bar_key_event self.af_bar.mousePressEvent = self.af_bar_mouse_event self.chromosome_combobox = QtGui.QComboBox() self.start_bar = QtGui.QLineEdit("Start coordinate") self.start_bar.keyPressEvent = self.start_bar_key_event self.start_bar.mousePressEvent = self.start_bar_mouse_event self.end_bar = QtGui.QLineEdit("End coordinate") self.end_bar.keyPressEvent = self.end_bar_key_event self.end_bar.mousePressEvent = self.end_bar_mouse_event self.layout_top_right.addWidget(self.chromosome_combobox) self.layout_top_right.addWidget(self.start_bar) self.layout_top_right.addWidget(self.end_bar) self.layout_top.addWidget(self.search_bar) self.layout_top.addWidget(self.af_bar) self.layout_top.addLayout(self.layout_top_right) self.tab_widget = QtGui.QTabWidget(self) self.tab_widget.currentChanged.connect(self.change_tab) self.statut_bar = QtGui.QStatusBar(self) self.layout.addLayout(self.layout_top) self.layout.addWidget(self.tab_widget) self.layout.addWidget(self.statut_bar)
def initUI(self) : self.main_HLayout = QtGui.QHBoxLayout(self) self.left_Vlayout = QtGui.QVBoxLayout() self.tab_alignment = QtGui.QTabWidget() self.label_info = QtGui.QLabel(self.get_label_info()) self.label_info.setWordWrap(True) self.tree_transcripts = QtGui.QTreeWidget() self.tree_transcripts.mousePressEvent = self.tree_transcripts_mouse_event self.left_Vlayout.addWidget(self.label_info) self.left_Vlayout.addWidget(self.tree_transcripts) self.main_HLayout.addLayout(self.left_Vlayout) self.main_HLayout.addWidget(self.tab_alignment)
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]
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]
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() QtCore.QObject.connect( self.uiList['langDefault_atnLang'], QtCore.SIGNAL("triggered()"), 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 [ QtGui.QLabel, QtGui.QPushButton, QtGui.QAction, QtGui.QCheckBox ]: # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox self.memoData['lang']['default'][ui_name] = str(ui_element.text()) elif type(ui_element) in [ QtGui.QGroupBox, QtGui.QMenu ]: # uiType: QMenu, QGroupBox self.memoData['lang']['default'][ui_name] = str(ui_element.title()) elif type(ui_element) in [ QtGui.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) QtCore.QObject.connect( self.uiList[langName+'_atnLang'], QtCore.SIGNAL("triggered()"), 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) QtCore.QObject.connect( self.uiList['langExport_atnLang'], QtCore.SIGNAL("triggered()"), self.exportLang )
def quickTabUI(self, name, tab_list, tab_names): self.uiList[name]=QtGui.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, QtGui.QWidget): self.uiList[name].addTab(each_tab, each_name) else: tmp_holder = QtGui.QWidget() tmp_holder.setLayout(each_tab) self.uiList[name].addTab(tmp_holder, each_name) return self.uiList[name]
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)
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)
def setupUi(self, Dialog, bookmark_data, favourites): Dialog.resize(740, 450) Dialog.setWindowTitle('Bookmarks Manager') self.layout = QtGui.QGridLayout(Dialog) self.urlLabel = QtGui.QLabel('URL :', Dialog) self.layout.addWidget(self.urlLabel, 0, 0, 1, 1) self.urlBox = UrlBox(Dialog) self.layout.addWidget(self.urlBox, 0, 1, 1, 5) # Create Tab Widget self.tabWidget = QtGui.QTabWidget(Dialog) self.tabWidget.setDocumentMode(True) self.tabWidget.tabBar().setExpanding(True) # Add Bookmarks Table self.bookmarks_table = BookmarksTable(Dialog, bookmark_data, True) self.tabWidget.addTab(self.bookmarks_table, 'Bookmarks') # Add Favourites table self.favs_table = BookmarksTable(Dialog, favourites) self.tabWidget.addTab(self.favs_table, 'HomePage Favourites') self.layout.addWidget(self.tabWidget, 1, 0, 1, 6) self.tabWidget.setTabIcon(0, QtGui.QIcon(':/bookmarks.png')) self.tabWidget.setTabIcon(1, QtGui.QIcon(':/favourites.png')) # Add Buttons self.moveUpBtn = QtGui.QPushButton(QtGui.QIcon(":/go-up.png"), '', Dialog) self.moveUpBtn.clicked.connect(self.moveItemUp) self.layout.addWidget(self.moveUpBtn, 2, 0, 1, 1) self.moveDownBtn = QtGui.QPushButton(QtGui.QIcon(":/go-down.png"), '', Dialog) self.moveDownBtn.clicked.connect(self.moveItemDown) self.layout.addWidget(self.moveDownBtn, 2, 1, 1, 1) self.copyLinkBtn = QtGui.QPushButton(QtGui.QIcon(":/edit-copy.png"), '', Dialog) self.copyLinkBtn.clicked.connect(self.copyItemLink) self.layout.addWidget(self.copyLinkBtn, 2, 2, 1, 1) self.editBtn = QtGui.QPushButton(QtGui.QIcon(":/edit.png"), '', Dialog) self.editBtn.clicked.connect(self.editItem) self.layout.addWidget(self.editBtn, 2, 3, 1, 1) self.deleteBtn = QtGui.QPushButton(QtGui.QIcon(":/edit-delete.png"), '', Dialog) self.deleteBtn.clicked.connect(self.deleteItem) self.layout.addWidget(self.deleteBtn, 2, 4, 1, 1) # Add ButtonBox self.buttonBox = QtGui.QDialogButtonBox(Dialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Close) self.layout.addWidget(self.buttonBox, 2, 5, 1, 1) self.bookmarks_table.urlSelected.connect(self.urlBox.setText) self.bookmarks_table.doubleclicked.connect(Dialog.accept) self.bookmarks_table.itemSelectionChanged.connect(self.toggleButtonAccess) self.favs_table.doubleclicked.connect(Dialog.accept) self.favs_table.urlSelected.connect(self.urlBox.setText) self.favs_table.itemSelectionChanged.connect(self.toggleButtonAccess) self.tabWidget.currentChanged.connect(self.toggleButtonAccess) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), Dialog.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), Dialog.reject) self.bookmarks_table.selectRow(0) self.bookmarks_table.setFocus()
def __init__(self, workingDir): '''Create the main window. The Class is initialized with the Layout, specified in the CPNSimGui.ui file in the directory: workingDir/gui/. :param workingDir: Working directory. ''' self.workingDir = workingDir super(QtGui.QMainWindow, self).__init__() uic.loadUi('%s/gui/CPNSimGui.ui'%(self.workingDir), self) self.editors = [] self.editorwidgets = [] self.editorwidgets.append(None) self.tabWidget = QtGui.QTabWidget(self) self.editors.append( DiagramEditor(mainWindow=self, parent=self, workingDir=self.workingDir) ) self.editors[0].resize(700, 800) self.tabWidget.addTab(self.editors[0], "Net") self.logWidget = QtGui.QListWidget(self) self.tabWidget.addTab(self.logWidget, "Log") self.verticalLayout.addWidget(self.tabWidget) self.setMinimumSize(QtCore.QSize(800, 600)) self.setMaximumSize(QtCore.QSize(1980, 1080)) self.centralwidget.setMinimumSize(QtCore.QSize(799, 599)) self.centralwidget.setMaximumSize(QtCore.QSize(1979, 1079)) self.pushButton_4.setCheckable(True) self.radioButton_2.toggle() self.simulator = CPNSimulator(self) self.timer = QtCore.QTimer() self.timer.timeout.connect(self.simulator.forwardStep) self.pushButton.connect(self.pushButton, QtCore.SIGNAL("pressed()"),self.simulator.back2beginning) self.pushButton_2.connect(self.pushButton_2, QtCore.SIGNAL("pressed()"),self.simulator.backStep) self.pushButton_3.connect(self.pushButton_3, QtCore.SIGNAL("pressed()"),self.simulator.stopSim) # self.pushButton_4.connect(self.pushButton_4, QtCore.SIGNAL("toggled(bool)"),self.editor.startSim) self.pushButton_4.connect(self.pushButton_4, QtCore.SIGNAL("pressed()"),self.simulator.startSim) self.pushButton_5.connect(self.pushButton_5, QtCore.SIGNAL("pressed()"),self.simulator.forwardStep) self.pushButton_6.connect(self.pushButton_6, QtCore.SIGNAL("pressed()"),self.simulator.forward2lastStep) self.pushButton_7.connect(self.pushButton_7, QtCore.SIGNAL("pressed()"),self.simulator.resetSimulator) self.actionNew_Net.connect(self.actionNew_Net, QtCore.SIGNAL("triggered()"), self.newNet) self.actionOpen_Net.connect(self.actionOpen_Net, QtCore.SIGNAL("triggered()"), self.loadNet) self.actionSave_Net.connect(self.actionSave_Net, QtCore.SIGNAL("triggered()"), self.saveNet) self.actionExport_Step_as_SVG.connect(self.actionExport_Step_as_SVG, QtCore.SIGNAL("triggered()"), self.export_Step_as_SVG) self.lineEdit_2.setText( "%d %%" %( int( self.editors[0].diagramView.scaleFactor*100 ) ) ) self.lineEdit.setText( "%d/%d"%( self.simulator.displayStep, self.simulator.simulationStep ) ) self.newNet(True) self.showMaximized() #-------------------------------------------------------------------
def createWidgetFromDefinitionDict(self): """ Automatically build a widget, based on dict definition of the items. @return: a QWidget containing all the elements of the configuration window """ logger.info('Creating configuration window') tab_widget = QTabWidget() definition = self.cfg_window_def #Create a dict with the sections' titles if not already defined. This dict contains sections' names as key and tabs' titles as values if '__section_title__' not in definition: definition['__section_title__'] = {} #Compute all the sections for section in sorted(definition): #skip the special section __section_title__ if section == '__section_title__': continue #Create the title for the section if it doesn't already exist if section not in definition['__section_title__']: #The title for this section doesn't exist yet if isinstance(definition[section], dict) and '__section_title__' in definition[section]: #The title for this section is defined into the section itself => we add the title to the dict containing all the titles definition['__section_title__'][section] = definition[section]['__section_title__'] else: #The title for this section is not defined anywhere, so we use the section name itself as a title definition['__section_title__'][section] = section.replace('_', ' ') #Create the tab (and the widget) for the current section, if it doesn't exist yet widget = None for i in range(tab_widget.count()): if definition['__section_title__'][section] == tab_widget.tabText(i): widget = tab_widget.widget(i) break if widget is None: widget = QWidget() tab_widget.addTab(widget, definition['__section_title__'][section]) #Create the tab content for this section self.createWidgetSubSection(definition[section], widget) #Add a separator at the end of this subsection if widget.layout() is not None: separator = QFrame() separator.setFrameShape(QFrame.HLine) widget.layout().addWidget(separator) widget.layout().addStretch() #Add a QSpacer at the bottom of each widget, so that the items are placed on top of each tab for i in range(tab_widget.count()): if tab_widget.widget(i).layout() is not None: tab_widget.widget(i).layout().addStretch() return tab_widget
def initLayout(self): # widgets hbox = QtGui.QHBoxLayout() # left pane widgetLeftPane = QtGui.QWidget() vboxLeftPane = QtGui.QVBoxLayout() vboxLeftPane.setSpacing(0) vboxLeftPane.setContentsMargins(0, 0, 0, 0) self.fenView = FenView(self) self.boardView = BoardView(self) self.infoView = InfoView() self.chessBox = ChessBox() vboxLeftPane.addWidget(self.fenView) vboxLeftPane.addWidget(self.boardView) self.tabBar1 = QtGui.QTabWidget() self.tabBar1.setTabPosition(1) self.tabBar1.addTab(self.infoView, Lang.value('TC_Info')) self.tabBar1.addTab(self.chessBox, Lang.value('TC_Pieces')) vboxLeftPane.addWidget(self.tabBar1, 1) widgetLeftPane.setLayout(vboxLeftPane) # right pane self.easyEditView = EasyEditView() self.solutionView = SolutionView() self.popeyeView = PopeyeView() self.yamlView = YamlView() self.publishingView = PublishingView() self.chestView = chest.ChestView(Conf, Lang, Mainframe) self.tabBar2 = QtGui.QTabWidget() self.tabBar2.addTab(self.popeyeView, Lang.value('TC_Popeye')) self.tabBar2.addTab(self.solutionView, Lang.value('TC_Solution')) self.tabBar2.addTab(self.easyEditView, Lang.value('TC_Edit')) self.tabBar2.addTab(self.yamlView, Lang.value('TC_YAML')) self.tabBar2.addTab(self.publishingView, Lang.value('TC_Publishing')) self.tabBar2.addTab(self.chestView, Lang.value('TC_Chest')) splitter = QtGui.QSplitter(QtCore.Qt.Vertical) self.overview = OverviewList() self.overview.init() splitter.addWidget(self.tabBar2) splitter.addWidget(self.overview) # putting panes together hbox.addWidget(widgetLeftPane) hbox.addWidget(splitter, 1) cw = QtGui.QWidget() self.setCentralWidget(cw) self.centralWidget().setLayout(hbox)
def setupUi(self, LuggageFrame): LuggageFrame.setObjectName(_fromUtf8("LuggageFrame")) LuggageFrame.resize(324, 358) LuggageFrame.setFrameShape(QtGui.QFrame.NoFrame) LuggageFrame.setFrameShadow(QtGui.QFrame.Raised) self.verticalLayout = QtGui.QVBoxLayout(LuggageFrame) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.horizontalLayout_2 = QtGui.QHBoxLayout() self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) self.button_close = QtGui.QPushButton(LuggageFrame) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.button_close.sizePolicy().hasHeightForWidth()) self.button_close.setSizePolicy(sizePolicy) self.button_close.setFocusPolicy(QtCore.Qt.TabFocus) self.button_close.setToolTip(_fromUtf8("")) self.button_close.setText(_fromUtf8("")) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/pyluggage/img/red_cross_16.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.button_close.setIcon(icon) self.button_close.setObjectName(_fromUtf8("button_close")) self.horizontalLayout_2.addWidget(self.button_close) self.label = QtGui.QLabel(LuggageFrame) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth()) self.label.setSizePolicy(sizePolicy) self.label.setObjectName(_fromUtf8("label")) self.horizontalLayout_2.addWidget(self.label) spacerItem = QtGui.QSpacerItem(5, 20, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) self.horizontalLayout_2.addItem(spacerItem) self.label_luggage_name = QtGui.QLabel(LuggageFrame) font = QtGui.QFont() font.setBold(True) font.setWeight(75) self.label_luggage_name.setFont(font) self.label_luggage_name.setObjectName(_fromUtf8("label_luggage_name")) self.horizontalLayout_2.addWidget(self.label_luggage_name) self.button_help = QtGui.QPushButton(LuggageFrame) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.button_help.sizePolicy().hasHeightForWidth()) self.button_help.setSizePolicy(sizePolicy) self.button_help.setText(_fromUtf8("")) icon1 = QtGui.QIcon() icon1.addPixmap(QtGui.QPixmap(_fromUtf8(":/pyluggage/img/help_16.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.button_help.setIcon(icon1) self.button_help.setObjectName(_fromUtf8("button_help")) self.horizontalLayout_2.addWidget(self.button_help) self.verticalLayout.addLayout(self.horizontalLayout_2) self.tab_contents = QtGui.QTabWidget(LuggageFrame) self.tab_contents.setObjectName(_fromUtf8("tab_contents")) self.verticalLayout.addWidget(self.tab_contents) self.retranslateUi(LuggageFrame) QtCore.QMetaObject.connectSlotsByName(LuggageFrame)
def __init__(self, parent=None): super(requestEditor, self).__init__(parent) self.ecurequestsparser = None layoutsss = gui.QHBoxLayout() self.checknosds = gui.QCheckBox("No SDS") self.checkplant = gui.QCheckBox("Plant") self.checkaftersales = gui.QCheckBox("After Sale") self.checkengineering = gui.QCheckBox("Engineering") self.checksupplier = gui.QCheckBox("Supllier") self.checknosds.toggled.connect(self.sdschanged) self.checkplant.toggled.connect(self.sdschanged) self.checkaftersales.toggled.connect(self.sdschanged) self.checkengineering.toggled.connect(self.sdschanged) self.checksupplier.toggled.connect(self.sdschanged) layoutsss.addWidget(self.checknosds) layoutsss.addWidget(self.checkplant) layoutsss.addWidget(self.checkaftersales) layoutsss.addWidget(self.checkengineering) layoutsss.addWidget(self.checksupplier) layout_action = gui.QHBoxLayout() button_reload = gui.QPushButton(_("Reload requests")) button_add = gui.QPushButton(_("Add request")) layout_action.addWidget(button_reload) layout_action.addWidget(button_add) layout_action.addStretch() button_reload.clicked.connect(self.reload) button_add.clicked.connect(self.add_request) self.layh = gui.QHBoxLayout() self.requesttable = requestTable() self.layh.addWidget(self.requesttable) self.layv = gui.QVBoxLayout() self.sendbyteeditor = paramEditor() self.receivebyteeditor = paramEditor(False) self.tabs = gui.QTabWidget() self.tabs.addTab(self.sendbyteeditor, _("Send bytes")) self.tabs.addTab(self.receivebyteeditor, _("Receive bytes")) self.layv.addLayout(layout_action) self.layv.addLayout(layoutsss) self.layv.addWidget(self.tabs) self.layh.addLayout(self.layv) self.setLayout(self.layh) self.requesttable.setSendByteEditor(self.sendbyteeditor) self.requesttable.setReceiveByteEditor(self.receivebyteeditor) self.enable_view(False)
def __init__(self, parent=None, mode=0): QtWidgets.QMainWindow.__init__(self, parent) #------------------------------ # class variables #------------------------------ self.version = '0.1' self.date = '2017.01.01' self.log = 'no version log in user class' self.help = 'no help guide in user class' self.uiList={} # for ui obj storage self.memoData = {} # key based variable data storage self.memoData['font_size_default'] = QtGui.QFont().pointSize() self.memoData['font_size'] = self.memoData['font_size_default'] self.memoData['last_export'] = '' self.memoData['last_import'] = '' self.name = self.__class__.__name__ 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.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', 'menu' : 'QMenu', 'menubar' : 'QMenuBar', } self.qui_user_dict = {}
def __init__(self, parent=None, mode=0): super_class.__init__(self, parent) #------------------------------ # class variables #------------------------------ self.version = "0.1" self.date = '2017.01.01' self.log = 'no version log in user class' self.help = 'no help guide in user class' self.uiList={} # for ui obj storage self.memoData = {} # key based variable data storage self.memoData['font_size_default'] = QtGui.QFont().pointSize() self.memoData['font_size'] = self.memoData['font_size_default'] self.memoData['last_export'] = '' self.memoData['last_import'] = '' 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', 'menu' : 'QMenu', 'menubar' : 'QMenuBar', } self.qui_user_dict = {} #------------------------------
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', '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)
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 = {} #------------------------------
def loadLang(self): if isinstance(self, QtWidgets.QMainWindow): 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.readFileData( os.path.join(lang_path,fileName) ) if isinstance(self, QtWidgets.QMainWindow): self.quickMenuAction(langName+'_atnLang', langName.upper(),'',langName + '.png', self.uiList['language_menu']) self.uiList[langName+'_atnLang'].triggered.connect(partial(self.setLang,langName)) # if no language file detected, add export default language option if isinstance(self, QtWidgets.QMainWindow) and len(self.memoData['lang']) == 1: self.quickMenuAction('langExport_atnLang', 'Export Default Language','','langExport.png', self.uiList['language_menu']) self.uiList['langExport_atnLang'].triggered.connect(self.exportLang)
def __init__(self, parent=None, mode=0): super_class.__init__(self, parent) #------------------------------ # class variables #------------------------------ self.version = "0.1" self.date = '2017.01.01' self.log = 'no version log in user class' self.help = 'no help guide in user class' self.uiList={} # for ui obj storage self.memoData = {} # key based variable data storage self.memoData['font_size_default'] = QtGui.QFont().pointSize() self.memoData['font_size'] = self.memoData['font_size_default'] 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', 'menu' : 'QMenu', 'menubar' : 'QMenuBar', } self.qui_user_dict = {} #------------------------------