Пример #1
0
def main():
    sys.excepthook = exception_logger
    os.environ['QT_MAC_WANTS_LAYER'] = '1'    # Workaround for https://bugreports.qt.io/browse/QTBUG-87014

    error = init_and_check_db(get_app_path())

    if error.code == LedgerInitError.EmptyDbInitialized:  # If DB was just created from SQL - initialize it again
        error = init_and_check_db(get_app_path())

    app = QApplication([])
    language = JalDB().get_language_code(JalSettings().getValue('Language', default=1))
    translator = QTranslator(app)
    language_file = get_app_path() + Setup.LANG_PATH + os.sep + language + '.qm'
    translator.load(language_file)
    app.installTranslator(translator)

    if error.code == LedgerInitError.OutdatedDbSchema:
        error = update_db_schema(get_app_path())
        if error.code == LedgerInitError.DbInitSuccess:
            error = init_and_check_db(get_app_path())

    if error.code != LedgerInitError.DbInitSuccess:
        window = QMessageBox()
        window.setAttribute(Qt.WA_DeleteOnClose)
        window.setWindowTitle("JAL: Start-up aborted")
        window.setIcon(QMessageBox.Critical)
        window.setText(error.message)
        window.setInformativeText(error.details)
    else:
        window = MainWindow(language)
    window.show()

    app.exec()
    app.removeTranslator(translator)
Пример #2
0
def main() -> None:
    """Mainline for interactive review of layout."""
    app = QApplication(sys.argv)
    win = MainWin()
    win.exit_action.triggered.connect(sys.exit)
    win.show()
    app.exec()
Пример #3
0
class Dephaser(object):
    def __init__(self):
        self.app = QApplication(sys.argv)

    def run(self):
        self.main = MainWidget(self)
        self.main.resize(1200, 400)
        self.main.show()
        self.app.exec()
Пример #4
0
def QVTKRenderWidgetConeExample():
    """A simple example that uses the QVTKRenderWindowInteractor class."""

    from vtkmodules.vtkFiltersSources import vtkConeSource
    from vtkmodules.vtkRenderingCore import vtkActor, vtkPolyDataMapper, vtkRenderer
    # load implementations for rendering and interaction factory classes
    import vtkmodules.vtkRenderingOpenGL2
    import vtkmodules.vtkInteractionStyle

    # every QT app needs an app
    app = QApplication(['QVTKRenderWindowInteractor'])

    window = QMainWindow()

    # create the widget
    widget = QVTKRenderWindowInteractor(window)
    window.setCentralWidget(widget)
    # if you don't want the 'q' key to exit comment this.
    widget.AddObserver("ExitEvent", lambda o, e, a=app: a.quit())

    ren = vtkRenderer()
    widget.GetRenderWindow().AddRenderer(ren)

    cone = vtkConeSource()
    cone.SetResolution(8)

    coneMapper = vtkPolyDataMapper()
    coneMapper.SetInputConnection(cone.GetOutputPort())

    coneActor = vtkActor()
    coneActor.SetMapper(coneMapper)

    ren.AddActor(coneActor)

    # show the widget
    window.show()

    widget.Initialize()
    widget.Start()

    # start event processing
    # Source: https://doc.qt.io/qtforpython/porting_from2.html
    # 'exec_' is deprecated and will be removed in the future.
    # Use 'exec' instead.
    try:
        app.exec()
    except AttributeError:
        app.exec_()
Пример #5
0
def run_gui(args):
    bridge = get_bridge()
    if not bridge:
        return
    if args.skip_req:
        bridge.disable_req()
    app = QApplication([])
    widget = HueControlWindow(bridge)
    widget.resize(600, 600)
    widget.show()

    sys.exit(app.exec())
Пример #6
0
def main():
    # Create the Qt Application
    app = QApplication(sys.argv)
    # load sytle
    with open("style.qss", "r") as f:
        _style = f.read()
        app.setStyleSheet(_style)
    # Create and show
    taplist = TapList()
    taplist.show()
    # Run the main Qt loop
    sys.exit(app.exec())
