Ejemplo n.º 1
0
    def __init__(self):
        ApplicationBase.__init__(self)
        self.prefs = Preferences()
        self.prefs.load()
        global APP_PREFS
        APP_PREFS = self.prefs
        locale = QLocale.system()
        dateFormat = self.prefs.dateFormat
        decimalSep = locale.decimalPoint()
        groupingSep = locale.groupSeparator()
        cachePath = QDesktopServices.storageLocation(QDesktopServices.CacheLocation)
        appdata = getAppData()
        plugin_model_path = op.join(BASE_PATH, 'plugin_examples')
        DateEdit.DATE_FORMAT = dateFormat
        self.model = MoneyGuruModel(
            view=self, date_format=dateFormat, decimal_sep=decimalSep,
            grouping_sep=groupingSep, cache_path=cachePath, appdata_path=appdata,
            plugin_model_path=plugin_model_path
        )
        # on the Qt side, we're single document based, so it's one doc per app.
        self.doc = Document(app=self)
        self.doc.model.connect()
        self.mainWindow = MainWindow(doc=self.doc)
        self.preferencesPanel = PreferencesPanel(self.mainWindow, app=self)
        self.aboutBox = AboutBox(self.mainWindow, self)
        if sys.argv[1:] and op.exists(sys.argv[1]):
            self.doc.open(sys.argv[1])
        elif self.prefs.recentDocuments:
            self.doc.open(self.prefs.recentDocuments[0])

        self.connect(self, SIGNAL('applicationFinishedLaunching()'), self.applicationFinishedLaunching)
        QCoreApplication.instance().aboutToQuit.connect(self.applicationWillTerminate)
Ejemplo n.º 2
0
    def __init__(self, filepath=None):
        ApplicationBase.__init__(self)
        self.prefs = Preferences()
        self.prefs.load()
        global APP_PREFS
        APP_PREFS = self.prefs
        locale = QLocale.system()
        dateFormat = self.prefs.dateFormat
        decimalSep = locale.decimalPoint()
        groupingSep = locale.groupSeparator()
        cachePath = QStandardPaths.standardLocations(QStandardPaths.CacheLocation)[0]
        appdata = getAppData()
        DateEdit.DATE_FORMAT = dateFormat
        self.model = MoneyGuruModel(
            view=self, date_format=dateFormat, decimal_sep=decimalSep,
            grouping_sep=groupingSep, cache_path=cachePath, appdata_path=appdata,
        )
        # on the Qt side, we're single document based, so it's one doc per app.
        self.doc = Document(app=self)
        self.doc.model.connect()
        self.mainWindow = MainWindow(doc=self.doc)
        self.preferencesPanel = PreferencesPanel(self.mainWindow, app=self)
        self.aboutBox = AboutBox(self.mainWindow, self)
        self.initialFilePath = None
        if filepath and op.exists(filepath):
            self.initialFilePath = filepath
        elif self.prefs.recentDocuments:
            self.initialFilePath = self.prefs.recentDocuments[0]

        self.finishedLaunching.connect(self.applicationFinishedLaunching)
        QCoreApplication.instance().aboutToQuit.connect(self.applicationWillTerminate)
Ejemplo n.º 3
0
 def __init__(self):
     LOGGING_LEVEL = logging.DEBUG if proxy.prefValue_(
         'DebugMode') else logging.WARNING
     logging.basicConfig(level=LOGGING_LEVEL,
                         format='%(levelname)s %(message)s',
                         handlers=[CocoaHandler()])
     install_exception_hook('https://github.com/hsoft/moneyguru/issues')
     logging.debug('started in debug mode')
     cache_path = op.join(proxy.getCachePath(), 'moneyGuru')
     appdata_path = op.join(proxy.getAppdataPath(), 'moneyGuru')
     currency_code = nonone(proxy.systemCurrency(), 'USD')
     logging.info('Currency code: {0}'.format(currency_code))
     try:
         system_currency = Currency(currency_code)
     except ValueError:  # currency does not exist
         logging.warning(
             'System currency {0} is not supported. Falling back to USD.'.
             format(currency_code))
         system_currency = USD
     date_format = proxy.systemShortDateFormat()
     logging.info('System date format: %s' % date_format)
     date_format = clean_format(date_format)
     logging.info('Cleaned date format: %s' % date_format)
     decimal_sep = proxy.systemNumberDecimalSeparator()
     grouping_sep = proxy.systemNumberGroupingSeparator()
     logging.info('System numeric separators: %s and %s' %
                  (grouping_sep, decimal_sep))
     model = Application(self,
                         date_format=date_format,
                         decimal_sep=decimal_sep,
                         grouping_sep=grouping_sep,
                         default_currency=system_currency,
                         cache_path=cache_path,
                         appdata_path=appdata_path)
     PyBaseApp.__init__(self, model)
