Пример #1
0
    def __init__(self, mode = 1):
        self.game = ""
        self.game_mode = mode
        # GUI enabled game
        if self.game_mode == 1:
            # Create GUI object
            self.gui = GUI(self)

            # Loop gui
            self.loop()


        # GUI enabled main without loop
        elif self.game_mode == 2:
            self.gui = GUI(self)

        # Comand line control with no GUI
        elif self.game_mode == 3:
            self.game = Game()

        elif self.game_mode == 4:
            self.game = Game()

        else:
            print("Not a selection!")
 def Run(self, simulate=False, date=Dates.empty(), lookBack=1):
     if not simulate:
         GUI().OpenBrowser(Configuration().getBrowserTitle(),
                           Configuration().getBrowserPath())
     for bank in self.banks:
         bank.Run(simulate=simulate, date=date, lookBack=lookBack)
         self.transactions.extend(bank.GetTransactions())
     if not simulate:
         GUI().CloseBrowser()
Пример #3
0
    def firm_loop(self):
        gui = GUI()
        gui.print_firm()

        select_char = "s"
        while select_char != "q":
            select_char = input("\nSelect action:\n"
                                "\t1. Display of containers\n"
                                "\t2. Edit containers\n"
                                "\t3. Add a new container\n"
                                "\t4. Display orders\n"
                                "\t5. Exit\n").upper()
            if select_char not in "12345" or len(select_char) != 1:
                print("No such action")
                continue

            if select_char == '1':
                for i in range(len(self.container_list)):
                    self.container_list[i].print_info(i)

            elif select_char == '2':
                for i in range(len(self.container_list)):
                    self.container_list[i].print_info(i)
                container_id = int(input("Enter the container id: "))
                self.container_list[container_id].edit_container()

            elif select_char == '3':
                container = Container()
                container.price = int(input("Enter price of the container: "))
                container.size = int(input("Enter container size: "))
                self.container_list.append(container)

            if select_char == '4':
                for i in range(len(self.order)):
                    self.order[i].print_order(i)

                order_input = int(
                    input("Action:\n"
                          "1. Accept order\n"
                          "2. Delete order\n"
                          "3. Return\n"))

                if order_input == 1:
                    index = int(input("Enter ID orders to accept"))
                    if 0 <= index <= len(self.order):
                        self.order[index].paid = True

                if order_input == 2:
                    index = int(input("Enter ID orders to deleted"))
                    if 0 <= index <= len(self.order):
                        self.order.remove(self.order[index])

            if select_char == '5':
                gui = GUI()
                gui.clear(0)
                return
Пример #4
0
 def take_item_event(self, game):
     if self.used:
         return False
     rose = game.im.items_store['rose']
     if rose in game.player.inventory.store:
         del game.player.inventory.store[game.player.inventory.store.index(rose)]
         game.gui = GUI(game).set_text('Выбери награду').set_choices(['Оружие', 'Доспехи'], self.callback)
         self.used = True
     else:
         game.gui = GUI(game).set_text('Принеси мне розу, и я дам тебе приз').set_choices(['ОК'], self.do_nothing)
     return False
Пример #5
0
    def __init__(self):
        self.gui = GUI(self.readHeader, self.readGame, self.startGame,
                       self.refreshCOMList, self.changeCOMDevice,
                       self.saveFile)

        self._reader = None
        self._cartridge = None
Пример #6
0
 def __init__(self, timeLimit, ID, code, startLocation, destination,
              latitude, longitude):
     self.truck = Truck(ID, code, startLocation, destination, latitude,
                        longitude)
     self.timeLimit = timeLimit
     self.setRoute()
     self.GUI = GUI()
