|
| 1 | +#!/usr/bin/env python |
| 2 | +""" |
| 3 | + Example tooltip operations. |
| 4 | + Removal of tooltips feature added in version 5.0.2.11 |
| 5 | + You disable a tooltip by using the remove_tooltip method or set the tooltip to the value None |
| 6 | +
|
| 7 | +
|
| 8 | + Copyright 2024 PySimpleSoft, Inc. and/or its licensors. All rights reserved. |
| 9 | +
|
| 10 | + Redistribution, modification, or any other use of PySimpleGUI or any portion thereof is subject to the terms of the PySimpleGUI License Agreement available at https://eula.pysimplegui.com. |
| 11 | +
|
| 12 | + You may not redistribute, modify or otherwise use PySimpleGUI or its contents except pursuant to the PySimpleGUI License Agreement. |
| 13 | +""" |
| 14 | + |
| 15 | +import PySimpleGUI as sg |
| 16 | + |
| 17 | +layout = [ [sg.Text('Tooltip Operations')], |
| 18 | + [sg.Input(key='-IN-', tooltip='My default tooltip')], |
| 19 | + [sg.Text(key='-OUT-')], |
| 20 | + [sg.Button('Remove'), sg.B('Add'), sg.B('Set None'), sg.Button('Exit')] ] |
| 21 | + |
| 22 | +window = sg.Window('Tooltip Test', layout, print_event_values=True) |
| 23 | + |
| 24 | +while True: |
| 25 | + event, values = window.read() |
| 26 | + if event == sg.WIN_CLOSED or event == 'Exit': |
| 27 | + break |
| 28 | + if event == 'Remove': |
| 29 | + window['-IN-'].remove_tooltip() |
| 30 | + window['-OUT-'].update('Tooltip removed') |
| 31 | + elif event == 'Add': |
| 32 | + window['-IN-'].set_tooltip(values['-IN-']) |
| 33 | + window['-OUT-'].update(f"Added tooltip {values['-IN-']}") |
| 34 | + elif event == 'Set None': |
| 35 | + window['-IN-'].set_tooltip(None) |
| 36 | + window['-OUT-'].update('Tooltip set to None') |
| 37 | + |
| 38 | +window.close() |
0 commit comments