Exemple #1
0
    def LoadPath(self, path, use=False):
        if path is None:
            path = fileservice.getDataFilePath(self.DB_NAME)

        store = PersistentStore(path)
        store.AutoSave = self.AutoSave
        model = store.GetModel()

        self.Models.append(model)
        if use:
            self.Model = model

        return model
Exemple #2
0
    def LoadPath(self, path, use=False):
        if path is None:
            path = fileservice.getDataFilePath(self.DB_NAME)

        store = PersistentStore(path)
        store.AutoSave = self.AutoSave
        model = store.GetModel()

        self.Models.append(model)
        if use:
            self.Model = model

        return model
Exemple #3
0
    def InitConfig(self):
        """Initialize our configuration object."""
        # It is only necessary to initialize any default values we
        # have which differ from the default values of the types,
        # so initializing an Int to 0 or a Bool to False is not needed.
        self.wxApp = wx.App(False)
        self.wxApp.SetAppName("wxBanker")
        self.wxApp.Controller = self
        configPath = fileservice.getConfigFilePath(self.CONFIG_NAME)

        # If we support XDG and the config file doesn't exist, it might be time to migrate.
        if fileservice.xdg and not os.path.exists(configPath):
            # If we can find the files at the old locations, we should migrate them.
            oldConfigPath = os.path.expanduser("~/.wxBanker")
            oldBankPath = os.path.expanduser("~/.wxbanker/bank.db")
            self.MigrateIfFound(
                oldConfigPath, fileservice.getConfigFilePath(self.CONFIG_NAME))
            self.MigrateIfFound(oldBankPath,
                                fileservice.getDataFilePath(self.DB_NAME))

        # Okay, now our files are in happy locations, let's go!
        config = wx.FileConfig(localFilename=configPath)
        wx.Config.Set(config)
        if not config.HasEntry("SIZE_X"):
            config.WriteInt("SIZE_X", 960)
            config.WriteInt("SIZE_Y", 720)
        if not config.HasEntry("POS_X"):
            config.WriteInt("POS_X", 100)
            config.WriteInt("POS_Y", 100)
        if not config.HasEntry("SHOW_CALC"):
            config.WriteBool("SHOW_CALC", False)
        if not config.HasEntry("AUTO-SAVE"):
            config.WriteBool("AUTO-SAVE", True)
        if not config.HasEntry("HIDE_ZERO_BALANCE_ACCOUNTS"):
            config.WriteBool("HIDE_ZERO_BALANCE_ACCOUNTS", False)
        if not config.HasEntry("SHOW_CURRENCY_NICK"):
            config.WriteBool("SHOW_CURRENCY_NICK", False)

        # Set the auto-save option as appropriate.
        self.AutoSave = config.ReadBool("AUTO-SAVE")
        self.ShowZeroBalanceAccounts = not config.ReadBool(
            "HIDE_ZERO_BALANCE_ACCOUNTS")
        self.ShowCurrencyNick = config.ReadBool("SHOW_CURRENCY_NICK")
Exemple #4
0
    def InitConfig(self):
        """Initialize our configuration object."""
        # It is only necessary to initialize any default values we
        # have which differ from the default values of the types,
        # so initializing an Int to 0 or a Bool to False is not needed.
        self.wxApp = wx.App(False)
        self.wxApp.SetAppName("wxBanker")
        self.wxApp.Controller = self
        configPath = fileservice.getConfigFilePath(self.CONFIG_NAME)

        # If we support XDG and the config file doesn't exist, it might be time to migrate.
        if fileservice.xdg and not os.path.exists(configPath):
            # If we can find the files at the old locations, we should migrate them.
            oldConfigPath = os.path.expanduser("~/.wxBanker")
            oldBankPath = os.path.expanduser("~/.wxbanker/bank.db")
            self.MigrateIfFound(oldConfigPath, fileservice.getConfigFilePath(self.CONFIG_NAME))
            self.MigrateIfFound(oldBankPath, fileservice.getDataFilePath(self.DB_NAME))
            
        # Okay, now our files are in happy locations, let's go!
        config = wx.FileConfig(localFilename=configPath)
        wx.Config.Set(config)
        if not config.HasEntry("SIZE_X"):
            config.WriteInt("SIZE_X", 960)
            config.WriteInt("SIZE_Y", 720)
        if not config.HasEntry("POS_X"):
            config.WriteInt("POS_X", 100)
            config.WriteInt("POS_Y", 100)
        if not config.HasEntry("SHOW_CALC"):
            config.WriteBool("SHOW_CALC", False)
        if not config.HasEntry("AUTO-SAVE"):
            config.WriteBool("AUTO-SAVE", True)
        if not config.HasEntry("HIDE_ZERO_BALANCE_ACCOUNTS"):
            config.WriteBool("HIDE_ZERO_BALANCE_ACCOUNTS", False)
        if not config.HasEntry("SHOW_CURRENCY_NICK"):
            config.WriteBool("SHOW_CURRENCY_NICK", False)

        # Set the auto-save option as appropriate.
        self.AutoSave = config.ReadBool("AUTO-SAVE")
        self.ShowZeroBalanceAccounts = not config.ReadBool("HIDE_ZERO_BALANCE_ACCOUNTS")
        self.ShowCurrencyNick = config.ReadBool("SHOW_CURRENCY_NICK")