Пример #7
0
 def __init__(self, players: List[DurakPlayer], render=False):
     """
     Constructor.
     :param players: List of players which will be playing the game. Between 2 and 6 players, and at most one human player.
     :param render: Weather to render the game of not.
     """
     # non-changing parameters:
     self.players = players
     self.to_render = render or (True in [isinstance(player, HumanPlayer) for player in players])  # if a human player is given, always render
     self.attacker = 0
     self.defender = 1
     self.trump_suit = Deck.HEARTS
     # changing parameters (will be re-initialized upon calling the reset method):
     self.active_players = players[:]
     self.attacking_player = None
     self.turn_player = None
     self.loser = None
     self.attacking_cards = list()
     self.defending_cards = list()
     self.legal_attacking_cards = list()
     self.legal_defending_cards = list()
     self.gui = GUI() if self.to_render else None
     self.deck = Deck()
     self.defending = True
     self.successful = False
     self.limit = 0
     self.last_action = Deck.NO_CARD
     self.reset_round = False
     self.attack_phase = True
     self.reset_attacker = True
     self.reward = 0
     self.first_initialize_players()
Пример #8
0
def main():

    oveja = {}
    gr=generate_graph(oveja)
    #gr.generate_cannibal()
    #gr.generate_sheep()
    gr.generate_sheep()
    
    with open('oveja.json') as file:
        data =json.load(file)
        
    t=data['graph']
    s=data['estado_inicial']
    u=data['estado_aceptacion']
    g=graph(t,s,u)
    
    copyg=g
    aux=gr.call_return_path(copyg,copyg.graph[0])
    print('CAMINO')
    
    for h in gr.path:
        print('--',h,'\n')
        
    aux=gr.return_path_pos(copyg)
    print(aux)
    print(aux[0][1])
    
    gui=GUI(g,gr)
    

    
    gui.window()
Пример #9
0
    def run(self):
        player = self.process_client.login(3)
        map_graph = self.process_client.read_map()
        objects = self.process_client.read_objects()
        strategy = Strategy(player, map_graph, objects)
        if self.is_gui:
            self.gui = GUI(player, map_graph, objects)

        while player.is_alive:
            if self.is_gui:
                self.gui.turn()
                if ((not self.gui.paused) or self.gui.onestep):
                    moves = strategy.get_moves()
                    if moves:
                        for move in moves:
                            self.process_client.move(move)
                    self.process_client.turn()
            else:
                moves = strategy.get_moves()
                if moves:
                    for move in moves:
                        self.process_client.move(move)
                self.process_client.turn()
                sleep(0.5)

        return player.is_alive  # for testing
Пример #10
0
def main():
    launchpad = launchpadManager.Launchpad()
    for path in paths:
        k = KeyProfile(path)
        profiles.append(k)

    UI = GUI(launchpad, profiles)
Пример #11
0
    def __init__(self):

        # Load GUI class
        self.G = GUI()
        # Load Prediction Model
        self.PM = PredictionModel()

        # Prepare the Figure
        plt.ion()
        self.fig = mpl.figure.Figure(
            figsize=(10, 5),
            dpi=80,
            facecolor='w',
        )
        self.ax = self.fig.add_subplot(111)

        # Urls for Real-Time DST and IMF data
        self.url_dst = 'http://wdc.kugi.kyoto-u.ac.jp/dst_realtime/presentmonth/index.html'
        self.url_imf = 'https://cdaweb.gsfc.nasa.gov/pub/data/omni/low_res_omni/omni2_2018.dat'

        # Load data
        self.fill_data()
        # Plot data
        self.plot_data()

        # Intilialize a scheduler
        self.scheduler = sched.scheduler(time.time, time.sleep)

        # Load new values
        self.update()
        # Show GUI
        self.G.start_gui()
Пример #12
0
    def create_gui(self):
        self.GUI = GUI(page_title="Library", page_width=800, page_height=400)
        self.GUI.create_canvas(img=None, bg="#FFBB00")

        head_frame = self.GUI.create_frame(location=(0.25, 0.1, 0.5, 0.13),
                                           bg="#FFBB00")
        self.GUI.create_label(head_frame,
                              text="Return Book",
                              bg="black",
                              fg="white",
                              font_size=15,
                              location=(0, 0, 1, 1))

        # details frame
        details_frame = self.GUI.create_frame(location=(0.1, 0.3, 0.8, 0.5),
                                              bg="black")

        label_bid = self.GUI.create_label(details_frame, "Book ID: ", "black",
                                          "white", (0.05, 0.02), 11)
        self.entry_bid = self.GUI.create_entry(details_frame,
                                               (0.3, 0.02, 0.5, 0.1))

        self.GUI.create_button(text="Return",
                               command=self.return_,
                               location=(0.28, 0.9, 0.18, 0.08))
        self.GUI.create_button(text="Quit",
                               command=self.GUI.root.destroy,
                               location=(0.53, 0.9, 0.18, 0.08))