Ejemplo n.º 4
0
    def __init__(self):

        Application.__init__(self)
        
        # Create player and put it in a spritegroup
        self.player = Player()
        self.playerGroup = pygame.sprite.GroupSingle(self.player)

        # Create the PlayerController and pass it player and add a keyboard listener to it
        self.pc = PlayerController(self.player)
        self.input.add_key_listener(self.pc)

        #Create Hud instance
        self.gameHud = Hud(self.player.health,self.hud)

        #Level change variable(s??)
        self.changing = False

        self.timer = 0
        self.check = False
        self.fadeAlpha = 255
        
        #self.fadeScreen = Surface(self.gameArea.get_size())
        #self.fadeScreen.fill((0,0,0))
        #self.fadeScreen.set_alpha(0)
                
        # Create the sound effects controller and give it a keyboard listener as well
        sc = SfxController(self.sounds, self)
        self.input.add_key_listener(sc)
        
        # Load the tilemap image, build a tilesheet out of it and render the tilesheet into an image which we can blit to the screen
        self.levels = []
        self.img_tiles = load_image(TILEMAP_IMAGE, (0,255,200))
        self.tileSheet = TileSheet(self.img_tiles, (TILE_SIZE)) 
        
        # Create an array of all the levels
        index = 0
        for levelFile in LEVELS:
            self.levels.append(Level(levelFile, self.tileSheet, index))
            index += 1
    
        self.currLevel = self.levels[0]
        self.count = 0

        #Camera init
        self.cam = Camera(self.player,self.currLevel.bounds,self.gameArea.get_size())
Ejemplo n.º 5
0
def main():
    # initialize pygame
    pygame.init()
    pygame.display.set_mode((1024, 768))
    pygame.display.set_caption("Super Coin Get v1.0")

    # create game
    app = Application(MainMenu)
    try:
        app.run()
    except KeyboardInterrupt:
        app.quit()
    finally:
        pygame.display.quit()
        pygame.quit()
Ejemplo n.º 6
0
    def __init__(self, filepath=None):
        ApplicationBase.__init__(self)
        self.prefs = Preferences()
        self.prefs.load()
        global APP_PREFS
        APP_PREFS = self.prefs
        locale = QLocale.system()
        dateFormat = self.prefs.dateFormat
        decimalSep = locale.decimalPoint()
        groupingSep = locale.groupSeparator()
        cachePath = QStandardPaths.standardLocations(
            QStandardPaths.CacheLocation)[0]
        appdata = getAppData()
        DateEdit.DATE_FORMAT = dateFormat
        self.model = MoneyGuruModel(
            view=self,
            date_format=dateFormat,
            decimal_sep=decimalSep,
            grouping_sep=groupingSep,
            cache_path=cachePath,
            appdata_path=appdata,
        )
        # on the Qt side, we're single document based, so it's one doc per app.
        self.doc = Document(app=self)
        self.doc.model.connect()
        self.mainWindow = MainWindow(doc=self.doc)
        self.preferencesPanel = PreferencesPanel(self.mainWindow, app=self)
        self.aboutBox = AboutBox(self.mainWindow, self)
        self.initialFilePath = None
        if filepath and op.exists(filepath):
            self.initialFilePath = filepath
        elif self.prefs.recentDocuments:
            self.initialFilePath = self.prefs.recentDocuments[0]

        self.finishedLaunching.connect(self.applicationFinishedLaunching)
        QCoreApplication.instance().aboutToQuit.connect(
            self.applicationWillTerminate)