def main():
    app = QApplication(sys.argv)
    app.setOrganizationName('kth')
    app.setOrganizationDomain('kth.se')
    app.setApplicationName('covid19-detector')

    window = Client(n_classes=3,
                    class_labels={
                        'covid-19': 0,
                        'normal': 1,
                        'pneumonia': 2
                    })
    window.showMaximized()
    sys.exit(app.exec())
Пример #8
0
def main():

    app = QApplication(sys.argv)
    pixmap = QPixmap("icon.ico")
    splash = QSplashScreen(pixmap)
    splash.show()
    if __debug__:
        start = timer()
    ex = TableClothGenerator()
    app.processEvents()
    ex.show()
    splash.finish(ex)
    if __debug__:
        end = timer()
        print("This took %d seconds." % (end - start))
    sys.exit(app.exec())
Пример #9
0
def main():
    print(f'PySide6=={PySideVer} Qt=={QtVer}')

    parser = ArgumentParser(
        description='cappuccino: Simple image viewer with download')
    parser.add_argument('download_keyword',
                        nargs='?',
                        default='',
                        help='image keyword to download')
    args = parser.parse_args()

    download_keyword = args.download_keyword
    if not download_keyword and not exist_images():
        download_keyword = DEFAULT_KEYWORD

    app = QApplication(sys.argv)
    app.setWindowIcon(QIcon(resource_path('cappuccino.ico')))
    window = MainWindow(download_keyword, IMAGES_DIR_NAME)
    window.show()
    sys.exit(app.exec())
Пример #10
0
    def __init__(self):
        QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
        app = QApplication(sys.argv)
        app.setStyle(QStyleFactory.create('Fusion'))

        ui_file_name = '%s.ui' % Path(__file__).stem
        ui_file = QFile(ui_file_name)
        if not ui_file.open(QIODevice.ReadOnly):
            print('Cannot open %s: %s' % (ui_file_name, ui_file.errorString()))
            sys.exit(-1)

        loader = QUiLoader()
        self.window = loader.load(ui_file)
        ui_file.close()
        if not self.window:
            print(loader.errorString())
            sys.exit(-1)

        self.connect()
        self.setting()

        self.window.show()

        sys.exit(app.exec())
Пример #11
0
def main():
    mp.set_start_method("spawn", force=True)  # required for Linux
    app_name = "MNELAB"
    if sys.platform.startswith("darwin"):
        # set bundle name on macOS (app name shown in the menu bar)
        from Foundation import NSBundle
        bundle = NSBundle.mainBundle()
        info = bundle.localizedInfoDictionary() or bundle.infoDictionary()
        info["CFBundleName"] = app_name

    matplotlib.use("QtAgg")
    app = QApplication(sys.argv)
    app.setApplicationName(app_name)
    app.setOrganizationName("cbrnr")
    if sys.platform.startswith("darwin"):
        app.setAttribute(Qt.ApplicationAttribute.AA_DontShowIconsInMenus, True)
    app.setAttribute(Qt.ApplicationAttribute.AA_UseHighDpiPixmaps)
    model = Model()
    model.view = MainWindow(model)
    if len(sys.argv) > 1:  # open files from command line arguments
        for f in sys.argv[1:]:
            model.load(f)
    model.view.show()
    sys.exit(app.exec())
Пример #12
0
def ventana():
    app = QApplication(sys.argv)
    ventana = MyApp()
    sys.exit(app.exec())
Пример #13
0
main_window.show()

main_window.actionPlay.triggered.connect(csound_play)
main_window.actionRender.triggered.connect(csound_render)
main_window.actionStop.triggered.connect(csound_stop)
main_window.actionSave.triggered.connect(csound_save_channels)
main_window.actionRestore.triggered.connect(csound_restore_channels)

# End of boilerplate code. The following code should configure the Csound
# control channels. Each Csound control channel has one widget, one signal,
# and one slot.

connect_channel(main_window.gk_MasterOutput_level, "gk_MasterOutput_level")
connect_channel(main_window.gk_Reverb_feedback, "gk_Reverb_feedback")
connect_channel(main_window.gi_Reverb_delay_modulation,
                "gi_Reverb_delay_modulation")
