示例#1
0
def startGui():

    settings = Settings()
    try:
        settings.load()
    except JSONSettings.SettingsError as e:
        print(e)
        quit()

    app = QGuiApplication([])
    app.setOrganizationName('Schweinesystem')
    app.setOrganizationDomain('schweinesystem.eu')
    app.setApplicationName('PasswdAdmin')

    signal.signal(signal.SIGINT, signit_handler)
    timer = QTimer()
    timer.start(500)  # You may change this if you wish.
    timer.timeout.connect(lambda: None)  # Let the interpreter run each 500 ms.

    engine = QQmlApplicationEngine()

    usermodel = UserModel(settings)

    context = engine.rootContext()
    context.setContextProperty('userModel', usermodel)

    thisFile = os.path.realpath(__file__)
    thisDir = os.path.dirname(thisFile)
    engine.load(thisDir + '/qml/MainWidget.qml')
    if not engine.rootObjects():
        sys.exit(-1)

    sys.exit(app.exec_())
示例#2
0
def run():
    """Start Virtual Warehouse application."""
    QGuiApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
    app = QGuiApplication(sys.argv)
    app.setOrganizationName("Bretislav Hajek")
    app.setOrganizationDomain("bretahajek.com")
    app.setApplicationName("Virtual Warehouse")
    app.setApplicationVersion(__version__)
    engine = QQmlApplicationEngine()

    controller = ViewController()
    engine.rootContext().setContextProperty("ViewController", controller)
    engine.rootContext().setContextProperty("versionNumber", __version__)

    app.setWindowIcon(QIcon(":/images/icon.png"))
    engine.load(QtCore.QUrl("qrc:/qml/main.qml"))

    if not engine.rootObjects():
        sys.exit(-1)
    sys.exit(app.exec_())
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)
# This Python file uses the following encoding: utf-8
import sys
import os

from PySide2.QtGui import QGuiApplication, QIcon
from PySide2.QtQml import QQmlApplicationEngine
from mainWindow import MainWindow

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

    # Get Context
    main = MainWindow()
    engine.rootContext().setContextProperty("backend", main)

    # Set App Extra Info
    app.setOrganizationName("Wanderson M. Pimenta")
    app.setOrganizationDomain("N/A")

    # Set Icon
    app.setWindowIcon(QIcon("app.ico"))

    # Load Initial Window
    engine.load(os.path.join(os.path.dirname(__file__),
                             "qml/splashScreen.qml"))

    if not engine.rootObjects():
        sys.exit(-1)
    sys.exit(app.exec_())
示例#5
0
文件: main.py 项目: ndeybach/DipSim
def shutdown():
    '''Delete engine and qml object before python garbage collection'''
    del globals()["engine"]


if __name__ == "__main__":
    #QGuiApplication.setAttribute(Qt.AA_EnableHighDpiScaling) #bug on linux scaling if activated
    sys.argv += ['--style', 'material']
    app = QGuiApplication(sys.argv)
    app.aboutToQuit.connect(shutdown)

    # set variables for settings
    app.setApplicationName("DipSim")
    app.setOrganizationName("IPR")
    app.setOrganizationDomain("IPR.com")

    hypervisor = SimHypervisor()  # python compute hypervisor
    engine = QQmlApplicationEngine()  # UI engine

    # add necesaary object linking UI and python data
    engine.rootContext().setContextProperty("hypervisor", hypervisor)
    engine.rootContext().setContextProperty("primCell", hypervisor.primCell)
    engine.rootContext().setContextProperty("dipModel", hypervisor.dipModel)
    engine.rootContext().setContextProperty("dipModelMinEnergy",
                                            hypervisor.dipModelMinEnergy)
    engine.rootContext().setContextProperty("dipModelMinEnergyMC",
                                            hypervisor.dipModelMinEnergyMC)

    engine.load(os.path.join(os.path.dirname(__file__), "main.qml"))
    if not engine.rootObjects():
示例#6
0
                  help="List of stocks in JSON format")

if sys.version_info[0] != 3:
    print("Error: This script requires Python 3")
    exit(1)

# arguments for QApplication
parser.add_option("--style", help="Passed to the constructor of QApplication")
(options, args) = parser.parse_args()

if len(args) != 0:
    parser.error("Wrong number of arguments. Use %s --help" % sys.argv[0])

