Tag: dialog
wxpython dialog
To display a dialog with wxPython requires only a few lines of code. We will demonstrate that below. We’ll discuss information dialog, simple dialog, error dialog, warning dialog and others.
Related course: Creating GUI Applications with wxPython
Information dialog
An information dialog can be shown with one line of code:
import wx |
The first parameter is the actual text to display. The second is the title and final parameter tells wx to show the information icon and button.
Output:

More dialogs: Warning dialog, Error dialog and default dialog
By modifying the parameters you can easily create other types of dailogs. An example below:
import wx |
Output (only one of the dialogs):

Question dialog
Wx can be used to create a question dialog (yes/no). Example code:
import wx |
Output:

Related course: Creating GUI Applications with wxPython
tkinter filedialog
tkFileDialog is a module with open and save dialog functions. Instead of implementing those in Tkinter GUI on your own.
This page is a collection of python tkinter file dialogs. The code is displayed here along with screenshots. Dialogs included in tkinter let you ask for a filename or directory.
tkinter file dialogs are easy to use, but not that easy to find out how to use. The main problem is that there is no simple example of how to do it. This article tries to fill the gap.
Related course:
Tkinter Open File
The askopenfilename function to creates an file dialog object. The extensions are shown in the bottom of the form (Files of type).
tkinter.tk.askopenfilename is an extension of the askopenfilename function provided in Tcl/Tk.
The code below will simply show the dialog and return the filename. If a user presses cancel the filename is empty. On a Windows machine change the initialdir to “C:\”.
Python 2.7 version:
from Tkinter import *from Tkinter import * |
Python 3 version:
|
Here is an example (on Linux):

Tkinter Save File
The asksaveasfilename function prompts the user with a save file dialog.
Python 2.7 version
|
Python 3 version
|
Tkinter Open Directory
Consider a scenario where your program needs to get a directory, the user clicked on the ok button and now you want to determine the path.
The askdirectory presents the user with a popup for directory selection.
Python 2.7 version
|

If you are new to programming Tkinter, I highly recommend this course.