Esempio n. 1
0
 def on_focus(self, instance, value):
     print('instance:', instance)
     if value:
         if instance == self.username:
             self.u_kb = Keyboard("text", instance)
         elif instance == self.password:
             self.p_kb = Keyboard("text", instance)
     else:
         instance.release()
         return False
Esempio n. 2
0
    def test_success_AddCarNr(self):
        message = RequestPayloadUT([
            "MESSAGE_REQUEST", "{{" + CMD_ADD_CAR_NR + "}}", "time_12:00",
            "user_id"
        ])
        rq = Request(message)
        # first entering into chat
        # ->incoming() with ViberMessageRequest called
        self.assertTrue(rq.state == 'NEW')
        self.assertTrue(rq.need_input() is False)

        rq.advance()
        self.assertTrue(rq.state == 'IDENTIFY')
        self.assertTrue(rq._user_identified is False)
        self.assertTrue(rq._user_confirmed is False)
        self.assertTrue(rq.need_input() is False)
        self.assertTrue(rq.get_message_out() == TXT_IDENTIFY__NEW_USER)
        self.assertTrue(rq.get_kbd().eq(
            Keyboard([
                Keyboard.cmd_button(CMD_REG_TEL),
                Keyboard.cmd_button(CMD_ADD_NAME),
                Keyboard.cmd_button(CMD_ADD_CAR_NR),
                Keyboard.cmd_button(CMD_ADD_HOME_FLAT_NR)
            ])))

        rq.advance()
        self.assertTrue(rq.state == 'ADD_CAR_NR')
        self.assertTrue(rq._user_identified is False)
        self.assertTrue(rq._user_confirmed is False)
        self.assertTrue(rq.need_input() is True)
        self.assertTrue(rq.get_message_out() == TXT_ADD_CAR_NR)
        self.assertTrue(rq.get_kbd().eq(Keyboard([])))
        message._payload[1] = 'вн1984не'

        rq.advance()
        self.assertTrue(rq.state == 'GOT_CAR_NR')
        self.assertTrue(rq._user_identified is False)
        self.assertTrue(rq._user_confirmed is False)
        self.assertTrue(rq.need_input() is False)
        self.assertTrue(rq.get_message_out() == TXT_GOT_CAR_NR)
        self.assertTrue(rq.get_kbd().eq(KBD_ALL_KEYS))

        rq.advance()
        self.assertTrue(rq.state == 'UPDATE_DB')
        self.assertTrue(rq._user_identified is False)
        self.assertTrue(rq._user_confirmed is False)
        self.assertTrue(rq.need_input() is False)
        self.assertTrue(rq.get_message_out() == TXT_GOT_CAR_NR)
        self.assertTrue(rq.get_kbd().eq(KBD_ALL_KEYS))

        rq.advance()
        self.assertTrue(rq.state == 'DELETE')
        self.assertTrue(rq.get_message_out() == TXT_GOT_CAR_NR)
        self.assertTrue(rq.need_input() is True)
Esempio n. 3
0
 def __init__(self):
     super(Window, self).__init__()
     self.player1 = Keyboard()
     self.player2 = Keyboard()
     # self.x = 128*3
     # self.y = 120*3
     # self.dx = 1*3
     # self.dy = 1*3
     self.x = 128
     self.y = 120
     self.dx = 1
     self.dy = 1
Esempio n. 4
0
    def __init__(self, connector):
        PyQGLViewer.QGLViewer.__init__(self)
        self.U, self.V = np.meshgrid(np.arange(0, 640, SAMPLE_STRIDE),
                                     np.arange(0, 480, SAMPLE_STRIDE))

        self.points = np.zeros((3, 1))
        self.connector = connector
        self.keyboards = [Keyboard(Keyboard.TYPE_FORWARD, 4, 1, 1, 0.001, 0,"keyboard1.npy" , connector), \
            Keyboard(Keyboard.TYPE_REVERSE, 4, 1, 1, 0.001, -8, "keyboard2.npy", connector), \
            Keyboard(Keyboard.TYPE_SELECT, 1, 2, 2, 0.01, -16, "keyboard3.npy", connector),\
            Keyboard(Keyboard.TYPE_DIRECTION_TOGGLE,1,2,2,0.01,8, "keyboard4.npy", connector) ]
        self.num_keyboard = 4
        self.keyboard = self.keyboards[0]
