예제 #1
0
 def check_board_state(self, name):
     """Return true if finds end of game."""
     if self.check_win():
         gui.Gui(self.screen).message_win(name)
         return True
     if self.check_draw():
         gui.Gui(self.screen).message_win(name)
         return True
     return False
예제 #2
0
def run(width=1920, height=1080):
    """Main run method"""

    pygame.init()

    screen = pygame.display.set_mode((width, height))
    pygame.display.toggle_fullscreen()

    clock = pygame.time.Clock()
    pool = entity_pool.EntityPool()
    box = text_box.TextBox(screen, pool)
    handler = event_handler.EventHandler(pool, box)
    outer_gui = gui.Gui(width, height)

    #Main logic loop
    while 1:
        screen.fill((137, 207, 255))
        handler.handle(pygame.event.get())
        delta = clock.tick()

        pool.update(delta)
        pool.render(screen)
        box.render()
        outer_gui.render(screen)

        pygame.display.flip()
예제 #3
0
def main(nrows, ncols, px_width):
    display = gui.Gui(nrows, ncols, px_width)

    worlds = [world.World(nrows, ncols), world.World(nrows, ncols)]
    curr_world = worlds[0]
    nxt_world = worlds[1]
    max_alives = int((nrows * ncols) / 5)
    load_rand_pattern(curr_world, max_alives)
    #load_glider(curr_world)
    display.update(curr_world)

    nticks = 0
    while 1:
        run_tick(curr_world, nxt_world)
        if curr_world == nxt_world:
            print("World is dead!!")
            break
        display.update(nxt_world)
        curr_world, nxt_world = nxt_world, curr_world
        time.sleep(0.1)
        nticks += 1
        if nticks % 100 == 0:
            print("++Finished Tick=", nticks)

    print(">>Ran the sim for ticks=" + str(nticks))
예제 #4
0
    def __init__(self):
        # load the config file
        self.config = config()
        self.ui = gui.Gui(self.config.setting["resolution"],
                          self.config.setting["fg_color"],
                          self.config.setting["bg_color"],
                          self.config.setting["show_mouse_cursor"])
        locale.setlocale(locale.LC_ALL,
                         self.config.setting["locale"] + ".utf8")

        self.musicplayer = MusicPlayer(self.config.setting["mopidy_host"])
        self.alarm = Alarm(self.config.setting["alarmtime"],
                           self.config.setting["enable_alarm"])
        self.alarm.alarm_active = False
        self.player_primed = False

        self.is_idle = False
        self.time_last_idle = time.time()
        self.check_idle_thread = threading.Thread(target=self.check_idle)
        self.check_idle_thread.daemon = True
        self.check_idle_thread.start()
        self.old_time = 0

        self.current_screen = self.idlescreen
        self.switch_to_defaultscreen()

        self.loop()
예제 #5
0
 def __init__(self, screen):
     """Init Game with all needed attributes. """
     self.screen = screen
     self.gui = gui.Gui(self.screen)
     self.gui.draw_background()
     self.game_running = True
     self.game_move_number = 0
     self.game_board = check_board_state.create_board()
     self.game_arbiter = check_board_state.CheckBoardState(
         self.screen, self.game_board)
     self.played_moves = []
     self.player1 = players.HumanPlayer(constants.PLAYER1_NAME,
                                        constants.WHITE)
     self.player2 = players.AiPlayer(self.screen, self.game_board,
                                     constants.BLACK)
     self.player_on_move = self.player1
     self.game_mode = constants.STANDARD
     self.gui_board = [[
         gui.Square(self.screen) for i in range(constants.BOARD_SIZE)
     ] for j in range(constants.BOARD_SIZE)]
     self.gui_on_move = gui.OnMove(self.screen)
     self.button_new_game = gui.ButtonRightMenu(self.screen, 0,
                                                constants.RESTART)
     self.button_menu = gui.ButtonRightMenu(self.screen, 1, constants.MENU)
     self.button_white_stone = gui.ButtonChooseColor(self.screen, 0)
     self.button_black_stone = gui.ButtonChooseColor(self.screen, 1)
     self.button_ai_opponent = gui.ButtonChooseOpponent(self.screen, 0)
     self.button_ai_player = gui.ButtonChooseOpponent(self.screen, 1)
     self.button_standard_game_mode = gui.ButtonChooseMode(self.screen, 0)
     self.button_swap2_game_mode = gui.ButtonChooseMode(self.screen, 1)
     self.last_move = LastMove
