当前位置: 首页>>代码示例>>Python>>正文


Python QDeclarativeView.engine方法代码示例

本文整理汇总了Python中PySide.QtDeclarative.QDeclarativeView.engine方法的典型用法代码示例。如果您正苦于以下问题:Python QDeclarativeView.engine方法的具体用法?Python QDeclarativeView.engine怎么用?Python QDeclarativeView.engine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PySide.QtDeclarative.QDeclarativeView的用法示例。


在下文中一共展示了QDeclarativeView.engine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MainWindow

# 需要导入模块: from PySide.QtDeclarative import QDeclarativeView [as 别名]
# 或者: from PySide.QtDeclarative.QDeclarativeView import engine [as 别名]

#.........这里部分代码省略.........
    def create_user(self):
        params = urllib.urlencode({'user[name]': self.curVars.user_name, 'user[email]': self.curVars.email, 'user[password]': self.curVars.password, 'user[password_confirmation]' : self.curVars.password_confirm})
        result = os.popen('curl -i -s -k --connect-timeout 10 '+ CONTROL_PANEL_URL_SSL + '/users.xml -d \"'+params+'\"').read().strip()

        if result.find("<key>") != -1:
            self.get_api_key(result)
            self.curVars.device_key = ""
        elif result.find("Email has already been taken") != -1:
            self.rootO.show_alert("Email has already been taken", "That email address already exists! If you signed up previously, please go back and select the Existing User option.",False)
            return
        else:
            self.rootO.show_alert("Couldn't create user!", "There was a problem creating your account. Please make sure the email address you entered is valid, as well as your password.",False)
            return

        self.apply_control_panel_settings()
        self.run_prey()
        self.rootO.show_alert("Account created!", "Your account has been succesfully created and configured in Prey's Control Panel.\n\nPlease check your inbox now, you should have received a verification email.", True)

    @Slot(bool, result=bool)
    def get_existing_user(self, show_devices):
        email = self.curVars.email
        password = self.curVars.password
        print email+' '+password
        result = os.popen('curl -i -s -k --connect-timeout 10 '+ CONTROL_PANEL_URL_SSL + '/profile.xml -u '+email+":'"+password+"'").read().strip()

        if result.find('401 Unauthorized') != -1:
            self.rootO.show_alert("User does not exist", "Couldn't log you in. Remember you need to activate your account opening the link we emailed you.\n\nIf you forgot your password please visit preyproject.com.",False)
            return False

        if result.find("<user>") != -1:
            self.get_api_key(result)
        else:
            self.report_connection_issue(result)
            return False

        has_available_slots = self.user_has_available_slots(result)
        if not has_available_slots and not show_devices:
            self.rootO.show_alert("Not allowed",  "It seems you've reached your limit for devices!\n\nIf you had previously added this PC, you should select the \"Device already exists\" option to select the device from a list of the ones you have already created.\n\nIf this is a new device, you can also upgrade to a Pro Account to increase your slot count and get access to additional features. For more information, please check\nhttp://preyproject.com/plans.",False)
            return False

        if show_devices:
            result = os.popen('curl -i -s -k --connect-timeout 10 '+ CONTROL_PANEL_URL_SSL + '/devices.xml -u '+email+":'"+password+"'").read().strip()
            if result.find("</devices>") != -1:
                return self.get_device_keys(result,has_available_slots)
            else:
                self.report_connection_issue(result)
                return False
        else:
            self.curVars.device_key = ""
            self.apply_control_panel_settings()
            self.exit_configurator()

    @Slot(int)
    def apply_device_settings(self,index):
        self.curVars.device_key = self.deviceKeys[index]
        self.apply_control_panel_settings()
        self.exit_configurator()




    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        # Create the Qt Application
        self.app = QApplication(["Prey-Config"])
        self.app.setWindowIcon(QIcon(''))
        self.view = QDeclarativeView()
        #self.setWindowTitle("Main Window")

        #get rootContext of QDeclarativeView
        self.context = self.view.rootContext()
        #make this class available to QML files as 'main' context
        self.context.setContextProperty('main', self)
        #create variables
        self.curVars = Vars()
        #make curVars available to QML files as 'vars' context
        self.context.setContextProperty('vars', self.curVars)
        # QML resizes to main window
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        # Renders './qml/main.qml'
        self.view.setSource(QUrl.fromLocalFile('./qml/main.qml'))
        #get rootObject
        self.rootO = self.view.rootObject()

        #connect quit signal
        self.view.engine().quit.connect(self.quit_app)

        #check for prey installation, write acess to config file, and configurationstatus
        if self.prey_exists():
            if self.is_config_writable():
                self.get_current_settings()
                if self.check_if_configured() == False:
                    self.rootO.show_alert('Welcome!',"It seems this is the first time you run this setup. Please set up your reporting method now, otherwise Prey won't work!",False)
                    #os.system('(/opt/cron/bin/crontab -l | tail -n+4 | grep -v prey; echo "*/30 * * * * aegis-exec -s /opt/prey/prey.sh > /var/log/prey.log") | /opt/cron/bin/crontab -')

 
 
    def quit_app(self):
        self.view.hide()
        self.app.exit()
开发者ID:student4life,项目名称:meePrey,代码行数:104,代码来源:prey-config.py

示例2: QApplication

# 需要导入模块: from PySide.QtDeclarative import QDeclarativeView [as 别名]
# 或者: from PySide.QtDeclarative.QDeclarativeView import engine [as 别名]
#!/usr/bin/python

import sys
from PySide.QtCore import *
from PySide.QtGui import *
from PySide.QtDeclarative import QDeclarativeView
from PySide.QtDeclarative import QDeclarativeEngine

app = QApplication(sys.argv)
view = QDeclarativeView()
url = QUrl('MemoGame.qml')
view.setSource(url)
QObject.connect(view.engine(), SIGNAL('quit()'), app, SLOT('quit()'))
view.show()

app.exec_()
开发者ID:kirotawa,项目名称:KanjiMemoGame,代码行数:18,代码来源:kanjimemogame.py

示例3: QApplication

# 需要导入模块: from PySide.QtDeclarative import QDeclarativeView [as 别名]
# 或者: from PySide.QtDeclarative.QDeclarativeView import engine [as 别名]
from PySide.QtCore import QUrl
from PySide.QtGui import QApplication
from PySide.QtDeclarative import QDeclarativeView
import sys

from device_model import DeviceListModel
from service_model import ServiceListModel
from device_manager import DeviceManager

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

    view = QDeclarativeView()
    engine = view.engine()
    engine.quit.connect(app.quit)

    if len(sys.argv) > 1:
        manager = DeviceManager(sys.argv[1])
    else:
        manager = DeviceManager()

    deviceListModel = DeviceListModel(manager)
    serviceListModel = ServiceListModel()
    deviceListModel.deviceSelected.connect(serviceListModel.loadDevice)

    view.rootContext().setContextProperty("deviceManager", manager)
    view.rootContext().setContextProperty("deviceListModel", deviceListModel)
    view.rootContext().setContextProperty("serviceListModel", serviceListModel)

    context = view.rootContext()
开发者ID:renatofilho,项目名称:BluezApp,代码行数:33,代码来源:main.py


注:本文中的PySide.QtDeclarative.QDeclarativeView.engine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。