Python PySide.QtCore 模块,QObject() 实例源码

我们从Python开源项目中,提取了以下47个代码示例,用于说明如何使用PySide.QtCore.QObject()

项目:guiQML    作者:gramps-project    | 项目源码 | 文件源码
def __build_main_window(self, engine):
        """
        Builds the QML interface
        """
        parentcontext = engine.rootContext()
        #Create a context for the family tree list
        self.qmlpersonlistcontext = QtDeclarative.QDeclarativeContext(parentcontext)
        #Create ListModel to use
        personlistmodel = QMLPersonListModel(self.dbstate.db)

        #register them in the context
        self.qmlpersonlistcontext.setContextProperty('Const', self.const)
        self.qmlpersonlistcontext.setContextProperty('QMLPersonList', self)
        self.qmlpersonlistcontext.setContextProperty('QMLPersonListModel', personlistmodel)

        #create a Component to show
        self.qmlpersonlist = QtDeclarative.QDeclarativeComponent(engine)
        self.qmlpersonlist.loadUrl(QtCore.QUrl.fromLocalFile(
                os.path.join(ROOT_DIR, "guiQML", 'views', 'peopleview.qml')))
        #and obtain the QObject of it
        self.Qpersonlist = self.qmlpersonlist.create(self.qmlpersonlistcontext)
项目:guiQML    作者:gramps-project    | 项目源码 | 文件源码
def __init__(self, dbstate, engine, onselectcallback):
        """
        The manager is initialised with a dbstate on which GRAMPS is
        working, and the engine to use context from.
        """
        self.__busy = False
        self.__onselect = onselectcallback
        QtCore.QObject.__init__(self)
        CLIDbManager.__init__(self, dbstate)
        #constants needed in the QML
        self.const = {
            'titlelabel': "Gramps - %s" % _("Family Trees"),
            'addbtnlbl': _("Add a Family Tree"),
            'famtreeicon': FAMTREE_ICONPATH
            }
        #there is one DeclarativeEngine for global settings
        self.__build_main_window(engine)
项目:guiQML    作者:gramps-project    | 项目源码 | 文件源码
def __build_main_window(self, engine):
        """
        Builds the QML interface
        """
        parentcontext = engine.rootContext()
        #Create a context for the family tree list
        self.centralviewcontext = QtDeclarative.QDeclarativeContext(parentcontext)
        #Create ListModel to use
        detviews = DetViewSumModel([DetailView('People')])

        #register them in the context
        self.centralviewcontext.setContextProperty('Const', self.const)
        self.centralviewcontext.setContextProperty('CentralView', self)
        self.centralviewcontext.setContextProperty('DetViewSumModel', detviews)

        #create a Component to show
        self.centralview = QtDeclarative.QDeclarativeComponent(engine)
        self.centralview.loadUrl(QtCore.QUrl.fromLocalFile(
                os.path.join(ROOT_DIR, "guiQML", 'views', 'centralview.qml')))
        #and obtain the QObject of it
        self.Qcentralview = self.centralview.create(self.centralviewcontext)
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def Establish_Connections(self):
        # loop button and menu action to link to functions
        for ui_name in self.uiList.keys():
            if ui_name.endswith('_btn'):
                QtCore.QObject.connect(self.uiList[ui_name], QtCore.SIGNAL("clicked()"), getattr(self, ui_name[:-4]+"_action", partial(self.default_action,ui_name)))
            elif ui_name.endswith('_atn'):
                QtCore.QObject.connect(self.uiList[ui_name], QtCore.SIGNAL("triggered()"), getattr(self, ui_name[:-4]+"_action", partial(self.default_action,ui_name)))
            elif ui_name.endswith('_btnMsg'):
                QtCore.QObject.connect(self.uiList[ui_name], QtCore.SIGNAL("clicked()"), getattr(self, ui_name[:-7]+"_message", partial(self.default_message,ui_name)))
            elif ui_name.endswith('_atnMsg'):
                QtCore.QObject.connect(self.uiList[ui_name], QtCore.SIGNAL("triggered()"), getattr(self, ui_name[:-7]+"_message", partial(self.default_message,ui_name)))
        # custom connection

    #=======================================
    # UI Response functions (custom + prebuilt functions)
    #=======================================
    #-- ui actions
