Ejemplo n.º 1
0
class BaseWidget(object):
    DEFAULT_INNER_CLASS=None
    def __init__(self,innercls=DEFAULT_INNER_CLASS,*args,**kw):
        self._log=LogUtil().logger('UI')
        self._innercls=innercls
        self._log.debug('InnerClass:%s'%(innercls.__name__,))
        self.createWidget(*args,**kw)
    def createWidget(self,*args,**kw):
        self._widget=None
    @property
    def widget(self):
        return self._widget
Ejemplo n.º 2
0
class InnerMessageBox(_QtGui.QMessageBox):
    TABLE_ICON={base.MessageBox.ICON_NONE:_QtGui.QMessageBox.NoIcon,
                base.MessageBox.ICON_INFORMATION:_QtGui.QMessageBox.Information,
                base.MessageBox.ICON_QUESTION:_QtGui.QMessageBox.Question,
                base.MessageBox.ICON_WARNING:_QtGui.QMessageBox.Warning,
                base.MessageBox.ICON_CRITICAL:_QtGui.QMessageBox.Critical}
    TABLE_BUTTON={base.MessageBox.BUTTON_OK:_QtGui.QMessageBox.Ok,
                  base.MessageBox.BUTTON_OK_CANCEL:_QtGui.QMessageBox.Ok|_QtGui.QMessageBox.Cancel,
                  base.MessageBox.BUTTON_YES_NO:_QtGui.QMessageBox.Yes|_QtGui.QMessageBox.No}
    TABLE_RET={_QtGui.QMessageBox.Yes:base.MessageBox.RET_YES,
               _QtGui.QMessageBox.No:base.MessageBox.RET_NO,
               _QtGui.QMessageBox.Ok:base.MessageBox.RET_OK,
               _QtGui.QMessageBox.Cancel:base.MessageBox.RET_CANCEL}
    @base.addwrapper
    def __init__(self,kw):
        defaultdict={'parent':None,
                     'title':self.__class__.__name__,
                     'text':'',
                     'icon':0,
                     'button':0}
        icon=kw.get('icon',base.MessageBox.ICON_NONE)
        kw['icon']=self.__class__.TABLE_ICON[icon]
        button=kw.get('button',base.MessageBox.BUTTON_OK)
        kw['button']=self.__class__.TABLE_BUTTON[button]
        for k in defaultdict.keys():
            defaultdict[k]=kw.get(k,defaultdict[k])
        if defaultdict['parent']==None:
            self._only=True
            self._log=LogUtil().logger('UI')
        else:
            self._only=False
        super(self.__class__,self).__init__(defaultdict['icon'],
                                            defaultdict['title'],
                                            defaultdict['text'],
                                            defaultdict['button'],
                                            defaultdict['parent'])
    def wrapshow(self):
        ret=self.exec_()
        if self._only:
            self._log.debug('Ret:%d'%(self.__class__.TABLE_RET[ret],))
            sys.exit(ret)
        return self.__class__.TABLE_RET[ret]