def reconstruct_keyboard(freq_cts, original_distribution, bbox_to_center,
                         bboxes):
    #tries to reconstruct observed keyboard

    im = plt.imread('random_keyboard_xr.png')

    observed_dist = sorted(freq_cts.items(),
                           key=operator.itemgetter(1),
                           reverse=True)
    observed_dict = {}

    recon_keyboard_dict = {}

    for idx, hyp in enumerate(observed_dist):

        center_h, count_h = hyp
        letter_h = list(original_distribution.keys())[idx]
        letter_real = bbox_to_center[center_h][1]

        info_hyp = bboxes[letter_h]
        bb_hyp = info_hyp[0]
        crop_hyp = info_hyp[1]

        bb_real = bboxes[letter_real][0]
        x_min, x_max, y_min, y_max = bb_real  # NEED TO GET REAL BB
        im[y_min:y_min + 32, x_min:x_min + 24, :] = crop_hyp
        recon_keyboard_dict[letter_h] = [crop_hyp, bb_real, letter_real]

        observed_dict[center_h] = {'hyp': letter_h, 'gt': letter_real}

    recon_keyboard = Keyboard(type='recon',
                              im_file_name=im,
                              key_to_info_dict=recon_keyboard_dict)

    return recon_keyboard, observed_dict
Esempio n. 6
0
def InitPasswordPage(main_screen):

    myvars.PasswordPage = Keyboard()
    myvars.PasswordPage._Name = "Enter wifi password"

    myvars.PasswordPage._Screen = main_screen
    myvars.PasswordPage.Init()
Esempio n. 7
0
def main(args):
    # start jackd and sooperlooper, and wait until finished
    if args.startup:
        startup = subprocess.Popen(['bash', args.startup_script])
        startup.communicate()

    # connect to SooperLooper via OSC
    if args.verbose:
        print('Setting up Sooper Looper OSC client...')
    sl_client = OscSooperLooper(client_url=args.osc_url,
                                empty_session=args.empty_session_file)

    # connect with either trellis PCB or keyboard
    if args.verbose:
        print('Initializing {} interface...'.format(args.interface))
    if args.interface == 'trellis':
        interface = Trellis(startup_color=args.color)
    elif args.interface == 'keyboard':
        interface = Keyboard(BUTTON_PRESSED, BUTTON_RELEASED)
    interface.set_color_map(COLOR_MAP)

    looper = Looper(sl_client=sl_client,
                    interface=interface,
                    session_dir=args.session_dir,
                    verbose=args.verbose)
    try:
        looper.start()
    except:
        looper.terminate()
        raise
Esempio n. 8
0
 def test_part_key_presses(self, inp, res):
     res = res.format(**key)
     kb = Keyboard('US')
     i = random.randint(0, len(res))
     pre_word, shift, caps = kb.part_key_press_string(res[:i])
     post_word, shift, caps = kb.part_key_press_string(res[i:], shift, caps)
     assert inp == pre_word + post_word
Esempio n. 9
0
 def test_keyboard_dist(self):
     inp_res_map = [(('t', 't'), (0)), (('t', 'T'), (0.8)),
                    (('a', 'S'), (1.8)), (('a', 'w'), (2)),
                    (('w', '$'), (3.8)), (('<', '>'), (1))]
     kb = Keyboard('US')
     for q, r in inp_res_map:
         assert kb.keyboard_dist(*q) == r
Esempio n. 10
0
 def test_loc(self):
     inp_res_map = [(('t'), (1, 5, 0)), (('T'), (1, 5, 1)),
                    (('a'), (2, 1, 0)), (('('), (0, 9, 1)),
                    (('M'), (3, 7, 1))]
     kb = Keyboard('US')
     for q, r in inp_res_map:
         assert kb.loc(*q) == r
