示例#1
0
文件: main.py 项目: welchr/snipper
def main():
    settings = Settings()

    # If there are no arguments, try to launch the UI.
    if len(sys.argv) <= 1:
        try:
            import ui
            ui.main()
        except:
            print >> sys.stderr, fill(
                "I tried to start the GUI since no arguments were given, but "
                "it failed (you may not have a python interpreter compiled "
                "against Tk.) Check the documentation for more info on this. "
                "In the meantime, you can run Snipper in command-line mode by "
                "supplying arguments. For a list, use -h. ")
            sys.exit(1)
    else:
        # Run in console mode.
        try:
            settings.getCmdLine()
            print_program_header()
            run_snipper(settings)
        except KeyboardInterrupt:
            print >> sys.stderr, ""
            print >> sys.stderr, "Program terminated by user."
        except:
            if _SNIPPER_DEBUG:
                print_debug()
            else:
                print sys.exc_value
示例#2
0
文件: main.py 项目: welchr/Snipper
def main(): 
  settings = Settings();

  # If there are no arguments, try to launch the UI. 
  if len(sys.argv) <= 1:
    try:
      import ui
      ui.main();
    except:
      print >> sys.stderr, fill("I tried to start the GUI since no arguments were given, but "
                        "it failed (you may not have a python interpreter compiled "
                        "against Tk.) Check the documentation for more info on this. "
                        "In the meantime, you can run Snipper in command-line mode by "
                        "supplying arguments. For a list, use -h. ");
      sys.exit(1);
  else:
    # Run in console mode. 
    try:
      settings.getCmdLine();
      print_program_header();
      run_snipper(settings);
    except KeyboardInterrupt:
      print >> sys.stderr, "";
      print >> sys.stderr, "Program terminated by user.";
    except:
      if _SNIPPER_DEBUG:
        print_debug();
      else:
        print sys.exc_value;
示例#3
0
def client_main():
    if try_resume():
        ui.main()
        return

    ui.set(ui.Label('loading...'))
    ui.execute_later(app_main)

    if features.get('app.profile'):
        profile_main()
    else:
        ui.main()
示例#4
0
def client_main():
    if try_resume():
        ui.main()
        return

    ui.set(ui.Label('loading...'))
    ui.execute_later(app_main)

    if features.get('app.profile'):
        profile_main()
    else:
        ui.main()
示例#5
0
文件: main.py 项目: Euphe/pycraft
def main():
    try:
        meta, settings, profile, name, port = setup()

        while True:
            data = ui.main(meta, settings)

            if data is None:
                break

            if data['local']:
                # Local Server
                server_obj = server_interface.LocalInterface(name, data['save'], port)
            else:
                # Remote Server
                server_obj = server_interface.RemoteInterface(name, data['ip'], data['port'])

            if not server_obj.error:
                if profile:
                    cProfile.runctx('game(server_obj, settings)', globals(), locals(), filename='game.profile')
                else:
                    game(server_obj, settings)

            if server_obj.error:
                ui.error(server_obj.error)

    finally:
        setdown()
def trigger_connect(event):
    global root
    global log
    global pas
    res = ui.main(event.widget.cget("text"), log, pas, root)
    if res == 1:
        print('cant successfully connect to database')
示例#7
0
文件: main.py 项目: itsapi/pycraft
def main():
    settings = None
    try:
        meta, settings, profile, debug, benchmarks, name, port = setup()

        while True:
            data = ui.main(meta, settings)

            if data is None:
                break

            if data['local']:
                # Local Server
                server_obj = server_interface.LocalInterface(name, data['save'], port, settings)
            else:
                # Remote Server
                server_obj = server_interface.RemoteInterface(name, data['ip'], data['port'])

            if not server_obj.error:
                render_interface.setup_render_module(settings)

                if profile:
                    cProfile.runctx('game(server_obj, settings, benchmarks)', globals(), locals(), filename='game.profile')
                elif debug:
                    pdb.run('game(server_obj, settings, benchmarks)', globals(), locals())
                else:
                    game(server_obj, settings, benchmarks)

            if server_obj.error:
                ui.error(server_obj.error)

    finally:
        setdown()
def trigger_auth(event):
    global root
    global login
    global password
    res = ui.main("gr", login.get(), password.get(), root)
    if res == 1:
        print('cant successfully connect to database')
示例#9
0
def client_main():
    action = sys.argv[1] if sys.argv[1:] else None
    if try_resume():
        ui.main()
        return
    
    if action == 'load':
        savename = sys.argv[2]
        save.load_game(savename)
    elif action == 'connect':
        host, port = sys.argv[2:]
        save.connect(host, int(port))
    else:
        show_main_menu()
    
    if features.get('app.profile'):
        profile_main()
    else:
        ui.main()
示例#10
0
def main():
    print(HIDE_CUR + CLS)

    saves.check_map_dir()
    blocks = render.gen_blocks()

    # Menu loop
    try:
        while True:
            game(blocks, *ui.main())

    finally:
        print(SHOW_CUR + CLS)
