Example #1
0
class App():
    def __init__(self):
        self.app = QGuiApplication(sys.argv + ['--style', 'material'])

        fontdatabase = QFontDatabase()
        fontdatabase.addApplicationFont("fonts/Exo2-Regular.ttf")
        exo = QFont("Exo 2", 15)
        self.app.setFont(exo)

        self.engine = QQmlApplicationEngine()
        self.bridge = Bridge(self.app, self.engine)

        #responder a KeyboardInterrupt
        signal.signal(signal.SIGINT, signal.SIG_DFL)

        self.engine.rootContext().setContextProperty("bridge", self.bridge)
        self.engine.load("assets/main.qml")

        listDicts = csvInterpreter.readCSV("components.csv")
        for d in listDicts:
            self.bridge.createComponent(d)

        # self.bridge.updateComponents(bytearray.fromhex('5553501408010401080110011F'))

        self.engine.quit.connect(self.app.quit)
        self.app.exec()
Example #2
0
def showError(message):
    writeSettings("", "")
    app = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine()
    engine.rootContext().setContextProperty("message", message)
    engine.load(QUrl("qrc:/message.qml"))
    sys.exit(app.exec())
class App():
    def __init__(self):
        self.app = QGuiApplication(sys.argv + ['--style', 'material'])

        fontdatabase = QFontDatabase()
        fontdatabase.addApplicationFont("fonts/Exo2-Regular.ttf")
        exo = QFont("Exo 2", 15)
        self.app.setFont(exo)

        self.engine = QQmlApplicationEngine()
        self.bridge = Bridge(self.app, self.engine)

        #responder a KeyboardInterrupt
        signal.signal(signal.SIGINT, signal.SIG_DFL)
        self.engine.rootContext().setContextProperty("bridge", self.bridge)
        self.engine.load("assets/main.qml")

        self.engine.quit.connect(self.app.quit)
        self.app.exec()
Example #4
0
def main():
    """application entry point"""
    app = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine()
    engine.quit.connect(app.quit)
    engine.load('main.qml')

    backend = BackendLogic()
    engine.rootObjects()[0].setProperty('backend', backend)
    backend.update_time()
    sys.exit(app.exec())
Example #5
0
def main(argv):
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    qapp = QGuiApplication([])

    engine = QQmlApplicationEngine()

    data_list = []
    for entry in os.scandir(argv[1]):
        url = "file://" + urllib.parse.quote(os.path.abspath(entry.path))
        digest = hashlib.md5(os.fsencode(url)).hexdigest()
        result = os.path.join(xdg.BaseDirectory.xdg_cache_home, "thumbnails", "normal", digest + ".png")
        data_list.append(Foo(entry.name, result, "2018-01-11T19:20"))

    engine.load(QUrl('main.qml'))

    ctxt = engine.rootContext()
    ctxt.setContextProperty("menu2", QVariant(data_list))

    win = engine.rootObjects()[0]
    win.show()

    sys.exit(qapp.exec())
Example #6
0
import sys

from PyQt5.QtGui import QGuiApplication
from PyQt5.QtQml import QQmlApplicationEngine

from finder import Finder


def cleanUp():
    finder.app_exited = True

app = QGuiApplication(sys.argv)
app.aboutToQuit.connect(cleanUp)

engine = QQmlApplicationEngine()
engine.load('UI/main.qml')

finder = Finder()
engine.rootObjects()[0].setProperty('finder', finder)
engine.quit.connect(app.quit)


sys.exit(app.exec())
Example #7
0
from _004_3d_loading_model_and_rotating.object import ModelUnderlay
import platform

if __name__ == '__main__':
	# Not working in Ubuntu 16.04, result in 1282 error for simple calling like glViewport(...)
	# TODO

	if platform.uname().system == 'Darwin':
		f = QSurfaceFormat()
		f.setVersion(4, 1)
		f.setDepthBufferSize(1)  # fix depth buffer error
		f.setStencilBufferSize(1)  # fix stencil buffer error

		# If CoreProfile is used, all the other QML rendering will fail, because they only use 2.1
		f.setProfile(QSurfaceFormat.CompatibilityProfile)
		QSurfaceFormat.setDefaultFormat(f)

	qmlRegisterType(ModelUnderlay, 'OpenGLUnderQml', 1, 0, 'ModelUnderlay')

	app = QGuiApplication(sys.argv)

	view = QQuickView()
	# view.setFormat(f)
	view.setPersistentSceneGraph(True)
	view.setPersistentOpenGLContext(True)
	view.setResizeMode(QQuickView.SizeRootObjectToView)  # Set for the object to resize correctly
	view.setSource(QUrl('ModelWindow.qml'))
	view.show()

	app.exec()
Example #8
0
# encoding: utf-8

from PyQt5.QtCore import  QUrl, QObject, pyqtSlot
from PyQt5.QtGui import QGuiApplication
from PyQt5.QtQuick import QQuickView
from calculate import *

class Calculator(QObject):

    @pyqtSlot(str,result = str)
    def output(self,exp):
        '''return the result of  exp'''
        return str(calculate(exp))

    @pyqtSlot(str,result = str)
    def del_input(self,input):
        '''the function for the "del" Button '''
        return input[:-1]

if __name__ == '__main__':
    path = 'calculate.qml'
    app = QGuiApplication([])
    view = QQuickView()
    con = Calculator()
    context = view.rootContext()
    context.setContextProperty("con",con)
    view.engine().quit.connect(app.quit)
    view.setSource(QUrl(path))
    view.show()
    app.exec()