Esempio n. 11
0
 def test_key_press_insert_edits(self, inp, res):
     inp_res_map = [(
         ('{s}pa'.format(**key), [CAPS_KEY, SHIFT_KEY,
                                  'a'], [CAPS_KEY, 't']),
         (
             'pA',
             'Pa',
             'aPa',
             'pa',
             'PA',
             'tpa',  # j=0
             'pA',
             'Pa',
             'Apa',
             'A',
             'a',
             'Ta',  # j=1
             'PA',
             'PA',
             'Paa',
             'P',
             'P',
             'Pt',  # j=2
             'Paa'))]
     kb = Keyboard('US')
     for inp, res in inp_res_map:
         for i, r in enumerate(kb.key_press_insert_edits(*inp)):
             print i, r, res[i]
             assert r == res[i]
Esempio n. 12
0
    def __init__(self):
        Gtk.DrawingArea.__init__(self)

        self.caret = Gdk.Rectangle()

        self.connect("draw", self.on_draw)
        self.connect("key-press-event", self.on_key_press)
        self.connect("key-release-event", self.on_key_release)
        self.connect("focus-in-event", self.on_focus_in)
        self.connect("focus-out-event", self.on_focus_out)

        self.im_context = Gtk.IMMulticontext()
        self.im_context.set_client_window(self.get_window())
        self.im_context.connect("commit", self.on_commit)
        self.im_context.connect("delete-surrounding",
                                self.on_delete_surrounding)
        self.im_context.connect("retrieve-surrounding",
                                self.on_retrieve_surrounding)
        self.im_context.connect("preedit-changed", self.on_preedit_changed)
        self.im_context.connect("preedit-end", self.on_preedit_end)
        self.im_context.connect("preedit-start", self.on_preedit_start)

        self.set_can_focus(True)

        self.roomazi = Roomazi()
        self.keyboard = Keyboard(self.roomazi)
        self.engine = Engine(self.roomazi)
Esempio n. 13
0
    def __init__(self, gpu):
        threading.Thread.__init__(self)
        self.gpu = gpu
        self.ram = [U8_MAX] * RAM_SIZE
        self.vram = [0x0] * VRAM_SIZE

        self.V = [U8_MAX] * NUM_REGISTERS
        self.I = U16_MAX
        self.D = 0x0
        self.S = 0x0

        self.stack = [U16_MAX] * STACK_SIZE
        self.sp = 0x0

        self.pc = PRG_START_ADDR

        self.running = False
        self.instructionSet = InstructionSet()
        self.debugger = None
        self.interrupt = None
        self.interruptTable = Interrupts()

        self.delayCycle = 0

        self.keyboard = Keyboard()

        fontOffset = 0
        for font in FONT_SPRITES:
            self.ram[FONT_ADDRESS + fontOffset] = font
            fontOffset += 1
Esempio n. 14
0
 def restart():
     Levels.player = Player()  # the player
     Levels.kbd = Keyboard()  # keyboard class to check movement for player
     Levels.room = None  # background for level
     Levels.Walls = [Wall(0), Wall(1), Wall(2), Wall(3)]  # all the walls
     Levels.playerInteraction = PlayerInteraction(
         Levels.player, Levels.kbd,
         Levels.Walls)  # interaction to keep player within the walls
     Levels.levels = [
     ]  # list of levels. levels get appended here when they load
     Levels.MeleeEnemies = []  # list of melee enemies
     Levels.ObjInteractions = [
     ]  # just initialising var to store interactions between melee enemies
     Levels.RangedEnemies = []  # list of ranged enemies
     Levels.Rocks = []  # List of rocks
     Levels.Projectiles = []  # list of projectiles
     Levels.wall_interactions = [
     ]  # list of wall interactions to help keep player within the walls
     for wall in Levels.Walls:
         Levels.wall_interactions.append(Interaction(Levels.player, wall))
     Levels.Gates = []  # list of gates to move player between levels
     Levels.GateInteractions = []  # list of interactions for above gates
     Levels.roomText = 0  # text to represent what room the player is in
     Scores.score = 0
     Levels.projectileCollision = ProjectileCollision(Levels.player)
