本文整理汇总了Python中PySide.QtUiTools.QUiLoader.createWidget方法的典型用法代码示例。如果您正苦于以下问题:Python QUiLoader.createWidget方法的具体用法?Python QUiLoader.createWidget怎么用?Python QUiLoader.createWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtUiTools.QUiLoader
的用法示例。
在下文中一共展示了QUiLoader.createWidget方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createWidget
# 需要导入模块: from PySide.QtUiTools import QUiLoader [as 别名]
# 或者: from PySide.QtUiTools.QUiLoader import createWidget [as 别名]
def createWidget(self, className, parent=None, name=""):
widget = QUiLoader.createWidget(self, className, parent, name)
if parent is None:
return self.baseinstance
else:
setattr(self.baseinstance, name, widget)
return widget
示例2: createWidget
# 需要导入模块: from PySide.QtUiTools import QUiLoader [as 别名]
# 或者: from PySide.QtUiTools.QUiLoader import createWidget [as 别名]
def createWidget(self, class_name, parent=None, name=''):
if parent is None and self.baseinstance:
return self.baseinstance
else:
# create a new widget for child widgets
widget = QUiLoader.createWidget(self, class_name, parent, name)
if self.baseinstance:
# set an attribute for the new child widget on the base
# instance, just like PyQt4.uic.loadUi does.
setattr(self.baseinstance, name, widget)
return widget
示例3: createWidget
# 需要导入模块: from PySide.QtUiTools import QUiLoader [as 别名]
# 或者: from PySide.QtUiTools.QUiLoader import createWidget [as 别名]
def createWidget(self, class_name, parent=None, name=''):
# Case where target should be used as widget.
if parent is None and self._target:
return self._target
# Otherwise create a new widget
else:
# create a new widget for child widgets
widget = QUiLoader.createWidget(self, class_name, parent, name)
# Adds attribute for the new child widget on the target to mimic PyQt4.uic.loadUi.
if self._target:
setattr(self._target, name, widget)
return widget
示例4: createWidget
# 需要导入模块: from PySide.QtUiTools import QUiLoader [as 别名]
# 或者: from PySide.QtUiTools.QUiLoader import createWidget [as 别名]
def createWidget(self, class_name, parent=None, name=''):
# don't create the top-level widget, if a base instance is set
if self._base_instance is not None and parent is None:
return self._base_instance
if class_name in self._custom_widgets:
widget = self._custom_widgets[class_name](parent)
else:
widget = QUiLoader.createWidget(self, class_name, parent, name)
if str(type(widget)).find(self.class_aliases.get(class_name, class_name)) < 0:
sys.modules['QtCore'].qDebug(str('PySide.loadUi(): could not find widget class "%s", defaulting to "%s"' % (class_name, type(widget))))
if self._base_instance is not None:
setattr(self._base_instance, name, widget)
return widget
示例5: createWidget
# 需要导入模块: from PySide.QtUiTools import QUiLoader [as 别名]
# 或者: from PySide.QtUiTools.QUiLoader import createWidget [as 别名]
def createWidget(self, class_name, parent=None, name=''):
if parent is None and self.baseinstance:
# supposed to create the top-level widget, return the base instance
# instead
return self.baseinstance
else:
# create a new widget for child widgets
widget = None
if hasattr(self.baseinstance, "customWidgets"):
if class_name in [classObj.__name__ for classObj in self.baseinstance.customWidgets]:
widgetClass = [classObj for classObj in self.baseinstance.customWidgets if classObj.__name__ == class_name][0]
widget = widgetClass(parent)
if widget is None:
widget = QUiLoader.createWidget(self, class_name, parent, name)
if self.baseinstance:
# set an attribute for the new child widget on the base
# instance, just like PyQt4.uic.loadUi does.
setattr(self.baseinstance, name, widget)
return widget
示例6: createWidget
# 需要导入模块: from PySide.QtUiTools import QUiLoader [as 别名]
# 或者: from PySide.QtUiTools.QUiLoader import createWidget [as 别名]
def createWidget(self, class_name, parent=None, name=''):
"""
Function that is called for each widget defined in ui file,
overridden here to populate baseinstance instead.
"""
if parent is None and self.baseinstance:
# supposed to create the top-level widget, return the base instance
# instead
return self.baseinstance
else:
if class_name in self.availableWidgets():
# create a new widget for child widgets
widget = QUiLoader.createWidget(self, class_name, parent, name)
else:
# if not in the list of availableWidgets,
# must be a custom widget
# this will raise KeyError if the user has not supplied the
# relevant class_name in the dictionary, or TypeError, if
# customWidgets is None
if class_name not in self.customWidgets:
raise Exception('No custom widget ' + class_name +
' found in customWidgets param of' +
'UiFile %s.' % self.uifile)
try:
widget = self.customWidgets[class_name](parent)
except Exception:
_logger.error("Fail to instanciate widget %s from file %s", class_name, self.uifile)
raise
if self.baseinstance:
# set an attribute for the new child widget on the base
# instance, just like PyQt*.uic.loadUi does.
setattr(self.baseinstance, name, widget)
# this outputs the various widget names, e.g.
# sampleGraphicsView, dockWidget, samplesTableView etc.
# print(name)
return widget
示例7: createWidget
# 需要导入模块: from PySide.QtUiTools import QUiLoader [as 别名]
# 或者: from PySide.QtUiTools.QUiLoader import createWidget [as 别名]
def createWidget(self, class_name, parent=None, name=''):
"""
Function that is called for each widget defined in ui file,
overridden here to populate baseinstance instead.
"""
if parent is None and self.baseinstance:
return self.baseinstance
else:
if class_name in self.availableWidgets():
# create a new widget for child widgets
widget = QUiLoader.createWidget(self, class_name, parent, name)
else:
try:
widget = self.customWidgets[class_name](parent)
except (TypeError, KeyError) as e:
raise Exception('No custom widget ' + class_name + ' found in customWidgets param of UiLoader __init__.')
if self.baseinstance:
setattr(self.baseinstance, name, widget)
return widget
示例8: createWidget
# 需要导入模块: from PySide.QtUiTools import QUiLoader [as 别名]
# 或者: from PySide.QtUiTools.QUiLoader import createWidget [as 别名]
def createWidget(self, class_name, parent=None, name=''):
if class_name not in self.availableWidgets():
if class_name in self._customWidgetNames():
widgetCls = [cls for cls in self.customWidgets if cls.__name__ == class_name][0]
widget = widgetCls(parent=parent)
if self.baseinstance:
# set an attribute for the new child widget on the base
# instance, just like PyQt4.uic.loadUi does.
setattr(self.baseinstance, name, widget)
return widget
if parent is None and self.baseinstance:
# supposed to create the top-level widget, return the base instance
# instead
return self.baseinstance
else:
# create a new widget for child widgets
widget = QUiLoader.createWidget(self, class_name, parent, name)
if self.baseinstance:
# set an attribute for the new child widget on the base
# instance, just like PyQt4.uic.loadUi does.
setattr(self.baseinstance, name, widget)
return widget
示例9: createWidget
# 需要导入模块: from PySide.QtUiTools import QUiLoader [as 别名]
# 或者: from PySide.QtUiTools.QUiLoader import createWidget [as 别名]
def createWidget(self, class_name, parent=None, name=''):
"""
Function that is called for each widget defined in ui file,
overridden here to populate baseinstance instead.
"""
if parent is None and self.baseinstance:
# supposed to create the top-level widget, return the base
# instance instead
return self.baseinstance
else:
# For some reason, Line is not in the list of available
# widgets, but works fine, so we have to special case it here.
if class_name in self.availableWidgets() or class_name == 'Line':
# create a new widget for child widgets
widget = QUiLoader.createWidget(self, class_name, parent, name)
else:
# If not in the list of availableWidgets, must be a custom
# widget. This will raise KeyError if the user has not
# supplied the relevant class_name in the dictionary or if
# customWidgets is empty.
try:
widget = self.customWidgets[class_name](parent)
except KeyError:
raise Exception('No custom widget ' + class_name + ' '
'found in customWidgets')
if self.baseinstance:
# set an attribute for the new child widget on the base
# instance, just like PyQt4.uic.loadUi does.
setattr(self.baseinstance, name, widget)
return widget
示例10: createWidget
# 需要导入模块: from PySide.QtUiTools import QUiLoader [as 别名]
# 或者: from PySide.QtUiTools.QUiLoader import createWidget [as 别名]
def createWidget(self, clsname, parent=None, name=""):
if clsname in self._custom_widgets:
widget = self._custom_widgets[clsname](parent)
else:
widget = qloader.createWidget(self, clsname, parent, name)
return widget