Пример #13
0
def gol():
    window = GUI()
    L = 0
    window.showGrid(arr)
    while True:
        if L == 100:
            break
        nextGen = arr[:]
        for i in range(len(nextGen)):
            if i == 0:
                nextGen[i] = arr[i]
            elif i == len(nextGen) - 1:
                nextGen[i] = arr[i]

            for j in range(len(nextGen)):
                if j == 0 or i == 0:
                    nextGen[i][j] = arr[i][j]
                elif j == len(nextGen) - 1 or i == len(nextGen) - 1:
                    continue
                else:
                    x = sum(arr[i - 1][j - 1:j + 1])
                    y = sum(arr[i + 1][j - 1:j + 1])
                    z = arr[i][j - 1] + arr[i][j + 1]
                    neighbors = x + y + z
                    nextGen[i][j] = checkRules(neighbors, arr[i][j])

        # updates image after creating new generation,
        # and puts pixels on the grid
        window.updateImage()
        #time.sleep(0.25)
        L += 1
Пример #14
0
    def __init__(self, image_path, min_width=400, min_height=400):
        self.con, self.cur = connectServer()

        self.image_path = image_path
        self.title = "Library"

        # database table names
        database_name = "Library2"
        self.books_table_name = "books"
        self.issued_books_table_name = "books_issued"
        create_new_db(name=database_name,
                      books_table_name=self.books_table_name,
                      books_issued_table_name=self.issued_books_table_name)

        # initialise the root frame of tkinter
        self.main_page = GUI(page_title=self.title)
        self.add_book_page = AddBook(
            bookTableName=self.books_table_name,
            bookIssuedTableName=self.issued_books_table_name)
        self.delete_page = DeleteBook(book_table=self.books_table_name,
                                      issue_table=self.issued_books_table_name)
        self.view_page = ViewBook(self.books_table_name,
                                  self.issued_books_table_name)
        self.issue_page = IssueBook(self.books_table_name,
                                    self.issued_books_table_name)
        self.return_page = ReturnBook(self.books_table_name,
                                      self.issued_books_table_name)
        self.issued_page = ViewIssued(self.books_table_name,
                                      self.issued_books_table_name)
Пример #15
0
def restart():
    """Reset all the values of the game and prepare to start over"""

    global dungeon, p, monsters_killed, gui

    gui.master.destroy()
    del gui

    # reset images for TKimage to work
    Goblin.reset()
    Slime.reset()

    gui = GUI()
    buyable_items = (Sword, HealthPot, armor_factory(1))
    gui.misc_config(buyable_items, restart)

    del p
    p = Player()
    gui.player_config(p)

    del dungeon
    dungeon = Dungeon()
    gui.dungeon_config(dungeon)

    dungeon.current_floor.disp.focus()

    monsters_killed = 0

    gui.master.mainloop()
Пример #16
0
class App(object):
    """Main App"""

    if __name__ == '__main__':

        firm = Firm()
        customer = Customer()
        gui = GUI()
        select_char = "s"

        while select_char != "q":

            gui.print_title()
            select_char = input("Select view:\n"
                               "\t1. Firm Panel\n"
                               "\t2. Customer Panel\n"
                               "\t3. Exit\n").upper()

            if select_char not in "123" or len(select_char) != 1:
                print("No such action")
                gui.clear(1);
                continue

            if select_char == '1':
                firm.firm_loop()

            elif select_char == '2':
                id = int(input("Enter customer id: "))
                customer.customer_loop(id, firm.container_list, firm.order)

            elif select_char == '3':
                os._exit(1)
