import sys
from PySide.QtCore import *
from PySide.QtGui import *
from PySide.QtUiTools import *


def load_ui_widget(filename, parent=None):
    loader = QUiLoader()
    uifile = QFile(filename)
    uifile.open(QFile.ReadOnly)
    ui = loader.load(uifile, parent)
    uifile.close()

    return ui


class ExampleWidget(QWidget):
    def __init__(self, filepath):
        super(ExampleWidget, self).__init__()
        self.ui = load_ui_widget(filepath)


if __name__ == "__main__":
    app = QApplication(sys.argv)

    widget = ExampleWidget("example.ui")
    widget.ui.show()

    sys.exit(app.exec_())

@@ -1,15 +1,4 @@
-import sys%0A
 from
@@ -79,16 +79,27 @@
 mport *%0A
+import sys%0A
 %0A%0Adef lo
@@ -131,13 +131,8 @@
 rent
-=None
 ):%0A 
@@ -223,13 +223,8 @@
 %0A   
- ui =
  loa
@@ -272,23 +272,8 @@
 ()%0A%0A
-    return ui%0A%0A
 %0Acla
@@ -390,18 +390,8 @@
     
- self.ui =
  loa
@@ -410,16 +410,49 @@
 filepath
+, parent=self)%0A        self.show(
 )%0A%0A%0Aif _
@@ -507,17 +507,16 @@
 s.argv)%0A
-%0A
     widg
@@ -551,29 +551,8 @@
 ui%22)
-%0A    widget.ui.show()
 %0A%0A  

update example.py to be slightly cleaner