Ejemplo n.º 7
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import click

from core.app import Application


@click.group()
def cli():
    pass


@cli.command()
@click.pass_context
def init_db(context):
    import core.models
    context.obj.db.create_all()


@cli.command()
@click.pass_context
def run(context):
    context.obj.run()


if __name__ == '__main__':
    cli(obj=Application())
Ejemplo n.º 8
0
class MoneyGuru(ApplicationBase):
    VERSION = MoneyGuruModel.VERSION
    LOGO_NAME = 'logo'

    def __init__(self, filepath=None):
        ApplicationBase.__init__(self)
        self.prefs = Preferences()
        self.prefs.load()
        global APP_PREFS
        APP_PREFS = self.prefs
        locale = QLocale.system()
        dateFormat = self.prefs.dateFormat
        decimalSep = locale.decimalPoint()
        groupingSep = locale.groupSeparator()
        cachePath = QStandardPaths.standardLocations(QStandardPaths.CacheLocation)[0]
        appdata = getAppData()
        DateEdit.DATE_FORMAT = dateFormat
        self.model = MoneyGuruModel(
            view=self, date_format=dateFormat, decimal_sep=decimalSep,
            grouping_sep=groupingSep, cache_path=cachePath, appdata_path=appdata,
        )
        # on the Qt side, we're single document based, so it's one doc per app.
        self.doc = Document(app=self)
        self.doc.model.connect()
        self.mainWindow = MainWindow(doc=self.doc)
        self.preferencesPanel = PreferencesPanel(self.mainWindow, app=self)
        self.aboutBox = AboutBox(self.mainWindow, self)
        self.initialFilePath = None
        if filepath and op.exists(filepath):
            self.initialFilePath = filepath
        elif self.prefs.recentDocuments:
            self.initialFilePath = self.prefs.recentDocuments[0]

        self.finishedLaunching.connect(self.applicationFinishedLaunching)
        QCoreApplication.instance().aboutToQuit.connect(self.applicationWillTerminate)

    # --- Public
    def showAboutBox(self):
        self.aboutBox.show()

    def showHelp(self):
        help_path = op.abspath(op.join(HELP_PATH, 'index.html'))
        if op.exists(help_path):
            url = QUrl.fromLocalFile(help_path)
        else:
            url = QUrl("https://www.hardcoded.net/moneyguru/help/en")
        QDesktopServices.openUrl(url)

    def showPreferences(self):
        self.preferencesPanel.load()
        if self.preferencesPanel.exec_() == QDialog.Accepted:
            self.preferencesPanel.save()
            self.prefs.prefsChanged.emit()

    # --- Event Handling
    def applicationFinishedLaunching(self):
        self.prefs.restoreGeometry('mainWindowGeometry', self.mainWindow)
        self.prefs.restoreGeometry('importWindowGeometry', self.mainWindow.importWindow)
        self.mainWindow.show()
        if self.initialFilePath:
            self.doc.open(self.initialFilePath, initial=True)

    def applicationWillTerminate(self):
        self.doc.close()
        self.willSavePrefs.emit()
        self.prefs.saveGeometry('mainWindowGeometry', self.mainWindow)
        self.prefs.saveGeometry('importWindowGeometry', self.mainWindow.importWindow)
        self.prefs.save()
        self.model.shutdown()

    # --- Signals
    willSavePrefs = pyqtSignal()

    # --- model --> view
    def get_default(self, key):
        return self.prefs.get_value(key)

    def set_default(self, key, value):
        self.prefs.set_value(key, value)

    def show_message(self, msg):
        window = QApplication.activeWindow()
        QMessageBox.information(window, '', msg)

    def open_url(self, url):
        url = QUrl(url)
        QDesktopServices.openUrl(url)

    def reveal_path(self, path):
        url = QUrl.fromLocalFile(str(path))
        QDesktopServices.openUrl(url)