Esempio n. 15
0
def input_wifi_password():
    global current_screen, screen_type
    current_screen = "wifi_password"
    screen_type = "keyboard"
    print("input_wifi_password")
    kb = Keyboard(oled, kb_callback)
    kb.show()
Esempio n. 16
0
    def __init__(self, **kwargs):
        super(IcarusTouchWidget,
              self).__init__(**kwargs)  # don't know if this is necessary?

        # add background image (and add it in the BACKGROUND! --> index modification)
        self.background = Background(
            source=self.app.config.get('Graphics', 'Background'))
        self.float_layout.add_widget(self.background,
                                     index=len(self.float_layout.children))

        # add feedback wall image
        self.feedback_wall = Feedback(source='images/feedbackwall.png',
                                      transparency=0)
        self.float_layout.add_widget(self.feedback_wall)

        # add the keyboard itself
        my_key_width = KEY_WIDTH
        self.keyboard = Keyboard(
            source=self.app.config.get('Graphics', 'Keyboard'),
            pos=(-540, 366),
            size=(
                12 * 5 * my_key_width, 468
            ),  # optimization for small screens (e.g. smartphones): 468 if self.get_parent_window().height > (468 + self.get_parent_window().height * 0.3) else self.get_parent_window().height * 0.7
            border_width=BORDER_WIDTH,
            key_width=my_key_width)
        self.add_widget(self.keyboard)

        # initialize the midi device
        pygame.midi.init()
        self.set_midi_device()

        # initialize the settings_panel (I'm doing this here, otherwise opening it in real-time takes ages...)
        self.my_settings_panel = MySettingsPanel()
Esempio n. 17
0
 def build(self):
     self.layout.add_widget(self.control_panel)
     self.layout.add_widget(self.screen)
     self.screen.difficulty.text = self.difficulty
     self.keyboard = Keyboard(self.screen.output, self.key_callback)
     self.layout.add_widget(self.keyboard)
     return self.layout
Esempio n. 18
0
    def full_restart(self):
        """Fully restart the game, clearing all history, etc."""
        # Initialize real and virtual keyboards.
        self.keyboard = Keyboard()
        self.virtual_keyboards = []
        
        # Initialize game objects
        self.players = [Ship(self.keyboard, self.view_size / 2.0)]
        self.bullets = []
        self.rand_state = random.getstate()

        self.asteroids = [Asteroid(self, clear_zone = self.view_size / 2.0,
                                   seed = random.random())
                          for i in range(self.num_asteroids)]
        
        self.DEBUG = DataToggle(source = self.keyboard[sf.Key.NUM0],
                                initVal = False)
                                
#        self.RECORDING = Toggle(source = self.keyboard[sf.Key.T],
#                                initVal = False)

        self.won = False

        # Start the system running
        self.running = DataToggle(
            source = DataOr(self.keyboard[sf.Key.ESCAPE],
                            DataAnd(self.keyboard[sf.Key.Q], 
                                    DataOr(self.keyboard[sf.Key.L_SYSTEM],
                                           self.keyboard[sf.Key.R_SYSTEM]))),
                                  initVal = True)
Esempio n. 19
0
 def main():
     copier = Copier()
     keyboard = Keyboard()
     scanner = Scanner()
     printer = Printer()
     database = Database()
     copier.copy(scanner, database)
    def __init__(self, master=None, **kwargs):
        tk.Frame.__init__(self, master, **kwargs)

        master.title("Hangman")
        master.geometry("1000x800")
        master.resizable(False, False)

        self.word = master.word  # get the value from the first screen

        self.score = 7
        self.display = list(len(self.word) * '_')

        # Place the hangman
        # TODO

        # Display the keyboard
        keyboard = Keyboard(self)
        keyboard.pack()

        # Place box for keeping track of word and sample word below
        word_box = tk.Frame(master, height=80, width=600, bd=5, bg='white')
        self.label = tk.Label(word_box, text=self.display)
        self.label.config(font=(None, 25))
        self.label.pack()
        lbl_txt = tk.Label(word_box, text=self.word)
        lbl_txt.pack()
        word_box.place(relx=0.5, y=700, anchor='n')