项目:kite    作者:pyrocko    | 项目源码 | 文件源码
def __init__(self, scene_model, *args, **kwargs):
        QtCore.QObject.__init__(self, *args, **kwargs)
        self.worker_thread = QtCore.QThread()
        self.moveToThread(self.worker_thread)
        self.worker_thread.start()

        self.model = None
        self.log = SceneLogModel(self)
        self.sources = SourceModel(self)

        self._log_handler = logging.Handler()
        self._log_handler.emit = self.sigLogRecord.emit

        self.cursor_tracker = CursorTracker()

        self.setModel(scene_model)
项目:kite    作者:pyrocko    | 项目源码 | 文件源码
def __init__(self, model, parent):
        QtCore.QObject.__init__(self)
        self.sigCalculateWeightMatrix.connect(
            model.calculateWeightMatrix)

        ret = QtGui.QMessageBox.information(
            parent,
            'Calculate full weight matrix',
            '''<html><head/><body><p>
This will calculate the quadtree's full weight matrix
(<span style='font-family: monospace'>Covariance.weight_matrix</span>)
for this noise/covariance configuration.</p><p>
The calculation is expensive and may take several minutes.
</p></body></html>
''', buttons=(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel))
        if ret == QtGui.QMessageBox.Ok:
            self.sigCalculateWeightMatrix.emit()
项目:kite    作者:pyrocko    | 项目源码 | 文件源码
def __init__(self):
        QtCore.QObject.__init__(self)

        self.scene = None
        self.frame = None
        self.quadtree = None
        self.covariance = None
        self.log = SceneLogModel(self)

        self._ = SignalProxy(self._sigQuadtreeChanged,
                             rateLimit=5,
                             delay=0,
                             slot=lambda: self.sigQuadtreeChanged.emit())

        self._log_handler = logging.Handler()
        self._log_handler.emit = self.sigLogRecord.emit

        self.qtproxy = QSceneQuadtreeProxy(self)

        self.worker_thread = QtCore.QThread()
        self.moveToThread(self.worker_thread)
        self.worker_thread.start()
项目:freecad-nurbs    作者:microelly2    | 项目源码 | 文件源码
def __init__(self):
        QtCore.QObject.__init__(self)
        self.mouseWheel=0
        self.enterleave=False
        self.enterleave=True
        self.keyPressed2=False
        self.editmode=False
        self.key='x'
        self.posx=-1
        self.posy=-1
        self.lasttime=time.time()
        self.lastkey='#'
        self.colorA=0
        self.colors=[]
        self.pts=[]
        self.ptsm=[]
        self.mode='n'
项目:guiQML    作者:gramps-project    | 项目源码 | 文件源码
def __init__(self, db, personhandle):
        QtCore.QObject.__init__(self)
        self.__handle = personhandle
        self.__db = db
项目:guiQML    作者:gramps-project    | 项目源码 | 文件源码
def __init__(self, dbstate, engine):
        """
        The manager is initialised with a dbstate on which GRAMPS is
        working, and the engine to use context from.
        """
        self.dbstate = dbstate
        QtCore.QObject.__init__(self)
        self.const = {
            'titlelabel': "%s" % self.dbstate.db.get_dbname(),
            }
        #there is one DeclarativeEngine for global settings
        self.__build_main_window(engine)
项目:guiQML    作者:gramps-project    | 项目源码 | 文件源码
def __init__(self, thing, dbman):
        QtCore.QObject.__init__(self)
        self.__dbman = dbman
        self.__name = thing[CLIDbManager.IND_NAME]
        self.__path = thing[CLIDbManager.IND_PATH]
        self.__path_namefile = thing[CLIDbManager.IND_PATH_NAMEFILE]
        self.__last_access = thing[CLIDbManager.IND_TVAL_STR]
        self.__use_icon = thing[CLIDbManager.IND_USE_ICON_BOOL]
        self.__icon = thing[CLIDbManager.IND_STOCK_ID]