# Company name: this avoids an error message
QGuiApplication.setOrganizationName("MyCompany")
QGuiApplication.setOrganizationDomain("mycompany.com")

# View model
stockListModel = JsonListModel()

# Python objects
tradingClient = TradingClient(stockListModel)
tradingClient.resetStocks()

# Main
if __name__ == '__main__':

    # Setup the application window, by default use google material style
    if '--style' not in sys.argv:
        sys.argv += ['--style', 'material']
    sys.argv += ['--qwindowtitle', 'Example of trading client in QML+Python']
示例#7
0

def shutdown():
    del globals()["engine"]


if __name__ == '__main__':
    main_context = MainContext()
    error_service = ErrorService()

    app = QGuiApplication(sys.argv)
    app.aboutToQuit.connect(shutdown)
    app.setWindowIcon(QIcon("icons/app.ico"))

    app.setOrganizationName("xavier CLEMENCE")
    app.setOrganizationDomain("xavier CLEMENCE")

    QQuickStyle.setStyle("Material")
    engine = QQmlApplicationEngine()

    context = engine.rootContext()

    context.setContextProperty("context", main_context)
    context.setContextProperty("error", error_service)

    qmlFile = join(application_path, "views/MainView.qml")
    engine.load(QUrl.fromLocalFile(qmlFile))

    if not engine.rootObjects():
        sys.exit(-1)
示例#8
0
from PySide2.QtQml import QQmlApplicationEngine, qmlRegisterType
from PySide2.QtCore import QUrl, Property, Signal, QObject, Slot
import eye
import videoio_uvc
#import calibration_hmd
import debugger as calibration_hmd
import cv2
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)
示例#9
0
            #ДЛЯ ОСТАНОВКИ ЦИКЛА
            if self.running == False:
                break
            #МЕНЯЕМ
            replaceok = self.openfile(file_path2).replace(chtomenaem,lst_zamena.pop(0))
            if replaceok.endswith('\n') == False:
                replaceok +='\n'
            #ЗАПИСЫВАЕМ В ФАЙЛ ГОТОВО
            self.writefile(file_path3,'a',replaceok)
            now_progbar +=1
            self.nowProgbar.emit(now_progbar)
        #ПРОГРЕССБАР НА 0
        self.nowProgbar.emit(0)
        self.allOk.emit("OK")




if __name__ == "__main__":
    app = QGuiApplication(sys.argv)
    app.setWindowIcon(QIcon("img/icon.png"))
    app.setOrganizationName("null")
    app.setOrganizationDomain("null")
    standart = Standart()
    engine = QQmlApplicationEngine()
    engine.rootContext().setContextProperty("standart", standart)
    engine.load(os.fspath(Path(__file__).resolve().parent / "main.qml"))
    if not engine.rootObjects():
        sys.exit(-1)
    sys.exit(app.exec_())
    @Slot()
    def stop_bot(self):
        """Stops the bot and terminates the Process.
        
        @Slot()

        Returns:
            None
        """
        if(self._bot_process != None):
            print("\n[STATUS] Stopping the bot and terminating the Thread.")
            self._bot_process.terminate()
        return None

if __name__ == "__main__":
    app = QGuiApplication(sys.argv)
    app.setOrganizationName("somename")
    app.setOrganizationDomain("somename")
    engine = QQmlApplicationEngine()

    # Get the Context.
    main = MainWindow()
    engine.rootContext().setContextProperty("backend", main)

    # Load the QML File.
    engine.load(os.path.join(os.path.dirname(__file__), "gui/qml/main.qml"))

    if not engine.rootObjects():
        sys.exit(-1)
    sys.exit(app.exec_())
示例#11
0
    # Function set name to label
    @Slot(str)
    def welcomeText(self, name):
        self.setName.emit("Welcome, " + name)


def qt_message_handler(mode, context, message):
    # Enables output from qml files with console.log("text") at python console
    # Other output: context.file, context.line, mode
    print(message)


if __name__ == "__main__":
    qInstallMessageHandler(qt_message_handler)
    app = QGuiApplication(sys.argv)
    app.setOrganizationName(" ")
    app.setOrganizationDomain(" ")

    engine = QQmlApplicationEngine()

    # Get Context
    main = MainWindow()
    engine.rootContext().setContextProperty("backend", main)

    # Load QML file
    engine.load(os.path.join(os.path.dirname(__file__), "qml/main.qml"))

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