当前位置: 首页>>代码示例>>Python>>正文


Python program.Program类代码示例

本文整理汇总了Python中program.Program的典型用法代码示例。如果您正苦于以下问题:Python Program类的具体用法?Python Program怎么用?Python Program使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Program类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

def main():
    root = tkinter.Tk()
    from libs import painter

    #import pdb;pdb.set_trace()
    program = Program(painter)
    try:
        fileToLoad = sys.argv[1]
    except IndexError:
        print("Ne file specified, opening first.lsa")
        fileToLoad = "first.lsa"
    program.load_file(fileToLoad)

    #Create the gui widgets
    menuBar = gui.MenuBar(root, program)
    stepChanger = gui.StepChanger(root, program)
    text = gui.TextInput(root, program)
    contextShower = painter.ContextShower(root)
    activeStateShower = gui.ActiveStateShower(root, program, contextShower)
    stepOutput = gui.StepOutput(root, text, program)
    textHelp = gui.TextHelp(root, text, program)
    help = gui.HelpShower(root, program)

    #Place them in the rigth order
    root['menu'] = menuBar
    root.grid_propagate(True)
    stepChanger.grid(row=0, column=0, columnspan=50, sticky="nesw")
    vScrollbar = tkinter.Scrollbar(root, orient=tkinter.VERTICAL)
    vScrollbar.grid(row=1, column=0, sticky="nesw")
    text.grid(row=1, column=10, sticky="nesw")
    textHelp.grid(row=1, column=11, sticky="nesw")
    stepOutput.grid(row=1, column=12, sticky="nesw")
    activeStateShower.grid(row=1, column=13, sticky="nesw")
    help.grid(row=2, column=0, columnspan=50, sticky="nesw")
    root.columnconfigure(0, weight=0)
    root.columnconfigure(10, weight=2)
    root.columnconfigure(11, weight=1)
    root.columnconfigure(12, weight=2)
    root.columnconfigure(13, weight=0)
    root.rowconfigure(0, weight=0)
    root.rowconfigure(1, weight=1)
    root.rowconfigure(2, weight=0)

    def proxy_yview(*args, **kwords):
        text.yview(*args, **kwords)
        textHelp.on_activeStep_changed()
        stepOutput.on_steps_changed()

    def proxy_set(*args, **kwords):
        vScrollbar.set(*args, **kwords)
        textHelp.on_activeStep_changed()
        stepOutput.on_steps_changed()

    text['yscrollcommand'] = proxy_set
    vScrollbar['command'] = proxy_yview

    # create the interpretor and go, go, go
    interpretor = interpreter.Interpreter(program)
    root.after(500, lambda : program.event("source_changed")())
    root.mainloop()
开发者ID:mgautierfr,项目名称:ediap,代码行数:60,代码来源:ediap.py

示例2: main

def main(argv=None, syslog=syslog):

    if argv is None:
        argv = sys.argv[1:]
        program = Program(__version__, __updated__, argv, syslog)
        program.mainLoop()
    program.logFinish()
开发者ID:magwas,项目名称:PDAnchor,代码行数:7,代码来源:cryptoserver.py

示例3: test_detach

 def test_detach(self):
     vert = VertexShader("A")
     frag = FragmentShader("B")
     program = Program(vert, frag)
     program.detach(frag)
     assert len(program.shaders) == 1
     assert program.shaders[0].code == "A"
开发者ID:gabr1e11,项目名称:GLSL-Examples,代码行数:7,代码来源:test_program.py

示例4: test_attach

 def test_attach(self):
     vert = VertexShader("A")
     frag = FragmentShader("B")
     program = Program(vert)
     program.attach(frag)
     assert len(program.shaders) == 2
     assert program.shaders[0].code == "A"
     assert program.shaders[1].code == "B"
开发者ID:gabr1e11,项目名称:GLSL-Examples,代码行数:8,代码来源:test_program.py

