def OnInit(self): import sys sys.stdout = sys.__stdout__ sys.stderr = sys.__stderr__ # needed for wx >= 2.3.4 to disable wxPyAssertionError exceptions if misc.check_wx_version(2, 3, 4): self.SetAssertMode(0) wx.InitAllImageHandlers() config.init_preferences() # ALB 2004-10-27 if wx.Platform == '__WXGTK__' and config.preferences.use_kde_dialogs: import kdefiledialog if kdefiledialog.test_kde(): misc.FileSelector = kdefiledialog.kde_file_selector misc.DirSelector = kdefiledialog.kde_dir_selector wx.ArtProvider.PushProvider(wxGladeArtProvider()) frame = wxGladeFrame() ## if wx.Platform == '__WXMSW__': ## def on_activate(event): ## if event.GetActive() and not frame.IsIconized(): ## frame.show_and_raise() ## event.Skip() ## wx.EVT_ACTIVATE_APP(self, on_activate) self.SetTopWindow(frame) self.SetExitOnFrameDelete(True) wx.EVT_IDLE(self, self.on_idle) return True
def init_stage2(use_gui): """\ Initialise the remaining (non-path) parts of wxGlade (second stage) @param use_gui: Starting wxGlade GUI @type use_gui: Boolean """ common.use_gui = use_gui if use_gui: # ensure minimal wx version if not hasattr(sys, 'frozen') and \ 'wxversion' not in sys.modules and \ 'wx' not in sys.modules: import wxversion wxversion.ensureMinimal("2.6") # store current platform (None is default) import wx common.platform = wx.Platform # codewrites, widgets and sizers are loaded in class main.wxGladeFrame else: # use_gui has to be set before importing config import config config.init_preferences() common.load_code_writers() common.load_widgets() common.load_sizers()
def command_line_code_generation( options, args ): """\ starts a code generator without starting the GUI. """ import common if not options: usage() if not options[0]: usage() # a language for code generation must be provided if len( args ) != 1: usage() # an input file name must be provided common.use_gui = False # don't import wxPython.wx # use_gui has to be set before importing config import config config.init_preferences() common.load_code_writers() common.load_widgets() common.load_sizers() try: from xml_parse import CodeWriter out_path = None language = '' for option, arg in options: if option == '-g' or option == '--generate-code': language = arg elif option == '-o' or option == '--output': out_path = _fix_path( arg ) writer = common.code_writers[language] CodeWriter( writer, _fix_path( args[0] ), out_path = out_path ) except KeyError: print >> sys.stderr, ( 'Error: no writer for language "%s" available' ) % language sys.exit( 1 ) except Exception, e: print >> sys.stderr, ( "Error: %s" ) % e import traceback; traceback.print_exc() sys.exit( 1 )
def setUp(self): """\ Initialise parts of wxGlade only """ # initialise path settings if self.init_stage1: wxglade.init_stage1() # initialise sizers, widgets, codewriter wxglade.init_stage2(use_gui=self.init_use_gui) # initialise wxGlade configuration import config config.init_preferences() # set some useful preferences config.preferences.autosave = False config.preferences.write_timestamp = False config.preferences.show_progress = False # initiate empty structure to store files and there content self.vFiles = {} # replace some original implementations by test specific implementation self.orig_save_file = common.save_file common.save_file = self._save_file self.orig_load_file = codegen.BaseSourceFileContent._load_file codegen.BaseSourceFileContent._load_file = self._load_lines self.orig_file_exists = codegen.BaseCodeWriter._file_exists self.orig_os_access = os.access os.access = self._os_access self.orig_os_makedirs = os.makedirs os.makedirs = self._os_makedirs self.orig_os_path_isdir = os.path.isdir os.path.isdir = self._os_path_isdir codegen.BaseCodeWriter._file_exists = self._file_exists codegen.BaseCodeWriter._show_warnings = False # set own version string to prevent diff mismatches common.version = '"faked test version"' # Determinate case directory self.caseDirectory = os.path.join( os.path.dirname(__file__), self.caseDirectory, )
def __init__( self, parent = None ): wx.Frame.__init__( self, parent, id = wx.ID_ANY, title = 'wxArchitect', pos = wx.DefaultPosition, size = wx.Size( 1140, 775 ) ) #self._mgr = VS2010ArtProvider. VS2010AuiManager() #aui.AuiManager() #self._mgr.SetArtProvider( VS2010ArtProvider.VS2010DockArt() ) self._mgr = aui.AuiManager() self._mgr.SetManagedWindow( self ) ## Initialize preferences config.init_preferences() self._mb = menu_toolbar.create_menubar( self, self._mgr ) #VS2010ArtProvider ) self._mgr.AddPane( self._mb, aui.AuiPaneInfo().MinSize( ( 9001, -1 ) ).Top().Row( 0 ).LeftDockable( False ).RightDockable( False ).ToolbarPane().Gripper( False ).Resizable( False ).PaneBorder( False ) ) self._tb1 = menu_toolbar.create_toolbar_1( self, self._mgr ) #VS2010ArtProvider ) self._mgr.AddPane( self._tb1, aui.AuiPaneInfo().Name( 'tb1' ).Caption( 'Main Toolbar' ).ToolbarPane().Top().Row( 1 ).LeftDockable( False ).RightDockable( False ) ) self._tb2 = menu_toolbar.create_toolbar_2( self, self._mgr ) #VS2010ArtProvider ) self._mgr.AddPane( self._tb2, aui.AuiPaneInfo().Name( 'tb2' ).Caption( 'Layout Toolbar' ).ToolbarPane().Top().Row( 2 ).LeftDockable( False ).RightDockable( False ) ) self.create_panes() ## Initialize code generators common.load_code_writers() # Load the available widgets and sizers #common.palette = self #core_btns, custom_btns = common.load_widgets() #sizer_btns = common.load_sizers( ) self._mgr.Update() self.CenterOnScreen()
def command_line_code_generation(options, args): """\ starts a code generator without starting the GUI. """ import common if not options: usage() if not options[0]: usage() # a language for code generation must be provided if len(args) != 1: usage() # an input file name must be provided common.use_gui = False # don't import wxPython.wx # use_gui has to be set before importing config import config config.init_preferences() common.load_code_writers() common.load_widgets() common.load_sizers() try: from xml_parse import CodeWriter out_path = None language = '' for option, arg in options: if option == '-g' or option == '--generate-code': language = arg elif option == '-o' or option == '--output': out_path = _fix_path(arg) writer = common.code_writers[language] CodeWriter(writer, _fix_path(args[0]), out_path=out_path) except KeyError: print >> sys.stderr, \ _('Error: no writer for language "%s" available') % language sys.exit(1) except Exception, e: print >> sys.stderr, _("Error: %s") % e import traceback; traceback.print_exc() sys.exit(1)