summaryrefslogtreecommitdiff
path: root/lib/taurus/qt/qtdesigner
diff options
context:
space:
mode:
authorcoutinho <coutinho@esrf.fr>2015-03-26 12:21:41 +0100
committercoutinho <coutinho@esrf.fr>2015-03-26 12:21:41 +0100
commit6f2a9f4d65212ef253a5ce6fc173d52b8a470c57 (patch)
tree674c3ba22a326794b20abf345ec5e01c102a1b11 /lib/taurus/qt/qtdesigner
parent3d39d0a483286c6cc6abc58d5514dc5390104736 (diff)
First commit in tauruslib. Restructure according to SEP10
Diffstat (limited to 'lib/taurus/qt/qtdesigner')
-rw-r--r--lib/taurus/qt/qtdesigner/__init__.py29
-rw-r--r--lib/taurus/qt/qtdesigner/containerplugin.py124
-rw-r--r--lib/taurus/qt/qtdesigner/extraguiqwtplugin.py39
-rw-r--r--lib/taurus/qt/qtdesigner/taurusdesigner.py143
-rw-r--r--lib/taurus/qt/qtdesigner/taurusplugin/__init__.py31
-rw-r--r--lib/taurus/qt/qtdesigner/taurusplugin/taurusplugin.py168
-rw-r--r--lib/taurus/qt/qtdesigner/tauruspluginplugin.py123
7 files changed, 657 insertions, 0 deletions
diff --git a/lib/taurus/qt/qtdesigner/__init__.py b/lib/taurus/qt/qtdesigner/__init__.py
new file mode 100644
index 00000000..fff65191
--- /dev/null
+++ b/lib/taurus/qt/qtdesigner/__init__.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## This file is part of Taurus
+##
+## http://taurus-scada.org
+##
+## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
+##
+## Taurus is free software: you can redistribute it and/or modify
+## it under the terms of the GNU Lesser General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## Taurus is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public License
+## along with Taurus. If not, see <http://www.gnu.org/licenses/>.
+##
+#############################################################################
+
+"""The taurus.qt.qtdesigner submodule. It contains qt-specific part of taurus"""
+
+__docformat__ = 'restructuredtext'
+
diff --git a/lib/taurus/qt/qtdesigner/containerplugin.py b/lib/taurus/qt/qtdesigner/containerplugin.py
new file mode 100644
index 00000000..2b75647e
--- /dev/null
+++ b/lib/taurus/qt/qtdesigner/containerplugin.py
@@ -0,0 +1,124 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## This file is part of Taurus
+##
+## http://taurus-scada.org
+##
+## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
+##
+## Taurus is free software: you can redistribute it and/or modify
+## it under the terms of the GNU Lesser General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## Taurus is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public License
+## along with Taurus. If not, see <http://www.gnu.org/licenses/>.
+##
+#############################################################################
+
+""" Every TaurusWidget should have the following Qt Designer extended capabilities:
+
+ - Task menu:
+ it means when you right click on the widget in the designer, it will have
+ the following additional items:
+ - 'Edit model...' - opens a customized dialog for editing the widget model
+
+ - Property Sheet:
+ it means that in the Qt Designer property sheet it will have the following
+ properties customized:
+ - 'model' - will have a '...' button that will open a customized dialog for
+ editing the widget model (same has 'Edit model...' task menu item
+"""
+
+from taurus.core.util.log import Logger
+from taurus.external.qt import Qt
+from taurus.external.qt import QtDesigner
+
+from taurus.qt.qtgui.container.qcontainer import QGroupWidget
+
+#import sip
+
+Q_TYPEID = {'QPyDesignerContainerExtension': 'com.trolltech.Qt.Designer.Container',
+ 'QPyDesignerPropertySheetExtension': 'com.trolltech.Qt.Designer.PropertySheet',
+ 'QPyDesignerTaskMenuExtension': 'com.trolltech.Qt.Designer.TaskMenu',
+ 'QPyDesignerMemberSheetExtension': 'com.trolltech.Qt.Designer.MemberSheet'}
+
+
+class QGroupWidgetContainerExtension(QtDesigner.QPyDesignerContainerExtension):
+ def __init__(self, widget, parent=None):
+ super(QGroupWidgetContainerExtension, self).__init__(parent)
+ self._widget = widget
+ self._page_widget = None
+
+ def addWidget(self, widget):
+ if self.count() > 0:
+ raise Exception("Can only have at maximum one child")
+ self._layout().addWidget(widget)
+ self._page_widget = widget
+
+ def _content(self):
+ return self._widget.content()
+
+ def _layout(self):
+ return self._content().layout()
+
+ def count(self):
+ return self._layout().count()
+
+ def currentIndex(self):
+ if self.count() > 0:
+ return 0
+ return -1
+
+ def insertWidget(self, index, widget):
+ self.addWidget(widget)
+
+ def remove(self, index):
+ self._layout().removeWidget(self.widget(index))
+
+ def setCurrentIndex(self, index):
+ pass
+
+ def widget(self, index):
+ return self._page_widget
+
+
+class QGroupWidgetExtensionFactory(QtDesigner.QExtensionFactory):
+ def __init__(self, parent=None):
+ super(QGroupWidgetExtensionFactory, self).__init__(parent)
+
+ def createExtension(self, obj, iid, parent):
+ if iid != Q_TYPEID['QPyDesignerContainerExtension']:
+ return None
+ if isinstance(obj, QGroupWidget):
+ return QGroupWidgetContainerExtension(obj, parent)
+ return None
+
+def create_plugin():
+ from taurusplugin.taurusplugin import TaurusWidgetPlugin
+
+ class QGroupWidgetPlugin(TaurusWidgetPlugin):
+
+ WidgetClass = QGroupWidget
+
+ def initialize(self, formEditor):
+ if self.isInitialized():
+ return
+
+ manager = formEditor.extensionManager()
+ if manager:
+ self.factory = QGroupWidgetExtensionFactory(manager)
+ manager.registerExtensions(self.factory, Q_TYPEID['QPyDesignerContainerExtension'])
+ self.initialized = True
+ return QGroupWidgetPlugin
+
+QGroupWidgetPlugin = create_plugin()
+
+ \ No newline at end of file
diff --git a/lib/taurus/qt/qtdesigner/extraguiqwtplugin.py b/lib/taurus/qt/qtdesigner/extraguiqwtplugin.py
new file mode 100644
index 00000000..e32da5d6
--- /dev/null
+++ b/lib/taurus/qt/qtdesigner/extraguiqwtplugin.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## This file is part of Taurus
+##
+## http://taurus-scada.org
+##
+## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
+##
+## Taurus is free software: you can redistribute it and/or modify
+## it under the terms of the GNU Lesser General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## Taurus is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public License
+## along with Taurus. If not, see <http://www.gnu.org/licenses/>.
+##
+#############################################################################
+
+"""
+guiqwt widgets plugins for Qt Designer
+"""
+
+try:
+ from guiqwt.qtdesigner import create_qtdesigner_plugin
+ PlotPlugin = create_qtdesigner_plugin("guiqwt", "guiqwt.plot", "CurveWidget",
+ icon="curve.png")
+
+ ImagePlotPlugin = create_qtdesigner_plugin("guiqwt", "guiqwt.plot", "ImageWidget",
+ icon="image.png")
+except ImportError:
+ from taurus.core.util.log import debug
+ debug("failed to load guiqwt designer plugin")
diff --git a/lib/taurus/qt/qtdesigner/taurusdesigner.py b/lib/taurus/qt/qtdesigner/taurusdesigner.py
new file mode 100644
index 00000000..3e7f1271
--- /dev/null
+++ b/lib/taurus/qt/qtdesigner/taurusdesigner.py
@@ -0,0 +1,143 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## This file is part of Taurus
+##
+## http://taurus-scada.org
+##
+## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
+##
+## Taurus is free software: you can redistribute it and/or modify
+## it under the terms of the GNU Lesser General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## Taurus is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public License
+## along with Taurus. If not, see <http://www.gnu.org/licenses/>.
+##
+#############################################################################
+
+import sys
+import os.path
+import optparse
+
+import taurus
+from taurus.external.qt import Qt
+
+def env_index(env, env_name):
+ env_name = str(env_name)
+ for i, e in enumerate(env):
+ e = str(e)
+ if e.startswith(env_name):
+ return i
+ return -1
+
+def has_env(env, env_name):
+ return env_index(env, env_name) != -1
+
+def get_env(env, env_name):
+ env_name = str(env_name)
+ for i, e in enumerate(env):
+ e = str(e)
+ if e.startswith(env_name):
+ return e.split("=")[1]
+ return None
+
+def append_or_create_env(env, env_name, env_value, is_path_like=True):
+ i = env_index(env, env_name)
+ if i == -1:
+ env.append(env_name + "=" + env_value)
+ else:
+ if is_path_like:
+ e_n, e_v = env[i].split("=")
+ paths = e_v.split(os.path.pathsep)
+ if not env_value in paths:
+ env_value += os.path.pathsep + e_v
+ env[i] = env_name + "=" + env_value
+
+def append_or_create_env_list(env, env_name, env_value):
+ env_value = os.path.pathsep.join(env_value)
+ append_or_create_env(env, env_name, env_value)
+
+def get_qtdesigner_bin():
+ designer_bin = str(Qt.QLibraryInfo.location(Qt.QLibraryInfo.BinariesPath))
+
+ plat = sys.platform
+ if plat == "darwin":
+ designer_bin = os.path.join(designer_bin, "Designer.app", "Contents", "MacOS")
+ elif plat in ("win32", "nt"):
+ import PyQt4
+ designer_bin = os.path.abspath(os.path.dirname(PyQt4.__file__))
+
+ designer_bin = os.path.join(designer_bin, "designer")
+ return designer_bin
+
+def get_taurus_designer_path():
+ """Returns a list of directories containing taurus designer plugins"""
+ # Set PYQTDESIGNERPATH to look inside taurus for designer plugins
+ taurus_path = os.path.dirname(os.path.abspath(taurus.__file__))
+ taurus_qt_designer_path = os.path.join(taurus_path, 'qt', 'qtdesigner')
+ return [taurus_qt_designer_path]
+
+def qtdesigner_prepare_taurus(env=None, taurus_extra_path=None):
+
+ # Tell Qt Designer where it can find the directory containing the plugins
+ if env is None:
+ env = Qt.QProcess.systemEnvironment()
+
+ # Set PYQTDESIGNERPATH to look inside taurus for designer plugins
+ taurus_designer_path = get_taurus_designer_path()
+
+ append_or_create_env_list(env, "PYQTDESIGNERPATH", taurus_designer_path)
+
+ # Set TAURUSQTDESIGNERPATH
+ if taurus_extra_path is not None:
+ append_or_create_env(env, "TAURUSQTDESIGNERPATH", taurus_extra_path)
+ append_or_create_env(env, "PYTHONPATH", taurus_extra_path)
+
+ #print "PYTHONPATH=%s" % get_env(env, "PYTHONPATH")
+ #print "PYQTDESIGNERPATH=%s" % get_env(env, "PYQTDESIGNERPATH")
+ return env
+
+def qtdesigner_start(args, env=None):
+ # Start Designer.
+ designer_bin = get_qtdesigner_bin()
+
+ designer = Qt.QProcess()
+ designer.setProcessChannelMode(Qt.QProcess.ForwardedChannels)
+ designer.setEnvironment(env)
+ designer.start(designer_bin, args)
+ designer.waitForFinished(-1)
+
+ return designer.exitCode()
+
+def main(env=None):
+ version = "taurusdesigner %s" % (taurus.Release.version)
+ usage = "Usage: %prog [options] <ui file(s)>"
+ description = "The Qt designer application customized for taurus"
+ parser = optparse.OptionParser(version=version, usage=usage, description=description)
+ parser.add_option("--taurus-path", dest="tauruspath", default="",
+ help="additional directories to look for taurus widgets")
+ parser.add_option("--qt-designer-path", dest="pyqtdesignerpath", default="",
+ help="additional directories to look for python qt widgets")
+
+ options, args = parser.parse_args()
+
+ taurus_extra_path = None
+ # Set TAURUSQTDESIGNERPATH
+ if len(options.tauruspath) > 0:
+ taurus_extra_path = options.tauruspath
+
+ env = qtdesigner_prepare_taurus(env=env, taurus_extra_path=taurus_extra_path)
+
+ sys.exit(qtdesigner_start(args, env=env))
+
+if __name__ == "__main__":
+ main()
+
diff --git a/lib/taurus/qt/qtdesigner/taurusplugin/__init__.py b/lib/taurus/qt/qtdesigner/taurusplugin/__init__.py
new file mode 100644
index 00000000..2121a3d6
--- /dev/null
+++ b/lib/taurus/qt/qtdesigner/taurusplugin/__init__.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## This file is part of Taurus
+##
+## http://taurus-scada.org
+##
+## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
+##
+## Taurus is free software: you can redistribute it and/or modify
+## it under the terms of the GNU Lesser General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## Taurus is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public License
+## along with Taurus. If not, see <http://www.gnu.org/licenses/>.
+##
+#############################################################################
+
+"""The taurus.qt.qtdesigner.taurusplugin submodule."""
+
+__docformat__ = 'restructuredtext'
+
+from .taurusplugin import *
+
diff --git a/lib/taurus/qt/qtdesigner/taurusplugin/taurusplugin.py b/lib/taurus/qt/qtdesigner/taurusplugin/taurusplugin.py
new file mode 100644
index 00000000..09d6d006
--- /dev/null
+++ b/lib/taurus/qt/qtdesigner/taurusplugin/taurusplugin.py
@@ -0,0 +1,168 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## This file is part of Taurus
+##
+## http://taurus-scada.org
+##
+## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
+##
+## Taurus is free software: you can redistribute it and/or modify
+## it under the terms of the GNU Lesser General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## Taurus is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public License
+## along with Taurus. If not, see <http://www.gnu.org/licenses/>.
+##
+#############################################################################
+
+""" Every TaurusWidget should have the following Qt Designer extended capabilities:
+
+ - Task menu:
+ it means when you right click on the widget in the designer, it will have
+ the following additional items:
+ - 'Edit model...' - opens a customized dialog for editing the widget model
+
+ - Property Sheet:
+ it means that in the Qt Designer property sheet it will have the following
+ properties customized:
+ - 'model' - will have a '...' button that will open a customized dialog for
+ editing the widget model (same has 'Edit model...' task menu item
+"""
+
+import inspect
+
+from taurus.external.qt import Qt
+from taurus.external.qt import QtDesigner
+
+from taurus.core.util.log import Logger
+
+def Q_TYPEID(class_name):
+ """ Helper function to generate an IID for Qt. Returns a QString."""
+ return Qt.QString("com.trolltech.Qt.Designer.%s" % class_name)
+
+designer_logger = Logger("PyQtDesigner")
+
+class TaurusWidgetPlugin(QtDesigner.QPyDesignerCustomWidgetPlugin):
+ """TaurusWidgetPlugin"""
+
+ def __init__(self, parent = None):
+ QtDesigner.QPyDesignerCustomWidgetPlugin.__init__(self)
+ self._log = Logger(self._getWidgetClassName(), designer_logger)
+ self.initialized = False
+
+ def initialize(self, formEditor):
+ """ Overwrite if necessary. Don't forget to call this method in case you
+ want the generic taurus extensions in your widget."""
+ if self.isInitialized():
+ return
+
+ self.initialized = True
+
+ def isInitialized(self):
+ return self.initialized
+
+ def getWidgetClass(self):
+ return self.WidgetClass
+
+ def _getWidgetClassName(self):
+ return self.getWidgetClass().__name__
+
+ def __getWidgetArgs(self, klass=None, designMode=True, parent=None):
+ if klass is None:
+ klass = self.getWidgetClass()
+ ctor = klass.__init__
+ aspec = inspect.getargspec(ctor)
+ if aspec.defaults is None:
+ kwspec = {}
+ else:
+ kwspec = dict(zip(aspec.args[-len(aspec.defaults):],
+ aspec.defaults))
+ args, kwargs = [], {}
+ if 'designMode' in kwspec:
+ kwargs['designMode'] = designMode
+ if 'parent' in kwspec:
+ kwargs['parent'] = parent
+ else:
+ args.append(parent)
+ return args, kwargs
+
+ def createWidget(self, parent):
+ try:
+ klass = self.getWidgetClass()
+ args, kwargs = self.__getWidgetArgs(klass=klass,
+ designMode=True,
+ parent=parent)
+ w = klass(*args, **kwargs)
+ except Exception, e:
+ name = self._getWidgetClassName()
+ print 100*"="
+ print "taurus designer plugin error creating %s: %s" % (name, str(e))
+ print 100*"-"
+ import traceback
+ traceback.print_exc()
+ w = None
+ return w
+
+ def getWidgetInfo(self, key, dft=None):
+ if not hasattr(self, '_widgetInfo'):
+ self._widgetInfo = self.getWidgetClass().getQtDesignerPluginInfo()
+ return self._widgetInfo.get(key, dft)
+
+ # This method returns the name of the custom widget class that is provided
+ # by this plugin.
+ def name(self):
+ return self._getWidgetClassName()
+
+ def group(self):
+ """ Returns the name of the group in Qt Designer's widget box that this
+ widget belongs to.
+ It returns 'Taurus Widgets'. Overwrite if want another group."""
+ return self.getWidgetInfo('group', 'Taurus Widgets')
+
+ def getIconName(self):
+ return self.getWidgetInfo('icon')
+
+ def icon(self):
+ icon = self.getWidgetInfo('icon')
+ if icon is None:
+ return Qt.QIcon()
+ elif isinstance(icon, Qt.QIcon):
+ return icon
+ else:
+ if not icon.startswith(":"):
+ icon = ':/designer/%s' % icon
+ import taurus.qt.qtgui.resource
+ return taurus.qt.qtgui.resource.getIcon(icon)
+
+ def domXml(self):
+ name = str(self.name())
+ lowerName = name[0].lower() + name[1:]
+ return '<widget class="%s" name=\"%s\" />\n' % (name, lowerName)
+
+ def includeFile(self):
+ """Returns the module containing the custom widget class. It may include
+ a module path."""
+ return self.getWidgetInfo('module')
+
+ def toolTip(self):
+ tooltip = self.getWidgetInfo('tooltip')
+ if tooltip is None:
+ tooltip = "A %s" % self._getWidgetClassName()
+ return tooltip
+
+ def whatsThis(self):
+ whatsthis = self.getWidgetInfo('whatsthis')
+ if whatsthis is None:
+ whatsthis = "This is a %s widget" % self._getWidgetClassName()
+ return whatsthis
+
+ def isContainer(self):
+ return self.getWidgetInfo('container', False)
diff --git a/lib/taurus/qt/qtdesigner/tauruspluginplugin.py b/lib/taurus/qt/qtdesigner/tauruspluginplugin.py
new file mode 100644
index 00000000..82c0928e
--- /dev/null
+++ b/lib/taurus/qt/qtdesigner/tauruspluginplugin.py
@@ -0,0 +1,123 @@
+#!/usr/bin/env python
+
+#############################################################################
+##
+## This file is part of Taurus
+##
+## http://taurus-scada.org
+##
+## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
+##
+## Taurus is free software: you can redistribute it and/or modify
+## it under the terms of the GNU Lesser General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## Taurus is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public License
+## along with Taurus. If not, see <http://www.gnu.org/licenses/>.
+##
+#############################################################################
+
+"""
+tauruspluginplugin.py:
+"""
+
+from taurus.external.qt import QtDesigner
+
+
+def build_qtdesigner_widget_plugin(klass):
+ import taurusplugin
+
+ class Plugin(taurusplugin.TaurusWidgetPlugin):
+ WidgetClass = klass
+
+ Plugin.__name__ = klass.__name__ + "QtDesignerPlugin"
+ return Plugin
+
+_SKIP = ["QLogo", "QGroupWidget", "TaurusGroupWidget"]
+
+_plugins = {}
+
+def main():
+ from taurus import Manager
+ from taurus.core.util.log import Logger
+ from taurus.core.taurusbasetypes import OperationMode
+ from taurus.qt.qtgui.util import TaurusWidgetFactory
+ Logger.setLogLevel(Logger.Debug)
+ _log = Logger(__name__)
+
+ Manager().setOperationMode(OperationMode.OFFLINE)
+
+ try:
+ wf = TaurusWidgetFactory()
+ klasses = wf.getWidgetClasses()
+ ok_nb, skipped_nb, e1_nb, e2_nb, e3_nb, e4_nb = 0, 0, 0, 0, 0, 0
+ for widget_klass in klasses:
+ name = widget_klass.__name__
+ #_log.debug("Processing %s" % name)
+ if name in _SKIP:
+ #_log.debug("Skipped %s" % name)
+ skipped_nb += 1
+ continue
+ # if getQtDesignerPluginInfo does not exist, returns None or raises
+ # an exception: forget the widget
+ cont=False
+ try:
+ qt_info = widget_klass.getQtDesignerPluginInfo()
+ if qt_info is None:
+ #_log.debug("E1: Canceled %s (getQtDesignerPluginInfo)" % name)
+ e1_nb += 1
+ cont = True
+ except AttributeError:
+ #_log.debug("E2: Canceled %s (widget doesn't have getQtDesignerPluginInfo())" % name)
+ e2_nb += 1
+ cont = True
+ except Exception,e:
+ #_log.debug("E3: Canceled %s (%s)" % (name, str(e)))
+ e3_nb += 1
+ cont = True
+
+ if cont: continue
+ for k in ('module', ):
+ if not qt_info.has_key(k):
+ #_log.debug("E4: Canceled %s (getQtDesignerPluginInfo doesn't have key %s)" % (name, k))
+ e4_nb += 1
+ cont=True
+ if cont: continue
+
+ plugin_klass = build_qtdesigner_widget_plugin(widget_klass)
+ plugin_klass_name = plugin_klass.__name__
+ globals()[plugin_klass_name] = plugin_klass
+ _plugins[plugin_klass_name] = plugin_klass
+
+ ok_nb += 1
+ #_log.debug("DONE processing %s" % name)
+ _log.info("Inpected %d widgets. %d (OK), %d (Skipped), %d (E1), %d (E2), %d (E3), %d(E4)" % (len(klasses), ok_nb, skipped_nb, e1_nb, e2_nb, e3_nb, e4_nb))
+ _log.info("E1: getQtDesignerPluginInfo() returns None")
+ _log.info("E2: widget doesn't implement getQtDesignerPluginInfo()")
+ _log.info("E3: getQtDesignerPluginInfo() throws exception")
+ _log.info("E4: getQtDesignerPluginInfo() returns dictionary with missing key (probably 'module' key)")
+ except Exception as e:
+ import traceback; traceback.print_exc()
+ #print e
+
+
+class TaurusWidgets(QtDesigner.QPyDesignerCustomWidgetCollectionPlugin):
+
+ def __init__(self, parent=None):
+ QtDesigner.QPyDesignerCustomWidgetCollectionPlugin.__init__(parent)
+ self._widgets = None
+
+ def customWidgets(self):
+ if self._widgets is None:
+ self._widgets = [ w(self) for w in _plugins.values() ]
+ return self._widgets
+
+if __name__ != "__main__":
+ main()
+