Ejemplo n.º 9
0
import logging
import tornado.web
import tornado.ioloop
import tornado.httpserver
from tornado.options import define, options
from core.app import Application

if __name__ == '__main__':
    define('port', default=8888, help='Port listened')
    tornado.options.parse_command_line()
    http_server = tornado.httpserver.HTTPServer(Application())
    http_server.listen(options.port)
    logging.basicConfig(format='%(asctime) %(message)s')
    logging.warning('WebSocket Injection Proxy Listening on 0.0.0.0:%d' %
                    options.port)
    tornado.ioloop.IOLoop.instance().start()
Ejemplo n.º 10
0
class MoneyGuru(ApplicationBase):
    VERSION = MoneyGuruModel.VERSION
    LOGO_NAME = 'logo'

    def __init__(self, filepath=None):
        ApplicationBase.__init__(self)
        self.prefs = Preferences()
        self.prefs.load()
        global APP_PREFS
        APP_PREFS = self.prefs
        locale = QLocale.system()
        dateFormat = self.prefs.dateFormat
        decimalSep = locale.decimalPoint()
        groupingSep = locale.groupSeparator()
        cachePath = QStandardPaths.standardLocations(
            QStandardPaths.CacheLocation)[0]
        appdata = getAppData()
        DateEdit.DATE_FORMAT = dateFormat
        self.model = MoneyGuruModel(
            view=self,
            date_format=dateFormat,
            decimal_sep=decimalSep,
            grouping_sep=groupingSep,
            cache_path=cachePath,
            appdata_path=appdata,
        )
        # on the Qt side, we're single document based, so it's one doc per app.
        self.doc = Document(app=self)
        self.doc.model.connect()
        self.mainWindow = MainWindow(doc=self.doc)
        self.preferencesPanel = PreferencesPanel(self.mainWindow, app=self)
        self.aboutBox = AboutBox(self.mainWindow, self)
        self.initialFilePath = None
        if filepath and op.exists(filepath):
            self.initialFilePath = filepath
        elif self.prefs.recentDocuments:
            self.initialFilePath = self.prefs.recentDocuments[0]

        self.finishedLaunching.connect(self.applicationFinishedLaunching)
        QCoreApplication.instance().aboutToQuit.connect(
            self.applicationWillTerminate)

    # --- Public
    def showAboutBox(self):
        self.aboutBox.show()

    def showHelp(self):
        url = QUrl.fromLocalFile(op.abspath(op.join(HELP_PATH, 'index.html')))
        QDesktopServices.openUrl(url)

    def showPreferences(self):
        self.preferencesPanel.load()
        if self.preferencesPanel.exec_() == QDialog.Accepted:
            self.preferencesPanel.save()
            self.prefs.prefsChanged.emit()

    # --- Event Handling
    def applicationFinishedLaunching(self):
        self.prefs.restoreGeometry('mainWindowGeometry', self.mainWindow)
        self.prefs.restoreGeometry('importWindowGeometry',
                                   self.mainWindow.importWindow)
        self.mainWindow.show()
        if self.initialFilePath:
            self.doc.open(self.initialFilePath, initial=True)

    def applicationWillTerminate(self):
        self.doc.close()
        self.willSavePrefs.emit()
        self.prefs.saveGeometry('mainWindowGeometry', self.mainWindow)
        self.prefs.saveGeometry('importWindowGeometry',
                                self.mainWindow.importWindow)
        self.prefs.save()
        self.model.shutdown()

    # --- Signals
    willSavePrefs = pyqtSignal()

    # --- model --> view
    def get_default(self, key):
        return self.prefs.get_value(key)

    def set_default(self, key, value):
        self.prefs.set_value(key, value)

    def show_message(self, msg):
        window = QApplication.activeWindow()
        QMessageBox.information(window, '', msg)

    def open_url(self, url):
        url = QUrl(url)
        QDesktopServices.openUrl(url)

    def reveal_path(self, path):
        url = QUrl.fromLocalFile(str(path))
        QDesktopServices.openUrl(url)
