예제 #1
0
파일: scans2pdfgui.py 프로젝트: Unrud/djpdf
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_())
예제 #2
0
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([])
    app.setWindowIcon(QIcon.fromTheme("com.github.unrud.djpdf"))
    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") == "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")))
    platform_integration.window = engine.rootObjects()[0]
    exit(app.exec_())
예제 #3
0
def run():
    sys.argv += ['--style', 'material']
    app = QApplication(sys.argv)
    engine = QQmlApplicationEngine()
    backend = Backend()
    engine.rootContext().setContextProperty("backend", backend)
    engine.rootContext().setContextProperty("parameters", backend.parameters)
    engine.addImageProvider("imgprovider", backend.image_provider)
    qml_file = join(dirname(__file__), 'views/main.qml')
    engine.load(abspath(qml_file))

    if not engine.rootObjects():
        sys.exit(-1)

    return app.exec_()
def main():
    qInstallMessageHandler(lambda x, y, msg: print(msg))

    argv = sys.argv

    # Trick to set the style / not found how to do it in pythonic way
    #argv.extend(["-style", "universal"])

    app = QApplication(argv)

    qmlRegisterType(FigureCanvasQTAgg, "Backend", 1, 0, "FigureCanvasByPython")
    qmlRegisterType(FigureCanvasQTAggToolbar, "Backend", 1, 0,
                    "FigureToolbarByPython")

    # this should work in the future
    # qmlRegisterType(
    #     QUrl.fromLocalFile( str(pathlib.Path(backend_qquick5agg.__file__)/'SubplotTool.qml')),
    #     "Backend", 1, 0, "SubplotTool")

    imgProvider = MatplotlibIconProvider()

    # !! You must specified the QApplication as parent of QQmlApplicationEngine
    # otherwise a segmentation fault is raised when exiting the app
    engine = QQmlApplicationEngine(parent=app)
    engine.addImageProvider("mplIcons", imgProvider)

    context = engine.rootContext()
    data_model = DataSeriesModel()
    context.setContextProperty("dataModel", data_model)
    mainApp = Form(data=data_model)
    context.setContextProperty("draw_mpl", mainApp)

    engine.load(
        QUrl(str(pathlib.Path(__file__).parent / 'main_mpl_qtquick_main.qml')))

    win = engine.rootObjects()[0]

    figure = win.findChild(QObject, "figure")
    mainApp.figure = figure.getFigure()

    rc = app.exec_()
    # There is some trouble arising when deleting all the objects here
    # but I have not figure out how to solve the error message.
    # It looks like 'app' is destroyed before some QObject
    sys.exit(rc)
def main():
    argv = sys.argv

    # Trick to set the style / not found how to do it in pythonic way
    argv.extend(["-style", "universal"])
    app = QGuiApplication(argv)

    # why needed now?
    app.setOrganizationName("Some Company")
    app.setOrganizationDomain("somecompany.com")
    app.setApplicationName("Amazing Application")

    qmlRegisterType(FigureCanvasQTAggToolbar, "Backend", 1, 0, "FigureToolbar")
    imgProvider = MatplotlibIconProvider()

    # !! You must specified the QApplication as parent of QQmlApplicationEngine
    # otherwise a segmentation fault is raised when exiting the app
    engine = QQmlApplicationEngine(parent=app)
    engine.addImageProvider("mplIcons", imgProvider)

    context = engine.rootContext()
    data_model = DataSeriesModel()
    context.setContextProperty("dataModel", data_model)
    mainApp = Form(data=data_model)
    context.setContextProperty("draw_mpl", mainApp)

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

    win = engine.rootObjects()[0]
    mainApp.figure = win.findChild(QObject, "figure").getFigure()

    rc = app.exec_()
    # There is some trouble arising when deleting all the objects here
    # but I have not figure out how to solve the error message.
    # It looks like 'app' is destroyed before some QObject
    sys.exit(rc)
예제 #6
0
    imgFuncionario = Property(str,
                              get_img_funcionario,
                              notify=imgFuncionarioChanged)

    # qrCode
    qrCodeChanged = Signal(str)

    def get_qrCode(self):
        return self.__qrCode

    qrCode = Property(str, get_qrCode, notify=qrCodeChanged)


if __name__ == '__main__':
    app = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine()

    #funcionario = Funcionario()
    #engine.rootContext().setContextProperty("funcionario", funcionario)
    qmlRegisterType(Funcionario, 'MyTools', 1, 0, 'Funcionario')
    qrcImage = QRCImage("Data")
    engine.addImageProvider("qrcode", qrcImage)

    engine.load(QUrl("Exercicio_01.qml"))

    if not engine.rootObjects():
        sys.exit(-1)

    sys.exit(app.exec_())
예제 #7
0
import time
import numpy as np
import multiprocessing as mp

if __name__ == '__main__':
    #mp.set_start_method('spawn')
    app = QGuiApplication(sys.argv)
    app.setOrganizationName('Cadu')
    app.setOrganizationDomain('Nowhere')
    engine = QQmlApplicationEngine()

    videoio = videoio_uvc.VideoIO_UVC()
    calib_hmd = calibration_hmd.HMDCalibrator(3, 3, 21, 3)

    le_cam = eye.EyeCamera('left')
    re_cam = eye.EyeCamera('right')
    videoio.set_active_cameras(le_cam, re_cam)
    calib_hmd.set_sources(le_cam, re_cam)

    engine.rootContext().setContextProperty("camManager", videoio)
    engine.rootContext().setContextProperty("leftEyeCam", le_cam)
    engine.rootContext().setContextProperty("rightEyeCam", re_cam)
    engine.rootContext().setContextProperty("calibHMD", calib_hmd)
    engine.addImageProvider('leyeimg', le_cam)
    engine.addImageProvider('reyeimg', re_cam)
    engine.load(QUrl("../UI/qml/main.qml"))

    if not engine.rootObjects():
        sys.exit(-1)

    sys.exit(app.exec_())