示例5: initgl

 def initgl(self):
     glEnable(GL_TEXTURE_2D)
     glEnable(GL_BLEND)
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
     self.program = Program.load(in_module('glsl/flat.glsl'))
     self.program_ms = Program.load(in_module('glsl/flat_ms.glsl'))
     self.use_program(self.resolution)
     self.stream = BufferStream(Vertex, GL_TRIANGLES)
开发者ID:cheery,项目名称:essence,代码行数:8,代码来源:__init__.py

示例6: handle_program_status

def handle_program_status():
    """
    Expose the program status
    """
    logging.debug("program_status")
    prog = Program("")
    if app.prog:
        prog = app.prog
    return json.dumps({'name': prog.name, "running": prog.is_running(), "log": app.prog_engine.get_log()})
开发者ID:CoderBotOrg,项目名称:coderbot,代码行数:9,代码来源:main.py

示例7: Commander

class Commander(object):
    
    def __init__(self, program):
        self.program = Program(program)
        self.army = list()
        self.enemies = list()
        self.army_name = self.find_army_name()
        
    def find_army_name(self):
        try:
            name = self.do_find_army_name()
        except Exception:
            # If program fails to implement -n properly, just choose
            # a random name.
            name = 'army-%d'% random.randint(1,10000000)
        return name
        
    def do_find_army_name(self):
        arguments = ProgramArguments()
        reader = FileReader(self)
        output_filename = FileUtils.get_new_filename()
        arguments.add('-n')
        arguments.add('-o', output_filename)
        self.program.execute(arguments)
        name = reader.read_name(output_filename)
        FileUtils.remove_file(output_filename)
        return name  
        
    def get_army_name(self):
        return self.army_name
        
    def get_army(self):
        return self.army
    
    def set_army(self, soldiers):
        map(self.set_army_on_soldier, soldiers)
        self.army = soldiers
    
    def set_army_on_soldier(self, soldier):
        army_name = self.get_army_name()
        soldier.set_army_name(army_name)
    
    def add_enemies(self, enemies):
        self.enemies.extend(enemies)
        
    def read_file_or_raise(self, filename, writer, context):
        reader = FileReader(context)
        try:
            data = reader.read(filename)
        except IOError:
            raise MissingFileException(self.army_name, self.program,
                                       writer.get_filename())
        except ParsingException, e:
            e.set_army_name(self.army_name)
            raise e
        else:
开发者ID:lukius,项目名称:algo2-fiuba-tp1-2q13,代码行数:56,代码来源:commander.py

示例8: eval

    def eval(self, text):
        """Respond to text entered by the user.

        :param text: the user's input
        """
        program = Program(text, echo=self.echo, transforms=self.transforms)
        tokens = program.gen_tokens()
        for sentence in program.gen_sentences(tokens, self.aliases):
            if self.echo:
                self.terminal.debug(str(sentence))
            program.interpret(sentence, self.commands)
开发者ID:Ceasar,项目名称:twosheds,代码行数:11,代码来源:cli.py

示例9: launch_intellij

 def launch_intellij(self):
     is_running = False
     for p in psutil.process_iter():
         try:
             if p.name() == "idea.exe":
                 print "IntelliJ IDEA is already running"
                 is_running = True
         except psutil.error:
             pass
     if not is_running:
         intellij = Program(self.intellij_path)
         intellij.start()
         print "program {} started".format(self.intellij_path)
开发者ID:coyf,项目名称:agl,代码行数:13,代码来源:main.py

示例10: launch_dia

 def launch_dia(self):
     is_running = False
     for p in psutil.process_iter():
         try:
             if p.name() == "dia.exe":
                 print "Dia is already running"
                 is_running = True
         except psutil.error:
             pass
     if not is_running:
         dia = Program(self.dia_path)
         dia.start()
         print "program {} started".format(self.dia_path)
开发者ID:coyf,项目名称:agl,代码行数:13,代码来源:main.py