Ejemplo n.º 11
0
def main():
    res = Resources()
    app = Application((800, 600), "Editor", resizable=True)
    app.process(Editor())
    app.run()
Ejemplo n.º 12
0
class MoneyGuru(ApplicationBase):
    VERSION = MoneyGuruModel.VERSION
    LOGO_NAME = 'logo'
    
    def __init__(self):
        ApplicationBase.__init__(self)
        global APP_INSTANCE
        APP_INSTANCE = self
        self.prefs = Preferences()
        self.prefs.load()
        locale = QLocale.system()
        dateFormat = self.prefs.dateFormat
        decimalSep = locale.decimalPoint()
        groupingSep = locale.groupSeparator()
        cachePath = QDesktopServices.storageLocation(QDesktopServices.CacheLocation)
        appdata = getAppData()
        plugin_model_path = op.join(BASE_PATH, 'plugin_examples')
        DateEdit.DATE_FORMAT = dateFormat
        self.model = MoneyGuruModel(view=self, date_format=dateFormat, decimal_sep=decimalSep,
            grouping_sep=groupingSep, cache_path=cachePath, appdata_path=appdata,
            plugin_model_path=plugin_model_path)
        # on the Qt side, we're single document based, so it's one doc per app.
        self.doc = Document(app=self)
        self.doc.model.connect()
        self.mainWindow = MainWindow(doc=self.doc)
        self.importWindow = ImportWindow(self.mainWindow, doc=self.doc)
        self.csvOptionsWindow = CSVOptionsWindow(self.mainWindow, doc=self.doc)
        self.preferencesPanel = PreferencesPanel(self.mainWindow, app=self)
        self.aboutBox = AboutBox(self.mainWindow, self, withreg=False)
        if sys.argv[1:] and op.exists(sys.argv[1]):
            self.doc.open(sys.argv[1])
        elif self.prefs.recentDocuments:
            self.doc.open(self.prefs.recentDocuments[0])
        
        self.connect(self, SIGNAL('applicationFinishedLaunching()'), self.applicationFinishedLaunching)
        QCoreApplication.instance().aboutToQuit.connect(self.applicationWillTerminate)

        self.prefsChanged.emit()
    
    #--- Public
    def showAboutBox(self):
        self.aboutBox.show()
    
    def showHelp(self):
        url = QUrl.fromLocalFile(op.abspath(op.join(HELP_PATH, 'index.html')))
        QDesktopServices.openUrl(url)
    
    def showPreferences(self):
        self.preferencesPanel.load()
        if self.preferencesPanel.exec_() == QDialog.Accepted:
            self.preferencesPanel.save()
            self.prefsChanged.emit()
    
    #--- Event Handling
    def applicationFinishedLaunching(self):
        self.prefs.restoreGeometry('mainWindowGeometry', self.mainWindow)
        self.prefs.restoreGeometry('importWindowGeometry', self.importWindow)
        self.mainWindow.show()
    
    def applicationWillTerminate(self):
        self.doc.close()
        self.willSavePrefs.emit()
        self.prefs.saveGeometry('mainWindowGeometry', self.mainWindow)
        self.prefs.saveGeometry('importWindowGeometry', self.importWindow)
        self.prefs.save()
        self.model.shutdown()
    
    #--- Signals
    prefsChanged = pyqtSignal()
    willSavePrefs = pyqtSignal()
    
    #--- model --> view
    def get_default(self, key):
        return self.prefs.get_value(key)
    
    def set_default(self, key, value):
        self.prefs.set_value(key, value)
    
    def show_fairware_nag(self, prompt):
        reg = Registration(self.model)
        reg.show_fairware_nag(prompt)
    
    def show_demo_nag(self, prompt):
        reg = Registration(self.model)
        reg.show_demo_nag(prompt)
    
    def show_message(self, msg):
        window = QApplication.activeWindow()
        QMessageBox.information(window, '', msg)
    
    def open_url(self, url):
        url = QUrl(url)
        QDesktopServices.openUrl(url)
    
    def reveal_path(self, path):
        url = QUrl.fromLocalFile(str(path))
        QDesktopServices.openUrl(url)