Esempio n. 21
0
    def __init__(self, master=None, **kwargs):
        tk.Frame.__init__(self, master, **kwargs)

        master.title("Hangman")
        master.geometry("900x550")
        master.resizable(False, False)

        self.word = master.word  # get the value from the first screen
        self.chosen_list = []
        self.score = 7
        self.display = list(len(self.word) * '_')
        self.image = f'images/hangman{self.score}.png'

        # Place the hangman
        hangman_draw = tk.Frame(master, height=580, width=600)
        self.photo = tk.PhotoImage(file=self.image)
        photo_label = tk.Label(hangman_draw, image=self.photo)
        photo_label.pack()

        hangman_draw.place(relx=0.5, y=100, anchor='n')

        # Display the keyboard
        keyboard = Keyboard(self)
        keyboard.pack()

        # Place box for keeping track of word and sample word below
        word_box = tk.Frame(master, height=80, width=600, bd=5)
        self.label = tk.Label(word_box, text=self.display)
        self.label.config(font=(None, 25))
        self.label.pack()
        self.lbl_txt = tk.Label(word_box, text=self.chosen_list)
        self.lbl_txt.pack()
        word_box.place(relx=0.5, y=425, anchor='n')
Esempio n. 22
0
 def __init__(self, tv=None):
     self._tv = tv
     self._gamepad = None
     self._gamepad_connected = threading.Event()
     self._last_activity_ts = time.time()
     self._locked = False
     self._kbd = Keyboard()
     self._stop = threading.Event()
Esempio n. 23
0
 def __init__(self):
     pygame.mixer.init(22050, -16, 2, 64)
     pygame.init()
     self.keyboard = Keyboard(VISABLE_FEEDBACK=Keyboard.VISABLE_ALWAYS,
                              WORD_CORRECTION=Keyboard.CORRECT_WORD)
     self.tracker_L = FingerTracker(1)
     self.tracker_R = FingerTracker(2)
     self.init_camera()
Esempio n. 24
0
def main():
    rom = file_explorer()
    if rom is None:
        sys.exit()
    renderer = Renderer()
    keyboard = Keyboard()
    cpu = Cpu(renderer, keyboard)
    game_starter(rom, cpu, renderer, keyboard)
Esempio n. 25
0
    def init_specials_commands(self):
        operation = Operations(self.results)

        quit = Keyboard(self.frame,
                        "QUITTER",
                        self.calculator.destroy,
                        1,
                        0,
                        16,
                        cospan=2,
                        bg='#CECECE')
        quit.add_buttons_signs()

        C = Keyboard(self.frame, 'C', operation.delete_all, 1, 2)
        C.add_buttons_signs()

        CE = Keyboard(self.frame, 'CE', operation.delete_last_digit, 1, 3)
        CE.add_buttons_signs()

        x2 = Keyboard(self.frame, 'x²', operation.power2, 1, 4)
        x2.add_buttons_signs()

        MC = Keyboard(self.frame, 'MC', operation.delete_memory, 2, 2)
        MC.add_buttons_signs()

        MR = Keyboard(self.frame, 'MR', operation.display_memory, 2, 3)
        MR.add_buttons_signs()

        Mplus = Keyboard(self.frame, 'M+', operation.add_memory, 2, 4)
        Mplus.add_buttons_signs()

        square = Keyboard(self.frame, '√', operation.square_root, 3, 4)
        square.add_buttons_signs()

        egal = Keyboard(self.frame,
                        '=',
                        operation.calculate,
                        5,
                        4,
                        height=9,
                        rospan=2)
        egal.add_buttons_signs()

        plusMinus = Keyboard(self.frame, '+/-', operation.plus_minus, 6, 2)
        plusMinus.add_buttons_signs()
