Python 3 WxPython Submit Form Data and Display it in Popup or Modal Window GUI Desktop App Full Project For Beginners

Python 3 WxPython Submit Form Data and Display it in Popup or Modal Window GUI Desktop App Full Project For Beginners


Welcome folks today in this blog post we will be looking at wxpython submit form data and display it in popup or modal window. All the full source code of the application is given 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 file and copy paste the following code


import wx
import pprint

about_txt = """\
The validator used in this example shows how the validator
can be used to transfer data to and from each text control
automatically when the dialog is shown and dismissed."""

class DataXferValidator(wx.PyValidator):
     def __init__(self, data, key):
         wx.PyValidator.__init__(self) = data
         self.key = key

     def Clone(self):
         Note that every validator must implement the Clone() method.
         return DataXferValidator(, self.key)

     def Validate(self, win):
         return True

     def TransferToWindow(self):
         textCtrl = self.GetWindow()
         textCtrl.SetValue(, ""))
         return True 

     def TransferFromWindow(self):
         textCtrl = self.GetWindow()[self.key] = textCtrl.GetValue()
         return True

class MyDialog(wx.Dialog):
    def __init__(self, data):
        wx.Dialog.__init__(self, None, -1, "Validators: data transfer")

        # Create the text controls
        about   = wx.StaticText(self, -1, about_txt)
        name_l  = wx.StaticText(self, -1, "Name:")
        email_l = wx.StaticText(self, -1, "Email:")
        phone_l = wx.StaticText(self, -1, "Phone:")
        name_t  = wx.TextCtrl(self, validator=DataXferValidator(data, "name"))
        email_t = wx.TextCtrl(self, validator=DataXferValidator(data, "email"))
        phone_t = wx.TextCtrl(self, validator=DataXferValidator(data, "phone"))

        # Use standard button IDs
        okay   = wx.Button(self, wx.ID_OK)
        cancel = wx.Button(self, wx.ID_CANCEL)

        # Layout with sizers
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(about, 0, wx.ALL, 5)
        sizer.Add(wx.StaticLine(self), 0, wx.EXPAND|wx.ALL, 5)
        fgs = wx.FlexGridSizer(3, 2, 5, 5)
        fgs.Add(name_l, 0, wx.ALIGN_RIGHT)
        fgs.Add(name_t, 0, wx.EXPAND)
        fgs.Add(email_l, 0, wx.ALIGN_RIGHT)
        fgs.Add(email_t, 0, wx.EXPAND)
        fgs.Add(phone_l, 0, wx.ALIGN_RIGHT)
        fgs.Add(phone_t, 0, wx.EXPAND)
        sizer.Add(fgs, 0, wx.EXPAND|wx.ALL, 5)

        btns = wx.StdDialogButtonSizer()
        sizer.Add(btns, 0, wx.EXPAND|wx.ALL, 5)


app = wx.PySimpleApp()

data = { "name" : "Jordyn Dunn" }
dlg = MyDialog(data)

wx.MessageBox("You entered these values:\n\n" +



See also  Python 3 Tkinter Multiplayer Tic Tac Toe Game GUI Desktop App Using Random Library Full Project For Beginners


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





Leave a Reply