connect_channel(main_window.gk_Harpsichord_level, "gk_Harpsichord_level")
connect_channel(main_window.gk_Harpsichord_pan, "gk_Harpsichord_pan")
connect_channel(main_window.gi_Harpsichord_pluck, "gi_Harpsichord_pluck")
connect_channel(main_window.gk_Harpsichord_pick, "gk_Harpsichord_pick")
connect_channel(main_window.gk_Harpsichord_reflection,
                "gk_Harpsichord_reflection")
connect_channel(main_window.gi_Harpsichord_release, "gi_Harpsichord_release")

# Actually run the piece.

result = application.exec()
csound_stop()
sys.exit(result)
Пример #14
0
import sys

from PySide6.QtWidgets import QApplication, QLabel

# We instantiate a QApplication passing the arguments of the script to it:
a = QApplication(sys.argv)

# Add a basic widget to this application:
# The first argument is the text we want this QWidget to show, the second
# one is the parent widget. Since Our "hello" is the only thing we use (the
# so-called "MainWidget", it does not have a parent.
hello = QLabel("<h2>Hello, World</h2>")

# ... and that it should be shown.
hello.show()

# Now we can start it.
a.exec()
Пример #15
0
def main():
    app = QApplication(sys.argv)
    window = ZeroPlayWindow()
    window.show()
    return app.exec()
Пример #16
0
class Screen(_Screen_):
    def __init__(self, *args, **kwargs):
        _Screen_.__init__(self, *args, **kwargs)
        self.app = QApplication(sys.argv)
        self.native_root = QMainWindow()

    def run(self):
        # setup update functions

        timers = []
        for fn, period in self._iter_registered_updates_():

            timers.append(_create_timer(fn, int(period * 1000)))

        sys.exit(self.app.exec())

    def on_root_set(self, root):
        pass

    def on_widget_nest_in(_, widget: Widget):
        pass  # raise NotImplementedError

    def on_widget_unnest_from(_, widget: Widget):
        pass  # raise NotImplementedError

    def on_widget_build(self, widget: Widget):
        # print("on_widget_build", widget, widget._superior_, widget._native_ is not None)
        if widget._native_ is not None:
            widget._native_.set_parent(widget._superior_._native_)

    def on_widget_demolish(self, widget: Widget):
        widget._native_ = None

    def on_widget_place(self, widget: Widget):
        # print(f"on_widget_place", widget)
        native = widget._native_
        if native is not None:
            x, y = widget._rel_coord_
            native.pos = QPoint(x, y)
            native.size = QSize(*widget._phys_size_)

    def on_widget_pickup(self, widget: Widget):
        # print(f"{self}.on_widget_place(widget={widget})")
        pass

    def on_widget_show(self, widget: Widget):
        if widget._native_ is not None:
            widget._native_.show()

    def on_widget_hide(self, widget: Widget):
        if widget._native_ is not None:
            widget._native_.hide()

    # container tie-ins
    def on_container_build(_, widget: Widget):
        widget._native_ = native = QWidget()
        superior = widget._superior_

        if superior is not None:
            native.set_parent(superior._native_)

    def on_container_demolish(_, widget: Widget):
        widget._native_ = None

    def on_container_place(_, widget: "Widget"):
        # if widget._native_ is not None:
        assert (
            widget._native_ is not None
        ), f"{widget} was probably not built w/ on_container_build (._native_)"
        x, y = widget._rel_coord_
        widget._native_.pos = QPoint(x, y)
        widget._native_.size = QSize(*widget._phys_size_)

    def on_container_pickup(_, widget: "Widget"):
        raise NotImplementedError

    def on_container_show(_, widget: Widget, _full_refresh=False):
        widget._native_.show()

    def on_container_hide(_, widget: Widget):
        widget._native_.hide()
