def __init__( self, parent, uifile = '' ): super(XConfigWidget, self).__init__(parent) # load the ui if specified if ( uifile ): curr_dir = QDir.currentPath() QDir.setCurrent(os.path.dirname(uifile)) uic.loadUi(uifile, self) QDir.setCurrent(curr_dir) self._plugin = None
def __init__( self, parent = None ): super(XConfigDialog,self).__init__(parent) # load the ui uifile = os.path.join(os.path.dirname(__file__),'ui/xconfigdialog.ui') uic.loadUi( uifile, self ) self._plugins = [] # create connections self.uiPluginTREE.itemSelectionChanged.connect( self.showConfig ) self.uiResetBTN.clicked.connect( self.reset ) self.uiSaveBTN.clicked.connect( self.save ) self.uiSaveExitBTN.clicked.connect( self.accept ) self.uiCancelBTN.clicked.connect( self.reject )
def __init__( self, parent = None ): super(XShortcutDialog,self).__init__(parent) # load the ui basefile = os.path.dirname(__file__) uifile = os.path.join( basefile,'ui/xshortcutdialog.ui' ) uic.loadUi( uifile, self ) # update the tree view header = self.uiActionTREE.header() header.setStretchLastSection(False) header.setResizeMode(0, header.Stretch) header.setResizeMode(1, header.ResizeToContents) # intercept key press events for the shortcut dialog self.uiShortcutTXT.installEventFilter(self) # create connections self.uiActionTREE.itemSelectionChanged.connect( self.updateAction ) self.uiClearBTN.clicked.connect( self.clear ) self.uiSaveBTN.clicked.connect( self.save )
def loadUi(modulefile, inst, uifile=None, theme='default', className=None): """ Load the ui file based on the module file location and the inputed class. :param modulefile | <str> inst | <subclass of QWidget> uifile | <str> || None :return <QWidget> """ if className is None: className = inst.__class__.__name__ import_qt(globals()) currpath = QtCore.QDir.currentPath() # use compiled information vs. dynamic generation widget = None if USE_COMPILED: # find the root module def find_root_module(cls, name): if cls.__name__ == name: return cls.__module__.rpartition('.')[0] else: for base in cls.__bases__: if not issubclass(base, QtGui.QWidget): continue out = find_root_module(base, name) if out: return out wrapper = QT_WRAPPER.lower() root_module = find_root_module(inst.__class__, className) if not root_module: root_module = inst.__module__.rpartition('.')[0] basename = className.lower() modname_a = '{0}.ui.{1}_{2}_{3}_ui'.format(root_module, basename, theme, wrapper) modname_b = '{0}.ui.{1}_{2}_ui'.format(root_module, basename, wrapper) modname_c = '{0}.ui.{1}_{2}_ui'.format(root_module, basename, theme) modname_d = '{0}.ui.{1}_ui'.format(root_module, basename) module = None for modname in (modname_a, modname_b, modname_c, modname_d): modname = modname.strip('.') logger.debug('Loading module: {0}...'.format(modname)) try: __import__(modname) module = sys.modules[modname] break except StandardError: pass # successfully loaded a module if module: # load the module information cls = getattr(module, 'Ui_%s' % className, None) if not cls: for key in module.__dict__.keys(): if key.startswith('Ui_'): cls = getattr(module, key) break # generate the class information if cls: widget = cls() widget.setupUi(inst) inst.__dict__.update(widget.__dict__) if not widget: if not uifile: uifile = uiFile(modulefile, inst, theme, className=className) # normalize the path uifile = os.path.normpath(uifile) if os.path.exists(uifile): QtCore.QDir.setCurrent(os.path.dirname(uifile)) widget = uic.loadUi(uifile, inst) QtCore.QDir.setCurrent(currpath) inst.addActions(findUiActions(inst)) return widget
def __init__( self, parent = None ): super(XAboutDialog, self).__init__(parent) # load the ui uifile = os.path.join( os.path.dirname(__file__),'ui/xaboutdialog.ui' ) uic.loadUi( uifile, self )
def __init__(self, parent=None): super(XAboutDialog, self).__init__(parent) # load the ui uifile = os.path.join(os.path.dirname(__file__), 'ui/xaboutdialog.ui') uic.loadUi(uifile, self)