本文整理汇总了Python中pyqtgraph.parametertree.ParameterTree.adjustSize方法的典型用法代码示例。如果您正苦于以下问题:Python ParameterTree.adjustSize方法的具体用法?Python ParameterTree.adjustSize怎么用?Python ParameterTree.adjustSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtgraph.parametertree.ParameterTree
的用法示例。
在下文中一共展示了ParameterTree.adjustSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ProjectSettingsDialog
# 需要导入模块: from pyqtgraph.parametertree import ParameterTree [as 别名]
# 或者: from pyqtgraph.parametertree.ParameterTree import adjustSize [as 别名]
class ProjectSettingsDialog(QtGui.QDialog):
path2key=dict()
def __init__(self, parent = None, savedstate=None):
super(ProjectSettingsDialog, self).__init__(parent)
self.setWindowTitle("Application Settings")
layout = QtGui.QVBoxLayout(self)
self.initKeyParamMapping()
self._settings = Parameter.create(name='params', type='group', children=settings_params)
if savedstate:
self._settings.restoreState(savedstate)
# Holds settings keys that have changed by the user when the
# dialog is closed. Used to update any needed gui values..
self._updated_settings={}
self._settings.sigTreeStateChanged.connect(self.handleSettingChange)
self.initSettingsValues()
self.ptree = ParameterTree()
self.ptree.setParameters(self._settings, showTop=False)
self.ptree.setWindowTitle('MarkWrite Application Settings')
layout.addWidget(self.ptree)
self.ptree.adjustSize()
# OK and Cancel buttons
self.buttons = QtGui.QDialogButtonBox(
QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel,
QtCore.Qt.Horizontal, self)
layout.addWidget(self.buttons)
self.buttons.accepted.connect(self.accept)
self.buttons.rejected.connect(self.reject)
self.resize(500,700)
def initKeyParamMapping(self):
if len(self.path2key)==0:
def replaceGroupKeys(paramlist, parent_path=[]):
for i,p in enumerate(paramlist):
if isinstance(p,basestring):
pdict=flattenned_settings_dict[p]
paramlist[i]=pdict
self.path2key['.'.join(parent_path+[pdict['name'],])]=p
elif isinstance(p,dict):
replaceGroupKeys(p.get('children'),parent_path+[p.get('name'),])
replaceGroupKeys(settings_params)
def initSettingsValues(self, pgroup=None):
global SETTINGS
if pgroup is None:
pgroup = self._settings
for child in pgroup.children():
if child.hasChildren():
self.initSettingsValues(child)
else:
path = self._settings.childPath(child)
if path is not None:
childName = '.'.join(path)
else:
childName = child.name()
if self.path2key.has_key(childName):
SETTINGS[self.path2key[childName]]=child.value()
## If anything changes in the tree, print a message
def handleSettingChange(self, param, changes):
global SETTINGS
for param, change, data in changes:
path = self._settings.childPath(param)
if path is not None:
childName = '.'.join(path)
else:
childName = param.name()
if change == 'value':
setting_key = self.path2key[childName]
SETTINGS[setting_key]=data
self._updated_settings[setting_key] = data
#print 'settings_state:',self.settings_state
# static method to create the dialog and return (date, time, accepted)
@staticmethod
def getProjectSettings(parent = None, usersettings = None):
dialog = ProjectSettingsDialog(parent, usersettings)
result = dialog.exec_()
usersettings=dialog._settings.saveState()
return dialog._updated_settings,SETTINGS, usersettings, result == QtGui.QDialog.Accepted