Exemple #1
0
def main():

    with open(JSON_LOGGING_CONFIG_FILENAME, 'r') as loggingConfigurationFile:
        configurationDictionary = json.load(loggingConfigurationFile)

    logging.config.dictConfig(configurationDictionary)
    logging.logProcesses = False
    logging.logThreads = False

    logger = logging.getLogger(MADE_UP_PRETTY_MAIN_NAME)

    themeLoader: ThemeLoader = ThemeLoader()
    themeLoader.load()
    themeRoot: Theme = themeLoader.themeRoot
    Theme.setThemeRoot(themeRoot)

    pygame.init()
    pygame.display.set_caption("Python Chip 8 Emulator")

    surface: Surface = pygame.display.set_mode(
        (Chip8Screen.WIDTH * Chip8Screen.SCALE_FACTOR,
         (Chip8Screen.HEIGHT * Chip8Screen.SCALE_FACTOR) +
         MENU_BAR_HEIGHT_ADJUSTMENT + INTERNALS_DISPLAY_HEIGHT_ADJUSTMENT))
    shell: Chip8UIShell = Chip8UIShell(theSurface=surface)

    logger.info(f"Starting {MADE_UP_PRETTY_MAIN_NAME}")

    shell.run()
Exemple #2
0
def main():

    with open(JSON_LOGGING_CONFIG_FILENAME, 'r') as loggingConfigurationFile:
        configurationDictionary = json.load(loggingConfigurationFile)

    logging.config.dictConfig(configurationDictionary)
    logging.logProcesses = False
    logging.logThreads = False

    logger = logging.getLogger(MADE_UP_PRETTY_MAIN_NAME)

    themeLoader: ThemeLoader = ThemeLoader()
    themeLoader.load()
    themeRoot: Theme = themeLoader.themeRoot
    Theme.setThemeRoot(themeRoot)

    pygame.init()
    pygame.display.set_caption("Python Chip 8 Emulator")

    windowWidthHeight: Tuple[int,int] = (720, 500)
    surface: Surface = pygame.display.set_mode(windowWidthHeight)
    shell:   Chip8ScreenTestUIShell = Chip8ScreenTestUIShell(theSurface=surface)

    logger.info(f"Starting {MADE_UP_PRETTY_MAIN_NAME}")

    shell.run()
Exemple #3
0
def main():

    with open(JSON_LOGGING_CONFIG_FILENAME, 'r') as loggingConfigurationFile:
        configurationDictionary = json.load(loggingConfigurationFile)

    logging.config.dictConfig(configurationDictionary)
    logging.logProcesses = False
    logging.logThreads = False

    #
    # Have to get all the theme attributes defined first before
    # anything is imported with ThemeProperty attributes
    #
    themeLoader: ThemeLoader = ThemeLoader()
    themeLoader.load()
    themeRoot: Theme = themeLoader.themeRoot
    Theme.setThemeRoot(themeRoot)

    pygame.init()

    gl_flags = flags | OPENGL

    if "-s" in sys.argv:
        print("Using single buffering")
    else:
        print("Using double buffering")
        gl_flags |= DOUBLEBUF

    display: Surface = pygame.display.set_mode(screen_size, gl_flags)
    root: RootWidget = RootWidget(display)
    root.bg_color: Color = Color("blue")

    add_demo_widgets(root)

    root.run()
 def setUpClass(cls):
     """"""
     TestBase.setUpLogging()
     themeLoader: ThemeLoader = ThemeLoader()
     themeLoader.load()
     themeRoot: Theme = themeLoader.themeRoot
     Theme.setThemeRoot(themeRoot)
