def initialize():
    if (Initialize.startInitialization(__name__)):
        return
    
    # initialization code (note: it's all a kluge, could be cleaned up pretty easily)

    # Note: the global declarations are needed due to the kluge above
    # involving globals()[example_command_classname]
    
    classnames = [ ] # extended below

    global ExampleCommand1
    from prototype.test_commands import ExampleCommand1
    classnames.append("ExampleCommand1")

    global ExampleCommand2
    from prototype.test_commands import ExampleCommand2
    classnames.append("ExampleCommand2")

    global test_connectWithState
    from prototype.test_connectWithState import test_connectWithState
    classnames.append("test_connectWithState")

    global ExampleCommand2E
    from prototype.example_expr_command import ExampleCommand2E
    classnames.append("ExampleCommand2E")

    for classname in classnames:
        cmdname = classname # for now
        register_debug_menu_command( cmdname, (lambda widget, classname = classname: enter_example_command(widget, classname)) )
    
    Initialize.endInitialization(__name__)
    return
Esempio n. 2
0
def initialize():
    if (Initialize.startInitialization(__name__)):
        return
    
    # initialization code
    global _iconprefix
    _iconprefix = os.path.dirname(os.path.abspath(sys.argv[0]))
    _iconprefix = os.sep.join(_iconprefix.split(os.sep)[:-1] + ["src"])
        # Note: for developers, this is .../cad/src and also contains the
        # toplevel python modules or packages (as of 080111 anyway);
        # within built releases, it may not be the same directory as that
        # even though it ends with "src". [bruce comment 080111]

    if EndUser.getAlternateSourcePath() != None:
        new_iconprefix = EndUser.getAlternateSourcePath()
        print "ALTERNATE_CAD_SRC_PATH: setting _iconprefix to %r rather than %r" % \
              ( new_iconprefix, _iconprefix )
        _iconprefix = new_iconprefix

    Initialize.endInitialization(__name__)
    return
def enter_example_command(widget, example_command_classname):
##    assert isinstance(widget, GLPane) # assumed by _reinit_modes; assertion disabled to fix an import cycle
    glpane = widget
    if 0 and EndUser.enableDeveloperFeatures(): ###during devel only; broken due to file splitting
        # reload before use (this module only)
        if 0 and 'try reloading preqs too': ### can't work easily, glpane stores all the mode classes (not just their names)...
            glpane._reinit_modes() # just to get out of current mode safely
            import command_support.modes as modes
            reload(modes)
            ## from selectAtomsMode import selectAtomsMode # commented so it doesn't affect import dependency tools
            _superclass = 'Undefined variable' # FIX
            if _superclass is selectAtomsMode:
                import commands.Select.selectMode as selectMode
                reload(selectMode)
                import commands.SelectAtoms.selectAtomsMode as selectAtomsMode
                reload(selectAtomsMode)
            
            ## glpane.mode = glpane.nullmode = modes.nullMode()
            # revised 071010 (glpane == commandSequencer == modeMixin), new code UNTESTED:
            glpane._recreate_nullmode()
            glpane.use_nullmode()

            glpane._reinit_modes() # try to avoid problems with changing to other modes later, caused by those reloads
                # wrong: uses old classes from glpane
        import prototype.test_command_PMs as test_command_PMs
        reload(test_command_PMs)
        Initialize.forgetInitialization(__name__)
        import prototype.test_commands_init as test_commands_init
        reload(test_commands_init)
        test_commands_init.initialize()
            # (note: reload code is untested since the change [bruce 071030]
            #  to call initialize explicitly rather than as import side effect,
            #  done together with splitting this module out of test_commands)
        from prototype.test_commands_init import enter_example_command_doit
    else:
        from prototype.test_commands_init import enter_example_command_doit
        
    enter_example_command_doit(glpane, example_command_classname)
    return
Esempio n. 4
0
def initialize():
    # must be called after mainwindow exists
    if (Initialize.startInitialization(__name__)):
        return
    PluginlikeGenerator.register(HeterojunctionGenerator)
    Initialize.endInitialization(__name__)