示例#1
0
    def main(cls):
        """
        Get the game number from ConfigFileManager.
        Begin main loop
            Instantiate Game object, passing it the game number.
            Execute Game.run() method
            If Game.run() returns 1, continue loop. Else, exit the program
        :return: none
        :rtype None:
        """
        rCode = Game.NEW_GAME
        while rCode == Game.NEW_GAME:
            cf = ConfigFileManager()
            game = Game(cf.gameNumber)
            rCode = game.run()

            # increment the game number in the config file
            if rCode == Game.QUIT_GAME:
                cf.gameNumber += 1

        return Game.QUIT_GAME
                #ConfigManager.write(self.config.events, filename=filename)
            except Exception as ex:
                sys.stderr.write(_("Unable to export file, exception: %s") % str(ex))
                error_dialog = Gtk.MessageDialog(self, 0,
                                        Gtk.MessageType.ERROR,
                                        Gtk.ButtonsType.CLOSE,
                                        _("Unable to export file"))
                error_dialog.format_secondary_text(str(ex))
                
                error_dialog.run()
                error_dialog.destroy()                         


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('filename', help='settings filename including path')
    parser.add_argument('instance', help='instance name')

    args = parser.parse_args()    

    filename = args.filename
    instance_name = args.instance

    # Display the window to allow the user to manage the events.
    config = ConfigFileManager(filename, instance_name)
    window = MainWindow(config)
    window.connect("delete-event", Gtk.main_quit)
    
    window.show_all()
    Gtk.main()
示例#3
0
 def loadConfigFile(self, configType):
     setattr(self, configType, ConfigFileManager(configType))