Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow load_ui to load local files #599

Merged
merged 1 commit into from
Mar 30, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions glue/qt/qtutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,9 +725,12 @@ def _load_ui_pyqt4(path, parent):
return loadUi(path, parent)


def load_ui(name, parent=None):
def load_ui(path, parent=None):
"""
Load a UI file, given it's name
Load a UI file, given its name.

This will first check if `path` exists, and if not it will assume it is the
name of a ui file to search for in the global glue ui directory.

Parameters
----------
Expand All @@ -742,14 +745,19 @@ def load_ui(name, parent=None):
w : QWidget
The new widget
"""
path = ui_path(name)

if not os.path.exists(path):
path = global_ui_path(path)

if is_pyside():
return _load_ui_pyside(path, parent)
return _load_ui_pyqt4(path, parent)
else:
return _load_ui_pyqt4(path, parent)


def ui_path(ui_name):
"""Return the absolute path to a .ui file
def global_ui_path(ui_name):
"""
Return the absolute path to a .ui file bundled with glue.

Parameters
----------
Expand Down