我们从Python开源项目中,提取了以下49个代码示例,用于说明如何使用PySide.QtGui.QGroupBox()。
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 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 createIconGroupBox(self): self.iconGroupBox = QtGui.QGroupBox("Tray Icon") self.iconLabel = QtGui.QLabel("Icon:") self.iconComboBox = QtGui.QComboBox() self.iconComboBox.addItem(QtGui.QIcon(':/icons/miner.svg'), "Miner") self.iconComboBox.addItem(QtGui.QIcon(':/images/heart.svg'), "Heart") self.iconComboBox.addItem(QtGui.QIcon(':/images/trash.svg'), "Trash") self.showIconCheckBox = QtGui.QCheckBox("Show icon") self.showIconCheckBox.setChecked(True) iconLayout = QtGui.QHBoxLayout() iconLayout.addWidget(self.iconLabel) iconLayout.addWidget(self.iconComboBox) iconLayout.addStretch() iconLayout.addWidget(self.showIconCheckBox) self.iconGroupBox.setLayout(iconLayout)
def generateWidget( self, idGDT, ContainerOfData ): self.idGDT = idGDT self.ContainerOfData = ContainerOfData self.group = QtGui.QGroupBox(self.Text) vbox = QtGui.QVBoxLayout() for l in self.List: vbox.addLayout(l.generateWidget(self.idGDT, self.ContainerOfData)) self.group.setLayout(vbox) return self.group
def create_directory_choose(self): group_box = QtGui.QGroupBox('An awesome web project called:') title_hbox = QHBoxLayout() title_hbox.setContentsMargins(10, 10, 10, 10) win_icon = self.create_icon_box('window_icon', 'Window Icon') exe_icon = self.create_icon_box('exe_icon', 'Exe Icon') mac_icon = self.create_icon_box('mac_icon', 'Mac Icon') self.title_label = QtGui.QLabel('TBD') self.title_label.setStyleSheet('font-size:20px; font-weight:bold;') title_hbox.addWidget(self.title_label) title_hbox.addWidget(QtGui.QLabel()) title_hbox.addWidget(win_icon) title_hbox.addWidget(exe_icon) title_hbox.addWidget(mac_icon) vlayout = QtGui.QVBoxLayout() vlayout.setSpacing(5) vlayout.setContentsMargins(10, 5, 10, 5) vlayout.addLayout(title_hbox) #vlayout.addLayout(input_layout) #vlayout.addLayout(output_layout) group_box.setLayout(vlayout) return group_box
def build_ui(self): self.setLayout(QtGui.QVBoxLayout()) self.label = QtGui.QLabel("some label") self.btn = QtGui.QPushButton("button") self.lineedit = QtGui.QLineEdit() self.textedit = QtGui.QTextEdit() self.grp = QtGui.QGroupBox("group box grid layout") self.grp.setLayout(QtGui.QGridLayout()) self.chkbx_1 = QtGui.QCheckBox("chkbx_1") self.chkbx_2 = QtGui.QCheckBox("chkbx_2l") self.chkbx_2.setDisabled(True) self.chkbx_3 = QtGui.QCheckBox("chkbx_2r") self.chkbx_4 = QtGui.QCheckBox("chkbx_3") self.chkbx_5 = QtGui.QCheckBox("chkbx_4") self.grp.layout().addWidget(self.chkbx_1, 0, 0) self.grp.layout().addWidget(self.chkbx_2, 1, 0) self.grp.layout().addWidget(self.chkbx_3, 1, 1) self.grp.layout().addWidget(self.chkbx_4, 2, 0) self.grp.layout().addWidget(self.chkbx_5, 3, 0) self.grp.layout().setColumnStretch(2,1) self.lrbox = QtGui.QHBoxLayout() self.lrbox.addWidget(self.textedit) self.lrbox.addWidget(self.grp) self.layout().addWidget(self.label) self.layout().addWidget(self.btn) self.layout().addWidget(self.lineedit) self.layout().addLayout(self.lrbox)
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 quickGrpUI(self, ui_name, ui_label, ui_layout): self.uiList[ui_name] = QtWidgets.QGroupBox(ui_label) if isinstance(ui_layout, QtWidgets.QLayout): self.uiList[ui_name].setLayout(ui_layout) elif isinstance(ui_layout, str): ui_layout = self.quickLayout(ui_name+"_layout", ui_layout) self.uiList[ui_name].setLayout(ui_layout) return [self.uiList[ui_name], ui_layout]
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 quickGrpUI(self, ui_name, ui_label, ui_layout): self.uiList[ui_name] = QtGui.QGroupBox(ui_label) if isinstance(ui_layout, QtGui.QLayout): self.uiList[ui_name].setLayout(ui_layout) elif isinstance(ui_layout, str): ui_layout = self.quickLayout(ui_name+"_layout", ui_layout) self.uiList[ui_name].setLayout(ui_layout) return [self.uiList[ui_name], ui_layout]
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 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 get_group_box(self, widget): group_box = QtGui.QGroupBox(widget) group_box.setFlat(False) if hasattr(self, 'description'): group_box.setTitle("%s" % self.description) else: group_box.setTitle("%s" % self.name) self.form = widget grid = self.get_grid() group_box.setLayout(grid) return group_box, grid
def get_group_box(self, widget): group_box = QtGui.QGroupBox(widget) group_box.setFlat(False) self.form = widget grid = self.get_grid() title = QtGui.QLabel(self.form) title.setText("Linked part to : %s" % self.part_link.name) grid.addWidget(title, 1, 0, 1, 2) group_box.setLayout(grid) group_box.setTitle(self.name) return group_box, grid
def get_group_box(self, widget): group_box = QtGui.QGroupBox(widget) group_box.setFlat(False) self.form = widget grid = self.get_grid() title = QtGui.QLabel(self.form) title.setText("Linked tab to : %s" % self.tab_link.description) grid.addWidget(title, 1, 0, 1, 2) group_box.setLayout(grid) group_box.setTitle(self.name) return group_box, grid
def setupUi(self, setupAPI): setupAPI.setObjectName("setupAPI") setupAPI.resize(374, 188) self.verticalLayout = QtGui.QVBoxLayout(setupAPI) self.verticalLayout.setObjectName("verticalLayout") self.apiFileLocationDisplay = QtGui.QLineEdit(setupAPI) self.apiFileLocationDisplay.setDragEnabled(True) self.apiFileLocationDisplay.setReadOnly(True) self.apiFileLocationDisplay.setObjectName("apiFileLocationDisplay") self.verticalLayout.addWidget(self.apiFileLocationDisplay) self.groupBox = QtGui.QGroupBox(setupAPI) self.groupBox.setObjectName("groupBox") self.verticalLayout_2 = QtGui.QVBoxLayout(self.groupBox) self.verticalLayout_2.setObjectName("verticalLayout_2") self.portSpin = QtGui.QSpinBox(self.groupBox) self.portSpin.setMinimum(1000) self.portSpin.setMaximum(10000) self.portSpin.setProperty("value", 1234) self.portSpin.setObjectName("portSpin") self.verticalLayout_2.addWidget(self.portSpin) self.verticalLayout.addWidget(self.groupBox) self.selectAPIFileButton = QtGui.QPushButton(setupAPI) self.selectAPIFileButton.setObjectName("selectAPIFileButton") self.verticalLayout.addWidget(self.selectAPIFileButton) self.addAPIEntryButton = QtGui.QPushButton(setupAPI) self.addAPIEntryButton.setObjectName("addAPIEntryButton") self.verticalLayout.addWidget(self.addAPIEntryButton) self.retranslateUi(setupAPI) QtCore.QMetaObject.connectSlotsByName(setupAPI)
def init_context_box(self, layout): context_box_group = QtGui.QGroupBox("Context") context_box_group_layout = QtGui.QHBoxLayout() context_box_group_layout.setSpacing(0) for check in [NukeCheckBox, NodesCheckBox, ViewerCheckBox]: checkbox = check() checkbox.HIGHLIGHT_SIGNAL.connect(self.colour_keyboard) context_box_group_layout.addWidget(checkbox) context_box_group.setLayout(context_box_group_layout) layout.addWidget(context_box_group)
def init_keyboard_base(self, layout): keyboard_group = QtGui.QGroupBox("Keyboard") keyboard_group_layout = QtGui.QVBoxLayout() keyboard_group_layout.setSpacing(0) keyboard_group_layout.setContentsMargins(0, 0, 0, 0) keyboard_inst = Keyboard(self.key_map) keyboard_group_layout.addWidget(keyboard_inst) keyboard_group.setLayout(keyboard_group_layout) layout.addWidget(keyboard_group)
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) freecadSettings = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/PCB") # self.listaBibliotek = QtGui.QComboBox() libraryFrame = QtGui.QGroupBox(u'Library:') libraryFrameLay = QtGui.QHBoxLayout(libraryFrame) libraryFrameLay.addWidget(self.listaBibliotek) # self.listaElementow = updateObjectTable() przSelectAllT = QtGui.QPushButton('') przSelectAllT.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor)) przSelectAllT.setFlat(True) przSelectAllT.setIcon(QtGui.QIcon(":/data/img/checkbox_checked_16x16.png")) przSelectAllT.setToolTip('Select all') self.connect(przSelectAllT, QtCore.SIGNAL('pressed ()'), self.selectAllObj) przSelectAllTF = QtGui.QPushButton('') przSelectAllTF.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor)) przSelectAllTF.setFlat(True) przSelectAllTF.setIcon(QtGui.QIcon(":/data/img/checkbox_unchecked_16x16.PNG")) przSelectAllTF.setToolTip('Deselect all') self.connect(przSelectAllTF, QtCore.SIGNAL('pressed ()'), self.unselectAllObj) self.adjustParts = QtGui.QCheckBox(u'Adjust part name/value') self.adjustParts.setChecked(freecadSettings.GetBool("adjustNameValue", False)) self.groupParts = QtGui.QCheckBox(u'Group parts') self.groupParts.setChecked(freecadSettings.GetBool("groupParts", False)) self.plytkaPCB_elementyKolory = QtGui.QCheckBox(u"Colorize elements") self.plytkaPCB_elementyKolory.setChecked(freecadSettings.GetBool("partsColorize", True)) packagesFrame = QtGui.QGroupBox(u'Packages:') packagesFrameLay = QtGui.QGridLayout(packagesFrame) packagesFrameLay.addWidget(przSelectAllT, 0, 0, 1, 1) packagesFrameLay.addWidget(przSelectAllTF, 1, 0, 1, 1) packagesFrameLay.addWidget(self.listaElementow, 0, 1, 3, 1) # lay = QtGui.QVBoxLayout() lay.addWidget(libraryFrame) lay.addWidget(packagesFrame) lay.addWidget(self.adjustParts) lay.addWidget(self.groupParts) lay.addWidget(self.plytkaPCB_elementyKolory) lay.setStretch(1, 10) self.setLayout(lay) # self.readLibs()
def tabGeneral(self): self.patherror = QtGui.QLabel('') self.objecterror = QtGui.QLabel('') self.filePath = QtGui.QLineEdit('') self.connect(self.filePath, QtCore.SIGNAL("textChanged (const QString&)"), self.changePathFInfo) self.filePath.setText(os.path.join(os.path.expanduser("~"), 'Unnamed.inc')) self.filePath.setReadOnly(True) self.objectName = QtGui.QLineEdit('') changePath = QtGui.QPushButton('...') changePath.setFixedWidth(30) self.connect(changePath, QtCore.SIGNAL("clicked ()"), self.changePathF) generalBox = QtGui.QGroupBox(u'General') generalBoxLay = QtGui.QGridLayout(generalBox) generalBoxLay.addWidget(QtGui.QLabel(u'Path '), 0, 0, 1, 1) generalBoxLay.addWidget(self.filePath, 0, 1, 1, 2) generalBoxLay.addWidget(changePath, 0, 3, 1, 1) generalBoxLay.addWidget(self.patherror, 1, 0, 1, 4) generalBoxLay.addWidget(QtGui.QLabel(u'Object name '), 2, 0, 1, 1) generalBoxLay.addWidget(self.objectName, 2, 1, 1, 3) generalBoxLay.addWidget(self.objecterror, 3, 0, 1, 4) generalBoxLay.setColumnStretch(1, 10) # self.exportObjects_All = QtGui.QRadioButton(u'All visible objects') self.exportObjects_All.setChecked(True) self.exportObjects_Selected = QtGui.QRadioButton(u'All selected objects') self.exportObjects_SelectedFaces = QtGui.QRadioButton(u'All selected faces') self.exportObjects_SelectedFaces.setDisabled(True) exportObjectsBox = QtGui.QGroupBox(u'Export objects') exportObjectsBoxLay = QtGui.QVBoxLayout(exportObjectsBox) exportObjectsBoxLay.addWidget(self.exportObjects_All) exportObjectsBoxLay.addWidget(self.exportObjects_Selected) exportObjectsBoxLay.addWidget(self.exportObjects_SelectedFaces) ##### widget = QtGui.QWidget() lay = QtGui.QGridLayout(widget) lay.addWidget(generalBox, 0, 0, 1, 4) lay.addWidget(separator(), 1, 0, 1, 4) lay.addWidget(exportObjectsBox, 2, 0, 1, 4) lay.setRowStretch(10, 10) return widget
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) # self.listaBibliotek = QtGui.QComboBox() self.listaBibliotekInfo = QtGui.QLabel(' ') # self.positionX = QtGui.QDoubleSpinBox() self.positionX.setSingleStep(0.1) self.positionX.setRange(-1000, 1000) self.positionX.setSuffix(' mm') self.positionY = QtGui.QDoubleSpinBox() self.positionY.setSingleStep(0.1) self.positionY.setRange(-1000, 1000) self.positionY.setSuffix(' mm') self.positionZ = QtGui.QDoubleSpinBox() self.positionZ.setSingleStep(0.1) self.positionZ.setRange(-1000, 1000) self.positionZ.setSuffix(' mm') self.rotationRX = QtGui.QDoubleSpinBox() self.rotationRX.setSingleStep(0.1) self.rotationRX.setRange(-360, 360) self.rotationRX.setSuffix(' deg') self.rotationRY = QtGui.QDoubleSpinBox() self.rotationRY.setSingleStep(0.1) self.rotationRY.setRange(-360, 360) self.rotationRY.setSuffix(' deg') self.rotationRZ = QtGui.QDoubleSpinBox() self.rotationRZ.setSingleStep(0.1) self.rotationRZ.setRange(-360, 360) self.rotationRZ.setSuffix(' deg') # translationFrame = QtGui.QGroupBox(u'Translation:') translationFrameLay = QtGui.QFormLayout(translationFrame) translationFrameLay.addRow(QtGui.QLabel('X:'), self.positionX) translationFrameLay.addRow(QtGui.QLabel('Y:'), self.positionY) translationFrameLay.addRow(QtGui.QLabel('Z:'), self.positionZ) translationFrameLay.setContentsMargins(5, 5, 5, 5) # rotationFrame = QtGui.QGroupBox(u'Rotation:') rotationFrameLay = QtGui.QFormLayout(rotationFrame) rotationFrameLay.addRow(QtGui.QLabel('RX:'), self.rotationRX) rotationFrameLay.addRow(QtGui.QLabel('RY:'), self.rotationRY) rotationFrameLay.addRow(QtGui.QLabel('RZ:'), self.rotationRZ) rotationFrameLay.setContentsMargins(5, 5, 5, 5) # libraryFrame = QtGui.QGroupBox(u'Library:') libraryFrameLay = QtGui.QVBoxLayout(libraryFrame) libraryFrameLay.addWidget(self.listaBibliotek) libraryFrameLay.addWidget(self.listaBibliotekInfo) # self.resetButton = QtGui.QPushButton(u'Reset') self.resetButton.setMaximumWidth(60) # lay = QtGui.QGridLayout() lay.addWidget(libraryFrame, 0, 0, 1, 2) lay.addWidget(translationFrame, 1, 0, 1, 1) lay.addWidget(rotationFrame, 1, 1, 1, 1) lay.addItem(QtGui.QSpacerItem(1, 10), 2, 0, 1, 2) lay.addWidget(self.resetButton, 3, 1, 1, 1, QtCore.Qt.AlignRight) lay.setRowStretch(4, 5) self.setLayout(lay)
def __init__(self, recent_projects, directory_callback, parent=None): super(ExistingProjectDialog, self).__init__(parent) self.setWindowTitle('Open Project Folder') self.setWindowIcon(QtGui.QIcon(get_file('files/images/icon.png'))) self.setMinimumWidth(500) group_box = QtGui.QGroupBox('Existing Projects') gbox_layout = QtGui.QVBoxLayout() self.project_list = QtGui.QListWidget() gbox_layout.addWidget(self.project_list) group_box.setLayout(gbox_layout) self.callback = directory_callback self.projects = recent_projects for i in range(len(recent_projects)): project = recent_projects[i] text = u'{} - {}'.format(os.path.basename(project), project) self.project_list.addItem(text) self.project_list.itemClicked.connect(self.project_clicked) self.cancel = QtGui.QPushButton('Cancel') self.open = QtGui.QPushButton('Open Selected') self.browse = QtGui.QPushButton('Browse...') self.open.setEnabled(False) self.open.clicked.connect(self.open_clicked) self.browse.clicked.connect(self.browse_clicked) buttons = QtGui.QWidget() button_layout = QtGui.QHBoxLayout() button_layout.addWidget(self.cancel) button_layout.addWidget(QtGui.QWidget()) button_layout.addWidget(self.browse) button_layout.addWidget(self.open) buttons.setLayout(button_layout) layout = QtGui.QVBoxLayout() layout.addWidget(group_box) layout.addWidget(buttons) self.setLayout(layout) self.cancel.clicked.connect(self.cancelled)
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 __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 = {} #------------------------------
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 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)
def createMessageGroupBox(self): self.messageGroupBox = QtGui.QGroupBox("Balloon Message") typeLabel = QtGui.QLabel("Type:") self.typeComboBox = QtGui.QComboBox() self.typeComboBox.addItem("None", QtGui.QSystemTrayIcon.NoIcon) self.typeComboBox.addItem(self.style().standardIcon( QtGui.QStyle.SP_MessageBoxInformation), "Information", QtGui.QSystemTrayIcon.Information) self.typeComboBox.addItem(self.style().standardIcon( QtGui.QStyle.SP_MessageBoxWarning), "Warning", QtGui.QSystemTrayIcon.Warning) self.typeComboBox.addItem(self.style().standardIcon( QtGui.QStyle.SP_MessageBoxCritical), "Critical", QtGui.QSystemTrayIcon.Critical) self.typeComboBox.setCurrentIndex(1) self.durationLabel = QtGui.QLabel("Duration:") self.durationSpinBox = QtGui.QSpinBox() self.durationSpinBox.setRange(5, 60) self.durationSpinBox.setSuffix(" s") self.durationSpinBox.setValue(15) durationWarningLabel = QtGui.QLabel("(some systems might ignore this " "hint)") durationWarningLabel.setIndent(10) titleLabel = QtGui.QLabel("Title:") self.titleEdit = QtGui.QLineEdit("Cannot connect to network") bodyLabel = QtGui.QLabel("Body:") self.bodyEdit = QtGui.QTextEdit() self.bodyEdit.setPlainText("Don't believe me. Honestly, I don't have " "a clue.\nClick this balloon for details.") self.showMessageButton = QtGui.QPushButton("Show Message") self.showMessageButton.setDefault(True) messageLayout = QtGui.QGridLayout() messageLayout.addWidget(typeLabel, 0, 0) messageLayout.addWidget(self.typeComboBox, 0, 1, 1, 2) messageLayout.addWidget(self.durationLabel, 1, 0) messageLayout.addWidget(self.durationSpinBox, 1, 1) messageLayout.addWidget(durationWarningLabel, 1, 2, 1, 3) messageLayout.addWidget(titleLabel, 2, 0) messageLayout.addWidget(self.titleEdit, 2, 1, 1, 4) messageLayout.addWidget(bodyLabel, 3, 0) messageLayout.addWidget(self.bodyEdit, 3, 1, 2, 4) messageLayout.addWidget(self.showMessageButton, 5, 4) messageLayout.setColumnStretch(3, 1) messageLayout.setRowStretch(4, 1) self.messageGroupBox.setLayout(messageLayout)
def __init__(self, parent, model): super(KeypointAlignmentWidget, self).__init__() self.model = model self._parent = parent layout = QtGui.QFormLayout() self.setLayout(layout) keypoint_gb = QtGui.QGroupBox("Keypoint") layout.addWidget(keypoint_gb) edit_layout = QtGui.QFormLayout() keypoint_gb.setLayout(edit_layout) self.kpts_sel = QtGui.QComboBox() self.kpts_sel.setModel(self.model.combo_adapter) self.kpts_sel.currentIndexChanged.connect(self.kptChanged) edit_layout.addRow("Keypoint:", self.kpts_sel) self.wx = UnitLineEdit(UNIT_GROUP_MM) self.wy = UnitLineEdit(UNIT_GROUP_MM) edit_layout.addRow("World X", self.wx) edit_layout.addRow("World Y", self.wy) self.wx.edited.connect(self.update_world) self.wy.edited.connect(self.update_world) self.px = UnitLineEdit(UNIT_GROUP_PX) self.py = UnitLineEdit(UNIT_GROUP_PX) edit_layout.addRow("Image X", self.px) edit_layout.addRow("Image Y", self.py) self.px.edited.connect(self.update_layer) self.py.edited.connect(self.update_layer) self.use_for_alignment = QtGui.QCheckBox() edit_layout.addRow("Use", self.use_for_alignment) self.use_for_alignment.clicked.connect(self.update_used) self.add_btn = QtGui.QPushButton("Add New") self.add_btn.clicked.connect(self.addKeypoint) self.del_btn = QtGui.QPushButton("Remove Current") self.del_btn.clicked.connect(self.delKeypoint) bhl = QtGui.QHBoxLayout() bhl.addWidget(self.add_btn) bhl.addWidget(self.del_btn) edit_layout.addRow(bhl) self.constraint_status_lbl = QtGui.QLabel("") self.constraint_status_lbl.setWordWrap(True) layout.addRow(self.constraint_status_lbl) self.model.changed.connect(self.modelChanged) self.modelChanged()