Exemplo n.º 1
0
def run():
    print(
        """This program can do following things with given .txt file. Select wanted operation:
    1. Takes a source text file and showing it.
    2. Conducts tokenization, lemmatization and stemming of a .txt file
    3. Removes stop words
    4. Returns the number of occurrences of each word in the .txt file
    5. Returns a given number of the most common words.
          """)
    while True:
        try:
            usr_input = int(
                input(
                    "Pick a wanted operation according to given list from 1 to 5: "
                ))
            if 0 <= usr_input >= 6:
                raise Exception
        except:
            print("Sorry, I didn't understand that.")
            continue
        else:
            break
    if usr_input == 1:
        Interface().First()
    if usr_input == 2:
        Interface().Second()
    if usr_input == 3:
        Interface().Third()
    if usr_input == 4:
        Interface().Fourth()
    if usr_input == 5:
        Interface().Fifth()
Exemplo n.º 2
0
    def __init__(self):
        # Debug.
        self.debug = False

        # Colors.
        self.white = 255, 255, 255
        self.green = 100, 175, 130
        self.red = 245, 35, 20
        self.blue = 0, 0, 255

        #images
        self.image_night_sky = pygame.image.load('ressources/images/background/night_sky.png')
        self.image_obstacle = pygame.image.load('ressources/images/obstacles/spike_a.png')

        # Init screen.
        self.size = self.width, self.height = 640, 480
        self.screen = pygame.display.set_mode(self.size)

        self.test_surface = pygame.Surface((320, 240))

        # Define the bg class
        self.bg = Background()

        # Define the obstacle manager class
        self.ground = Background.build_ground(self.bg, self.height, self.width)
        self.om = ObstacleManager(self.ground.height, self.width)

        # Define the interface class
        self.interface = Interface(self.screen, self.height, self.width)
Exemplo n.º 3
0
    def tvitem_click(self, event, item=None):
        self.save_records()

        sel_items = self.tv.selection() if item is None else item
        if sel_items:
            popup = Interface.popupEntry(self.root,
                                         title="更改 object 名稱",
                                         string="請輸入新的名稱。")
            self.root.wait_window(popup.top)
            sel_item = sel_items[0]

            try:
                new_key = popup.value
                if new_key in [
                        v['display_name'] for k, v in self.object_name.items()
                ]:
                    self.msg('%s 已經被使用了。' % new_key)
                    self.tvitem_click(item=sel_items)
                elif new_key in [" " * i for i in range(10)]:
                    self.msg('請輸入空白鍵以外的字串。')
                    self.tvitem_click(item=sel_items)
                elif len(new_key) > 6:
                    self.msg('請輸入長度小於 6 的字串。')
                    self.tvitem_click(item=sel_items)
                else:
                    self.object_name[sel_item]['display_name'] = new_key
                    self.all_buttons[self.object_name[sel_item]['ind'] +
                                     2].config(text=new_key)
            except:
                pass
Exemplo n.º 4
0
def default_interface():
    created_interfaces = []
    port = 'fa0/1'
    cidr = '192.168.0.0/24'
    ip_address = '192.168.1.1'
    interface = Interface(port=port, cidr=cidr, ip_address=ip_address)
    return interface
Exemplo n.º 5
0
def main():
    devlist = [None, None, None, None]
    ardlist = handshake(devlist)

    serialcom = Serialcom(ardlist)
    serialcom.startreadingserial()
    #data_thread=Thread(target=serialcom.startreadingserial)
    #data_thread.start()

    root = tk.Tk()
    root.attributes('-zoomed', True)
    root.configure(bg='white')

    interf = Interface(root, ardlist)
    interf.guiloop()

    shutdown(ardlist)
Exemplo n.º 6
0
def run(observe=False):
    if not os.path.exists('./logs'):
        os.makedirs('./logs')

    if not os.path.exists('./model'):
        os.makedirs('./model')

    interface = Interface()
    agent = Agent(interface)
    state = State(agent, interface)
    nn = NNModel()
    model = nn.build_model()

    try:
        nn.trainNetwork(model, state, observe=observe)
    except StopIteration:
        print("No model")
        interface.close()
