Python 3 WxPython Combobox or Choice Box Dialog or Modal Get Selected Value Example GUI Desktop App Full Project For Beginners

Python 3 WxPython Combobox or Choice Box Dialog or Modal Get Selected Value Example GUI Desktop App Full Project For Beginners

 

Welcome folks today in this blog post we will be displaying a combobox or choice box dialog and then we will be getting the selected value in python using wxpython. All the full source code of the application is shown below.

 

 

Get Started

 

 

In order to get started you need to install the below library using the pip command as shown below

 

pip install wxpython

 

After installing this library you need to make an app.py file and copy paste the following code

See also  Python PyAutoGUI TypeWriter Omegle API Message Bot to Send out Unlimited Messages to People in Regular Intervals of Time Full Project For Beginners

 

app.py

 

import wx

if __name__ == "__main__":
    app = wx.PySimpleApp()
    choices = ["Alpha", "Baker", "Charlie", "Delta"]
    dialog = wx.SingleChoiceDialog(None, "Pick A Word", "Choices",
            choices)
    if dialog.ShowModal() == wx.ID_OK:
        print("You selected: %s\n" % dialog.GetStringSelection())

    dialog.Destroy()

 

 

If you execute the above python script by typing the below command

 

python app.py

 

 

 

 

Leave a Reply