Skip to content

Commit

Permalink
refactor loadUi to a global documentable function (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk-thomas committed Jun 6, 2013
1 parent 93b6c7f commit 7e8d7cc
Showing 1 changed file with 26 additions and 31 deletions.
57 changes: 26 additions & 31 deletions src/python_qt_binding/binding_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,9 @@ def _load_pyqt(required_modules, optional_modules):
except ImportError:
pass

global loadUi

def loadUi(uifile, baseinstance=None, custom_widgets=None):
"""
@type uifile: str
@param uifile: Absolute path of .ui file
@type baseinstance: QWidget
@param baseinstance: the optional instance of the Qt base class.
If specified then the user interface is created in
it. Otherwise a new instance of the base class is
automatically created.
@param custom_widgets: Unlike the method with the same name in pyside
binding, this argument won't be used. Ref:
http://answers.ros.org/question/56382/what-does-python_qt_bindingloaduis-3rd-arg-do-in-pyqt-binding/
"""
global _loadUi

def _loadUi(uifile, baseinstance=None, custom_widgets_=None):
from PyQt4 import uic
return uic.loadUi(uifile, baseinstance=baseinstance)

Expand Down Expand Up @@ -192,22 +180,9 @@ def _load_pyside(required_modules, optional_modules):
except ImportError:
pass

global loadUi

def loadUi(uifile, baseinstance=None, custom_widgets=None):
"""
@type uifile: str
@param uifile: Absolute path of .ui file
@type baseinstance: QWidget
@param baseinstance: the optional instance of the Qt base class.
If specified then the user interface is created in
it. Otherwise a new instance of the base class is
automatically created.
@type custom_widgets: dict of {str:QWidget}
@param custom_widgets: Class name and type of the custom classes used
in uifile if any. This can be None if no custom
class is in use.
"""
global _loadUi

def _loadUi(uifile, baseinstance=None, custom_widgets=None):
from PySide.QtUiTools import QUiLoader
from PySide.QtCore import QMetaObject

Expand Down Expand Up @@ -256,6 +231,26 @@ def createWidget(self, class_name, parent=None, name=''):
return PySide.__version__


def loadUi(uifile, baseinstance=None, custom_widgets=None):
"""
@type uifile: str
@param uifile: Absolute path of .ui file
@type baseinstance: QWidget
@param baseinstance: the optional instance of the Qt base class.
If specified then the user interface is created in
it. Otherwise a new instance of the base class is
automatically created.
@type custom_widgets: dict of {str:QWidget}
@param custom_widgets: Class name and type of the custom classes used
in uifile if any. This can be None if no custom
class is in use. (Note: this is only necessary
for PySide, see
http://answers.ros.org/question/56382/what-does-python_qt_bindingloaduis-3rd-arg-do-in-pyqt-binding/
for more information)
"""
return _loadUi(uifile, baseinstance, custom_widgets)


QT_BINDING = None
QT_BINDING_MODULES = {}
QT_BINDING_VERSION = None
Expand Down

0 comments on commit 7e8d7cc

Please sign in to comment.