Exemplo n.º 7
0
 def jump_frame(self):
     popup = Interface.popupEntry(self.root,
                                  title="移動幀數",
                                  string="請輸入介於 %s ~ %s 的數字。" %
                                  (1, self.total_frame),
                                  validnum=True)
     self.root.wait_window(popup.top)
     try:
         n = int(popup.value)
         if n >= 1 and n <= self.total_frame:
             self.n_frame = n
         else:
             self.msg("請輸入介於 %s ~ %s 的數字。" % (1, self.total_frame))
             self.jump_frame()
     except Exception as e:
         print(e)
Exemplo n.º 8
0
class Main:

    recognizer = None
    model = None
    interface = None
    video_capture = None

    def __init__(self):
        self.recognizer = Recognizer()
        self.interface = Interface()

    def run(self, object_type, show_border, show_image):

        self.model = self.recognizer.training(object_type)
        self.video_capture = self.interface.startVideoCapture(
            object_type, show_border, show_image)

        while True:

            self.interface.waitCameraOpen(self.video_capture)

            frame = self.interface.getCurrentFrame(self.video_capture)
            objects = self.recognizer.detectObjects(self.model, frame)

            self.interface.drawObjects(objects, frame)

            if self.endKeyWasPressed():
                return self.stop()

            self.interface.displayFrame(frame)

    def endKeyWasPressed(self):
        if cv2.waitKey(1) & 0xFF == ord('q'):
            return True

        return False

    def stop(self):
        self.video_capture.release()
        cv2.destroyAllWindows()
        return True
Exemplo n.º 9
0
 def __init__(self):
     self.recognizer = Recognizer()
     self.interface = Interface()
Exemplo n.º 10
0
from src.interface import Interface

if __name__ == '__main__':
    program = Interface()
    program.run()
Exemplo n.º 11
0
class Display:

    def __init__(self):
        # Debug.
        self.debug = False

        # Colors.
        self.white = 255, 255, 255
        self.green = 100, 175, 130
        self.red = 245, 35, 20
        self.blue = 0, 0, 255

        #images
        self.image_night_sky = pygame.image.load('ressources/images/background/night_sky.png')
        self.image_obstacle = pygame.image.load('ressources/images/obstacles/spike_a.png')

        # Init screen.
        self.size = self.width, self.height = 640, 480
        self.screen = pygame.display.set_mode(self.size)

        self.test_surface = pygame.Surface((320, 240))

        # Define the bg class
        self.bg = Background()

        # Define the obstacle manager class
        self.ground = Background.build_ground(self.bg, self.height, self.width)
        self.om = ObstacleManager(self.ground.height, self.width)

        # Define the interface class
        self.interface = Interface(self.screen, self.height, self.width)

    # Display the background.
    def show_background(self):
        # Fill the bg color
        self.screen.fill(self.bg.color)

        # Display the sky
        image = pygame.transform.scale(self.image_night_sky, (self.width, self.ground.height))
        self.screen.blit(image, (0, 0))

        # Build the ground.
        pygame.draw.line(
            self.screen,
            self.ground.color,
            (self.ground.start, self.ground.height), (self.ground.end, self.ground.height)
        )

    # Display the score.
    def show_score(self, player):
        score = player.score_counter()

        # Use the interface to position the text.
        self.interface.display_score(score)

    # Display the obstacles.
    def show_obstacles(self):

        # Get the obstacles and draw them.
        obstacles = self.om.run()

        # self.debug = True
        for obstacle in obstacles:
            if self.debug:
                obstacle_pos = obstacle.pos_x, obstacle.pos_y
                obstacle_size = obstacle.size_x, obstacle.size_y
                pygame.draw.rect(self.screen, obstacle.color, (obstacle_pos, obstacle_size))

            image = pygame.transform.scale(self.image_obstacle, (24, 24))
            self.screen.blit(image, (obstacle.pos_x, obstacle.pos_y - 3))

    def check_collision(self, player):
        self.om.check_collision(player)

    # Display the score.
    def show_end_screen(self, player):
        score = player.score_counter()

        self.interface.display_end_screen(score)

    # Reset the game. player pos and obstacle pos.
    def reset(self, player):
        player.score = 0
        player.dead = False
        self.om.clear_all_obstacles()