Пример #17
0
def run_app(moves):
    """
    @param moves: iterable of Move objects
    """
    try:
        controller = Controller(settings.SERIAL_PORT)
        controller.set_board(moves)

        gui = GUI(controller)
        gui.drawer.init_pen('simmove', 400)

        controller.set_gui(gui)

        # set start position
        controller.virtualmachine.position[0] = 1
        controller.virtualmachine.position[1] = 1
        #For some reason setting this also changes the local computer movetable!!! Why???
        controller.virtualmachine.position[2] = 0.002

        # mill board!
        controller.mill_board()

        # gui should continue running until user presses escape key
        while True:
            gui.check_events()
            time.sleep(0.2)
    except Exception, error:
        print " ERROR "
        print Exception, error
        self.controller.exit()
        sys.exit(0)
Пример #18
0
        def thread_function():
            app = QtWidgets.QApplication(sys.argv)

            gui = GUI(app, self.specs)
            self.gui = gui
            print(gui, '1')
            gui.start()
def main(debug=False):

    ONTO_PATH = "Ontology\\GoalOntoV1.owl"

    MODEL = "model"

    win = GUI(debug)
    win.update()

    cam = io.Camera(host="192.168.1.21", port=9999)
    #cam = tools.CameraEmul("train_test.mp4")

    outputStack = io.OutputStack(host="192.168.1.21", port=9998)
    goalOnto = onto.GoalOnto(ONTO_PATH)
    roomClassification = ctx.RoomClassification(MODEL, 20)
    clockTime = ctx.ClockTime()
    assistanceLevel = cal.TextAssistance()
    decisionKernel = dk.GoalDecisionKernel(goalOnto, assistanceLevel)
    decisionKernel.add(roomClassification, clockTime)

    while win.isOpened():

        for _ in range(1):
            cam.updateFrame()
        decisionKernel.update()
Пример #20
0
def test_base():
    factory = WorldGetter(3)
    _map = Map(factory.get_map())
    _map.pos = factory.get_pos()
    objects = Objects(factory.get_objects())
    player = Player(factory.get_player())
    i = 30
    gui = GUI(player, _map, objects, None)
    gui.fps = 30
    gui.paused = True
    while player.is_alive:
        gui.turn()
        if gui.paused == False:
            objects.trains[1].line_idx = 1
            if objects.trains[1].position == 4:
                objects.trains[1].speed = -1
            elif objects.trains[1].position == 0:
                objects.trains[1].speed = 1
            objects.trains[1].position += objects.trains[1].speed
            objects.trains[1].line_idx = 10
            if objects.trains[2].position == 5:
                objects.trains[2].speed = -1
            elif objects.trains[2].position == 0:
                objects.trains[2].speed = 1
            objects.trains[2].position += objects.trains[2].speed
            if i > 0:
                i -= 1
            else:
                player.is_alive = False

    gui.close()
Пример #21
0
def main():
    RESTAURANT_NAME = "Wuxi"  # TODO 1: add your own restaurant name in the quotes
    restaurantTime = datetime.datetime(2017, 5, 1, 5, 0)
    #Create the menu object
    menu = Menu("menu.csv")  # TODO 2: uncomment this once the Menu class is implemented
    #create the waiter object using the created Menu we just created
    waiter = Waiter(menu)  # TODO 4: uncomment this one the Waiter class is implemented

    dinerList = []

    print("Welcome to " + RESTAURANT_NAME + "!")
    print(RESTAURANT_NAME + " is now open for dinner.\n")

    for i in range(21):
        restaurantTime += datetime.timedelta(minutes=15)
        potentialDiner = RestaurantHelper.randomDinerGenerator(restaurantTime)
        if potentialDiner is not None:
            dinerList.append(potentialDiner)
        else:
            dinerList.append(str(restaurantTime))

    # create main GUI
    root = Tk()
    root.title("Resturant")
    root.geometry("800x600")
    myAPP = GUI(root, waiter, dinerList)
    myAPP.mainloop()
    print('end of gui')
    print("Goodbye!")
Пример #22
0
    def main(self):
            # initialize the board, gui and player
            board = Board(self.size, self.timeLimit, self.whatSide)
            gui = GUI(board)
            player = Player(board, gui, self.whatSide)
            player2 = None
            if(self.whatSide == "green"):
                player2 = Player(board, gui, "red")
            else:
                player2 = Player(board, gui, "green")

            # for later
            #computer = Computer(board, gui, self.whatSide)

            # main run function
            while not board.gameWon:
                # move the player that is green first
                if(player.whatSide == "green"):
                    piece = player.getPiece()
                    while player.avaiableMoves() and not player.turnDone() and board.time():
                        position = player.nextMove()
                        valid = board.isValid(piece, position)
                        if(valid):
                            board.move(piece, position)
                        else:
                            gui.printStatus("Invalid move")
                    gui.printStatus("IM THINKING")
