本文整理汇总了Python中PyQt4.QtGui.QSpinBox方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QSpinBox方法的具体用法?Python QtGui.QSpinBox怎么用?Python QtGui.QSpinBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui
的用法示例。
在下文中一共展示了QtGui.QSpinBox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setupUi
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QSpinBox [as 别名]
def setupUi(self, Form):
Form.setObjectName(_fromUtf8("Form"))
Form.resize(400, 300)
self.gridLayout = QtGui.QGridLayout(Form)
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.sizeSpin = QtGui.QSpinBox(Form)
self.sizeSpin.setProperty("value", 10)
self.sizeSpin.setObjectName(_fromUtf8("sizeSpin"))
self.gridLayout.addWidget(self.sizeSpin, 1, 1, 1, 1)
self.pixelModeCheck = QtGui.QCheckBox(Form)
self.pixelModeCheck.setObjectName(_fromUtf8("pixelModeCheck"))
self.gridLayout.addWidget(self.pixelModeCheck, 1, 3, 1, 1)
self.label = QtGui.QLabel(Form)
self.label.setObjectName(_fromUtf8("label"))
self.gridLayout.addWidget(self.label, 1, 0, 1, 1)
self.plot = PlotWidget(Form)
self.plot.setObjectName(_fromUtf8("plot"))
self.gridLayout.addWidget(self.plot, 0, 0, 1, 4)
self.randCheck = QtGui.QCheckBox(Form)
self.randCheck.setObjectName(_fromUtf8("randCheck"))
self.gridLayout.addWidget(self.randCheck, 1, 2, 1, 1)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
示例2: __init__
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QSpinBox [as 别名]
def __init__(self, dataitem, parent=None):
super(otherPanel, self).__init__(parent)
self.setFrameStyle(widgets.QFrame.Sunken)
self.setFrameShape(widgets.QFrame.Box)
self.data = dataitem
layout = widgets.QGridLayout()
labelnob = widgets.QLabel(_("Number of bytes"))
lableunit = widgets.QLabel(_("Unit"))
layout.addWidget(labelnob, 0, 0)
layout.addWidget(lableunit, 1, 0)
layout.setRowStretch(2, 1)
self.inputnob = widgets.QSpinBox()
self.inputnob.setRange(1, 10240)
self.inputtype = widgets.QComboBox()
self.inputtype.addItem("ASCII")
self.inputtype.addItem("BCD/HEX")
layout.addWidget(self.inputnob, 0, 1)
layout.addWidget(self.inputtype, 1, 1)
self.setLayout(layout)
self.init()
示例3: createDEToptGroup
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QSpinBox [as 别名]
def createDEToptGroup(self):
self.detgroupBox = QtGui.QGroupBox("& DET options")
self.enable_show_label_cb = QtGui.QCheckBox('enable show label name')
self.label_font_size_sl = QtGui.QSlider(QtCore.Qt.Horizontal)
self.label_font_size_sl.setRange(5,50)
self.label_font_size_sp = QtGui.QSpinBox()
self.label_font_size_sp.setRange(5,50)
QtCore.QObject.connect(self.label_font_size_sl, QtCore.SIGNAL("valueChanged(int)"),
self.label_font_size_sp, QtCore.SLOT("setValue(int)"))
self.label_font_size_sl.valueChanged.connect(self.change_label_font_size)
self.label_font_size_sl.setValue(self.__class__.label_font_size)
vbox = QtGui.QVBoxLayout()
vbox.addWidget(self.enable_show_label_cb)
vbox.addWidget(QtGui.QLabel('label font size'))
vbox.addWidget(self.label_font_size_sl)
vbox.addWidget(self.label_font_size_sp)
vbox.addStretch()
self.detgroupBox.setLayout(vbox)
return self.detgroupBox
示例4: createEditor
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QSpinBox [as 别名]
def createEditor(self, parent, option, index):
editor = QtGui.QSpinBox(parent)
editor.setMinimum(0)
editor.setMaximum(100)
return editor
示例5: add_item
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QSpinBox [as 别名]
def add_item(self):
value = -999
self.itemtable.setRowCount(self.itemtable.rowCount() + 1)
newrow = self.itemtable.rowCount() - 1
spinvalue = widgets.QSpinBox()
spinvalue.setRange(-1000000, 1000000)
spinvalue.setValue(value)
self.itemtable.setCellWidget(newrow, 0, spinvalue)
self.itemtable.setItem(newrow, 1, widgets.QTableWidgetItem(_("New item")))
self.itemtable.setItem(newrow, 0, widgets.QTableWidgetItem(str(value).zfill(5)))
self.itemtable.resizeRowsToContents()
self.itemtable.resizeColumnsToContents()
示例6: init
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QSpinBox [as 别名]
def init(self):
if not self.data:
return
self.itemtable.clear()
keys = self.data.items.keys()
self.itemtable.setRowCount(len(keys))
self.inputsigned.setChecked(self.data.signed)
self.inputnob.setValue(self.data.bitscount)
count = 0
for k, v in self.data.items.iteritems():
spinvalue = widgets.QSpinBox()
spinvalue.setRange(-1000000,1000000)
spinvalue.setValue(int(v))
self.itemtable.setCellWidget(count, 0, spinvalue)
self.itemtable.setItem(count, 0, widgets.QTableWidgetItem(str(v).zfill(5)))
self.itemtable.setItem(count, 1, widgets.QTableWidgetItem(k))
count += 1
headerstrings = str(_("Value;Text")).split(";")
self.itemtable.setHorizontalHeaderLabels(headerstrings)
self.itemtable.resizeColumnsToContents()
self.itemtable.resizeRowsToContents()
self.itemtable.sortItems(0, core.Qt.AscendingOrder)
#self.itemtable.setSortingEnabled(True)
示例7: _addTraceSelectorIndicator
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QSpinBox [as 别名]
def _addTraceSelectorIndicator(self,Form,sizePolicy,TraceSelector = "", TraceIndicator="", prefix = "Trace: "):
self.TraceSelIndLayout = QtGui.QVBoxLayout()
self.TraceSelIndLayout.setSizeConstraint(QtGui.QLayout.SetMinimumSize)
self.TraceSelIndLayout.setObjectName(_fromUtf8("TraceSelIndLayout"))
self.TraceSelIndLayout.setContentsMargins(0,0,0,0)
self.TraceSelIndLayout.setContentsMargins(QtCore.QMargins(0,0,0,0))
self.TraceSelIndLayout.setSpacing(1)
setattr(self,TraceSelector,QtGui.QSpinBox(Form))
temp_SelInd = getattr(self,TraceSelector)
temp_SelInd.setSizePolicy(sizePolicy)
temp_SelInd.setSuffix(_fromUtf8(""))
temp_SelInd.setMinimum(-99999)
temp_SelInd.setMaximum(99999)
temp_SelInd.setProperty("value", -1)
temp_SelInd.setObjectName(_fromUtf8(TraceSelector))
temp_SelInd.setPrefix(_translate("Form", prefix , None))
self.TraceSelIndLayout.addWidget(temp_SelInd)
setattr(self,TraceIndicator,QtGui.QLineEdit(Form))
temp_SelInd = getattr(self,TraceIndicator)
temp_SelInd.setSizePolicy(sizePolicy)
temp_SelInd.setReadOnly(False)
temp_SelInd.setObjectName(_fromUtf8("TraceValue"))
self.TraceSelIndLayout.addWidget(temp_SelInd)
self.horizontalLayout.addLayout(self.TraceSelIndLayout,stretch = -10)
示例8: save_settings
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QSpinBox [as 别名]
def save_settings(self, ini_name):
"""
Technique structured from the code from: "https://stackoverflow.com
/questions/23279125/python-pyqt4-functions-to-save-and-restore-ui-
widget-values"
:param ini_name: Name of the .ini file (Ex. pysecmaster.ini)
:return:
"""
settings = QtCore.QSettings(ini_name, QtCore.QSettings.IniFormat)
# For child in ui.children(): # works like getmembers, but because it
# traverses the hierarchy, you would have to call the method recursively
# to traverse down the tree.
for name, obj in inspect.getmembers(self):
if isinstance(obj, QtGui.QComboBox):
name = obj.objectName()
text = obj.currentText()
settings.setValue(name, text)
elif isinstance(obj, QtGui.QLineEdit):
name = obj.objectName()
value = obj.text()
settings.setValue(name, value)
elif isinstance(obj, QtGui.QSpinBox):
name = obj.objectName()
value = obj.value()
settings.setValue(name, value)
elif isinstance(obj, QtGui.QCheckBox):
name = obj.objectName()
state = obj.checkState()
settings.setValue(name, state)
示例9: initUI
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QSpinBox [as 别名]
def initUI(self):
# Rows
rowsLabel = QtGui.QLabel("Rows: ",self)
self.rows = QtGui.QSpinBox(self)
# Columns
colsLabel = QtGui.QLabel("Columns",self)
self.cols = QtGui.QSpinBox(self)
# Cell spacing (distance between cells)
spaceLabel = QtGui.QLabel("Cell spacing",self)
self.space = QtGui.QSpinBox(self)
# Cell padding (distance between cell and inner text)
padLabel = QtGui.QLabel("Cell padding",self)
self.pad = QtGui.QSpinBox(self)
self.pad.setValue(10)
# Button
insertButton = QtGui.QPushButton("Insert",self)
insertButton.clicked.connect(self.insert)
# Layout
layout = QtGui.QGridLayout()
layout.addWidget(rowsLabel,0,0)
layout.addWidget(self.rows,0,1)
layout.addWidget(colsLabel,1,0)
layout.addWidget(self.cols,1,1)
layout.addWidget(padLabel,2,0)
layout.addWidget(self.pad,2,1)
layout.addWidget(spaceLabel,3,0)
layout.addWidget(self.space,3,1)
layout.addWidget(insertButton,4,0,1,2)
self.setWindowTitle("Insert Table")
self.setGeometry(300,300,200,100)
self.setLayout(layout)
示例10: __init__
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QSpinBox [as 别名]
def __init__(self, fig, plot_fun, *args, **kwargs):
if 'bins' not in kwargs: kwargs.update(bins=np.r_[:10:0.02])
if 't_max' not in kwargs: kwargs.update(t_max=-1)
# Save some variables
self.fig = fig
self.AX = kwargs['AX']
self.plot_fun = plot_fun
self.f_args = args
self.f_kwargs = kwargs
self.time_max = args[0].time_max()
# Some handy shortcut
self.draw = self.fig.canvas.draw
# Create the spinboxes for setting the range
mlabel = QtGui.QLabel()
mlabel.setText("m:")
self.m_spinbox = QtGui.QSpinBox()
self.m_spinbox.setRange(2,500)
self.m_spinbox.setKeyboardTracking(False)
self.m_spinbox.setValue(self.f_kwargs['m'])
self.m_spinbox.valueChanged.connect(self.par_changed)
blabel = QtGui.QLabel()
blabel.setText("bin:")
self.bin_spinbox = QtGui.QDoubleSpinBox()
self.bin_spinbox.setRange(1e-6,1e6)
self.bin_spinbox.setDecimals(3)
self.bin_spinbox.setKeyboardTracking(False)
bins = self.f_kwargs['bins']
self.bin_spinbox.setValue(bins[1]-bins[0])
self.bin_spinbox.valueChanged.connect(self.par_changed)
tlabel = QtGui.QLabel()
tlabel.setText("t max (s):")
self.tmax_spinbox = QtGui.QDoubleSpinBox()
self.tmax_spinbox.setRange(0,3600)
self.tmax_spinbox.setKeyboardTracking(False)
if kwargs['t_max'] <= 0 or kwargs['t_max'] > self.time_max:
kwargs['t_max'] = self.time_max
self.tmax_spinbox.setValue(kwargs['t_max'])
self.tmax_spinbox.valueChanged.connect(self.par_changed)
addWidget = fig.canvas.toolbar.addWidget
addWidget(mlabel); addWidget(self.m_spinbox)
addWidget(blabel); addWidget(self.bin_spinbox)
addWidget(tlabel); addWidget(self.tmax_spinbox)
self.draw()
self.save_params()
示例11: createMessageGroupBox
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QSpinBox [as 别名]
def createMessageGroupBox(self): # Add the message test GUI window grouping.
self.messageGroupBox = QtGui.QGroupBox("Balloon Message Test:")
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(2, 15)
self.durationSpinBox.setSuffix("s")
self.durationSpinBox.setValue(5)
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.")
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)
示例12: setupUi
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QSpinBox [as 别名]
def setupUi(self, InfoDialog):
InfoDialog.setObjectName(_fromUtf8("InfoDialog"))
InfoDialog.resize(281, 225)
self.verticalLayout = QtGui.QVBoxLayout(InfoDialog)
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
self.formLayout = QtGui.QFormLayout()
self.formLayout.setObjectName(_fromUtf8("formLayout"))
self.label = QtGui.QLabel(InfoDialog)
self.label.setObjectName(_fromUtf8("label"))
self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.label)
self.firstName = QtGui.QLineEdit(InfoDialog)
self.firstName.setObjectName(_fromUtf8("firstName"))
self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.firstName)
self.label_2 = QtGui.QLabel(InfoDialog)
self.label_2.setObjectName(_fromUtf8("label_2"))
self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.label_2)
self.lastName = QtGui.QLineEdit(InfoDialog)
self.lastName.setObjectName(_fromUtf8("lastName"))
self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.lastName)
self.label_3 = QtGui.QLabel(InfoDialog)
self.label_3.setObjectName(_fromUtf8("label_3"))
self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.label_3)
self.email = QtGui.QLineEdit(InfoDialog)
self.email.setObjectName(_fromUtf8("email"))
self.formLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.email)
self.label_4 = QtGui.QLabel(InfoDialog)
self.label_4.setObjectName(_fromUtf8("label_4"))
self.formLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.label_4)
self.age = QtGui.QSpinBox(InfoDialog)
self.age.setMinimum(1)
self.age.setObjectName(_fromUtf8("age"))
self.formLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.age)
self.verticalLayout.addLayout(self.formLayout)
self.buttonBox = QtGui.QDialogButtonBox(InfoDialog)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
self.verticalLayout.addWidget(self.buttonBox)
self.retranslateUi(InfoDialog)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), InfoDialog.accept)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), InfoDialog.reject)
QtCore.QMetaObject.connectSlotsByName(InfoDialog)
示例13: setupUi
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QSpinBox [as 别名]
def setupUi(self, DoubleProperty):
DoubleProperty.setObjectName(_fromUtf8("DoubleProperty"))
DoubleProperty.resize(258, 166)
self.gridLayout = QtGui.QGridLayout(DoubleProperty)
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.label_3 = QtGui.QLabel(DoubleProperty)
self.label_3.setObjectName(_fromUtf8("label_3"))
self.gridLayout.addWidget(self.label_3, 0, 0, 1, 1)
self.sbPrecision = QtGui.QSpinBox(DoubleProperty)
self.sbPrecision.setMinimum(1)
self.sbPrecision.setMaximum(50)
self.sbPrecision.setProperty("value", 1)
self.sbPrecision.setObjectName(_fromUtf8("sbPrecision"))
self.gridLayout.addWidget(self.sbPrecision, 0, 1, 1, 1)
self.label_4 = QtGui.QLabel(DoubleProperty)
self.label_4.setObjectName(_fromUtf8("label_4"))
self.gridLayout.addWidget(self.label_4, 1, 0, 1, 1)
self.sbScale = QtGui.QSpinBox(DoubleProperty)
self.sbScale.setMaximum(20)
self.sbScale.setObjectName(_fromUtf8("sbScale"))
self.gridLayout.addWidget(self.sbScale, 1, 1, 1, 1)
self.label = QtGui.QLabel(DoubleProperty)
self.label.setObjectName(_fromUtf8("label"))
self.gridLayout.addWidget(self.label, 2, 0, 1, 1)
self.edtMinVal = QtGui.QLineEdit(DoubleProperty)
self.edtMinVal.setObjectName(_fromUtf8("edtMinVal"))
self.gridLayout.addWidget(self.edtMinVal, 2, 1, 1, 1)
self.label_2 = QtGui.QLabel(DoubleProperty)
self.label_2.setObjectName(_fromUtf8("label_2"))
self.gridLayout.addWidget(self.label_2, 3, 0, 1, 1)
self.edtMaxVal = QtGui.QLineEdit(DoubleProperty)
self.edtMaxVal.setObjectName(_fromUtf8("edtMaxVal"))
self.gridLayout.addWidget(self.edtMaxVal, 3, 1, 1, 1)
self.buttonBox = QtGui.QDialogButtonBox(DoubleProperty)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
self.gridLayout.addWidget(self.buttonBox, 4, 0, 1, 2)
self.retranslateUi(DoubleProperty)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), DoubleProperty.accept)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), DoubleProperty.reject)
QtCore.QMetaObject.connectSlotsByName(DoubleProperty)
示例14: __init__
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QSpinBox [as 别名]
def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent)
self.resize(320, 100)
self.setWindowTitle('set remote db')
self.remote_cb = QtGui.QCheckBox("use remote database")
if self.__class__.remote_mode:
self.remote_cb.toggle()
self.remote_cb.stateChanged.connect(self.set_remote_mode)
grid = QtGui.QGridLayout()
grid.addWidget(self.remote_cb, 0, 0, 1, 1)
grid.addWidget(
QtGui.QLabel(
u'dowload image thread num',
parent=self),
1,
0,
1,
1)
self.thread_num = QtGui.QSpinBox()
self.thread_num.setRange(1, 10)
self.thread_num.setValue(self.__class__.dowload_thead_num)
self.thread_num.valueChanged.connect(self.set_thread_num)
grid.addWidget(self.thread_num, 1, 1, 1, 1)
grid.addWidget(
QtGui.QLabel(
u'remote db url[123.57.438.245/]',
parent=self),
2,
0,
1,
1)
self.remote_url_line = QtGui.QLineEdit(parent=self)
if self.__class__.remote_url:
self.remote_url_line.setText(self.__class__.remote_url)
grid.addWidget(self.remote_url_line, 2, 1, 1, 1)
grid.addWidget(
QtGui.QLabel(
u'remote image list',
parent=self),
3,
0,
1,
1)
self.server_image_list = QtGui.QLineEdit(parent=self)
if self.__class__.server_image_list:
self.server_image_list.setText(self.__class__.server_image_list)
grid.addWidget(self.server_image_list, 3, 1, 1, 1)
buttonBox = QtGui.QDialogButtonBox(parent=self)
buttonBox.setOrientation(QtCore.Qt.Horizontal)
buttonBox.setStandardButtons(
QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Ok)
buttonBox.accepted.connect(self.accept)
buttonBox.rejected.connect(self.reject)
layout = QtGui.QVBoxLayout()
layout.addLayout(grid)
spacerItem = QtGui.QSpacerItem(
20, 48, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
layout.addItem(spacerItem)
layout.addWidget(buttonBox)
self.setLayout(layout)
示例15: restore_settings
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QSpinBox [as 别名]
def restore_settings(self, ini_name):
"""
Technique structured from the code from: "https://stackoverflow.com
/questions/23279125/python-pyqt4-functions-to-save-and-restore-ui-
widget-values"
:param ini_name: Name/path of the .ini file (Ex. pySecMaster_gui.ini)
"""
settings = QtCore.QSettings(ini_name, QtCore.QSettings.IniFormat)
for name, obj in inspect.getmembers(self):
if isinstance(obj, QtGui.QComboBox):
name = obj.objectName()
value = str(settings.value(name)) # .toString())
if value == "":
continue
# Get the corresponding index for specified string in combobox
index = obj.findText(value)
# Check if the value exists, otherwise add it to the combobox
if index == -1:
obj.insertItems(0, [value])
index = obj.findText(value)
obj.setCurrentIndex(index)
else:
obj.setCurrentIndex(index)
elif isinstance(obj, QtGui.QLineEdit):
name = obj.objectName()
value = str(settings.value(name))
obj.setText(value)
elif isinstance(obj, QtGui.QSpinBox):
name = obj.objectName()
value = int(settings.value(name))
obj.setValue(value)
elif isinstance(obj, QtGui.QCheckBox):
name = obj.objectName()
value = settings.value(name)
if value:
obj.setChecked(value) # setCheckState enables tristate