项目:guiQML    作者:gramps-project    | 项目源码 | 文件源码
def __init__(self, name):
        QtCore.QObject.__init__(self)
        self.__name = name
项目:guiQML    作者:gramps-project    | 项目源码 | 文件源码
def __init__(self, dbstate, engine, viewshow):
        """
        The manager is initialised with a dbstate on which GRAMPS is
        working, and the engine to use context from.
        """
        self.dbstate = dbstate
        self.__viewshow = viewshow
        QtCore.QObject.__init__(self)
        self.const = {
            'titlelabel': str("%s" % self.dbstate.db.get_dbname()),
            }
        print(self.const['titlelabel'])
        #there is one DeclarativeEngine for global settings
        self.__build_main_window(engine)
项目:BlendTransforms    作者:duncanskertchly    | 项目源码 | 文件源码
def BT_GetMayaWindow():
    ptr = apiUI.MQtUtil.mainWindow()
    if ptr is not None:
        if BT_MayaVersionNumber < 2014:
            return wrapinstance(long(ptr), QtCore.QObject)
        else:
            return wrapInstance(long(ptr), QtGui.QWidget)
项目:BlendTransforms    作者:duncanskertchly    | 项目源码 | 文件源码
def BT_GetMayaWindow():
    ptr = apiUI.MQtUtil.mainWindow()
    if ptr is not None:
        if BT_MayaVersionNumber < 2014:
            return wrapinstance(long(ptr), QtCore.QObject)
        else:
            return wrapInstance(long(ptr), QtGui.QWidget)
项目:BlendTransforms    作者:duncanskertchly    | 项目源码 | 文件源码
def BT_GetMayaWindow():
    ptr = apiUI.MQtUtil.mainWindow()
    if ptr is not None:
        if BT_MayaVersionNumber < 2014:
            return wrapinstance(long(ptr), QtCore.QObject)
        else:
            return wrapInstance(long(ptr), QtGui.QWidget)
项目:BlendTransforms    作者:duncanskertchly    | 项目源码 | 文件源码
def BT_GetMayaWindow():
    ptr = apiUI.MQtUtil.mainWindow()
    if ptr is not None:
        if BT_MayaVersionNumber < 2014:
            return wrapinstance(long(ptr), QtCore.QObject)
        else:
            return wrapInstance(long(ptr), QtGui.QWidget)
项目:BrainModulyzer    作者:sugeerth    | 项目源码 | 文件源码
def __init__(self):
        QtCore.QObject.__init__(self)
项目:HearthPacks    作者:Arzaroth    | 项目源码 | 文件源码
def __init__(self):
        QtCore.QObject.__init__(self)
        self.pool = QtCore.QThreadPool()
        self.pool.setMaxThreadCount(5)
        self.cards = []
        self.result = {}
        self.tmpdir = tempfile.mkdtemp()
项目:ECoG-ClusterFlow    作者:sugeerth    | 项目源码 | 文件源码
def __init__(self,WebView,startval=42):
        QtCore.QObject.__init__(self)
        self.Start= startval 
        self.WebView = WebView
        self.sendTimeStepFromSankey.connect(self.WebView.sendTimeStepFromSankey)
项目:ECoG-ClusterFlow    作者:sugeerth    | 项目源码 | 文件源码
def signalConnection(self):
        self.connect(self.page().mainFrame(), QtCore.SIGNAL("javaScriptWindowObjectCleared ()"), self.javaScriptWindowObjectCleared)
        self.settings().setAttribute(QtWebKit.QWebSettings.WebAttribute.DeveloperExtrasEnabled, True)
        QtCore.QObject.connect(self.page(), QtCore.SIGNAL('selectionChanged()'), self.selectionChanged)
项目:ECoG-ClusterFlow    作者:sugeerth    | 项目源码 | 文件源码
def __init__(self):
        QtCore.QObject.__init__(self)
