()
| 18 | """ |
| 19 | |
| 20 | def main(): |
| 21 | sg.theme('dark green 7') |
| 22 | |
| 23 | PIN = '📌' |
| 24 | |
| 25 | # This custom titlebar inveses the normal text/background colors. Uses a little bigger font |
| 26 | my_titlebar = [[sg.Text('Window title', expand_x=True, grab=True, |
| 27 | text_color=sg.theme_background_color(), background_color=sg.theme_text_color(), font='_ 12', pad=(0,0)), |
| 28 | sg.Text(PIN, enable_events=True, k='-PIN-', font='_ 12', pad=(0,0), metadata=False, |
| 29 | text_color=sg.theme_background_color(), background_color=sg.theme_text_color())]] |
| 30 | |
| 31 | layout = my_titlebar + \ |
| 32 | [ [sg.Text('This is my window layout')], |
| 33 | [sg.Input(key='-IN-')], |
| 34 | [sg.Button('Go'), sg.Button('Exit')] ] |
| 35 | |
| 36 | window = sg.Window('Window Title', layout, no_titlebar=True, resizable=True, margins=(0,0)) |
| 37 | |
| 38 | while True: |
| 39 | event, values = window.read() |
| 40 | print(event, values) |
| 41 | if event == sg.WIN_CLOSED or event == 'Exit': |
| 42 | break |
| 43 | if event == '-PIN-': |
| 44 | window['-PIN-'].metadata = not window['-PIN-'].metadata # use metadata to store current state of pin |
| 45 | if window['-PIN-'].metadata: |
| 46 | window['-PIN-'].update(text_color='red') |
| 47 | window.keep_on_top_set() |
| 48 | else: |
| 49 | window['-PIN-'].update(text_color=sg.theme_background_color()) |
| 50 | window.keep_on_top_clear() |
| 51 | |
| 52 | window.close() |
| 53 | |
| 54 | # Temp definitions of the Window methods added to 4.46.0.7 of PySimpleGUI |
| 55 | def keep_on_top_set(window): |
no test coverage detected