示例#11
0
def load_game(_surface, _username, is_origin):
    doc = None
    if is_origin:
        doc = saving.load('origin')
        # 进入开篇剧情,提问出身
        choice = start_ask(_surface)
        if choice == 0:
            doc.warrior.bag.armor.append(internal.armor(database.get_armor('sword-4')))     # 达官显贵
        elif choice == 1:
            doc.warrior.bag.money += 100                                                    # 巨商大贾
            doc.warrior.bag.armor.append(internal.armor(database.get_armor('book-4')))
        elif choice == 2:
            doc.warrior.bag.armor.append(internal.armor(database.get_armor('book-1')))      # 知识分子
        elif choice == 3:
            doc.POLICE_PROB = 0.001                                                         # 平头百姓
        doc.choice = choice
        doc.save(_username)
    else:
        doc = saving.load(_username)
    import ui
    ui.ID = _username
    ui.parse_doc(doc)
    database.commit()
    ui.main(_username, is_origin)
示例#12
0
def main():
    print 'waiting for arm...'
    wait_for_host(config.doggo_arm_ip)

    print 'waiting for overview...'
    wait_for_host(config.doggo_overview_ip)

    print 'waiting for control...'
    wait_for_host(config.doggo_control_ip)

    stream_cmd = "mplayer -fps 200 -demuxer h264es ffmpeg://tcp://%s:9999 > /dev/null &"

    print 'ready'
    print 'launching cameras...'

    if not os.getenv('NO_CAMERA'):
        os.system(stream_cmd % config.doggo_arm_ip)
        os.system(stream_cmd % config.doggo_overview_ip)
        
        time.sleep(1)

        os.system('''i3-msg '[class="MPlayer"] floating enable' ''')

    ui.main()
示例#13
0
def main():
    settings = None
    try:
        meta, settings, profile, debug, benchmarks, name, port = setup()

        while True:
            data = ui.main(meta, settings)

            if data is None:
                break

            if data['local']:
                # Local Server
                server_obj = server_interface.LocalInterface(
                    name, data['save'], port, settings)
            else:
                # Remote Server
                server_obj = server_interface.RemoteInterface(
                    name, data['ip'], data['port'])

            if not server_obj.error:
                render_interface.setup_render_module(settings)

                if profile:
                    cProfile.runctx('game(server_obj, settings, benchmarks)',
                                    globals(),
                                    locals(),
                                    filename='game.profile')
                elif debug:
                    pdb.run('game(server_obj, settings, benchmarks)',
                            globals(), locals())
                else:
                    game(server_obj, settings, benchmarks)

            if server_obj.error:
                ui.error(server_obj.error)

    finally:
        setdown()
'''
Created on Oct 29, 2018

@author: Adi
'''

from ui import main

main()
示例#15
0
#!/usr/bin/env python
from ui import main

if __name__ == '__main__':
  main()
示例#16
0
def main(instance):

    print 'waiting for connection to ' + instance + '...'
    wait_for_host(get_param('ip'))

    ui.main()
示例#17
0
            img = self.font.render(word, 1, self.color)
            if current_width != 0 and img.get_width() + current_width > self.width:
                words = []
                lines.append(words)
                current_width = 0
            words.append(img)
            current_width += img.get_width() + spacing
        
        height = sum( max([ word.get_height() for word in line ] + [0]) for line in lines )
        
        surf = pygame.Surface((width, height), pygame.SRCALPHA)
        
        y = 0
        for line in lines:
            if not line: continue
            x = 0
            for word in line:
                surf.blit(word, (x, y))
                x += word.get_width() + spacing
            y += max( word.get_height() for word in line )
        
        return surf

if __name__ == '__main__':
    import os; os.chdir('..')
    pygame.display.set_mode((800, 480))
    ui.init()
    w = LongTextWidget(open('data/android-help.txt').read(), 800, ui.consolefont)
    ui.set(w)
    ui.main()
示例#18
0
    model = TechtreeClientModel(client)
    widget = TechTreeWidget(model, *tree)
    widget = ui.ScrollWrapper(widget, ways=ui.SCROLL_WIDTH | ui.SCROLL_HEIGHT)
    ui.set(widget)


if __name__ == '__main__':
    tree = load_techtree('data/techtree.index')

    class ExampleModel:
        def is_researched(self, name):
            name = name.strip("'")
            return name in [
                'Alphabet', 'Masonry', 'Currency', 'Bronze Working',
                'Mathematics'
            ]

        def is_available(self, name):
            return False

    model = ExampleModel()

    graphics.init()
    ui.init()
    wnd = graphics.create_window((800, 600))
    ui.screen_width, ui.screen_height = ui.screen_size = wnd.get_size()
    widget = TechTreeWidget(model, *tree)
    widget = ui.ScrollWrapper(widget, ways=ui.SCROLL_WIDTH | ui.SCROLL_HEIGHT)
    ui.replace(widget)
    ui.main()
示例#19
0
        else:
            foundstore = (storehash, dist, i+1)
    else:
        print '  Store %i is not within %s kilometers from our store.' % (i+1, threshold)
    print
print 
generic = False
store = None
if not foundstore:
    print "!! Didn't find a store within our threshold !!"
    print "!!     Using the store's generic layout     !!"
    generic = True
else:
    try:        
        store = db.storemaps[foundstore[0]]
        print "Selected Store %s, with hash %s, which is the closest at %0.4f kilometers." % (foundstore[2], foundstore[0], foundstore[1])  
    except:
        print "!!   There is no data for that store.   !!"
        print "!!   Using the store's generic layout   !!"
        generic = True
        
print

if generic:
    store = db.genmaps[storename]
    
print
raw_input("hit enter to run the UI.")
import ui
ui.main(store, storename)