我们从Python开源项目中,提取了以下31个代码示例,用于说明如何使用PySide.QtGui.QFormLayout()。
def __init__(self): super(SettingsDialog, self).__init__() vl = QtGui.QVBoxLayout() self.layout = QtGui.QFormLayout() self.setLayout(vl) vl.addLayout(self.layout) bb = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel) vl.addWidget(bb) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) self.__saved_pos = QtGui.QCursor.pos()
def initUI(self): self.layout = QtGui.QFormLayout() self.setLayout(self.layout) self.reloadParameter()
def quickLayout(self, type, ui_name=""): the_layout = '' if type in ("form", "QFormLayout"): the_layout = QtWidgets.QFormLayout() the_layout.setLabelAlignment(QtCore.Qt.AlignLeft) the_layout.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow) elif type in ("grid", "QGridLayout"): the_layout = QtWidgets.QGridLayout() elif type in ("hbox", "QHBoxLayout"): the_layout = QtWidgets.QHBoxLayout() the_layout.setAlignment(QtCore.Qt.AlignTop) else: the_layout = QtWidgets.QVBoxLayout() the_layout.setAlignment(QtCore.Qt.AlignTop) if ui_name != "": self.uiList[ui_name] = the_layout return the_layout
def quickLayout(self, type, ui_name=""): the_layout = '' if type in ("form", "QFormLayout"): the_layout = QtGui.QFormLayout() the_layout.setLabelAlignment(QtCore.Qt.AlignLeft) the_layout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow) elif type in ("grid", "QGridLayout"): the_layout = QtGui.QGridLayout() elif type in ("hbox", "QHBoxLayout"): the_layout = QtGui.QHBoxLayout() the_layout.setAlignment(QtCore.Qt.AlignTop) else: the_layout = QtGui.QVBoxLayout() the_layout.setAlignment(QtCore.Qt.AlignTop) if ui_name != "": self.uiList[ui_name] = the_layout return the_layout
def quickLayout(self, type, ui_name=""): the_layout = QtGui.QVBoxLayout() if type == "form": the_layout = QtGui.QFormLayout() the_layout.setLabelAlignment(QtCore.Qt.AlignLeft) the_layout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow) elif type == "grid": the_layout = QtGui.QGridLayout() elif type == "hbox": the_layout = QtGui.QHBoxLayout() the_layout.setAlignment(QtCore.Qt.AlignTop) else: the_layout = QtGui.QVBoxLayout() the_layout.setAlignment(QtCore.Qt.AlignTop) if ui_name != "": self.uiList[ui_name] = the_layout return the_layout
def __init__(self): super(AutoSettingsWidget, self).__init__() self.editables = [] self.layout = QtGui.QFormLayout() self.setLayout(self.layout)
def __init__(self, mdl, ctrl): super(ComponentSettings, self).__init__() self.mdl = mdl hfl = QtGui.QFormLayout() ct_cmb = QtGui.QComboBox() for _, i in sorted(mdl_meta.items(), key=lambda i: i[0]): ct_cmb.addItem(i.text) ct_cmb.setCurrentIndex(self.mdl.cmptype) ct_cmb.currentIndexChanged.connect(self.changeTab) hfl.addRow("Component Type", ct_cmb) self.w_x = UnitEditable(ctrl.flow, "center.x", UNIT_GROUP_MM) hfl.addRow("Position X:", self.w_x.widget) self.w_y = UnitEditable(ctrl.flow, "center.y", UNIT_GROUP_MM) hfl.addRow("Position Y:", self.w_y.widget) self.w_theta = DegreeEditable(ctrl.flow, "theta") hfl.addRow("Theta:", self.w_theta.widget) self.headerWidget.setLayout(hfl) for k, i in sorted(mdl_meta.items(), key=lambda i: i[0]): self.addAutoWidget(i.widget_cons(mdl.model_instances[k])) self.selectWidget(self.mdl.cmptype) self.ctrl = ctrl
def setupUi(self): """Bruh""" self.setGeometry(50, 50, 300, 150) self.setWindowTitle("ZeZe's TWTools - Input Speeds") self.setWindowIcon(QtGui.QIcon(resource_path("images/icon.png"))) """Background color""" self.backgroundPalette = QtGui.QPalette() self.backgroundColor = QtGui.QColor(217, 204, 170) self.backgroundPalette.setColor(QtGui.QPalette.Background, self.backgroundColor) self.setPalette(self.backgroundPalette) """Form layout""" self.formLayout = QtGui.QFormLayout(self) self.formLayout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow) """World speed label & input box""" self.world_speedLabel = QtGui.QLabel("World Speed:", self) self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.world_speedLabel) self.world_speedBox = QtGui.QDoubleSpinBox(self) self.world_speedBox.setDecimals(1) self.world_speedBox.setMaximum(1000.0) self.world_speedBox.setSingleStep(0.5) self.world_speedBox.setProperty("value", 1.0) self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.world_speedBox) """Unit speed label & input box""" self.unit_speedLabel = QtGui.QLabel("Unit Speed:", self) self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.unit_speedLabel) self.unit_speedBox = QtGui.QDoubleSpinBox(self) self.unit_speedBox.setDecimals(1) self.unit_speedBox.setMaximum(1000.0) self.unit_speedBox.setSingleStep(0.5) self.unit_speedBox.setProperty("value", 1.0) self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.unit_speedBox) """Spacer""" self.Spacer = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.formLayout.setItem(2, QtGui.QFormLayout.FieldRole, self.Spacer) """Ok button""" self.okButton = QtGui.QPushButton("Ok", self) self.formLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.okButton) self.okButton.clicked.connect(self.get_data)
def setupUi(self, MainDialog): MainDialog.setObjectName("MainDialog") MainDialog.resize(242, 128) self.verticalLayout_2 = QtGui.QVBoxLayout(MainDialog) self.verticalLayout_2.setObjectName("verticalLayout_2") self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") self.label = QtGui.QLabel(MainDialog) font = QtGui.QFont() font.setPointSize(20) self.label.setFont(font) self.label.setAlignment(QtCore.Qt.AlignCenter) self.label.setObjectName("label") self.verticalLayout.addWidget(self.label) self.formLayout = QtGui.QFormLayout() self.formLayout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow) self.formLayout.setObjectName("formLayout") self.label_2 = QtGui.QLabel(MainDialog) self.label_2.setObjectName("label_2") self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.label_2) self.labelLoLRunning = QtGui.QLabel(MainDialog) self.labelLoLRunning.setStyleSheet("color: rgb(255, 0, 0)") self.labelLoLRunning.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) self.labelLoLRunning.setObjectName("labelLoLRunning") self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.labelLoLRunning) self.label_3 = QtGui.QLabel(MainDialog) self.label_3.setObjectName("label_3") self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.label_3) self.labelVorpXRunning = QtGui.QLabel(MainDialog) self.labelVorpXRunning.setStyleSheet("color: rgb(255, 0, 0)") self.labelVorpXRunning.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) self.labelVorpXRunning.setObjectName("labelVorpXRunning") self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.labelVorpXRunning) self.verticalLayout.addLayout(self.formLayout) self.pushButtonStart = QtGui.QPushButton(MainDialog) self.pushButtonStart.setObjectName("pushButtonStart") self.verticalLayout.addWidget(self.pushButtonStart) spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) self.verticalLayout_2.addLayout(self.verticalLayout) self.retranslateUi(MainDialog) QtCore.QMetaObject.connectSlotsByName(MainDialog)
def setupUi(self, Form): """Setting up Log in UI Form """ Form.setObjectName("Form") Form.setFixedSize(400, 300) self.formLayoutWidget = QtGui.QWidget(Form) self.formLayoutWidget.setGeometry(QtCore.QRect(70, 110, 251, 71)) self.formLayoutWidget.setObjectName("formLayoutWidget") self.formLayout = QtGui.QFormLayout(self.formLayoutWidget) self.formLayout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow) self.formLayout.setContentsMargins(0, 0, 0, 0) self.formLayout.setObjectName("formLayout") self.Username = QtGui.QLabel(self.formLayoutWidget) self.Username.setObjectName("Username") self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.Username) self.Password = QtGui.QLabel(self.formLayoutWidget) self.Password.setObjectName("Password") self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.Password) self.iUsername = QtGui.QLineEdit(self.formLayoutWidget) self.iUsername.setObjectName("iUsername") self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.iUsername) self.iPassword = QtGui.QLineEdit(self.formLayoutWidget) self.iPassword.setObjectName("iPassword") self.formLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.iPassword) spacerItem = QtGui.QSpacerItem( 20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.formLayout.setItem(1, QtGui.QFormLayout.LabelRole, spacerItem) self.Login = QtGui.QPushButton(Form) self.Login.setGeometry(QtCore.QRect(210, 220, 75, 23)) self.Login.setObjectName("Login") self.Captslog = QtGui.QLabel(Form) self.Captslog.setGeometry(QtCore.QRect(90, 50, 221, 41)) font = QtGui.QFont() font.setPointSize(30) font.setWeight(75) font.setBold(True) self.Captslog.setFont(font) self.Captslog.setObjectName("Captslog") self.ErrorMessage = QtGui.QLabel(Form) self.ErrorMessage.setGeometry(QtCore.QRect(120, 190, 151, 20)) self.ErrorMessage.setText("") self.ErrorMessage.setAlignment(QtCore.Qt.AlignCenter) self.ErrorMessage.setObjectName("ErrorMessage") self.Signup = QtGui.QPushButton(Form) self.Signup.setGeometry(QtCore.QRect(100, 220, 75, 23)) self.Signup.setObjectName("Signup") self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form)
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 createWidgets(self): mainVLayout = QtGui.QVBoxLayout() fileFLayout = QtGui.QFormLayout() self.exportPath = QtGui.QLineEdit(self) self.exportPath.setText(config.tiltBrushExportDir) fileFLayout.addRow('Exported Files path: ', self.exportPath) self.outputPath = QtGui.QLineEdit(self) self.outputPath.setText(config.tiltBrushExportDir) fileFLayout.addRow('Output path: ', self.outputPath) mainVLayout.addLayout(fileFLayout) self.updateListButton = QtGui.QPushButton(self) self.updateListButton.setText("Update List") mainVLayout.addWidget(self.updateListButton) optionsHLayout = QtGui.QHBoxLayout() optionsFLayout1 = QtGui.QFormLayout() self.add_backface = QtGui.QCheckBox(self) optionsFLayout1.addRow("Add Backface: ", self.add_backface) self.weld_verts = QtGui.QCheckBox(self) optionsFLayout1.addRow("Weld Vertices: ", self.weld_verts) optionsFLayout2 = QtGui.QFormLayout() self.merge_stroke = QtGui.QCheckBox(self) optionsFLayout2.addRow("Merge Strokes: ", self.merge_stroke) self.merge_brush = QtGui.QCheckBox(self) self.merge_brush.setChecked(True) optionsFLayout2.addRow("Merge Brushes: ", self.merge_brush) optionsHLayout.addLayout(optionsFLayout1) optionsHLayout.addLayout(optionsFLayout2) mainVLayout.addLayout(optionsHLayout) listVLayout = QtGui.QVBoxLayout() listVLayout.addWidget(QtGui.QLabel('Exported Files:')) self.jsonFiles = QListWidget(parent=self) listVLayout.addWidget(self.jsonFiles) mainVLayout.addLayout(listVLayout) self.convertButton = QtGui.QPushButton(self) self.convertButton.setText('Convert') mainVLayout.addWidget(self.convertButton) self.setLayout(mainVLayout)
def createWidgets(self): mainVLayout = QtGui.QVBoxLayout() fileFLayout = QtGui.QFormLayout() self.exportPath = QtGui.QLineEdit(self) self.exportPath.setText(config.tiltBrushExportDir) fileFLayout.addRow('Exported Files path: ', self.exportPath) self.outputPath = QtGui.QLineEdit(self) self.outputPath.setText(config.tiltBrushExportDir) fileFLayout.addRow('Output path: ', self.outputPath) mainVLayout.addLayout(fileFLayout) self.updateListButton = QtGui.QPushButton(self) self.updateListButton.setText("Update List") mainVLayout.addWidget(self.updateListButton) optionsFLayout = QtGui.QFormLayout() self.cooked = QtGui.QCheckBox(self) self.cooked.setChecked(True) optionsFLayout.addRow("Cook meshes: ", self.cooked) mainVLayout.addLayout(optionsFLayout) listVLayout = QtGui.QVBoxLayout() listVLayout.addWidget(QtGui.QLabel('Exported Files:')) self.jsonFiles = QListWidget(parent=self) listVLayout.addWidget(self.jsonFiles) mainVLayout.addLayout(listVLayout) self.convertButton = QtGui.QPushButton(self) self.convertButton.setText('Convert') mainVLayout.addWidget(self.convertButton) self.setLayout(mainVLayout)
def setupUi(self, NewProjectDialog): NewProjectDialog.setObjectName("NewProjectDialog") NewProjectDialog.resize(514, 243) self.buttonBox = QtGui.QDialogButtonBox(NewProjectDialog) self.buttonBox.setGeometry(QtCore.QRect(50, 180, 341, 32)) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) self.buttonBox.setObjectName("buttonBox") self.formLayoutWidget = QtGui.QWidget(NewProjectDialog) self.formLayoutWidget.setGeometry(QtCore.QRect(9, 40, 481, 111)) self.formLayoutWidget.setObjectName("formLayoutWidget") self.formLayout = QtGui.QFormLayout(self.formLayoutWidget) self.formLayout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow) self.formLayout.setContentsMargins(0, 0, 0, 0) self.formLayout.setObjectName("formLayout") self.nameLabel = QtGui.QLabel(self.formLayoutWidget) self.nameLabel.setObjectName("nameLabel") self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.nameLabel) self.settingsFileLabel = QtGui.QLabel(self.formLayoutWidget) self.settingsFileLabel.setObjectName("settingsFileLabel") self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.settingsFileLabel) self.nameGridLayout = QtGui.QGridLayout() self.nameGridLayout.setObjectName("nameGridLayout") self.namePushButton = QtGui.QPushButton(self.formLayoutWidget) self.namePushButton.setObjectName("namePushButton") self.nameGridLayout.addWidget(self.namePushButton, 0, 1, 1, 1) self.nameLineEdit = QtGui.QLineEdit(self.formLayoutWidget) self.nameLineEdit.setObjectName("nameLineEdit") self.nameGridLayout.addWidget(self.nameLineEdit, 0, 0, 1, 1) self.formLayout.setLayout(0, QtGui.QFormLayout.FieldRole, self.nameGridLayout) self.settingsFileGridLayout = QtGui.QGridLayout() self.settingsFileGridLayout.setObjectName("settingsFileGridLayout") self.settingsFilePushButton = QtGui.QPushButton(self.formLayoutWidget) self.settingsFilePushButton.setObjectName("settingsFilePushButton") self.settingsFileGridLayout.addWidget(self.settingsFilePushButton, 0, 1, 1, 1) self.settingsFileLineEdit = QtGui.QLineEdit(self.formLayoutWidget) self.settingsFileLineEdit.setObjectName("settingsFileLineEdit") self.settingsFileGridLayout.addWidget(self.settingsFileLineEdit, 0, 0, 1, 1) self.formLayout.setLayout(1, QtGui.QFormLayout.FieldRole, self.settingsFileGridLayout) self.retranslateUi(NewProjectDialog) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), NewProjectDialog.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), NewProjectDialog.reject) QtCore.QMetaObject.connectSlotsByName(NewProjectDialog)
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 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 __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 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 __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()
def initUI(self): self.setWindowTitle("QueryTool") self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) self.setMouseTracking(True) #1st row self.labName = QtGui.QLabel("(seleziona un oggetto)", self) #2nd row self.labBaseVal = QtGui.QLabel("(base)", self) self.subFLayout1=QtGui.QFormLayout() self.subFLayout1.addRow('Base: ',self.labBaseVal) #3rd row self.labRotAng = QtGui.QLabel("(angle)", self) self.subFLayout2=QtGui.QFormLayout() self.subFLayout2.addRow('Rotation angle: ',self.labRotAng) # 4th row self.labRotAx = QtGui.QLabel("v = (x,y,z)", self) self.subFLayout3=QtGui.QFormLayout() self.subFLayout3.addRow('Rotation axis: ',self.labRotAx) # 5th row self.labSubObj = QtGui.QLabel("(Sub object property)", self) # 6th row self.labBeam = QtGui.QLabel("(Beam property)", self) # 7th row self.labProfile = QtGui.QLabel("(Profile property)", self) # 8th row self.pushButton1 = QtGui.QPushButton('QueryObject') self.pushButton1.setDefault(True) self.pushButton1.clicked.connect(self.onPushButton1) self.pushButton1.setMinimumWidth(90) self.cancelButton = QtGui.QPushButton('Exit') self.cancelButton.clicked.connect(self.onCancel) self.subHLayout1=QtGui.QHBoxLayout() self.subHLayout1.addWidget(self.pushButton1) self.subHLayout1.addWidget(self.cancelButton) # arrange the layout self.mainVLayout=QtGui.QVBoxLayout() self.mainVLayout.addWidget(self.labName) self.mainVLayout.addLayout(self.subFLayout1) self.mainVLayout.addLayout(self.subFLayout2) self.mainVLayout.addLayout(self.subFLayout3) self.mainVLayout.addWidget(self.labSubObj) self.mainVLayout.addWidget(self.labBeam) self.mainVLayout.addWidget(self.labProfile) self.mainVLayout.addLayout(self.subHLayout1) QtGui.QWidget.setLayout(self,self.mainVLayout) # now make the window visible self.show()