Пример #1
0
def main_app(base_path, file, file_config):
    """Run the GUI of xBan

    The function initiates and resize the application
    """
    app = QApplication(sys.argv)

    if hasattr(QStyleFactory, "AA_UseHighDpiPixmaps"):
        app.setAttribute(Qt.AA_UseHighDpiPixmaps)

    with open(os.path.join(base_path, "xBanStyle.css"), "r") as style_sheet:
        style = style_sheet.read()

    app.setWindowIcon(QIcon(os.path.join(base_path, "xBanUI.png")))
    xBanApp = xBanWindow(base_path, file, file_config)

    xBanApp.setStyleSheet(style)

    # resize and move screen to center

    primary_screen = QGuiApplication.primaryScreen()
    if primary_screen:
        screen_size = primary_screen.availableSize()

        xBanApp.resize(screen_size.width() / 3, screen_size.height() / 2)
        xBanApp.move(
            (screen_size.width() - xBanApp.width()) / 2,
            (screen_size.height() - xBanApp.height()) / 2,
        )

        app.setStyle("Fusion")
        sys.exit(app.exec_())

    else:
        main_logger.error("Primary screen not found")
Пример #2
0
def main():

    app = QApplication(sys.argv)
    app.setStyle('Fusion')
    ex = MainWindow()
    ex.show()
    print("here goes")
    sys.exit(app.exec_())
Пример #3
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())
Пример #4
0
        with open(resource_path(f"assets/themes/{theme}"), "r") as fh:
            self.setStyleSheet(fh.read())

    def forwarder_generator(self):
        selected_app = self.ui.listAppsWidget.currentItem().data(Qt.UserRole)
        self.forwarder_gen_window = forwardergen.ForwarderWizard(self, selected_app=selected_app)
        self.forwarder_gen_window.show()


if __name__ == "__main__":
    global app
    app = QApplication()

    # set windows style for macOS users
    if platform.system() == "Darwin":
        app.setStyle('Fusion')

    global splash
    global splash_color

    # Splash
    image = QtGui.QImage(resource_path("assets/gui/splash.png"))
    splash_color = QColor("White")
    splash = QSplashScreen(QtGui.QPixmap(image))
    splash.show()

    window = MainWindow()
    window.show()
    splash.hide()
    app.exec()
Пример #5
0
            else:
                self.A0D1()

        # 3v1 rolls
        while (self.atk_total_armies >= 4) and (self.def_total_armies == 1):
            self.onslaught_atk_dice = sorted([randint(1, 6), randint(1, 6), randint(1, 6)])
            self.onslaught_def_dice = [randint(1, 6)]
            if (self.onslaught_def_dice[0] >= self.onslaught_atk_dice[0]) and \
                    (self.onslaught_def_dice[0] >= self.onslaught_atk_dice[1]) and \
                    (self.onslaught_def_dice[0] >= self.onslaught_atk_dice[2]):
                self.A1D0()
            else:
                self.A0D1()

        # Display roll results
        self.ui.atk_onslaught_result.setText(f"ATK -{str(self.atk_army_losses)}")
        self.ui.def_onslaught_result.setText(f"DEF -{str(self.def_army_losses)}")

        # Runs army_total_reset function (necessary to prevent previous result from being added to current result)
        self.army_total_reset()


# Boilerplate code block that makes a PySide6 app run (with the exception of 'app.setStyle('Windows')', which I included 
# in order to modify the app's aesthetic)
if __name__ == '__main__':             
    app = QApplication(sys.argv)
    app.setStyle('Windows')
    window = MainWindow()
    window.show()
    sys.exit(app.exec_())
Пример #6
0
        return True

    def setCurrentFile(self, fileName):
        self.curFile = fileName
        self.textEdit.document().setModified(False)
        self.setWindowModified(False)

        if self.curFile:
            shownName = self.strippedName(self.curFile)
        else:
            shownName = 'untitled.txt'

        self.setWindowTitle(" %s[*] - MateWriter" % shownName)

    def strippedName(self, fullFileName):
        return QFileInfo(fullFileName).fileName()


if __name__ == '__main__':
    import sys

    app = QApplication(sys.argv)
    app.setStyle('windowsvista')
    w = FramelessWindow()
    w.setWindowTitle('MateWriter')
    w.setWindowIcon(QIcon('icon-white.ico'))
    #    w.setWidget(MainWindow(MainWindow))       # Добавить свое окно
    w.setWidget(MainWindow())  # !!!
    w.show()
    sys.exit(app.exec_())
Пример #7
0
#############################################################################

import sys
from os.path import abspath, dirname, join

from PySide6.QtQml import QQmlApplicationEngine
from PySide6.QtWidgets import QApplication

from backend.application import Application
from backend.slotHandler import SlotHandler
import pathlib

if __name__ == '__main__':
    app = QApplication(sys.argv)
    engine = QQmlApplicationEngine()
    app.setStyle('Material')

    # Instance of the Python object
    my_app = Application(engine)

    # Expose the Python object to QML
    context = engine.rootContext()
    context.setContextProperty("app", my_app.slot_handler)

    # Get the path of the current directory, and then add the name
    # of the QML file, to load it.
    qmlFile = f'{pathlib.Path().absolute()}/frontend/view/Application.qml'

    engine.load(qmlFile)
    my_app.onload()
Пример #8
0
            base_dir = get_base_dir(local)

        if not is_exist(base_dir):
            mkdir(base_dir)
        cd(base_dir)
        if item.ss_type == 'file':
            if not is_exist(local):
                get_file(item.accessibleText())

        open_file(base_dir)
        if item.ss_type == 'project':
            open_file('cmd')

    def mousePressEvent(self, event: QtGui.QMouseEvent) -> None:
        self.__last_pos = event.globalPos()

    def mouseMoveEvent(self, event: QtGui.QMouseEvent) -> None:
        dx = event.globalX() - self.__last_pos.x()
        dy = event.globalY() - self.__last_pos.y()
        self.__last_pos = event.globalPos()
        self.move(self.x() + dx, self.y() + dy)


if __name__ == "__main__":
    logging.basicConfig(level=logging.DEBUG)
    app = QApplication([])
    app.setStyle(QStyleFactory.create("Fusion"))
    mainWindow = Exp()
    mainWindow.show()
    sys.exit(app.exec_())