Created
January 18, 2019 04:07
-
-
Save MikeTheWatchGuy/2f12caeadff9d57bddf98318921e9fd9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PySimpleGUI as sg | |
NUM_ROWS = 20 | |
NUM_COLS = 80 | |
layout = [ | |
*[[sg.T(f'{i:02} ',background_color='white', text_color = 'gray60'), sg.In(size=(NUM_COLS,1), do_not_clear=True, key=i)] for i in range(NUM_ROWS)], | |
[sg.Button('Exit')] | |
] | |
window = sg.Window('Window Title', element_padding=(0,0), border_depth=0, return_keyboard_events=True).Layout(layout) | |
focus = 0 | |
while True: # Event Loop | |
event, values = window.Read() | |
if event.startswith('Down') or event == '\r': | |
focus += (focus < NUM_ROWS-1) | |
window.Element(focus).SetFocus() | |
elif event.startswith('Up'): | |
focus -= (focus > 0) | |
window.Element(focus).SetFocus() | |
if event is None or event == 'Exit': | |
break | |
window.Close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment