本文整理汇总了Python中PyQt5.QtQuick.QQuickView.setResizeMode方法的典型用法代码示例。如果您正苦于以下问题:Python QQuickView.setResizeMode方法的具体用法?Python QQuickView.setResizeMode怎么用?Python QQuickView.setResizeMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtQuick.QQuickView
的用法示例。
在下文中一共展示了QQuickView.setResizeMode方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LoginWin
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setResizeMode [as 别名]
class LoginWin(QtCore.QObject):
def __init__(self, state, app):
QtCore.QObject.__init__(self)
self.state = state
self.app = app
# Create the QML user interface.
self.login_win = QQuickView()
self.login_win.setTitle(self.tr("Xiami Login"))
self.login_win.setSource(QUrl('login.qml'))
self.login_win.setResizeMode(QQuickView.SizeRootObjectToView)
self.login_win.show()
# Connect signals
self.root_obj = self.login_win.rootObject()
self.root_obj.loginClicked.connect(self.login_clicked)
self.root_obj.exitClicked.connect(self.exit_clicked)
def set_state(self, msg):
self.root_obj.setStatus(msg)
def exit_clicked(self):
sys.exit(0)
def login_clicked(self, username, password):
code = self.root_obj.getVerificationCode()
if code != "":
try:
login.login_with_code(self.state, self.key, code)
except Exception as e:
self.set_state(e.message)
self.root_obj.hideCode()
return
self.ok()
else:
try:
ret = login.login(self.state, username, password)
except Exception as e:
self.set_state(e.message)
return
if not ret[0]:
with open(login.img_path, 'wb') as imgf:
imgf.write(ret[2])
self.set_state(self.tr("Please enter verification code"))
self.root_obj.setVerificationImage("file://%s"
% login.img_path)
self.key = ret[1]
else:
self.ok()
def ok(self):
self.login_win.close()
self.app.auth_ok()
示例2: __init__
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setResizeMode [as 别名]
def __init__(self):
super(QmlStartPage, self).__init__()
box = QVBoxLayout(self)
box.setContentsMargins(0, 0, 0, 0)
# View
view = QQuickView()
view.setSource(QUrl.fromLocalFile(PATH_QML))
view.setResizeMode(QQuickView.SizeRootObjectToView)
# Root object
self._root = view.rootObject()
widget_container = QWidget.createWindowContainer(view)
box.addWidget(widget_container)
self._root.animationFinished.connect(self._on_animation_finished)
示例3: TabletShortcuts
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setResizeMode [as 别名]
class TabletShortcuts(QGuiApplication):
def __init__(self, argv):
QGuiApplication.__init__(self, argv)
self.view = QQuickView()
self.bus = QDBusConnection.sessionBus()
self.server = MyDBUSServer(self)
self.bus.registerObject("/app", self.server)
self.bus.registerService("sevanteri.TabletShortcuts")
self.view.setTitle("TabletShortcuts")
self.view.setResizeMode(QQuickView.SizeRootObjectToView)
self.view.setSource(QUrl('main.qml'))
self.root = self.view.rootObject()
self.showView()
self.root.runCommand.connect(self.run)
self.root.hideView.connect(self.view.hide)
self.view.engine().quit.connect(self.quit)
def run(self, cmd):
return Popen(shlex.split(cmd))
def quit(self):
self.exit()
def showView(self):
if self.view.isVisible():
self.view.hide()
else:
# width, height = TabletShortcuts.getScreenGeometry()
# self.view.setGeometry(1, 1, width, height)
self.view.show()
def getScreenGeometry():
output = Popen("xrandr | grep 'current'", shell=True, stdout=PIPE)\
.communicate()[0].decode('UTF-8')
m = re.search('current.([0-9]+).x.([0-9]+)', output)
width = int(m.group(1))
height = int(m.group(2))
return (width, height)
示例4: __init__
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setResizeMode [as 别名]
def __init__(self):
super(StartPage, self).__init__()
vbox = QVBoxLayout(self)
vbox.setContentsMargins(0, 0, 0, 0)
view = QQuickView()
qml = os.path.join(settings.QML_PATH, "StartPage.qml")
view.setSource(QUrl.fromLocalFile(qml))
view.setResizeMode(QQuickView.SizeRootObjectToView)
widget = QWidget.createWindowContainer(view)
vbox.addWidget(widget)
self.__root = view.rootObject()
# Connections
self.__root.openDatabase.connect(self.__open_database)
self.__root.newDatabase.connect(self.__new_database)
self.__root.removeCurrent.connect(self.__remove_current)
示例5: __init__
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setResizeMode [as 别名]
def __init__(self, parent=None):
super(MessageError, self).__init__(parent,
Qt.Dialog | Qt.FramelessWindowHint)
self._parent = parent
self.setModal(True)
self.setFixedHeight(150)
self.setFixedWidth(350)
box = QVBoxLayout(self)
box.setContentsMargins(0, 0, 0, 0)
view = QQuickView()
qml = os.path.join(settings.QML_PATH, "MessageError.qml")
view.setSource(QUrl.fromLocalFile(qml))
view.setResizeMode(QQuickView.SizeRootObjectToView)
self.widget = QWidget.createWindowContainer(view)
box.addWidget(self.widget)
self._root = view.rootObject()
self._root.close.connect(self.close)
示例6: run_app
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setResizeMode [as 别名]
def run_app():
app = QGuiApplication(sys.argv)
app.setApplicationName("Worship Prototype")
view = QQuickView()
view.setResizeMode(QQuickView.SizeRootObjectToView)
view.setSource(QUrl.fromLocalFile(os.path.join(os.path.dirname(__file__), 'main.qml')))
view.show()
root = view.rootObject()
preview = DefaultScreen()
preview.wire_to_gui(root, 'previewScreen')
preview.show_background(VideoBackground(os.path.join(os.path.dirname(__file__), '../echo.mp4')))
# preview_live = DefaultScreen()
# live = DefaultScreen()
modules = [
LyricsModule(SongsList(), root, preview),
]
sys.exit(app.exec_())
示例7: QVariant
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setResizeMode [as 别名]
return animal.type()
if role == self.SizeRole:
return animal.size()
return QVariant()
def roleNames(self):
return self._roles
if __name__ == '__main__':
import sys
app = QGuiApplication(sys.argv)
model = AnimalModel()
model.addAnimal(Animal("Wolf", "Medium"))
model.addAnimal(Animal("Polar bear", "Large"))
model.addAnimal(Animal("Quoll", "Small"))
view = QQuickView()
view.setResizeMode(QQuickView.SizeRootObjectToView)
ctxt = view.rootContext()
ctxt.setContextProperty('myModel', model)
view.setSource(QUrl('qrc:view.qml'))
view.show()
sys.exit(app.exec_())
示例8: import
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setResizeMode [as 别名]
# -*- coding: utf-8 -*-
import os, sys, re
from PyQt5.QtNetwork import *
from fboinsgrenderer import *
from textureinsgnode_rc import *
from PyQt5.QtGui import QSurfaceFormat
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import (QVariant, QUrl, QDir, QSortFilterProxyModel, pyqtProperty, QSize,
Q_ENUMS, QObject, QRegExp, QAbstractItemModel, pyqtSignal, Qt, QModelIndex, QByteArray)
from PyQt5.QtQml import (QQmlApplicationEngine, QQmlEngine, QQmlFileSelector, qmlRegisterType,
QQmlParserStatus, QJSValue)
from PyQt5.QtQuick import QQuickView, QQuickItem, QQuickWindow
if __name__ == '__main__':
app = QApplication(sys.argv)
qmlRegisterType(FboInSGRenderer, "SceneGraphRendering", 1, 0, "Renderer")
widgetWindow = QQuickView()
widgetWindow.setResizeMode(QQuickView.SizeRootObjectToView)
widgetWindow.setSource(QUrl("qrc:///main.qml"))
widgetWindow.show()
sys.exit(app.exec_())
示例9: P2CQMLApplication
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setResizeMode [as 别名]
class P2CQMLApplication(QGuiApplication):
def __init__(self, list_of_str):
super().__init__(list_of_str)
self._current_category = None
self._current_torrent = None
self._current_torrent_info = None
self._status_timer = QTimer(self)
self._movies_thread = None
self._search_thread = None
def run_view(self):
self._view = QQuickView()
self._view.engine().addImportPath("qml")
self._rctx = self._view.rootContext()
self._view.setResizeMode(QQuickView.SizeRootObjectToView)
# set context variables
self.categories = []
self._rctx.setContextProperty("categoriesModel", self.categories)
self.tiles = []
self.torrents = []
self._rctx.setContextProperty("moviesModel", self.tiles)
self._set_loading(False)
self._view.setSource(QUrl('qrc:/qml.qml'))
self._view.showFullScreen()
# self._view.show()
def connect_daemon(self, daemon: P2CDaemon):
self._daemon = daemon
self._set_categories()
self._connect_signals()
def play(self, movie: Movie):
self._set_movie_status("Ready to play!")
self._set_media(movie)
self._daemon.play(movie)
self._set_additional_media_info()
def buffer(self, movie: Movie):
seconds = self._current_torrent.get_seconds_to_buffer()
info = "just started"
if seconds:
if seconds < 15:
info = "just a moment"
else:
# rount to minutes
minutes = int(seconds / 60) + 1
if minutes == 1:
info = "1 minute"
else:
info = "{} minutes".format(minutes)
self._set_movie_status("Buffering... ({})".format(info))
self._daemon.buffer(movie)
self._set_additional_media_info()
def wait_for_metadata(self):
self._set_movie_status("Getting metadata...")
if self._current_torrent:
self._set_additional_media_info(self._current_torrent.name)
def select_movie(self, torrent: Torrent) -> Movie:
movies = torrent.get_movies()
if len(movies) == 0:
return
# TODO: show dialog with movie selecting instead of doing it automatically
return max(movies, key=lambda x: x.size)
def update_status(self):
torrent = self._current_torrent
if torrent:
if(torrent.has_torrent_info()):
movie = self.select_movie(torrent)
if not movie:
self._set_movie_status("No movie in this torrent. Please, select another.")
return
torrent.download_file(movie.path)
self._set_duration(movie)
if not self._daemon.is_playing(movie):
if(movie.can_play()):
# print(movie.get_subtitles())
self.play(movie)
else:
self.buffer(movie)
### DEBUG INFO
text = "s: %s, num p: %s, rate: %s kbs, p_rate: %s kbs" % (
torrent.get_status()['state'],
torrent.get_status()['num_peers'],
int(torrent.get_status()['download_rate'] / 1024),
int(torrent.get_status()['download_payload_rate'] / 1024),
)
self._view.rootObject().setProperty("debugText", text)
### END DEBUG INFO
else:
self.wait_for_metadata()
else:
self.wait_for_metadata()
#.........这里部分代码省略.........
示例10: View
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setResizeMode [as 别名]
class View(object):
shapes = ["rectangle", "ellipse", "image"]
edgetypes = ["line", "curve"]
def __init__(self):
self._controller = Controller(self)
self._gui = QGuiApplication(sys.argv)
self._qml_dir = os.path.dirname(os.path.realpath(__file__))
self._main = QQuickView()
self._main.setResizeMode(QQuickView.SizeRootObjectToView)
self._main.setSource(QUrl(self._qml_dir + '/main.qml'))
self._main.rootObject().create_node.connect(
self._controller.create_node)
self._main.rootObject().mouse_position.connect(
self._controller.mouse_position)
self._main.rootObject().save.connect(
self._controller.save)
self._main.rootObject().load.connect(
self._controller.load)
self._main.rootObject().lose_focus.connect(
self._controller.lose_focus)
self._main.rootObject().node_color_sel.connect(
self._controller.node_color_sel)
self._main.rootObject().edge_color_sel.connect(
self._controller.edge_color_sel)
self._main.rootObject().workspace_height_changed.connect(
self._controller.workspace_height_changed)
self._main.rootObject().workspace_width_changed.connect(
self._controller.workspace_width_changed)
self._main.rootObject().edge_type_sel.connect(
self._controller.edge_type_sel)
self._main.rootObject().node_shape_sel.connect(
self._controller.node_shape_sel)
self._main.rootObject().clear_workspace.connect(
self._controller.clear_workspace)
self._main.rootObject().node_width_changed.connect(
self._controller.node_width_changed)
self._main.rootObject().node_height_changed.connect(
self._controller.node_height_changed)
self._main.rootObject().node_text_color_sel.connect(
self._controller.node_text_color_sel)
self._main.rootObject().node_text_size_changed.connect(
self._controller.node_text_size_changed)
self._main.rootObject().edge_thickness_changed.connect(
self._controller.edge_thickness_changed)
self._main.rootObject().show_edge_controls.connect(
self._controller.show_edge_controls)
self._main.rootObject().hide_edge_controls.connect(
self._controller.hide_edge_controls)
self._main.rootObject().exporting.connect(
self._controller.exporting)
self._main.setProperty(
"width", self._controller.project.workspace_width)
self._main.setProperty(
"height", self._controller.project.workspace_height)
self._main.show()
def run(self):
return self._gui.exec_()
def create_node(self, node):
# Creates new node from source QML and puts it inside of main window
qml_node = QQuickView(QUrl(self._qml_dir + '/shapes/' +
self.shapes[node.shape] + '.qml'),
self._main)
workspace = self._main.rootObject().findChild(QQuickItem, "workspace")
# Sets all properties
qml_node.rootObject().setProperty("parent", workspace)
qml_node.rootObject().setProperty("objectId", str(node.id))
qml_node.rootObject().setProperty("background",
str(node.background))
qml_node.rootObject().setProperty("width", str(node.width))
qml_node.rootObject().setProperty("height", str(node.height))
qml_node.rootObject().setProperty("text", str(node.text.text))
qml_node.rootObject().setProperty("textFont", str(node.text.font))
qml_node.rootObject().setProperty("textSize", str(node.text.size))
qml_node.rootObject().setProperty("textColor", str(node.text.color))
# Sets drag boundaries
qml_node.rootObject().setProperty("workspaceWidth",
str(workspace.property("width")))
qml_node.rootObject().setProperty("workspaceHeight",
str(workspace.property("height")))
# Signal connection
qml_node.rootObject().node_delete.connect(
self._controller.node_delete)
qml_node.rootObject().node_text_changed.connect(
self._controller.node_text_changed)
qml_node.rootObject().node_position_changed.connect(
self._controller.node_position_changed)
qml_node.rootObject().node_connect.connect(
self._controller.node_connect)
qml_node.rootObject().node_focus.connect(
self._controller.node_focus)
#.........这里部分代码省略.........