예제 #6
0
    def main(self):

        pygame.init()
        screen = pygame.display.set_mode((1200, 1000))

        input = gui.Input()

        the_gui = gui.Gui(input)

        input.addMouseListener(the_gui)
        input.addKeyboardListener(the_gui)

        self.init(the_gui)

        run = True
        while (run):
            event_consumed = False
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    run = False
                else:
                    event_consumed = input.handleEvent(event)
                    if not event_consumed:
                        pass  # The gui didn't consumed the event, process the event as you like.
                    else:
                        print "Event consumed"

            screen.fill((255, 255, 255))
            the_gui.draw(screen)
            pygame.display.flip()

        pygame.quit()
예제 #7
0
def main():

    root = tk.Tk()
    gui.Gui(root).pack(side="top", fill="both", expand=True)
    try:
        root.mainloop()
    except AppError as e:
        print(str(e))
예제 #8
0
	def __init__(self):
		self.exit = 0
		# create objects
		self.commandline = commandline.CommandLine(self);
		self.irc = irc.Irc(self, 'mikeux.dyndns.org', 6667, 'xatahi');
		self.gui = gui.Gui(self);
		# start the app
		self.gui.start()
예제 #9
0
 def __init__(self, config, core):
     super(RaspiradioFrontend, self).__init__()
     self.core = core
     self.cur_ui = None
     self.gui = gui.Gui(config['raspiradio'])
     self.set_gui_mode(gui.GuiModes.CLOCK)
     self.update_thread = timers.UpdateInterval(1.0/config['raspiradio']['refresh_rate'], self.playback_position_update)
     self.cur_pos = 0
     self.timeout_thread = timers.Timeout(config['raspiradio']['inactivity_timeout'], self.switch_to_clock)
예제 #10
0
    def __init__(self):
        self.gui = gui.Gui()
        self.board = board.Board(3)
        self.players = []
        self.current_player = None
        self.other_player = None
        self.game_over = False

        self.start()
예제 #11
0
파일: main.py 프로젝트: nlMeminger/GearBox
def main():
    sys = systemhost.SystemHost()
    sys.setVolume(50)
    sys.setBrightness(50)

    #bluetoothDev = btdevice.BtDevice(macAddress= 'A0:56:F3:60:8C:D8')
    #bluetoothDev.connectToPlayer()

    mainGui = gui.Gui(sysHost=sys)
예제 #12
0
 def __init__(self, f):
     self.f = f
     self.t = 0
     self.scale = ''
     image = self.getSnapshot()
     w, h = image.size
     self.wh = (w, h)
     self.g = gui.Gui(w, h, self.onKey)
     self.g.showImage(image)
예제 #13
0
def main():

    maingui = gui.Gui()
    statemachine = state_machine.StateMachine()

    maingui.start()
    statemachine.start()

    maingui.end()
    statemachine.end()
예제 #14
0
def SelectSheet(config, name=""):
    sheets = GetSheets(config)
    if name == "":
        name = settings["defaultSheet"]
    if name == "" or name not in config['sheets']:
        selector = finder.createFinder(settings["finder"], sheets, True)
        selectGui = gui.Gui(selector, settings, True)
        selectGui.run()
        name = selectGui.sheet
    return name
예제 #15
0
    def __init__(self):
        super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
        arcade.set_background_color(arcade.color.AMAZON)

        self.env = environment.Environment(level1)
        self.gui = gui.Gui(SCREEN_WIDTH,SCREEN_HEIGHT,PADDING,self.env)
        self.set_update_rate(1/60)
        self.fps = FPSCounter()
        self.gamestate = GameState.GAME_RUNNING
        self.timer = 0
예제 #16
0
    def __init__(self):


        self.app = gui.QApplication(sys.argv)
        self.gui = gui.Gui(self)
        self.translator = translation_watson.Translator()
        self.gui.initUI()


        sys.exit(self.app.exec_())