项目:ECoG-ClusterFlow    作者:sugeerth    | 项目源码 | 文件源码
def __init__(self):
        QtCore.QObject.__init__(self)
项目:Electrify    作者:jyapayne    | 项目源码 | 文件源码
def find_child_by_name(self, name):
        return self.findChild(QtCore.QObject, name)
项目:Electrify    作者:jyapayne    | 项目源码 | 文件源码
def find_all_children(self, names):
        children = []
        for child in self.find_children(QtCore.QObject):
            if child.object_name() in names:
                children.append(child)

        return children
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def mui_to_qt(self, mui_name):
        if hostMode != "maya":
            return
        ptr = mui.MQtUtil.findControl(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findLayout(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findMenuItem(mui_name)
        if ptr is not None:
            if qtMode in (0,2):
                # ==== for pyside ====
                return shiboken.wrapInstance(long(ptr), QtWidgets.QWidget)
            elif qtMode in (1,3):
                # ==== for PyQt====
                return sip.wrapinstance(long(ptr), QtCore.QObject)
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def mui_to_qt(self, mui_name):
        if hostMode != "maya":
            return
        ptr = mui.MQtUtil.findControl(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findLayout(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findMenuItem(mui_name)
        if ptr is not None:
            if qtMode in (0,2):
                # ==== for pyside ====
                return shiboken.wrapInstance(long(ptr), QtWidgets.QWidget)
            elif qtMode in (1,3):
                # ==== for PyQt====
                return sip.wrapinstance(long(ptr), QtCore.QObject)
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def mui_to_qt(self, mui_name):
        if hostMode != "maya":
            return
        ptr = mui.MQtUtil.findControl(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findLayout(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findMenuItem(mui_name)
        if ptr is not None:
            if qtMode in (0,2):
                # ==== for pyside ====
                return shiboken.wrapInstance(long(ptr), QtWidgets.QWidget)
            elif qtMode in (1,3):
                # ==== for PyQt====
                return sip.wrapinstance(long(ptr), QtCore.QObject)
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def mui_to_qt(self, mui_name):
        ptr = mui.MQtUtil.findControl(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findLayout(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findMenuItem(mui_name)
        if ptr is not None:
            if qtMode == 0:
                # ==== for pyside ====
                return shiboken.wrapInstance(long(ptr), QtGui.QWidget)
            elif qtMode == 1:
                # ==== for PyQt====
                return sip.wrapinstance(long(ptr), QtCore.QObject)
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def main(mode=0):
    parentWin = None
    app = None
    if deskMode == 0:
        if qtMode == 0:
            # ==== for pyside ====
            parentWin = shiboken.wrapInstance(long(mui.MQtUtil.mainWindow()), QtGui.QWidget)
        elif qtMode == 1:
            # ==== for PyQt====
            parentWin = sip.wrapinstance(long(mui.MQtUtil.mainWindow()), QtCore.QObject)
    if deskMode == 1:
        app = QtGui.QApplication(sys.argv)

    # single UI window code, so no more duplicate window instance when run this function
    global single_TMP_UniversalToolUI_TND
    if single_TMP_UniversalToolUI_TND is None:
        single_TMP_UniversalToolUI_TND = TMP_UniversalToolUI_TND(parentWin, mode) # extra note: in Maya () for no parent; (parentWin,0) for extra mode input
    single_TMP_UniversalToolUI_TND.show()

    if deskMode == 1:
        sys.exit(app.exec_())

    # example: show ui stored
    # print(single_TMP_UniversalToolUI_TND.uiList.keys())
    return single_TMP_UniversalToolUI_TND

# If you want to be able to load multiple windows of the same ui in Maya, use code below
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def Establish_Connections(self):
        # loop button and menu action to link to functions
        for ui_name in self.uiList.keys():
            if ui_name.endswith('_btn'):
                QtCore.QObject.connect(self.uiList[ui_name], QtCore.SIGNAL("clicked()"), getattr(self, ui_name[:-4]+"_action", partial(self.default_action,ui_name)))
            if ui_name.endswith('_atn'):
                QtCore.QObject.connect(self.uiList[ui_name], QtCore.SIGNAL("triggered()"), getattr(self, ui_name[:-4]+"_action", partial(self.default_action,ui_name)))
            if ui_name.endswith('_atnMsg') or ui_name.endswith('_btnMsg'):
                QtCore.QObject.connect(self.uiList[ui_name], QtCore.SIGNAL("triggered()"), getattr(self, ui_name[:-7]+"_message", partial(self.default_message,ui_name)))
        QtCore.QObject.connect(self.uiList["dict_table"].horizontalHeader(), QtCore.SIGNAL("sectionDoubleClicked(int)"), self.changeTableHeader)

    #############################################
    # UI Response functions
    ##############################################
    #-- ui actions
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def loadLang(self):
        self.quickMenu(['language_menu;&Language'])
        cur_menu = self.uiList['language_menu']
        self.quickMenuAction('langDefault_atnLang', 'Default','','langDefault.png', cur_menu)
        cur_menu.addSeparator()
        QtCore.QObject.connect( self.uiList['langDefault_atnLang'], QtCore.SIGNAL("triggered()"), partial(self.setLang, 'default') )
        # store default language
        self.memoData['lang']={}
        self.memoData['lang']['default']={}
        for ui_name in self.uiList:
            ui_element = self.uiList[ui_name]
            if type(ui_element) in [ QtGui.QLabel, QtGui.QPushButton, QtGui.QAction, QtGui.QCheckBox ]:
                # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
                self.memoData['lang']['default'][ui_name] = str(ui_element.text())
            elif type(ui_element) in [ QtGui.QGroupBox, QtGui.QMenu ]:
                # uiType: QMenu, QGroupBox
                self.memoData['lang']['default'][ui_name] = str(ui_element.title())
            elif type(ui_element) in [ QtGui.QTabWidget]:
                # uiType: QTabWidget
                tabCnt = ui_element.count()
                tabNameList = []
                for i in range(tabCnt):
                    tabNameList.append(str(ui_element.tabText(i)))
                self.memoData['lang']['default'][ui_name]=';'.join(tabNameList)
            elif type(ui_element) == str:
                # uiType: string for msg
                self.memoData['lang']['default'][ui_name] = self.uiList[ui_name]

        # try load other language
        lang_path = os.path.dirname(self.location) # better in packed than(os.path.abspath(__file__))
        baseName = os.path.splitext( os.path.basename(self.location) )[0]
        for fileName in os.listdir(lang_path):
            if fileName.startswith(baseName+"_lang_"):
                langName = fileName.replace(baseName+"_lang_","").split('.')[0].replace(" ","")
                self.memoData['lang'][ langName ] = self.readRawFile( os.path.join(lang_path,fileName) )
                self.quickMenuAction(langName+'_atnLang', langName.upper(),'',langName + '.png', cur_menu)
                QtCore.QObject.connect( self.uiList[langName+'_atnLang'], QtCore.SIGNAL("triggered()"), partial(self.setLang, langName) )
        # if no language file detected, add export default language option
        if len(self.memoData['lang']) == 1:
            self.quickMenuAction('langExport_atnLang', 'Export Default Language','','langExport.png', cur_menu)
            QtCore.QObject.connect( self.uiList['langExport_atnLang'], QtCore.SIGNAL("triggered()"), self.exportLang )
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def main():
    parentWin = None
    app = None
    if deskMode == 0:
        if qtMode == 0:
            # ==== for pyside ====
            parentWin = shiboken.wrapInstance(long(mui.MQtUtil.mainWindow()), QtGui.QWidget)
        elif qtMode == 1:
            # ==== for PyQt====
            parentWin = sip.wrapinstance(long(mui.MQtUtil.mainWindow()), QtCore.QObject)
    if deskMode == 1:
        app = QtGui.QApplication(sys.argv)

    # single UI window code, so no more duplicate window instance when run this function
    global single_UITranslator
    if single_UITranslator is None:
        single_UITranslator = UITranslator(parentWin) # extra note: in Maya () for no parent; (parentWin,0) for extra mode input
    single_UITranslator.show()

    if deskMode == 1:
        sys.exit(app.exec_())

    # example: show ui stored
    print(single_UITranslator.uiList.keys())
    return single_UITranslator

# If you want to be able to load multiple windows of the same ui, use code below
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def mui_to_qt(self, mui_name):
        if hostMode != "maya":
            return
        ptr = mui.MQtUtil.findControl(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findLayout(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findMenuItem(mui_name)
        if ptr is not None:
            if qtMode in (0,2):
                # ==== for pyside ====
                return shiboken.wrapInstance(long(ptr), QtWidgets.QWidget)
            elif qtMode in (1,3):
                # ==== for PyQt====
                return sip.wrapinstance(long(ptr), QtCore.QObject)
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def mui_to_qt(self, mui_name):
        if hostMode != "maya":
            return
        ptr = mui.MQtUtil.findControl(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findLayout(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findMenuItem(mui_name)
        if ptr is not None:
            if qtMode in (0,2):
                # ==== for pyside ====
                return shiboken.wrapInstance(long(ptr), QtWidgets.QWidget)
            elif qtMode in (1,3):
                # ==== for PyQt====
                return sip.wrapinstance(long(ptr), QtCore.QObject)
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def mui_to_qt(self, mui_name):
        if hostMode != "maya":
            return
        ptr = mui.MQtUtil.findControl(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findLayout(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findMenuItem(mui_name)
        if ptr is not None:
            if qtMode in (0,2):
                # ==== for pyside ====
                return shiboken.wrapInstance(long(ptr), QtWidgets.QWidget)
            elif qtMode in (1,3):
                # ==== for PyQt====
                return sip.wrapinstance(long(ptr), QtCore.QObject)
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def mui_to_qt(self, mui_name):
        if hostMode != "maya":
            return
        ptr = mui.MQtUtil.findControl(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findLayout(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findMenuItem(mui_name)
        if ptr is not None:
            if qtMode in (0,2):
                # ==== for pyside ====
                return shiboken.wrapInstance(long(ptr), QtWidgets.QWidget)
            elif qtMode in (1,3):
                # ==== for PyQt====
                return sip.wrapinstance(long(ptr), QtCore.QObject)
项目:kite    作者:pyrocko    | 项目源码 | 文件源码
def __init__(self, model, source, index):
        QtCore.QObject.__init__(self)
        self.source = source
        self.model = model
        self.index = index
        self.rois = []

        self.editing_dialog = None

        if model.selection_model is not None:
            self.setSelectionModel()

        self.model.selectionModelChanged.connect(self.setSelectionModel)
项目:kite    作者:pyrocko    | 项目源码 | 文件源码
def __init__(self, scene_proxy):
        QtCore.QObject.__init__(self, scene_proxy)
        self.scene_proxy = scene_proxy
项目:freecad-nurbs    作者:microelly2    | 项目源码 | 文件源码
def __init__(self):
        QtCore.QObject.__init__(self)
        self.mouseWheel=0
        self.enterleave=False
        self.enterleave=True
        self.keyPressed2=False
        self.editmode=False
        self.key='x'
        self.posx=-1
        self.posy=-1
        self.lasttime=time.time()
        self.lastkey='#'
项目:pcbre    作者:pcbre    | 项目源码 | 文件源码
def __setattr__(self, key, value):
        if key not in ("changed", "__editing", "__changed"):
            if hasattr(self, key):
                old_value = getattr(self, key)
                if hasattr(old_value, "changed"):
                    old_value.changed.disconnect(self.change)

            if hasattr(value, "changed"):
                value.changed.connect(self.change)

        QtCore.QObject.__setattr__(self, key, value)
项目:pcbre    作者:pcbre    | 项目源码 | 文件源码
def __init__(self, x, y):
        ViewPort.__init__(self, x, y)
        QtCore.QObject.__init__(self)

        self.__current_layer = None
        self.currentLayerChanged.connect(self.changed)
        self.__show_images = True
        self.__draw_other_layers = True
        self.layer_permute = 0
项目:ECoG-ClusterFlow    作者:sugeerth    | 项目源码 | 文件源码
def readFile():
    #Should be swapped with a read of a template
    class JavaScriptObjectToSend(QtCore.QObject):  
        """Simple class with one slot and one read-only property."""  

        @QtCore.Slot(str)  
        def showMessage(self, msg):  
            """Open a message box and display the specified message."""  
            QtGui.QMessageBox.information(None, "Info", msg)  

        def _pyVersion(self):  
            """Return the Python version."""  
            return sys.version  

        """Python interpreter version property."""  
        pyVersion = Property(str, fget=_pyVersion) 

    class jsonObject(QObject):
        def __init__(self,startval=42):
            QObject.__init__(self)
            self.ppval="source"
            self.pp = Property(str,self.readPP,self.setPP)

        @QtCore.Slot(str)  
        def readPP(self,msg):
            return msg,self.ppval

        @QtCore.Slot(str)  
        def setPP(self,val):
            self.ppval = val


    obj = jsonObject()

    basepath = os.path.dirname(os.path.abspath(__file__))
    basepath = str(basepath)+'/'

    win = QtWebKit.QWebView()

    win.setWindowTitle('D3d visualization')
    layout = QtGui.QVBoxLayout()
    win.setLayout(layout)
    myObj = JavaScriptObjectToSend()

    view = QtWebKit.QWebView()
    view.settings().setAttribute(QtWebKit.QWebSettings.LocalContentCanAccessRemoteUrls, True)

    view.page().mainFrame().addToJavaScriptWindowObject("pyObj", myObj)
    view.page().mainFrame().addToJavaScriptWindowObject("jsonObj", obj)  

    view.settings().setAttribute(QtWebKit.QWebSettings.PluginsEnabled, True)
    view.settings().setAttribute(QtWebKit.QWebSettings.WebAttribute.DeveloperExtrasEnabled, True)
    view.settings().setAttribute(QtWebKit.QWebSettings.PrivateBrowsingEnabled, True)

    view.setHtml(html, baseUrl=QtCore.QUrl().fromLocalFile(basepath))
    return view
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def main(mode=0):
    # get parent window in Maya
    parentWin = None
    if hostMode == "maya":
        if qtMode in (0,2): # pyside
            parentWin = shiboken.wrapInstance(long(mui.MQtUtil.mainWindow()), QtWidgets.QWidget)
        elif qtMode in (1,3): # PyQt
            parentWin = sip.wrapinstance(long(mui.MQtUtil.mainWindow()), QtCore.QObject)
    # create app object for certain host
    app = None
    if hostMode in ("desktop", "blender"):
        app = QtWidgets.QApplication(sys.argv)

    #--------------------------
    # ui instance
    #--------------------------
    # template 1 - Keep only one copy of windows ui in Maya
    global single_UITranslator
    if single_UITranslator is None:
        if hostMode == "maya":
            single_UITranslator = UITranslator(parentWin, mode)
        else:
            single_UITranslator = UITranslator()
        # extra note: in Maya () for no parent; (parentWin,0) for extra mode input
    single_UITranslator.show()
    ui = single_UITranslator

    # template 2 - allow loading multiple windows of same UI in Maya
    '''
    if hostMode == "maya":
        ui = UITranslator(parentWin)
        ui.show()
    else:

    # extra note: in Maya () for no parent; (parentWin,0) for extra mode input

    '''

    # loop app object for certain host
    if hostMode in ("desktop"):
        sys.exit(app.exec_())

    return ui
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def main(mode=0):
    # get parent window in Maya
    parentWin = None
    if hostMode == "maya":
        if qtMode in (0,2): # pyside
            parentWin = shiboken.wrapInstance(long(mui.MQtUtil.mainWindow()), QtWidgets.QWidget)
        elif qtMode in (1,3): # PyQt
            parentWin = sip.wrapinstance(long(mui.MQtUtil.mainWindow()), QtCore.QObject)
    # create app object for certain host
    app = None
    if hostMode in ("desktop", "blender"):
        app = QtWidgets.QApplication(sys.argv)

    #--------------------------
    # ui instance
    #--------------------------
    # template 1 - Keep only one copy of windows ui in Maya
    global single_UniversalToolUI
    if single_UniversalToolUI is None:
        if hostMode == "maya":
            single_UniversalToolUI = UniversalToolUI(parentWin, mode)
        else:
            single_UniversalToolUI = UniversalToolUI()
        # extra note: in Maya () for no parent; (parentWin,0) for extra mode input
    single_UniversalToolUI.show()
    ui = single_UniversalToolUI

    # template 2 - allow loading multiple windows of same UI in Maya
    '''
    if hostMode == "maya":
        ui = UniversalToolUI(parentWin)
        ui.show()
    else:

    # extra note: in Maya () for no parent; (parentWin,0) for extra mode input

    '''

    # loop app object for certain host
    if hostMode in ("desktop"):
        sys.exit(app.exec_())

    return ui
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def main(mode=0):
    # get parent window in Maya
    parentWin = None
    if hostMode == "maya":
        if qtMode in (0,2): # pyside
            parentWin = shiboken.wrapInstance(long(mui.MQtUtil.mainWindow()), QtWidgets.QWidget)
        elif qtMode in (1,3): # PyQt
            parentWin = sip.wrapinstance(long(mui.MQtUtil.mainWindow()), QtCore.QObject)
    # create app object for certain host
    app = None
    if hostMode in ("desktop", "blender"):
        app = QtWidgets.QApplication(sys.argv)

    #--------------------------
    # ui instance
    #--------------------------
    # template 1 - Keep only one copy of windows ui in Maya
    global single_UserClassUI
    if single_UserClassUI is None:
        if hostMode == "maya":
            single_UserClassUI = UserClassUI(parentWin, mode)
        else:
            single_UserClassUI = UserClassUI()
        # extra note: in Maya () for no parent; (parentWin,0) for extra mode input
    single_UserClassUI.show()
    ui = single_UserClassUI

    # template 2 - allow loading multiple windows of same UI in Maya
    '''
    if hostMode == "maya":
        ui = UserClassUI(parentWin)
        ui.show()
    else:

    # extra note: in Maya () for no parent; (parentWin,0) for extra mode input

    '''

    # loop app object for certain host
    if hostMode in ("desktop"):
        sys.exit(app.exec_())

    return ui
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def main(mode=0):
    # get parent window in Maya
    parentWin = None
    if hostMode == "maya":
        if qtMode in (0,2): # pyside
            parentWin = shiboken.wrapInstance(long(mui.MQtUtil.mainWindow()), QtWidgets.QWidget)
        elif qtMode in (1,3): # PyQt
            parentWin = sip.wrapinstance(long(mui.MQtUtil.mainWindow()), QtCore.QObject)
    # create app object for certain host
    app = None
    if hostMode in ("desktop", "blender"):
        app = QtWidgets.QApplication(sys.argv)

    #--------------------------
    # ui instance
    #--------------------------
    # template 1 - Keep only one copy of windows ui in Maya
    global single_UniversalToolUI
    if single_UniversalToolUI is None:
        if hostMode == "maya":
            single_UniversalToolUI = UniversalToolUI(parentWin, mode)
        else:
            single_UniversalToolUI = UniversalToolUI()
        # extra note: in Maya () for no parent; (parentWin,0) for extra mode input
    single_UniversalToolUI.show()
    ui = single_UniversalToolUI

    # template 2 - allow loading multiple windows of same UI in Maya
    '''
    if hostMode == "maya":
        ui = UniversalToolUI(parentWin)
        ui.show()
    else:

    # extra note: in Maya () for no parent; (parentWin,0) for extra mode input

    '''

    # loop app object for certain host
    if hostMode in ("desktop"):
        sys.exit(app.exec_())

    return ui