def main(): global dbus parser = ArgumentParser() parser.add_argument("-v", "--verbose", help="increase output verbosity", action="store_true") args = parser.parse_args() QtQml.qmlRegisterType(QmlPage, "djpdf", 1, 0, "DjpdfPage") app = QApplication([]) engine = QQmlApplicationEngine() thumbnail_image_provider = ThumbnailImageProvider() engine.addImageProvider("thumbnails", thumbnail_image_provider) ctx = engine.rootContext() pages_model = QmlPagesModel(verbose=args.verbose) if os.environ.get("DJPDF_PLATFORM_INTEGRATION", "") == "flatpak": import dbus import dbus.mainloop.glib dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) bus = dbus.SessionBus() platform_integration = QmlFlatpakPlatformIntegration(bus) else: platform_integration = QmlPlatformIntegration() ctx.setContextProperty("pagesModel", pages_model) ctx.setContextProperty("platformIntegration", platform_integration) engine.load(QUrl.fromLocalFile( os.path.join(QML_DIR, "main.qml"))) if os.environ.get("DJPDF_PLATFORM_INTEGRATION", "") == "flatpak": platform_integration.win_id = engine.rootObjects()[0].winId() exit(app.exec_())
def main(): global _bi _bi = Bi() op_init() app = QtGui.QGuiApplication(sys.argv) screens = QtGui.QGuiApplication.screens() for screen in screens: screen.setOrientationUpdateMask(Qt.LandscapeOrientation | Qt.PortraitOrientation | Qt.InvertedLandscapeOrientation | Qt.InvertedPortraitOrientation) QQuickWindow.setDefaultAlphaBuffer(True) engine = QtQml.QQmlApplicationEngine() engine.rootContext().setContextProperty('bi', _bi) engine.load(QtCore.QUrl.fromLocalFile(f'{CURRENT_DIR}/window.qml')) if not engine.rootObjects(): return -1 # https://wiki.qt.io/Qt_for_Python_Signals_and_Slots app.aboutToQuit.connect(op_exit) return app.exec_()
def main(): QtCore.QCoreApplication #subprocess.run(['xset', '-dpms']) subprocess.run(['xset', 's', 'off', '-dpms']) app = QtWidgets.QApplication(sys.argv) QtWebEngine.QtWebEngine.initialize() engine = QtQml.QQmlApplicationEngine() settings = settingsController() try: settings.check() settings.load() except: subprocess.run([ 'x-terminal-emulator', '-T', settings.system_id, '-geometry', '146x80', '-e', 'sudo nmtui' ]) exit(403) t = threading.Thread(target=settings.while_touch) t.daemon = True t.start() printer = printController(settings.settings, settings) ctx = engine.rootContext() ctx.setContextProperty('KioskPrinter', printer) ctx.setContextProperty('KioskSettings', settings) engine.load(QtCore.QUrl("qrc:/Kiosk.qml")) c = app.exec_() content.resource.qCleanupResources() return c
return self.y = newY self.handYChanged.emit() @qtc.Property(float, notify=handZChanged) def handZ(self): return self.z @handZ.setter def setZ(self, newZ): # Do not emit a changed signal if the icon is the same if self.z == newZ: return self.z = newZ self.handZChanged.emit() if __name__ == '__main__': # Initializes the app, engine, and classes app = qtg.QGuiApplication(sys.argv) engine = qtm.QQmlApplicationEngine() root_context = engine.rootContext() handgest = HandGest() root_context.setContextProperty('handgest', handgest) engine.load(qtc.QUrl.fromLocalFile('../test.qml')) sys.exit(app.exec_())
import sys from PySide2 import QtCore as qtc, QtWidgets as qtw, QtGui as qtgui, QtQml as qtqml from main import Main if __name__ == "__main__": # Set attributes qtw.QApplication.setAttribute(qtc.Qt.AA_EnableHighDpiScaling) qtc.QCoreApplication.setAttribute(qtc.Qt.AA_UseHighDpiPixmaps) # Define application app = qtw.QApplication(sys.argv) app.setOrganizationName("Yeahlowflicker Production") # Define engine engine = qtqml.QQmlApplicationEngine() manager = Main(engine) engine.load(qtc.QUrl("/mnt/YFP/Projects/PRJ000-Simple-Text-Editor/proj/main.qml")) # Exit handler sys.exit(app.exec_())
def register_qml_types(): QtQml.qmlRegisterType(DeviceInfo, 'DeviceConfig', 1, 0, 'DeviceInfo') QtQml.qmlRegisterType(DeviceInfoList, 'DeviceConfig', 1, 0, 'DeviceInfoList')
def register_qml_types(): QtQml.qmlRegisterType(CameraPreview, 'DeviceModels', 1, 0, 'CameraPreview')
def register_qml_types(): for cls in MODEL_CLASSES: QtQml.qmlRegisterType(cls, 'MidiModels', 1, 0, cls.__name__)
# from PySide2.QtCore import QUrl, qDebug, QObject, Signal, Property, Slot # from PySide2.QtGui import QGuiApplication, QOpenGLFramebufferObjectFormat, QOpenGLFramebufferObject # from PySide2.QtQml import qmlRegisterType, QQmlApplicationEngine # from PySide2.QtQuick import QQuickItem, QQuickView, QQuickFramebufferObject # from PySide2.QtWidgets import QApplication from PySide2 import QtCore, QtGui, QtQuick, QtQml import squircle import os, sys if __name__ == '__main__': app = QtGui.QGuiApplication(sys.argv) QtQml.qmlRegisterType(squircle.Squircle, "OpenGLUnderQML", 1, 0, "Squircle") view = QtQuick.QQuickView() view.setResizeMode(QtQuick.QQuickView.SizeRootObjectToView) view.setSource(QtCore.QUrl("resources//main2.qml")) view.show() sys.exit(app.exec_())
pos = invt * invt * invt * self._p1 + 3 * invt * invt * t * self._p2 + 3 * invt * t * t * self._p3 + t * t * t * self._p4 x = pos.x() * itemSize.width() y = pos.y() * itemSize.height() verts[x].set(x, y) node.markDirty(QtQuick.QSGNode.DirtyGeometry) return node # Property p1 = QtCore.Property(QtCore.QPointF, p1, setP1, notify=p1Changed) p2 = QtCore.Property(QtCore.QPointF, p2, setP1, notify=p2Changed) p3 = QtCore.Property(QtCore.QPointF, p3, setP1, notify=p3Changed) p4 = QtCore.Property(QtCore.QPointF, p4, setP1, notify=p4Changed) segmentCount = QtCore.Property(int, segmentCount, setSegmentCount, notify=segmentCountChanged) if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv[1:]) QtQml.qmlRegisterType(CurveItem, "CustomGeometry", 1, 0, 'BezierCurve') view = QtQuick.QQuickView() surface = view.format() surface.setSamples(16) view.setFormat(surface) view.engine().addImportPath(os.path.dirname(__file__)) view.setSource('resource\\main2.qml') view.show() sys.exit(app.exec_())
def run(): # Sets path of QML files qml_path = "" if os.path.isdir(sys.path[0] + "/qml"): qml_path = sys.path[0] + "/qml" else: qml_path = sys.path[0] + "/../qml" # Create a Qt Application object from the system arguments app = QtWidgets.QApplication(sys.argv) # Set the application icon app.setWindowIcon(QtGui.QIcon("assets/img/icon.png")) # Enable material design in the app os.environ["QT_QUICK_CONTROLS_STYLE"] = "Material" # When the SIGINT signal is received, exit signal.signal(signal.SIGINT, signal.SIG_DFL) # Creates an engine for the application to run under engine = QtQml.QQmlApplicationEngine() # A function to start the main part of the program. # It is conditionally executed based on if the program # has been started before. def start_main(): # Access the global proc and app vars # Load in the config config.load() # Prep the engine (see views.main) views.main.prep_engine(engine, qml_path) # Get the list of root objects: n = engine.rootObjects() # If there are more than one objects in the list, use the second one. # This occurs when the wizard is shown first. if len(n) > 1: root = engine.rootObjects()[1] else: # Else, show the first one root = engine.rootObjects()[0] # Establish all the properties from the config nameProp = QtQml.QQmlProperty(root, "name") schoolProp = QtQml.QQmlProperty(root, "school") hostProp = QtQml.QQmlProperty(root, "hostname") nameProp.write(config.user["firstName"] + " " + config.user["lastName"]) schoolProp.write(config.user["school"]) hostProp.write(config.hostname) # Show the root window root.show() # And execute the application proc = app.exec_() # Register this client to the main server network.register_client() # A function to start the wizard # Again, it is conditionally executed. def start_wizard(): global proc # A function to start the main application from the wizard: def start_main_from_wizard(root): # Close the main window root.close() # and execute start_main start_main() # Load in the interface so it is accessible from QML context = engine.rootContext() engine.load(qml_path + "/wizard/wizard.qml") interface = WizardInterface(lambda: start_main_from_wizard(root)) root = engine.rootObjects()[0] context.setContextProperty("wizardInterface", interface) # Bind user_created to onUserCreated interface.user_created.connect(root.onUserCreated) # And execute the application proc = app.exec_() # If the config file exists, show the main window, if not, show the wizard. if config.exists(): start_main() else: start_wizard() # Exit python when the app starts sys.exit()
# Use render loop that supports persistent 60fps os.environ['QSG_RENDER_LOOP'] = 'windows' # Create QML components from Python classes # major_version and minor_version represent major and minor version numbers for when we import it in QML from ApplicationViewModel import ApplicationViewModel from OnboardingViewModel import OnboardingViewModel from HistoryViewModel import HistoryViewModel from HistoryListModel import HistoryListModel from ProfileViewModel import ProfileViewModel from FriendsViewModel import FriendsViewModel from FriendsListModel import FriendsListModel from DetailsViewModel import DetailsViewModel from shared.components.NetworkImage import NetworkImage QtQml.qmlRegisterType(ApplicationViewModel, MODULE_NAME, MAJOR_VERSION, MINOR_VERSION, 'ApplicationViewModel') QtQml.qmlRegisterType(OnboardingViewModel, MODULE_NAME, MAJOR_VERSION, MINOR_VERSION, 'OnboardingViewModel') QtQml.qmlRegisterType(HistoryViewModel, MODULE_NAME, MAJOR_VERSION, MINOR_VERSION, 'HistoryViewModel') QtQml.qmlRegisterType(HistoryListModel, MODULE_NAME, MAJOR_VERSION, MINOR_VERSION, 'HistoryListModel') QtQml.qmlRegisterType(ProfileViewModel, MODULE_NAME, MAJOR_VERSION, MINOR_VERSION, 'ProfileViewModel') QtQml.qmlRegisterType(FriendsViewModel, MODULE_NAME, MAJOR_VERSION, MINOR_VERSION, 'FriendsViewModel') QtQml.qmlRegisterType(FriendsListModel, MODULE_NAME, MAJOR_VERSION, MINOR_VERSION, 'FriendsListModel') QtQml.qmlRegisterType(DetailsViewModel, MODULE_NAME, MAJOR_VERSION, MINOR_VERSION, 'DetailsViewModel') QtQml.qmlRegisterType(NetworkImage, MODULE_NAME, MAJOR_VERSION,
def register_qml_types(): QtQml.qmlRegisterType(ScanConfigData, 'ScanTools', 1, 0, 'ScanConfigData') QtQml.qmlRegisterType(ScannerInterface, 'ScanTools', 1, 0, 'ScannerInterface')
@QtCore.Slot(QtCore.QDate, result="QVariantList") def eventsForDate(self, date): events = [] for event in self._cache_events: start = event["start"] if start.date() == date: events.append(event) return events @QtCore.Slot(list) def _handle_events(self, events): self._cache_events = events self.loaded.emit() logging.debug("Loaded") if __name__ == "__main__": app = QtGui.QGuiApplication(sys.argv) QtQml.qmlRegisterType(CalendarProvider, "MyCalendar", 1, 0, "CalendarProvider") cal2 = CalendarProvider() engine = QtQml.QQmlApplicationEngine() engine.rootContext().setContextProperty("cal2", cal2) filename = os.path.join(CURRENT_DIR, "CalendarDraft.qml") engine.load(QtCore.QUrl.fromLocalFile(filename)) if not engine.rootObjects(): sys.exit(-1) sys.exit(app.exec_())
def register_qml_types(): QtQml.qmlRegisterType(EngineModel, 'DeviceModels', 1, 0, 'EngineModel')
test_rect.setTopLeft(rect.topLeft() + QtCore.QPointF(rect.width() / 6, rect.height() / 6).toPoint()) test_rect.setBottomRight(rect.bottomRight() - QtCore.QPointF(rect.width() / 6, rect.height() / 6).toPoint()) pen = QtGui.QPen(QtGui.QBrush(QtCore.Qt.red), 2) painter.setPen(pen) painter.drawRoundRect(test_rect, 10) painter.drawRoundRect(rect, 10) painter.restore() if __name__ == "__main__": app = QtGui.QGuiApplication(sys.argv[1:]) QtQml.qmlRegisterType(QuickItem, "Demo", 1, 0, "PaintItem") # 类型不能小写开头,要和qml中的类似,大写开头 # -------------------------------------------主体是window # engine = QtQml.QQmlApplicationEngine() # engine.addImportPath(os.path.dirname(__file__)) # engine.load('resource\\main.qml') # -------------------------------------------------------- view = QtQuick.QQuickView() # view 不支持window 作为root view.setResizeMode(QtQuick.QQuickView.SizeRootObjectToView) view.engine().addImportPath(os.path.dirname(__file__)) view.setSource('resource\\main.qml') view.show() # ---------------------------------------------------------- sys.exit(app.exec_())
from TodosViewModel import TodosViewModel from SettingsViewModel import SettingsViewModel from TodosListModel import TodosListModel # App constants MODULE_NAME = 'QtTodos' MAJOR_VERSION = 0 MINOR_VERSION = 1 # Enable Ctrl-C to kill signal.signal(signal.SIGINT, signal.SIG_DFL) if __name__ == '__main__': # Create QML components from a Python classes # major_version and minor_version represent major and minor version numbers for when we import it in QML QtQml.qmlRegisterType(TodosViewModel, MODULE_NAME, MAJOR_VERSION, MINOR_VERSION, 'TodosViewModel') QtQml.qmlRegisterType(SettingsViewModel, MODULE_NAME, MAJOR_VERSION, MINOR_VERSION, 'SettingsViewModel') QtQml.qmlRegisterType(TodosListModel, MODULE_NAME, MAJOR_VERSION, MINOR_VERSION, 'TodosListModel') # Use render loop that supports persistent 6major_versionfps os.environ['QSG_RENDER_LOOP'] = 'windows' # Create system app app = QtGui.QGuiApplication(sys.argv) # Initialize QML rendering engine engine = QtQml.QQmlApplicationEngine(parent=app) engine.load('main.qml')
# coding: utf-8 from PySide2 import QtWidgets, QtCore, QtGui, QtQuick, QtQml import sys import os from resources import qml if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv[1:]) engine = QtQml.QQmlApplicationEngine() engine.addImportPath(os.path.join(os.path.dirname(__file__), 'imports')) # import path 是qml中用来improt 的路径,类似python sys.path # plugin path 是能读到qmdir的路径 engine.load("qrc:/main.qml") sys.exit(app.exec_())
def register_qml_types(): QtQml.qmlRegisterType(PaletteManager, 'Palette', 1, 0, 'PaletteManager')