예제 #17
0
 def __init__(self, threadID, name):
     threading.Thread.__init__(self)
     self.threadID = threadID
     self.name = name
     self.parser = parse.Parser()
     self.guiQ = Queue.Queue(10)
     self.killall = threading.Event()
     self.killall.clear()
     self.stop_listen = threading.Event()
     self.stop_listen.clear()
     self.gui = gui.Gui(2, "gui", self.guiQ, self.killall, self.stop_listen)
예제 #18
0
def interfejs():
    """Funkcja tworzaca obiekt klasy Gui"""
    global b, root
    root = Tk()

    b = gui.Gui(root)
    root.title('bonsai.py')
    try:
        root.iconbitmap(r'bonsai.ico') #Designed by Freepik from www.flaticon.com
    except TclError:
        pass
    root.mainloop()
예제 #19
0
    def __init__(self):
        self.db = DB("data")
        self.db.create_table("equations")

        self.changer_animation_plot = ChangerAnimationPlot(self)

        self.window = tk.Tk()
        self.window.attributes()
        self.my_gui = gui.Gui(self.window, self)
        self.my_gui.master.minsize(1000, 600)
        self.my_gui.pack()
        self.window.mainloop()
예제 #20
0
 def __init__(self):
     self.players = []
     self.whose_action = None
     self.colorbank = [
         "coral", "darkolivegreen", "dodgerblue", "darkviolet", "orangered",
         "darkslategray", "dimgray", "salmon", "sienna", "goldenrod",
         "yellow", "black"
     ]
     self.gui = g.Gui(self)
     self.opt = options.Options(self)
     self.temple = dimensions.Temple()
     self.all_dimensions = {self.temple, dimensions.Guardian_Dimension()}
예제 #21
0
def main():
    """The main function of the server."""
    # parsing command line argumants
    parser = optparse.OptionParser()
    parser.add_option('-c',
                      '--config',
                      dest='config_file',
                      default='logging.json',
                      help='change the logging configuration file')
    parser.add_option('-p',
                      '--port',
                      dest='port',
                      default='2048',
                      type='int',
                      help='set custom connection port')

    options, args = parser.parse_args()

    # configurate the loggers of the threads
    with open(options.config_file, 'rb') as f:
        config = json.loads(f.read())
        logging.config.dictConfig(config)

    logger = logging.getLogger('other')
    logger.info('main thread started')

    logic_queue = Queue.Queue()
    gui_queue = Queue.Queue()
    network_queue = Queue.Queue()

    network_receiver_thread = network.NetworkReceiverThread(
        network_queue=network_queue,
        logic_queue=logic_queue,
        port=options.port)

    network_sender_thread = network.NetworkSenderThread(
        network_queue=network_queue,
        logic_queue=logic_queue,
        port=options.port)

    logic_thread = logic.LogicThread(logic_queue=logic_queue,
                                     gui_queue=gui_queue,
                                     network_queue=network_queue)

    gui_thread = gui.Gui(gui_queue=gui_queue, logic_queue=logic_queue)

    network_receiver_thread.start()
    network_sender_thread.start()
    logic_thread.start()
    gui_thread.main()

    logger.info('main thread ended')
예제 #22
0
 def __init__(self):
     args = self.parse_command_line_arguments()
     self.screen = pygame.display.set_mode((args.width, args.height))
     self.screen_rect = self.screen.get_rect()
     pygame.display.set_caption("Place Pictures")
     pygame.key.set_repeat(100, 100)
     self.map = maps.Map(self)
     self.map.create_map(2000, 2000, 0, 0, 0)
     self.gui = gui.Gui(self)
     self.pictures = pictures.Pictures(self)
     self.mouse = mouse.Mouse()
     self.savegame = savegame.Savegame(self)
     pygame.display.flip()
예제 #23
0
 def load(self):
     self.screen.fill((0, 0, 0))
     pygame.display.set_caption(self.name)
     #initialise objects
     level = l.Level("level.map", "key.txt", self.tile_size)
     level.load_tiles("tiles.png")
     level.load_map()
     self.background, self.background_rect = level.create()
     player = p.Player()
     self.entities = pygame.sprite.Group(player)
     self.set_player_center(player)
     self.set_level_offset(level, player)
     self.gui = gui.Gui()
     return level, player
