wxPython input dialog

Input dialogs let your user give you feedback or input. They appear in desktop applications once in a while.

wxPython supports input dialogs, they are included with the framework.
A typical wxPython dialog may look like:

wx input
input dialog made with wxPython

wxPython input dialog

The example code below creates an input dialog with wxPython:

import wx
def onButton(event):
    print "Button pressed."
app = wx.App()
frame = wx.Frame(None, -1, 'win.py')
# Create text input
dlg = wx.TextEntryDialog(frame, 'Enter some text','Text Entry')
if dlg.ShowModal() == wx.ID_OK:
    print('You entered: %s\n' % dlg.GetValue())

A wxPython textbox can be added to a window using the function:

wx.TextEntryDialog(frame, 'Enter some text','Text Entry')

Where the first argument is the frame, the second argument is the label and the last argument is the window title.

The function below displays the dialog and waits for a user to press one of the buttons:


You can get the button pressed by picking one of these:


(the result is either one of these)

After input is been given, you can get the input text using dlg.GetValue() function.

wxPython file dialog
wxPython menu