Exemplo n.º 1
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"))
Exemplo n.º 2
0
Arquivo: main.py Projeto: 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())
Exemplo n.º 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 = []
Exemplo n.º 4
0
Arquivo: main.py Projeto: 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)
Exemplo n.º 5
0
def main():
    appctxt = ApplicationContext()
    window = TextractGui()
    window.show()
    exit_code = appctxt.app.exec_()
    sys.exit(exit_code)
Exemplo n.º 6
0
import sys

from fbs_runtime.application_context import ApplicationContext
from PyQt5 import QtWidgets, QtGui

from app import App

if __name__ == '__main__':
    appctxt = ApplicationContext()  # 1. Instantiate ApplicationContext
    app = QtWidgets.QApplication(sys.argv)
    # load from fbs resources
    splash_image = appctxt.get_resource('signalum.png')
    pixmap = QtGui.QPixmap(splash_image)
    splash = QtWidgets.QSplashScreen(pixmap)
    splash.show()
    app.setOrganizationName("BisonCorps")
    app.setApplicationName("Signalum")
    a = App()
    splash.showMessage("Loading application")
    a.setWindowTitle("Signalum Desktop - (BisonCorps, 2019)")
    a.show()
    splash.showMessage("Finished loading application")
    splash.finish(a)
    # app.exec_()
    exit_code = appctxt.app.exec_()  # 2. Invoke appctxt.app.exec_()
    sys.exit(exit_code)
Exemplo n.º 7
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))
Exemplo n.º 8
0
 def setUp(self):
     set_app_context(ApplicationContext())
Exemplo n.º 9
0
class MainApp(QMainWindow, design.Ui_MainWindow):
    resized = QtCore.pyqtSignal()

    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 = []

    def stickman_update(self):
        self.label_4.setPixmap(
            QPixmap(
                self.appctxt.get_resource(
                    f'Man {str(self.attempt[0])}|{str(int(self.attempt[1]))}.svg'
                )))

    def logic(self, letter=None):
        if type(letter) != str:
            pass
        else:
            letter = letter.lower()
            right = False
            for x in range(0, len(self.word['word'])):
                if letter == self.word['word'][x]:
                    self.answered[x] = letter
                    right = True
            if letter.upper() in self.all_letters:
                if not right and not letter in self.prev:
                    self.attempt[0] += 1
                self.prev.append(letter)

        self.label_3.setText('Attempt left ' + str(7 - self.attempt[0]))
        self.label.setText(f'Description: {self.word["description"]}')
        self.label_2.setText(f"Word: {' '.join(self.answered)}")
        self.stickman_update()
        if 7 - self.attempt[0] <= 0:
            self.gameover()
        elif self.word['word'] == ''.join(self.answered):
            self.win()

    def gameover(self):
        QMessageBox.information(
            self, "Game Over",
            f"Right word is {self.word['word']}\nYou loose this game")
        self.close()

    def win(self):
        QMessageBox.information(
            self, "Win",
            f"Right word is {self.word['word']}\nСongratulations, you guessed this word)"
        )
        self.close()

    def resizeEvent(self, event):
        self.resized.emit()
        return super(MainApp, self).resizeEvent(event)

    def on_mwresize(self):
        if self.geometry().height() < 642:
            self.verticalFrame_2.setHidden(True)
        elif self.geometry().height() >= 642:
            self.verticalFrame_2.setHidden(False)

    def keyPressEvent(self, e):
        if e.key() == Qt.Key_Escape:
            self.close()
        for x in range(0, len(self.all_letters)):
            if self.all_letters[x] == e.text().upper():
                eval(f'self.key_pressed(self.pushButton_{x+1})')

    def key_pressed(self, letter):
        if letter.text() != "":
            self.logic(letter.text())
            letter.setText("")

    def setListener(self):
        self.all_letters = []
        for x in range(1, 27):
            eval(
                f'self.pushButton_{x}.clicked.connect(partial(self.key_pressed,self.pushButton_{x}))'
            )
            eval(f"self.all_letters.append(self.pushButton_{x}.text())")
Exemplo n.º 10
0
#!/usr/bin/env python3
from fbs_runtime.application_context import ApplicationContext
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import sys
import rdict
import hdict