예제 #24
0
    def __init__(self, master):
        self.master = master
        self.game = chessgame.ChessGame()
        self.history = []  #the history which is shown in the listbox

        self.gui = gui.Gui(self)
        self.gui.gameDisplay.game = self.game

        self.players = [None, None]
        self.players[const.WHITE] = players.Human(self, const.WHITE)
        self.players[const.BLACK] = players.AI(self, const.BLACK)

        self.game.setBoard(mat.TESTBOARD)

        self.master.bind("<<turn_complete>>", self.turnComplete)
예제 #25
0
파일: main.py 프로젝트: lukasp2/my-programs
def main():
    _gui = gui.Gui()

    tt = trafficTracker.TrafficTracker()
    tt.gui_add(_gui)
    #tt.print_timetables()

    tv = tvSchedule.TvSchedule()
    tv.gui_add(_gui)

    h2o = flowers.Watering()
    h2o.gui_add(_gui)

    wt = weather.Weather()
    wt.gui_add(_gui)

    _gui.show()
예제 #26
0
    def __init__(self, pandaWorld=None, parent=None):
        super(QDialog, self).__init__(parent)
        self.setWindowTitle("Test")
        s = 80
        self.setGeometry(0,0,21*s,9*s)
        
        self.pandaContainer = QTPandaWidget(self) 
 
        layout = QHBoxLayout()
        layout.addWidget(self.pandaContainer) 
        user_interface = gui.Gui(self, pandaWorld=pandaWorld)
        layout.addWidget(user_interface)
        
        self.setLayout(layout) 
        self.pandaWorld = pandaWorld
        pandaWorld.bindToWindow(int(self.winId())) # window.pandaContainer.winId() or window.winId()? 
        # this basically creates an idle task
        # TODO(victor): run panda in separate thread if possible
        self.timer =  QTimer(self)
        self.timer.timeout.connect( pandaWorld.step )
        self.timer.start(0.01)
예제 #27
0
import tkinter as tk
import gui
import price_init

root = tk.Tk()
my_gui = gui.Gui(root)
price_init.start(my_gui)
root.mainloop()
예제 #28
0
else:
    content_map = 'content_map.yaml'


if __name__ == "__main__":
    # generate 6 ports 
    ports = [Port(i) for i in range(1,7)]

    # Create our pick by light object
    PBL = pick_by_light.PickByLight(ports, default_content_map_path=content_map)

    # Create our station ua serer, passing in our pick by light instance.
    SUAS = suas.StationUAServer(PBL)

    # Create our gui interface, passing in our pick by light instance.
    GUI = gui.Gui(PBL)

    if args.festo_connect:
        # Create festo connect object
        FC = festo_connect.FestoServer(PBL,args.festo_connect_ip)

    try:
        # GUI.run blocks untill it exits
        GUI.run()
    except KeyboardInterrupt:
        print('interrupted!')
    finally:
        # Finally stop the ua server
        SUAS.ua_server.stop()

예제 #29
0
        if hasattr(self.currentWindow, "getCancel"):
            self.currentWindow.getCancel()
        gtk.main_quit()

    #monkey-patch alert!
    gui.Gui.cancelButtonPressed = monkeyCancel


if __name__ == "__main__":
    if len(sys.argv) < 2:
        print 'You need to provide a step to jump to'
        print 'Usage: python2.4 skip_to_step.py [-t] <stepname>'
        sys.exit(1)

    mode = "gui"
    (opts, args) = getopt.getopt(sys.argv[1:], "t", [])
    for opt, arg in opts:
        if opt == "-t":
            mode = "text"

    step = args[0]
    fnName = 'prepare_' + step
    if fnName in globals():
        globals()[fnName]()

    if mode == "gui":
        DebugCheatingOn(step)
        gui.Gui()
    elif mode == "text":
        textui.main.main(["main.py", step])
예제 #30
0
def main():
    g1 = gui.Gui()
    g1.guiInit()