Web Analytics Made Easy - Statcounter
Skip to content

popup - Input Popups (Popup Windows 2 of 4)

import PySimpleGUI as sg

text = sg.popup_get_text('What is your name?')

image

The "Input popups" give you the ability to get information from your user using a single function call. Input popups functions begin with popup_get_.

As can be seen from this screenshot of using the code completion feature of PyCharm, there are 4 varieties of this category of popups, each getting a unique type of data:

  1. popup_get_text - Get a string
  2. popup_get_file - Get one of more filenames as a string
  3. popup_get_folder - Get a folder as a string
  4. popup_get_date - Get a date as a tuple

image

Return Values

For the text, file, and folder input popups, the return value is a string. For popup_get_date, the return value is a tuple of 3 ints representing the month, day and year chosen.

If the operation is canceled or the window is closed with the "X", then like the output popups, the return value is WIN_CLOSED (None). In the example at the top, if the cancel button was clicked, the value returned from popup_get_text would be None.

Try It For Yourself

Experiment with the values returned.