print('Word Book. Alpha version. Developer: Rishabh Ranjan')
appctxt = ApplicationContext()  # 1. Instantiate ApplicationContext
app = QApplication(sys.argv)
app.setStyle('Fusion')

# upper_window = QWidget()
#
# upper_layout = QVBoxLayout()
#
# upper_title = QLabel('<b><span style="color: #4d2600">Word Book</span></b>')
# upper_title.setFont(QFont('Chalkboard', 48))
# upper_layout.addWidget(upper_title, alignment = Qt.AlignCenter)
#
# upper_subtitle = QLabel('Make words your best friends!')
# upper_subtitle.setFont(QFont('Chalkboard', 20))
# upper_layout.addWidget(upper_subtitle, alignment = Qt.AlignCenter)
#
# upper_layout.setAlignment(Qt.AlignTop)
# upper_window.setLayout(upper_layout)
#
# lower_window = QWidget()
#
Exemplo n.º 11
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)
Exemplo n.º 12
0
        dial = QDial(self.bottomRightGroupBox)
        dial.setValue(30)
        dial.setNotchesVisible(True)

        layout = QGridLayout()
        layout.addWidget(lineEdit, 0, 0, 1, 2)
        layout.addWidget(spinBox, 1, 0, 1, 2)
        layout.addWidget(dateTimeEdit, 2, 0, 1, 2)
        layout.addWidget(slider, 3, 0)
        layout.addWidget(scrollBar, 4, 0)
        layout.addWidget(dial, 3, 1, 2, 1)
        layout.setRowStretch(5, 1)
        self.bottomRightGroupBox.setLayout(layout)

    def createProgressBar(self):
        self.progressBar = QProgressBar()
        self.progressBar.setRange(0, 10000)
        self.progressBar.setValue(0)

        timer = QTimer(self)
        timer.timeout.connect(self.advanceProgressBar)
        timer.start(1000)


if __name__ == '__main__':
    appctxt = ApplicationContext()
    gallery = WidgetGallery()
    gallery.show()
    sys.exit(appctxt.app.exec_())
Exemplo n.º 13
0
#!/usr/bin/env python3

from fbs_runtime.application_context import ApplicationContext

appctxt = ApplicationContext()
datafile = appctxt.get_resource('hdict.data')
tdict = {}


def parse():
    global tdict
    for line in open(datafile):
        l = line.split(':')
        tdict[l[0]] = l[1].strip()


def define(w):
    global jdict
    nf_msg = '<span style="color:red">Sorry! Word not found.</span>'
    if w in tdict:
        r = ''
        for i, s in enumerate(tdict[w].split(','), start=1):
            r += f'{i:>3}. {s}<br/>'
        return r
    else:
        return nf_msg


# cli dictionary when run directly
def main():
    parse()
Exemplo n.º 14
0
from fbs_runtime.application_context import ApplicationContext
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QWidget, QLabel, QPushButton, QVBoxLayout

import requests
import sys

class MainWindow(QWidget):
    def __init__(self):
        super().__init__()
        text = QLabel()
        text.setWordWrap(True)
        button = QPushButton('Next quote >')
        button.clicked.connect(lambda: text.setText(_get_quote()))
        layout = QVBoxLayout()
        layout.addWidget(text)
        layout.addWidget(button)
        layout.setAlignment(button, Qt.AlignHCenter)
        self.setLayout(layout)

def _get_quote():
    return requests.get('https://build-system.fman.io/quote').text

if __name__ == '__main__':
    appctxt = ApplicationContext()
    stylesheet = appctxt.get_resource('styles.qss')
    appctxt.app.setStyleSheet(open(stylesheet).read())
    window = MainWindow()
    window.show()
    exit_code = appctxt.app.exec_()
    sys.exit(exit_code)
Exemplo n.º 15
0
def main():
    # app = QtWidgets.QApplication(sys.argv)  # Новый экземпляр QApplication
    app = ApplicationContext()
    window = ExampleApp()  # Создаём объект класса ExampleApp
    window.show()  # Показываем окно
    app.app.exec_()  # и запускаем приложение