Пример #23
0
def main():
    # file_input("Pepe.txt")
    gui = input("Do you want to use the G)UI or C)onsole?: ")
    if gui == 'C':
        mode = input("Do you wish to import custom currencies via a file? (y or n): ")
        valid = False
        while not valid:
            if mode == "y":
                valid = True
                dic, new_name = file_input()
                o = input("What is your starting currency?: ")
                name = input("What do you want to convert to?: ")
                amount = float(input("How much do you want to convert?: "))
                money = Currency(o, name, amount)
                money.add_entry(new_name, dic)
                converted = money.convert()
                # money.show_rates()
                print("Converted {:,.2f} {} to {:,.2f} {}".format(amount, o, converted, name))
            elif mode == "n":
                valid = True
                original = input("What is your starting currency?: ")
                amount = float(input("How much do you want to convert?: "))
                name = input("What do you want to convert to?: ")
                money = Currency(original, name, amount)
                converted = money.convert()
                # money.show_rates()
                print("Converted {:,.2f} {} to {:,.2f} {}".format(amount, original, converted, name))
            else:
                print("Invalid choice, try again...")
                valid = False
    else:
        GUI().run()
Пример #24
0
def main():
    
    # ----Now comes the sockets part----
    start_server = input('Host new server (y/n): ')
    HOST = input('Enter host: ')
    PORT = input('Enter port: ')
    if not PORT:
        PORT = 33000
    else:
        PORT = int(PORT)

    ADDR = (HOST, PORT)

    server = None

    if start_server.lower() == 'y':
        server = Server(HOST, PORT)
        server_thread = Thread(target=server.run_server())
        server_thread.start()

    print("GOT HERE")
    client = Client(ADDR)
    
    root = Tk()
    my_gui = GUI(root, client)

    receive_thread = Thread(target=my_gui.update_msg)
    receive_thread.start()

    root.mainloop()

    server.shutdown()
    def create_gui(self):
        self.GUI = GUI(page_title="Library", page_width=1000, page_height=500)
        self.GUI.create_canvas(img=None, bg="#006B38")
        head_frame = self.GUI.create_frame(location=(0.25, 0.1, 0.5, 0.13))
        head_label = self.GUI.create_label(frame=head_frame,
                                           text="Delete Book",
                                           bg="black",
                                           fg="white",
                                           font_size=15,
                                           location=(0, 0, 1, 1))

        delete_frame = self.GUI.create_frame(location=(0.25, 0.3, 0.5, 0.5),
                                             bg="black")

        delete_body = self.GUI.create_label(delete_frame,
                                            text="Book ID",
                                            bg="black",
                                            fg="white",
                                            font_size=11,
                                            location=(0.05, 0.5, 0.3, 0.1))
        self.delete_entry = self.GUI.create_entry(delete_frame,
                                                  location=(0.4, 0.5, 0.3,
                                                            0.13))

        self.GUI.create_button(text="SUBMIT",
                               command=self.delete_book,
                               location=(0.28, 0.9, 0.18, 0.08))
        self.GUI.create_button(text="Quit",
                               command=self.GUI.root.destroy,
                               location=(0.53, 0.9, 0.18, 0.08))
