コード例 #1
0
def main(test=False):
    """ Main program.

    :param test: Indicate function is being tested
    :type test: bool
    :return: None
    """

    # Init pygame
    pygame.init()
    screen = pygame.display.set_mode((500, 400))

    # Create keyboard
    layout = vkboard.VKeyboardLayout(vkboard.VKeyboardLayout.AZERTY)
    keyboard = vkboard.VKeyboard(screen, on_key_event, layout)

    clock = pygame.time.Clock()

    # Main loop
    while True:
        clock.tick(100)  # Ensure not exceed 100 FPS

        for event in pygame.event.get():
            keyboard.on_event(event)
            if event.type == pygame.QUIT:
                print("Average FPS: ", clock.get_fps())
                exit()

        # Flip the entire surface
        pygame.display.flip()

        # At first loop returns
        if test:
            break
コード例 #2
0
ファイル: menu.py プロジェクト: rmrfcool/pibooth
    def __init__(self, window, config, counters, onclose=None):
        self.win = window
        self.cfg = config
        self.count = counters
        self._changed = False
        self._close_callback = onclose

        size = self.win.get_rect().size
        self.size = (min(600, size[0]), min(400, size[1]))
        self._main_menu = pgm.Menu(title="Settings v{}".format(pibooth.__version__),
                                   width=self.size[0],
                                   height=self.size[1],
                                   theme=THEME_DARK,
                                   onclose=self._on_close)
        self._main_menu.disable()

        self._keyboard = vkb.VKeyboard(self.win.surface,
                                       self._on_keyboard_event,
                                       vkb.VKeyboardLayout(vkb.VKeyboardLayout.QWERTY),
                                       renderer=vkb.VKeyboardRenderer.DARK,
                                       show_text=True,
                                       joystick_navigation=True)
        self._keyboard.disable()

        for name in DEFAULT:
            submenu = self._build_submenu(name)
            if submenu._widgets:
                self._main_menu.add_button(submenu.get_title(), submenu)
        self._main_menu.add_button('Exit', self._on_exit)
コード例 #3
0
ファイル: menu.py プロジェクト: jo-ei/pibooth
    def __init__(self, plugins_manager, configuration, application, window, onclose=None):
        self.app = application
        self.win = window
        self.cfg = configuration
        self.pm = plugins_manager
        self._changed = False
        self._close_callback = onclose

        size = self.win.get_rect().size
        self.size = (min(600, size[0]), min(400, size[1]))
        self._main_menu = pgm.Menu(title="Settings v{}".format(pibooth.__version__),
                                   width=self.size[0],
                                   height=self.size[1],
                                   theme=THEME_DARK,
                                   touchscreen=True,
                                   onclose=self._on_close)
        self._main_menu.disable()
        self._main_menu.add.vertical_margin(20)

        self._keyboard = vkb.VKeyboard(self.win.surface,
                                       self._on_keyboard_event,
                                       vkb.VKeyboardLayout(vkb.VKeyboardLayout.QWERTY),
                                       renderer=vkb.VKeyboardRenderer.DARK,
                                       show_text=True,
                                       joystick_navigation=True)
        self._keyboard.disable()

        for name in DEFAULT:
            submenu = self._build_submenu(name)
            if len(submenu._widgets) > 2:
                self._main_menu.add.button(submenu.get_title(), submenu)
        self._main_menu.add.button('Exit', self._on_exit)
        self._main_menu.add.vertical_margin(20)
コード例 #4
0
ファイル: resize.py プロジェクト: Faylixe/pygame-vkeyboard
def main(test=False):
    """ Main program.

    :param test: Indicate function is being tested
    :type test: bool
    :return: None
    """

    # Init pygame
    pygame.init()
    screen = pygame.display.set_mode((500, 300), pygame.RESIZABLE)
    screen.fill((100, 100, 100))

    # Create keyboard
    layout = vkboard.VKeyboardLayout(vkboard.VKeyboardLayout.QWERTY,
                                     allow_special_chars=False,
                                     allow_space=False)
    keyboard = vkboard.VKeyboard(screen,
                                 on_key_event,
                                 layout,
                                 renderer=vkboard.VKeyboardRenderer.DARK,
                                 show_text=True,
                                 joystick_navigation=True)

    clock = pygame.time.Clock()

    # Main loop
    while True:
        clock.tick(100)  # Ensure not exceed 100 FPS

        events = pygame.event.get()

        for event in events:
            if event.type == pygame.QUIT:
                print("Average FPS: ", clock.get_fps())
                exit()
            if event.type == pygame.VIDEORESIZE:
                screen.fill((100, 100, 100))

        keyboard.update(events)
        rects = keyboard.draw(screen)

        # Flip only the updated area
        pygame.display.update(rects)

        # At first loop returns
        if test:
            break
コード例 #5
0
ファイル: numeric.py プロジェクト: yagui/pygame-vkeyboard
def main(test=False):
    """ Main program.

    :param test: Indicate function is being tested
    :type test: bool
    :return: None
    """

    # Init pygame
    pygame.init()
    screen = pygame.display.set_mode((400, 400))

    # Create keyboard
    model = ['123', '456', '789', '*0#']
    layout = vkboard.VKeyboardLayout(model,
                                     key_size=30,
                                     padding = 15,
                                     height_ratio=0.8,
                                     allow_uppercase=False,
                                     allow_special_chars=False,
                                     allow_space=False)
    keyboard = vkboard.VKeyboard(screen, on_key_event, layout,
                                 joystick_navigation=True)

    # Main loop
    while True:

        events = pygame.event.get()

        for event in events:
            if event.type == pygame.QUIT:
                exit()

        keyboard.update(events)
        rects = keyboard.draw(screen)

        # Flip only the updated area
        pygame.display.update(rects)

        # At first loop returns
        if test:
            break