Exemplo n.º 12
0
import sys
reload(sys)
sys.setdefaultencoding('utf8')
import json
from src.interface import Interface
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, DispatcherHandlerStop

if __name__ == '__main__':

    with open('config.json', mode='r') as f:
        config = json.load(f)

    updater = Updater(config['token'])
    dispatcher = updater.dispatcher

    interface = Interface(config['allowed_users'], config['output_dir'])

    start_handler = CommandHandler('start', interface.start)
    check_handler = CommandHandler('squeue_me', interface.check_queue)
    checkall_handler = CommandHandler('squeue_all', interface.check_queue_all)
    check_space_handler = CommandHandler('diskspace',
                                         interface.check_disk_space)
    check_progress_handler = CommandHandler('progress',
                                            interface.check_progress)

    dispatcher.add_handler(start_handler)
    dispatcher.add_handler(check_handler)
    dispatcher.add_handler(checkall_handler)
    dispatcher.add_handler(check_space_handler)
    dispatcher.add_handler(check_progress_handler)
Exemplo n.º 13
0
from src.interface import Interface
from settings.generalSettings import generalSettingsDict


if __name__ == '__main__':
    myinterface = Interface(generalSettingsDict)
    myinterface.run()
Exemplo n.º 14
0
from tkinter import Tk, Image

from src.game import Game
from src.interface import Interface
from src.storage import Storage

storage = Storage()

root = Tk()
root.title("Saper")
interface = Interface(root)
interface.pack()
game = Game(root)

interface.registerCallback(game.initGameCallBack)

root.mainloop()
Exemplo n.º 15
0
import sys

from PyQt5.QtQml import QQmlApplicationEngine
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QUrl

from src.interface import Interface

if __name__ == '__main__':
    app = QApplication(sys.argv)

    appEngine = QQmlApplicationEngine()

    context = appEngine.rootContext()

    appEngine.load(QUrl('./main.qml'))

    win = appEngine.rootObjects()[0]

    # Register Python classes with qml
    interface = Interface(app, context, win)

    context.setContextProperty('iface', interface)

    win.show()
    try:
        apcode = app.exec_()
    except:
        print('there was an issue')
    finally:
        sys.exit(apcode)
Exemplo n.º 16
0
def default_interface():
    port = 'fa0/1'
    cidr = '192.168.0.0/24'
    ip_address = '192.168.1.1'
    fa01 = Interface(port=port, cidr=cidr, ip_address=ip_address)
    return fa01