Пример #17
0
        self.opsTabs.setCurrentIndex(0)
        self.setWindowTitle("stepsListView")



        QMetaObject.connectSlotsByName(self)
        self.stepUpBtn.setText("Up")
        self.stepDownBtn.setText("Down")

    # def retranslateUi(self):
    #     self.setWindowTitle(QCoreApplication.translate(b"stepsListView", b"stepsListView", None))
    #     ___qtreewidgetitem = self.stepsTreeWidget.headerItem()
    #     ___qtreewidgetitem.setText(2, QCoreApplication.translate(b"stepsListView", b"Target", None));
    #     ___qtreewidgetitem.setText(1, QCoreApplication.translate(b"stepsListView", b"Operation", None));
    #     ___qtreewidgetitem.setText(0, QCoreApplication.translate(b"stepsListView", b"#", None));
    #     self.stepDownBtn.setText(QCoreApplication.translate(b"stepsListView", b"<", None))
    #     self.stepUpBtn.setText(QCoreApplication.translate(b"stepsListView", b">", None))
    #     self.removeStepBtn.setText(QCoreApplication.translate(b"stepsListView", b"-", None))
    #     self.addStepBtn.setText(QCoreApplication.translate(b"stepsListView", b"+", None))
    #     self.runBtn.setText(QCoreApplication.translate(b"stepsListView", b"Run", None))
    #     self.opsTabs.setTabText(self.opsTabs.indexOf(self.stepsTab), QCoreApplication.translate(b"stepsListView", b"Steps", None))
    #     self.opsTabs.setTabText(self.opsTabs.indexOf(self.optionsTab), QCoreApplication.translate(b"stepsListView", b"Options", None))
    #     self.opsTabs.setTabText(self.opsTabs.indexOf(self.templatesTab), QCoreApplication.translate(b"stepsListView", b"Templates", None))

if __name__ == "__main__":
    a = QApplication(sys.argv)
    w = StepsData()
    w.show()
    sys.exit(a.exec())
Пример #18
0
class Application:
    app: QApplication
    window: MainWindow
    stages: list[Stage]
    current_stage: int
    history: list[Stage]

    def __init__(self):
        self.app = QApplication(sys.argv)
        self.stages = stages
        self.current_stage = 0
        self.history = []
        self.image_file = None

        self.window = MainWindow(self.stages)
        self.window.show()
        self.set_handlers()

    def set_handlers(self):
        for rb in self.window.stages_radio_buttons:
            rb.clicked.connect(self.change_stage)
        self.window.proceed_button.clicked.connect(self.proceed_current_stage)
        self.window.settings_widget.settings_changed_signal.connect(
            self.settings_changed)
        self.window.open_file.triggered.connect(self.open_file)
        self.stages[self.current_stage].ready_signal.connect(
            self.current_stage_ready)

    def exec(self):
        return self.app.exec()

    def open_file(self):
        self.image_file, _ = QFileDialog.getOpenFileName(
            self.window, 'Открыть изображение', '', 'TIFF (*.tiff *.tif)')
        if self.image_file:
            for s in self.stages:
                s.input_data = None
            image = Image.open(self.image_file)
            self.current_stage = 0
            self.stages[0].input_data = image
            self.window.stages_radio_buttons[0].click()
            for rb in self.window.stages_radio_buttons[1:]:
                rb.setEnabled(False)
            self.window.proceed_button.setEnabled(True)
            self.add_image(image)

    def add_image(self, image):
        for i in self.window.main_image_scene.items():
            self.window.main_image_scene.removeItem(i)
        self.window.main_image_scene.addItem(
            QGraphicsPixmapItem(pil2pixmap(image)))

    def change_stage(self):
        for i, rb in enumerate(self.window.stages_radio_buttons):
            if rb.isChecked():
                if i != self.current_stage:
                    self.current_stage = i
                    self.window.set_stage(self.stages[i])
                    self.stages[i].ready_signal.connect(
                        self.current_stage_ready)
                    if self.stages[i].input_data is not None:
                        self.window.proceed_button.setEnabled(True)
                break

    def settings_changed(self):
        # print(*self.stages[self.current_stage].settings, sep='\n')
        pass

    def proceed_current_stage(self):
        print(f'Proceeding {self.stages[self.current_stage].name}')
        self.window.proceed_button.setEnabled(False)
        self.stages[self.current_stage].proceed()

    def current_stage_ready(self):
        s = self.stages[self.current_stage]
        print(f'Ready {s.name}')
        self.add_image(s.visualizer(s.result))
        if self.current_stage < len(self.window.stages_radio_buttons) - 1:
            self.window.stages_radio_buttons[self.current_stage +
                                             1].setEnabled(True)
            self.window.stages_radio_buttons[self.current_stage +
                                             1].setChecked(True)
            self.change_stage()
            self.window.proceed_button.setEnabled(True)
