Примерно так:
import wx
class MyWin(wx.Frame):
"""
Creates the GUI
"""
def __init__(self):
super().__init__(None, title="My Enigma Machine", style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX))
#### Widgets
## Panel
self.panel = wx.Panel(self)
## Buttons
self.buttonEncript = wx.Button(self.panel, label='Encript')
self.buttonDecript = wx.Button(self.panel, label='Decript')
## TextCtrl
self.tcToEncript = wx.TextCtrl(self.panel, value="", size=(515, 22))
self.tcToDecript = wx.TextCtrl(self.panel, value="", size=(515, 22))
#### Sizers
self.sizer = wx.GridBagSizer(1, 1)
self.sizer.Add(self.tcToEncript, pos=(0, 0), border=2, flag=wx.EXPAND|wx.ALL)
self.sizer.Add(self.buttonEncript, pos=(0, 1), border=2, flag=wx.ALIGN_CENTER|wx.ALL)
self.sizer.Add(self.tcToDecript, pos=(1, 0), border=2, flag=wx.EXPAND|wx.ALL)
self.sizer.Add(self.buttonDecript, pos=(1, 1), border=2, flag=wx.ALIGN_CENTER|wx.ALL)
self.panel.SetSizer(self.sizer)
self.sizer.Fit(self)
#### Bind
self.buttonEncript.Bind(wx.EVT_BUTTON, self.OnEncript)
self.buttonDecript.Bind(wx.EVT_BUTTON, self.OnDecript)
#### Methods of the class
def OnEncript(self, event):
"""
Encript the text. It will just change the case of each letter
"""
string = self.tcToEncript.GetValue()
stringEncripted = string.swapcase()
self.tcToDecript.SetValue(stringEncripted)
def OnDecript(self, event):
"""
Same as OnEncript
"""
string = self.tcToDecript.GetValue()
stringDecripted = string.swapcase()
self.tcToEncript.SetValue(stringDecripted)
if __name__ == '__main__':
app = wx.App()
frame = MyWin()
frame.Show()
app.MainLoop()