Exemplo n.º 17
0
def main():
    # Make the multiprocessing logic used in the modules happy.
    mp.freeze_support()

    # Load the tileset and context
    tileset = tcod.tileset.load_tilesheet("tilesets/yayo_c64_16x16.png", 16, 16,
                                          charmap=tcod.tileset.CHARMAP_CP437)
    context = tcod.context.new(width=WIDTH,
                               height=HEIGHT,
                               tileset=tileset,
                               sdl_window_flags=FLAGS)

    interface = Interface(context)

    # Mock-up of generating the main menu, which should be its own class, I think
    menu = Menu(width=floor(WIDTH/(2*TILESET_SIZE)),
                height=floor(HEIGHT/TILESET_SIZE),
                interface=interface,
                spacing=1)

    def launch_the_game(event):
        interface.new_playfield(width=200,
                                height=80)

        floors = []
        for y in range(0, 40):
            floors.append([(x, y, WalkableTerrain())
                           for x in range(0, 60)])

        for f in sum(floors, []):
            x, y, ent = f
            ent.introduce_at(x, y, interface.playfield)

        walls = [(x, 20, Wall()) for x in range(0, 11)]
        for w in walls:
            x, y, ent = w
            ent.introduce_at(x, y, interface.playfield)

        player_char = Mobile(size=4,
                             sigil=Sigil("@", priority=3),
                             name="Player Character")
        player_char.introduce_at(10, 10, interface.playfield)
        interface.playfield.player_character = player_char

        interface.playfield.origin = (2, 2)
        interface.add_animation(7, 7, Animation(frames=[AnimationFrame(Sigil("\\"), 5),
                                                        AnimationFrame(Sigil("|"), 5),
                                                        AnimationFrame(Sigil("/"), 5),
                                                        AnimationFrame(Sigil("-"), 5)],
                                                repeating=True))
        blue_floor = WalkableTerrain(color=(50, 50, 255))
        blue_floor.sigil = Sigil("!", priority=blue_floor.sigil.priority)
        blue_floor.introduce_at(12, 12, interface.playfield)

        # print(interface.playfield.get_cell(12, 12).sigils)
        interface.new_game_log(height=10, width=40)
        interface.print_to_log("This is a log tests!", color=(25, 250, 25))
        interface.print_to_log("This is an exceptionally long log tests so we can see how well it handles multiples of these.")
        interface.print_to_log("This is another line.")
        interface.print_to_log("This is yet another line.")
        interface.print_to_log("This should bump the first line off of the screen.")
        menu.close_menu()

    menu.add_option(MenuOption(text="Start Game",
                               width=24, height=5,
                               on_select=launch_the_game))
    menu.add_option(MenuOption(text="Do Nothing",
                               width=24, height=5,
                               on_select=lambda x: print("Did nothing!")))
    menu.add_option(MenuOption(text="Do Nothing Else",
                               width=24, height=5,
                               on_select=lambda x: print("Did more nothing!")))
    menu.add_option(MenuOption(text="Do More Nothing",
                               width=24, height=5,
                               on_select=lambda x: print("Did more nothing!")))
    menu.add_option(MenuOption(text="Make this menu long",
                               width=24, height=5,
                               on_select=lambda x: print("Did more nothing!")))
    menu.add_option(MenuOption(text="Like REALLY long",
                               width=24, height=5,
                               on_select=lambda x: print("Did more nothing!")))
    menu.add_option(MenuOption(text="Because we, ah...",
                               width=24, height=5,
                               on_select=lambda x: print("Did more nothing!")))
    menu.add_option(MenuOption(text="Need to tests something",
                               width=24, height=5,
                               on_select=lambda x: print("Did more nothing!")))
    menu.add_option(MenuOption(text="You know, uh...",
                               width=24, height=5,
                               on_select=lambda x: print("Did more nothing!")))
    menu.add_option(MenuOption(text="that one thing...",
                               width=24, height=5,
                               on_select=lambda x: print("Did more nothing!")))
    menu.add_option(MenuOption(text="Oh yeah!",
                               width=24, height=5,
                               on_select=lambda x: print("Did more nothing!")))
    menu.add_option(MenuOption(text="Overflow behavior! :)",
                               width=24, height=5,
                               on_select=lambda x: print("Did more nothing!")))
    interface.open_menu(menu)

    last_tick = __time_ms()  # In epoch milliseconds
    tick_length = 50         # Milliseconds per engine tick
    while True:
        now_ms = __time_ms()

        # Only run the main loop logic if we've reached the next clock increment
        if now_ms - last_tick >= tick_length:
            if interface.playfield:
                win_width, win_height = context.recommended_console_size(min_columns=50,
                                                                         min_rows=40)
                interface.playfield.window = (win_width - READOUT_WIDTH,
                                              win_height - GAMELOG_HEIGHT)
            interface.tick()
            interface.print_self()

            # Forward the reference time to the time at which we started this batch of logic
            last_tick = now_ms
Exemplo n.º 18
0
from src.interface import Interface


if __name__ == '__main__':
    Interface()

Exemplo n.º 19
0
import tkinter as tk
import pygame
from src.interface import Interface
from src.board import Board
from src.ladder import Ladders
from src.pawn import Pawn
from src.data import Sounds

# Interface
window = tk.Tk()
i = Interface(window)
window.mainloop()

# Game
if i.ready:
    players = i.players
    # print(players)

    # Ladders
    ladders = Ladders()
    for start, end in zip(
        [5, 8, 14, 19, 25, 39, 47, 49, 58, 62, 68, 74, 84],
        [24, 50, 48, 44, 56, 60, 75, 90, 77, 98, 92, 95, 96]):
        ladders.append(start, end)

    # Board
    b = Board(ladders)

    # Pawns
    for p in players.players:
        p.pawn = Pawn(p.color, b)
Exemplo n.º 20
0
 def __init__(self):
     self.interface = Interface()