示例11: launch_f2c

 def launch_f2c(self):
     is_running = False
     for p in psutil.process_iter():
         try:
             if p.name() == "FlowchartToCode.exe":
                 print "Flowchart To Code is already running"
                 is_running = True
         except psutil.error:
             pass
     if not is_running:
         f2c = Program(self.f2c_path)
         f2c.start()
         print "program {} started".format(self.f2c_path)
开发者ID:coyf,项目名称:agl,代码行数:13,代码来源:main.py

示例12: programTest

class programTest(unittest.TestCase):

    def setUp(self):
        self.fixture = Program(1, 1, "-d 1".split(' '), FakeSyslog())

    def test_default_options_are_set(self):
        fixture = self.fixture
        self.assertEqual('1', fixture.opts.keyid)
        self.assertEqual(None, fixture.opts.verbose)
        self.assertEqual('0000', fixture.opts.pin)
        self.assertEqual('/usr/lib/opensc-pkcs11.so', fixture.opts.module)
        self.assertEqual(None, fixture.opts.environment)
        self.assertEqual('localhost', fixture.opts.host)
        self.assertEqual(256, fixture.opts.inputlength)
        self.assertEqual(256, fixture.opts.outputlength)
        self.assertEqual('SHA512-RSA-PKCS', fixture.opts.mechanism)
        self.assertEqual(9999, fixture.opts.port)

    def test_keyid_can_be_given_with_d(self):
        self.fixture.parseArgs("-d 2222".split(' '))
        self.assertEqual('2222', self.fixture.opts.keyid)

    def test_verbose_can_be_set_with_v(self):
        self.fixture.parseArgs("-d 1 -v".split(' '))
        self.assertEqual(1, self.fixture.opts.verbose)

    def test_verbose_level_is_increased_with_all_v(self):
        self.fixture.parseArgs("-d 1 -vvvv".split(' '))
        self.assertEqual(4, self.fixture.opts.verbose)

    def test_outputlength_is_set_by_o(self):
        self.fixture.parseArgs("-d 1 -o 511".split(' '))
        self.assertEqual(511, self.fixture.opts.outputlength)
开发者ID:magwas,项目名称:PDAnchor,代码行数:33,代码来源:programtest.py

示例13: execute_file

def execute_file(fname):
    program = Program(fname)
    state = ExecutionState()
    done = False

    try:
        while not done:
            pc = state.read_program_cntr()
            state.write_program_cntr(pc + 1)
            cmd = program.fetch(pc)
            if DEBUG_MODE:
                print "Executing: '"+str(cmd)+"'"
            done = cmd.execute(state)

    except Exception as e: print e
    finally: print "Stack:", str(state)
开发者ID:ajbonkoski,项目名称:pushpop,代码行数:16,代码来源:interpretor.py

示例14: __init__

 def __init__(self, name, command, positions, verbose):
     Thread.__init__(self)
     self._name = name
     self._positions = positions
     self._verbose = verbose
     command = command + " --logfile-name=" + name + ".log"
     self._program = Program(command, verbose)
开发者ID:PawelTroka,项目名称:LogicalGamesEnginesGenerator,代码行数:7,代码来源:book-solve.py

示例15: load_programs_from_xml

def load_programs_from_xml(xml_root, exercise_type_dict):
    program_dict = {}
    programs_node = xml_root.find("programs")
    for program_node in programs_node:
        program_name = program_node.get("name")
        program_description = program_node.get("description")
        program = Program(program_name, program_description)
        for action_node in program_node:
            action_exercise_name = action_node.get("exercise")
            action_exercise_type = exercise_type_dict[action_exercise_name]
            action_nb_series = int(action_node.get("nbSeries"))
            action_rest = int(action_node.get("rest"))
            action_min = int(action_node.get("min"))
            action_goal = int(action_node.get("goal"))
            program.add_action(action_exercise_type, action_nb_series, action_rest, action_min, action_goal)
        program_dict[program_name] = program
    return program_dict
开发者ID:powy,项目名称:projects,代码行数:17,代码来源:xmlManager.py


注:本文中的program.Program类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。