本文整理汇总了Python中PyQt4.QtDeclarative.QDeclarativeView.engine方法的典型用法代码示例。如果您正苦于以下问题:Python QDeclarativeView.engine方法的具体用法?Python QDeclarativeView.engine怎么用?Python QDeclarativeView.engine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtDeclarative.QDeclarativeView
的用法示例。
在下文中一共展示了QDeclarativeView.engine方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from PyQt4.QtDeclarative import QDeclarativeView [as 别名]
# 或者: from PyQt4.QtDeclarative.QDeclarativeView import engine [as 别名]
def run(self):
app = QApplication(sys.argv)
imageProvider = ImageProvider()
# Create the QML user interface.
view = QDeclarativeView()
view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
engine = view.engine()
engine.addImageProvider("mazakodron", imageProvider)
view.setSource(QUrl('symulator/mazakodron.qml'))
rootObject = view.rootObject()
if not rootObject:
view.setSource(QUrl('mazakodron.qml'))
rootObject = view.rootObject()
rootObject.requestDraw.connect(imageProvider.draw)
self.rootObject = rootObject
view.setGeometry(0, 0, 800, 600)
view.show()
timer = QTimer()
timer.start(1000/60) # 60FPS
timer.timeout.connect(self.process)
sys.exit(app.exec_());
示例2: main
# 需要导入模块: from PyQt4.QtDeclarative import QDeclarativeView [as 别名]
# 或者: from PyQt4.QtDeclarative.QDeclarativeView import engine [as 别名]
def main():
os.chdir(sys.path[0])
app = QApplication(sys.argv)
canvas = QDeclarativeView()
canvas.setFixedSize(360, 500)
canvas.setWindowTitle('Ubezee - Lock Your System')
icon = QIcon()
icon.addPixmap(QPixmap('qml/images/UbezeeIcon.png'), QIcon.Normal, QIcon.Off)
canvas.setWindowIcon(QIcon(icon))
qr = canvas.frameGeometry()
cp = QDesktopWidget().availableGeometry().center()
qr.moveCenter(cp)
canvas.move(qr.topLeft())
engine = canvas.engine()
element = MyElement()
engine.rootContext().setContextObject(element)
canvas.setSource(QUrl.fromLocalFile('qml/Ubezee.qml'))
engine.quit.connect(app.quit)
canvas.setResizeMode(QDeclarativeView.SizeRootObjectToView)
canvas.show()
sys.exit(app.exec_())
示例3: QApplication
# 需要导入模块: from PyQt4.QtDeclarative import QDeclarativeView [as 别名]
# 或者: from PyQt4.QtDeclarative.QDeclarativeView import engine [as 别名]
home = path.expanduser("~")
app = QApplication(sys.argv)
app.setGraphicsSystem("raster")
app.setWindowIcon(QIcon('qml/img/encode.png'))
defaultBgColor=app.palette().color(QPalette.Window).name()
Plasma.Theme.defaultTheme().setUseGlobalSettings(False)
Plasma.Theme.defaultTheme().setThemeName("AirNeptune")
#Plasma::Theme::defaultTheme()->setUseGlobalSettings(false); //don't change every plasma theme!
#Plasma::Theme::defaultTheme()->setThemeName("appdashboard");
# Create the QML user interface.
view = QDeclarativeView()
# Use PlasmaComponents
engine = view.engine()
engine.addImportPath("/usr/lib/kde4/imports")
# Set main qml here
view.setSource(QUrl("3ncode.qml"))
view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
# Get the root object of the user interface.
rootObject = view.rootObject()
# Set default background
rootObject.setBgColor(defaultBgColor)
# Check for parameters
if len(sys.argv) > 1:
openF(str(sys.argv[1]).decode('utf-8'))
示例4: QApplication
# 需要导入模块: from PyQt4.QtDeclarative import QDeclarativeView [as 别名]
# 或者: from PyQt4.QtDeclarative.QDeclarativeView import engine [as 别名]
if size is not None:
size = self.gameMap.size
if 'background' in id:
return self._requestBackground(id)
elif 'attack' in id:
return self._requestAttack(id)
app = QApplication(sys.argv)
if len(app.arguments()) > 1:
mapName = app.arguments()[1]
else:
mapName = 'world'
view = QDeclarativeView()
provider = MapImageProvider(mapName)
view.engine().addImageProvider('map', provider)
view.setSource(QUrl('main.qml'))
view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
root = view.rootObject()
for country in xrange(1, provider.gameMap.countries + 1):
x, y = provider.gameMap.center[country]
root.addCountry.emit(country, x, y)
provider.setPlayerColor(1, QColor(Qt.green))
provider.setPlayerColor(2, QColor(Qt.red))
provider.setPlayerColor(3, QColor(Qt.blue))
for country in xrange(1, provider.gameMap.countries + 1):
player = random.randint(1, 3)
color = provider.gameMap.color[player].darker()