Single Choice Dialog

Single Choice Dialog Sample

Creating the Dialog

Create a Multiple Choice Dialog by calling dialog.multipleChoiceDialog with the arguments shown in the following table.

Argument
Data type/notes
self
the window (background) that is the parent for the dialog
message
quoted string displayed inside dialog box as prompt for user input
title
quoted string displayed in title bar of dialog
lst
list of values representing contents of dialog choice list

Example:

Above dialog was created with this line of code:

result = dialog.singleChoiceDialog(self, "message", "title", ['one', 'two', 'three'])

Interacting With the Dialog

The singleChoiceDialog component returns a wxPython DialogResults object which contains 2 attributes, as shown in the following table

Name of value
Description
accepted
True = user clicked OK
False = user clicked Cancel
selection
string containing the list element selected by the user

Example:

The sample dialog shown at the top of this page returns the following results:

accepted: True
selection: three