Skip to content

Instantly share code, notes, and snippets.

@MikeTheWatchGuy
Created January 18, 2019 04:07
Show Gist options
  • Save MikeTheWatchGuy/2f12caeadff9d57bddf98318921e9fd9 to your computer and use it in GitHub Desktop.
Save MikeTheWatchGuy/2f12caeadff9d57bddf98318921e9fd9 to your computer and use it in GitHub Desktop.
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