Example #1
0
File: main.py Project: ekisu/NC2DT
def main():
    appctxt = ApplicationContext()
    set_app_context(appctxt)

    osu_path = get_osu_path()
    osu_db_file_path = osu_path is not None and (osu_path /
                                                 Path("osu!.db")) or None

    if osu_path is None or \
        not osu_db_file_path.exists():
        QtWidgets.QMessageBox.warning(
            None, "NC2DT", ("Couldn't find your osu! installation.\n"
                            "Please select the folder where it's installed."))
        new_path = QtWidgets.QFileDialog.getExistingDirectory(
            None, "Please select your osu! installation")
        if new_path == "":
            QtWidgets.QMessageBox.critical(None, "NC2DT",
                                           "No folder was selected, exiting.")
            sys.exit(1)

        set_osu_path(new_path)
        osu_db_file_path = Path(new_path) / Path("osu!.db")

    try:
        osu_db = OsuDB(osu_db_file_path)
    except FileNotFoundError:
        QtWidgets.QMessageBox.critical(None, "NC2DT",
                                       "Couldn't open osu!.db. Exiting.")
        sys.exit(1)

    main_window = MainWindow(osu_db)
    main_window.show()
    sys.exit(appctxt.app.exec())
Example #2
0
 def setUp(self):
     set_app_context(ApplicationContext())
     self.osu_path = asset_path_builder(Path("mock_osu_folder"))
     self.beatmap_folder = self.osu_path / Path("Songs/1")
     self.beatmap = Beatmap("Artist", "Title", "Creator", "Diff", "audio.mp3", "1")
     beep = self.beatmap_folder / Path("beep.mp3")
     shutil.copy(beep, self.beatmap_folder / Path("audio.mp3"))
Example #3
0
 def __init__(self):
     super().__init__()
     self.setupUi(self)
     self.auto_add = True
     self.resized.connect(self.on_mwresize)
     self.show()
     self.appctxt = ApplicationContext()
     self.setListener()
     self.attempt = [1, False]
     try:
         a = parser.RandomRightWord()
         self.word = a.get_word()
     except requests.exceptions.ConnectionError:
         try:
             a = parser.RandomWord()
             self.word = a.get_word()
         except requests.exceptions.ConnectionError:
             with open(self.appctxt.get_resource('dictionary.txt'),
                       'r') as f:
                 f = f.read().split('\n')
                 for x in range(len(f) - 1, -1, -1):
                     if f[x] == '':
                         del f[x]
                 random.shuffle(f)
                 word = f[0].split('||')
                 self.word = {'word': word[0], 'description': word[1]}
         except FileNotFoundError:
             QMessageBox.warning(
                 self, "Error",
                 "Connect to internet or make dictionary in the program's resource folder"
             )
             return
     if self.auto_add:
         with open("dictionary.txt", 'a') as f:
             f.write(word['word'] + "||" + word['description'])
     self.answered = ['_' for x in self.word['word']]
     self.logic()
     self.prev = []
Example #4
0
File: main.py Project: nlpcvai/fbs
from fbs_runtime.application_context import ApplicationContext
from ${python_bindings}.QtWidgets import QMainWindow

import sys

if __name__ == '__main__':
    appctxt = ApplicationContext()       # 1. Instantiate ApplicationContext
    window = QMainWindow()
    window.resize(250, 150)
    window.show()
    exit_code = appctxt.app.exec_()      # 2. Invoke appctxt.app.exec_()
    sys.exit(exit_code)
Example #5
0
def main():
    appctxt = ApplicationContext()
    window = TextractGui()
    window.show()
    exit_code = appctxt.app.exec_()
    sys.exit(exit_code)
Example #6
0
#!/usr/bin/env python3

# TODO: support for derivative words

from fbs_runtime.application_context import ApplicationContext
import json

# TODO: solve absolute path issue in the scr/.../rdict.py file
appctxt = ApplicationContext()
datafile = appctxt.get_resource('rdict.json')
jdict = None

# reads json file 'datafile' into 'jdict' list
def parse():
    global jdict
    df = open(datafile)
    raw = df.read()
    df.close()
    jdict = json.loads(raw)

# recursively adds lines of formatted 'val' to 'outlist'
def _fstr(val, outlist, offstr = '', tabstr = ' ' * 4):
    if type(val) == dict:
        for k, v in val.items():
            outlist.append('{}{}:'.format(offstr, '<b>' + k + '</b>'))
            _fstr(v, outlist, offstr + tabstr, tabstr)
    elif type(val) == list:
        if len(val) == 1:
            _fstr(val[0], outlist, offstr, tabstr)
        elif type(val[0]) == str:
            outlist.append(offstr + ', '.join(val))
Example #7
0
 def setUp(self):
     set_app_context(ApplicationContext())
Example #8
0
from fbs_runtime.application_context import ApplicationContext
from PyQt5.QtWidgets import QMainWindow
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPalette
from mainUI import Ui_MainWindow

import sys

if __name__ == '__main__':


    app = ApplicationContext()

    window = QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(window)
    window.show()
    exit_code = app.app.exec_()      # 2. Invoke appctxt.app.exec_()
    sys.exit(exit_code)
Example #9
0
def main():
    # app = QtWidgets.QApplication(sys.argv)  # Новый экземпляр QApplication
    app = ApplicationContext()
    window = ExampleApp()  # Создаём объект класса ExampleApp
    window.show()  # Показываем окно
    app.app.exec_()  # и запускаем приложение