當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。