Esempio n. 26
0
 def __init__(self, ratio=1):
     self.RUN = True
     self.TOGGLE = False
     self.vision = Vision(ratio=ratio)
     self.keyboard = Keyboard(sleep=1)
     self.KEYCODES = {1: 18, 2: 19, 3: 20, 4: 21, 5: 23}
     self.potions_box = {"top": 850, "left": 1920, "width": 500, "height": 200}
     self.menu_box = {"top": 300, "left": 1920 + 680, "width": 320, "height": 260}
     self.mouse = Mouse()
Esempio n. 27
0
def flasks():
    # listener = Listener()
    # listener.listen()
    keyboard = Keyboard(sleep=1)
    keyboard.key(KeyCode.from_vk(18))  # Flask 1
    keyboard.key(KeyCode.from_vk(19))  # Flask 2
    keyboard.key(KeyCode.from_vk(20))  # Flask 3
    keyboard.key(KeyCode.from_vk(21))  # Flask 4
    keyboard.key(KeyCode.from_vk(23))  # Flask 5
Esempio n. 28
0
def keyboard_routine():
    keyboard = Keyboard(sleep=1)
    keyboard.space()
    keyboard.key("1")
    keyboard.key("1")
    keyboard.key("1")
    keyboard.enter()
    keyboard.write("Hello World")
    keyboard.enter()
Esempio n. 29
0
def run():
    for event in longpoll.listen():
        if event.type == VkEventType.MESSAGE_NEW:
            print('\n' + get_name(event.user_id) + ' (id: ' +
                  str(event.user_id) + ')')
            print('Сообщение пришло в: ' +
                  str(datetime.strftime(datetime.now(), "%H:%M:%S")))
            print('Текст сообщения: ' + str(event.text))
            print("---------------------------------\n")
            response = event.text.lower()
            keyboard = Keyboard()
            if event.from_user and event.to_me:
                if found_user(event.user_id) == False:
                    print(event.user_id)
                    print(type(event.user_id))
                    send = {
                        'lang': '',
                        'level': '',
                        'format': '',
                        'discus': ''
                    }
                    steps = {
                        '1': False,
                        '2': False,
                        '3': False,
                        '4': False,
                        '5': False
                    }
                    bot = VkBot(event.user_id, send, steps)
                    add_into_user_bot(event.user_id, send, steps, bot)
                else:
                    if 'vkbot' not in users_bot[event.user_id].keys():
                        user = users_bot[event.user_id]
                        bot = VkBot(event.user_id, user['send'], user['steps'])
                        add_into_user_bot(event.user_id, user['send'],
                                          user['steps'], bot)
                bot_Object = users_bot[event.user_id]['vkbot']
                keyboard = keyboard.create_keyboard(response,
                                                    bot_Object.get_step())
                bb = bot_Object.message(response, keyboard)
                add_into_user_bot(event.user_id, bot_Object.send,
                                  bot_Object.STEPS, bot_Object)
                print(bb)
                print(users_bot)
                print(bot_Object.send)
                print(bot_Object.STEPS)
                add_data_in_json(event.user_id)
                if bb == None:
                    continue
                elif len(bb) == 4:
                    send_message(vk,
                                 bb[0],
                                 bb[1],
                                 message=bb[2],
                                 keyboard=bb[3])
                elif len(bb) == 3:
                    send_message(vk, bb[0], bb[1], message=bb[2])
Esempio n. 30
0
 def test_other_key_presses_to_word(self, inp, res):
     key = {'c': CAPS_KEY, 's': SHIFT_KEY}
     KB = Keyboard('US')
     kw = KB.key_presses_to_word('{c}asdf{s}1{c}sdf'.format(**key))
     assert 'ASDFasdf' == KB.key_presses_to_word(
         '{c}asdf{s}a{c}sdf'.format(**key))
     assert 'ASDF!sdf' == KB.key_presses_to_word(
         '{c}asdf{s}1{c}sdf'.format(**key))
     assert KB.key_presses_to_word('{s}apa'.format(**key)) == 'Apa'