Exemple #5
0
    def loadAClass(self, classDict: SectionProxy) -> Theme:

        themeName = classDict["name"]

        theme = Theme(name=themeName)

        for attr in classDict:
            if self.ignoreAttribute(attr):
                pass
            else:
                attrStrValue: str = classDict[attr]
                if not attrStrValue:
                    setattr(theme, attr, None)
                elif "color" in attr or "font" in attr:
                    attrTuple = make_tuple(attrStrValue)
                    setattr(theme, attr, attrTuple)
                elif "True" in attrStrValue or "False" in attrStrValue:
                    attrBool = bool(attrStrValue)
                    setattr(theme, attr, attrBool)
                elif attrStrValue.isnumeric():
                    attrInt = int(attrStrValue)
                    setattr(theme, attr, attrInt)
                elif ThemeLoader.isFloat(attrStrValue):
                    floatAttr = float(attrStrValue)
                    setattr(theme, attr, floatAttr)
                else:
                    setattr(theme, attr, attrStrValue)

        return theme
    def testFontLoad(self):

        testTheme: Theme = Theme(name="bogus")
        fontSpec: tuple = (18, BUILT_IN_BOLD_FONT_NAME)
        fontPath: str = testTheme._findFontFile(fontSpec)

        exists = os.path.isfile(fontPath)
        self.assertTrue(exists, "Where is my font!")
def main():
    #
    # This has to be done as early as possible to affect the logging
    # statements in the class files
    # Pycharm gives a warning on the order of imports, Oh well
    #

    with open(JSON_LOGGING_CONFIG_FILENAME, 'r') as loggingConfigurationFile:
        configurationDictionary = json.load(loggingConfigurationFile)

    logging.config.dictConfig(configurationDictionary)
    logging.logProcesses = False
    logging.logThreads = False

    #
    # Have to get all the theme attributes defined first before
    # anything is imported with ThemeProperty attributes
    #
    themeLoader: ThemeLoader = ThemeLoader()
    themeLoader.load()
    themeRoot: Theme = themeLoader.themeRoot
    Theme.setThemeRoot(themeRoot)

    from albow.demo.AlbowDemoShell import AlbowDemoShell

    pygame.init()
    pygame.display.set_caption(f'{DEMO_WINDOW_TITLE}')

    # "file_handler": {
    #   "class": "logging.FileHandler",
    #   "level": "DEBUG",
    #   "formatter": "simple",
    #   "filename": "demo_logging.log",
    #   "encoding": "utf8"
    #   },
    logger = logging.getLogger(__name__)
    display = pygame.display.set_mode(SCREEN_SIZE, DISPLAY_FLAGS)
    shellArgs = {'margin': 5}
    shell = AlbowDemoShell(display, **shellArgs)

    logger.info("Starting %s", __name__)

    shell.run()
    def testFontCacheHit(self):
        pygame.init()

        testTheme: Theme = Theme(name="bogus")

        fontSpec: tuple = (18, BUILT_IN_BOLD_FONT_NAME)
        fontPath: str = testTheme._findFontFile(fontSpec)
        font1 = testTheme._loadFont(fontPath=fontPath, fontSize=fontSpec[0])
        font2 = testTheme._loadFont(fontPath=fontPath, fontSize=fontSpec[0])

        self.assertEqual(first=font1,
                         second=font2,
                         msg="Should be the one from the cache")
    def testFontCacheLoad(self):

        self.assertTrue(
            len(Theme.fontCache) == 0, "Oops not in an initial state")

        pygame.init()

        testTheme: Theme = Theme(name="bogus")

        fontSpec: tuple = (18, BUILT_IN_BOLD_FONT_NAME)
        fontPath: str = testTheme._findFontFile(fontSpec)
        testTheme._loadFont(fontPath=fontPath, fontSize=fontSpec[0])

        self.assertTrue(len(Theme.fontCache) == 1, "Oops cache is not working")
 def get_from_theme(self, cls, name):
     return Theme.getThemeRoot().get_font(cls, name)
Exemple #11
0
 def predict_font(self, kwds, name='font'):
     return kwds.get(name) or Theme.getThemeRoot().get_font(
         self.__class__, name)
Exemple #12
0
 def predict(self, kwds, name):
     try:
         return kwds[name]
     except KeyError:
         return Theme.getThemeRoot().get(self.__class__, name)