Пример #19
0
def main():
    app = QApplication(sys.argv)
    window = ShibumiWindow()
    window.show()
    return app.exec()
Пример #20
0
"""Entry point into the QBE application.

Instantiates the main window and executes it."""

# This import is deliberately placed at the top of __main__.py to guarantee
# that hagadias is able to import ElementTree before any other package does,
# enabling it to switch to the Python-mode XML parser to get line numbers.
from hagadias import gameroot  # noqa F401

import sys

from PySide6.QtWidgets import QApplication

from qbe.config import config
from qbe.explorer import MainWindow

qbe_app = QApplication(sys.argv)
qbe_app.setApplicationName(config['App name'])
main_window = MainWindow(qbe_app)
qbe_app.exec()
Пример #21
0
        self.myLayout.addWidget(self.infoLabel)

        self.setLayout(self.myLayout)
        self.show()

    def keyPressEvent(self, event: PySide6.QtGui.QKeyEvent) -> None:
        if event.key() == Qt.Key_Escape:
            self.close()

    def mouseDoubleClickEvent(self, event: PySide6.QtGui.QMouseEvent) -> None:
        self.close()

    def resizeEvent(self, event: PySide6.QtGui.QResizeEvent) -> None:
        self.infoLabel.setText("Window Resized to QSize(%d, %d)" %
                               (event.size().width(), event.size().height()))


if __name__ == '__main__':
    # Exception Handling
    try:
        myApp = QApplication(sys.argv)
        myWidget = MyWidget()
        myApp.exec()
        sys.exit(0)
    except NameError:
        print("Name Error:", sys.exc_info()[1])
    except SystemExit:
        print("Closing Window...")
    except Exception:
        print(sys.exc_info()[1])
Пример #22
0
        self.countBtn.clicked.connect(self.countClicks)
        self.longRunningBtn = QPushButton("Long-Running Task!", self)
        self.longRunningBtn.clicked.connect(self.runLongTask)
        # Set the layout
        layout = QVBoxLayout()
        layout.addWidget(self.clicksLabel)
        layout.addWidget(self.countBtn)
        layout.addStretch()
        layout.addWidget(self.stepLabel)
        layout.addWidget(self.longRunningBtn)
        self.centralWidget.setLayout(layout)

    def countClicks(self):
        self.clicksCount += 1
        self.clicksLabel.setText(f"Counting: {self.clicksCount} clicks")

    def reportProgress(self, n):
        self.stepLabel.setText(f"Long-Running Step: {n}")

    def runLongTask(self):
        """Long-running task in 5 steps."""
        for i in range(5):
            sleep(1)
            self.reportProgress(i + 1)


app = QApplication(sys.argv)
win = Window()
win.show()
sys.exit(app.exec())
Пример #23
0
        layout.addWidget(self.lblo)
        layout.addWidget(self.pbar)
        self.setLayout(layout)

    def timerEvent(self, e: QTimerEvent):
        if self.timer.isActive() or self.pbar.value() >= 100:
            self.timer.stop()
            self.lblh.setText("finished")
            return
        self.index += 1
        self.set(self.index)

    @Slot()
    def start(self):
        self.timer.start(100, self)

    @Slot()
    def finish(self):
        self.lblh.setText("Finished")
        self.lblo.setText(f"{self.curr_op} is complete.")

    def set(self, amt: int | float):
        self.pbar.setValue(int(amt))


if __name__ == "__main__":
    app = QApplication(sys.argv)
    progress = Progress()
    progress.show()
    app.exec()
Пример #24
0
def main():
    app = QApplication(sys.argv)
    ex = Scraper()
    ex.show()
    sys.exit(app.exec())