class MainApplication(wx.App, GridActionEventMixin): """Main application class for pyspread.""" dimensions = (1, 1, 1) # Will be overridden anyways options = {} filename = None def __init__(self, *args, **kwargs): try: self.S = kwargs.pop("S") except KeyError: self.S = None # call parent class initializer wx.App.__init__(self, *args, **kwargs) def OnInit(self): """Init class that is automatically run on __init__""" # Get command line options and arguments self.get_cmd_args() # Initialize the prerequisitions to construct the main window wx.InitAllImageHandlers() # Main window creation from src.gui._main_window import MainWindow self.main_window = MainWindow(None, title="pyspread", S=self.S) ## Initialize file loading via event # Create GPG key if not present try: from src.lib.gpg import genkey genkey() except ImportError: pass except ValueError: # python-gnupg is installed but gnupg is not insatlled pass # Show application window self.SetTopWindow(self.main_window) self.main_window.Show() # Load filename if provided if self.filepath is not None: post_command_event(self.main_window, self.GridActionOpenMsg, attr={"filepath": self.filepath}) self.main_window.filepath = self.filepath return True def get_cmd_args(self): """Returns command line arguments Created attributes ------------------ options: dict \tCommand line options dimensions: Three tuple of Int \tGrid dimensions, default value (1,1,1). filename: String \tFile name that is loaded on start """ cmdp = Commandlineparser() self.options, self.filepath = cmdp.parse() if self.filename is None: rows, columns, tables = self.options.dimensions cmdp.config["grid_rows"] = str(rows) cmdp.config["grid_columns"] = str(columns) cmdp.config["grid_tables"] = str(tables)
class MainApplication(wx.App, GridActionEventMixin): """Main application class for pyspread.""" def __init__(self, *args, **kwargs): try: self.S = kwargs.pop("S") except KeyError: self.S = None from src.config import config self.config = config # call parent class initializer wx.App.__init__(self, *args, **kwargs) def OnInit(self): """Init class that is automatically run on __init__""" # Get command line options and arguments cmdp = Commandlineparser() options, filename = cmdp.parse() kwargs = {"title": "pyspread", "S": self.S} # Store command line input in config if no file is provided if filename is None: kwargs["dimensions"] = options.dimensions # Main window creation from src.gui._main_window import MainWindow self.main_window = MainWindow(None, **kwargs) # Initialize file loading via event if options.new_gpgkey: # Create GPG key if not present try: from src.lib.gpg import genkey self.config["gpg_key_fingerprint"] = repr("") genkey() except ImportError: pass except ValueError: # python-gnupg is installed but gnupg is not installed pass # Show application window self.SetTopWindow(self.main_window) self.main_window.Show() # Load filename if provided if filename is not None: post_command_event(self.main_window, self.GridActionOpenMsg, attr={"filepath": filename}) self.main_window.filepath = filename return True