Пример #26
0
    def __init__(self):
        #start the gui! - We have to update everything manually here :S
        self.GUI = GUI(self)
        os.system(
            "sudo bash -c 'echo 0 > /sys/class/backlight/rpi_backlight/bl_power'"
        )
        self.GUI.drawLoader()

        self.TextOut = TextOut(self.GUI)
        self.TextOut.addText(
            "[J.A.R.V.I.S.]: Loading Dataset! This could need a second!")
        self.GUI.display.update()
        self.mnist_loader = MNIST_LOADER()
        self.mnist_loader.loadMNIST()
        self.TextOut.addText("[J.A.R.V.I.S.]: Dataset loadeded!")
        self.GUI.display.update()
        self.RandomPicker = RandomPicker(self.mnist_loader)
        self.TextOut.addText("[J.A.R.V.I.S.]: Loading AI!")
        self.GUI.display.update()
        self.ai = AI_LITE()
        self.ai_keras = AI_KERAS()
        self.TextOut.addText("[J.A.R.V.I.S.]: Loading ImageEditor!")
        self.GUI.display.update()
        self.PicEditor = PicEditor()
        self.TextOut.addText("[J.A.R.V.I.S.]: Loading Camera!")
        self.GUI.display.update()

        self.GUI.initCam()
        self.GUI.drawMain()

        self.ai.initialize()
        self.TextOut.addText("[J.A.R.V.I.S.]: Everything's done, Sir.")
        self.GUI.handler()
Пример #27
0
    def startup(self):

        gui = GUI(self.appTitle)
        webcam = Webcam()

        while True:
            frame = webcam.getFrame()
            event, values = gui.getEvents()

            gui.loadFrame(webcam.frame_to_data(frame))

            if (event == 'Tirar Foto'):
                filename = gui.inputFilename()

                if (filename):
                    webcam.take_photo(self.imagesDir, filename)

            if ([event for item in gui.camFilters if item['value'] == event]):
                webcam.applyFilter(event)

            if event == 'Sobre':
                gui.about()

            if ([event for tema in gui.themes if tema == event]):
                gui.applyTheme(event)

            if (event is None or event == 'Fechar'):
                webcam = webcam.off()
                break

        gui = gui.close()
Пример #28
0
 def __init__(self):
     self.topHandler = TopHandler()
     self.GUI = GUI(self.topHandler)
     self.topHandler.setGUI(self.GUI)
     self.statechart = Statechart(self.GUI.getStatechartHandler())
     self.statechart.setCanvas(self.GUI.getCanvas())
     self.topHandler.setStatechart(self.statechart)
Пример #29
0
 def reset(self) -> StateType:
     """
     Resets the environment for the game.
     :return: The initial state of the game.
     """
     random.shuffle(self.players)
     self.active_players = self.players[:]
     self.attacking_player = None
     self.turn_player = None
     self.loser = None
     self.attacking_cards = list()
     self.defending_cards = list()
     self.legal_attacking_cards = list()
     self.legal_defending_cards = list()
     self.gui = GUI() if self.to_render else None
     self.deck = Deck()
     self.defending = True
     self.successful = False
     self.limit = 0
     self.last_action = Deck.NO_CARD
     self.reset_round = False
     self.attack_phase = True
     self.reset_attacker = True
     self.reward = 0
     self.initialize_players()
     self.set_first_attacker()
     self.do_reset_round()
     self.update_legal_cards()
     players_hands_sizes = [player.hand_size for player in self.players]
     return self.attacking_cards[:], self.defending_cards[:], self.legal_attacking_cards[:], self.legal_defending_cards[:], self.deck.current_num_cards, players_hands_sizes
    def __init__(self):
        self._playlists = []
        self.currentPlaylist = None
        self.currentSong = None
        self.currentUser = None

        # Populate our song list for usage (Custom offline songs)
        self._audioList.append(Song(None, "Darude Sandstorm", rating=2))
        self._audioList.append(Song(None, "Baby Dont Hurt Me", rating=1))
        self._audioList.append(Song(None, "I Want To Break Free", rating=4))
        self._audioList.append(Podcast(None, "How Its Made", 1, rating=4))
        self._audioList.append(Podcast(None, "How Its Made", 2, rating=3))
        self._audioList.append(Podcast(None, "How Its Made", 3, rating=3))

        self.newPlaylist(self._masterPlaylistName, self._audioList)

        # Populate more with online REST information pulled from last.fm
        self.importSongWithREST("Sweet Mountain River", "Monster Truck")
        self.importSongWithREST("Aural Psynapse", "deadmau5")
        self.importSongWithREST("Piano Man", "Billy Joel")
        self.importSongWithREST("Best Of You", "Foo Fighters")
        self.importSongWithREST("One More Time", "Daft Punk")

        # Start our GUI
        self.gui = GUI()
        self.gui.startGUI(self)