Is it possible write a single def for both ComboBox and RadioBox events?
<p>Here the code writes parts of a string selected by the user. After each event, the TextCtrl gains one more piece of the string until it's time to the user to copy the text to the clipboard. It works fine, but it's not elegant since there is too much repetition in the code.</p>

<pre><code>import wx   
import pyperclip

class Ementor(wx.Frame): 

def __init__(self, parent, title): 
  super(Ementor, self).__init__(parent, title = title,size = (500,300)) 

  self.InitUI() 

def InitUI(self):    
  pnl = wx.Panel(self)
  menubar=wx.MenuBar()
  filem=wx.Menu()
  clearmenuitem = filem.Append(wx.NewId(), "Clea&amp;r","Clear TextBox")
  self.Bind(wx.EVT_MENU, self.onClear, clearmenuitem)
  exitmenuitem = filem.Append(wx.NewId(), "Exi&amp;t", "Bye bye")
  self.Bind(wx.EVT_MENU, self.onExit, exitmenuitem)
  editm=wx.Menu()
  copymenuitem = editm.Append(wx.NewId(), "&amp;Copy", "Copy String")
  self.Bind(wx.EVT_MENU, self.onCopy, copymenuitem)
  helpm=wx.Menu()
  helpmenuitem = helpm.Append(wx.NewId(), "&amp;About","Details")
  self.Bind(wx.EVT_MENU, self.onHelp, helpmenuitem)

  menubar.Append(filem, '&amp;File')
  menubar.Append(editm, '&amp;Edit')
  menubar.Append(helpm, '&amp;Help')

  self.SetMenuBar(menubar)

  # Campos de preenchimento da ementa
  lblList = ['Processo Administrativo Sancionador. ','Processo Administrativo Contencioso. ','Processo Administrativo Simplificado. ']
  self.rbox = wx.RadioBox(pnl, label = 'Tipo', pos = (10,10), choices = lblList, majorDimension = 3, style = wx.RA_SPECIFY_ROWS) 
  self.rbox.Bind(wx.EVT_RADIOBOX,self.onRadioBox) 

  statusAnalise = ['Julgamento Originario. ','Julgamento Recursal. ']
  self.rbox1 = wx.RadioBox(pnl, label = 'EstÃ¡gio da AnÃ¡lise', pos = (10,120), choices=statusAnalise,  majorDimension = 2, style = wx.RA_SPECIFY_ROWS)
  self.rbox1.Bind(wx.EVT_RADIOBOX,self.onRadioBox1)

  tipoJulgamento = ['Recurso conhecido e provido. ','Recurso conhecido e nao provido. ','Recurso nao conhecido']
  self.combo = wx.ComboBox(pnl, choices=tipoJulgamento, pos=(10,200))
  self.combo.Bind(wx.EVT_COMBOBOX, self.onCombo)

  tipoProcedimento = ['Fiscalizacao ordinaria - PAF. ','Fiscalizacao Extraordinaria. ']
  self.combo1 = wx.ComboBox(pnl, choices=tipoProcedimento, pos=(10,230))
  self.combo1.Bind(wx.EVT_COMBOBOX, self.onCombo1)

  #Ãrea de concatenaÃ§Ã£o
  self.t3 = wx.TextCtrl(pnl,pos=(310,10),size = (180,170),style = wx.TE_MULTILINE)

  self.Centre() 
  self.Show(True)    

# Funcoes para eventos

def onRadioBox(self, e): 
  rb = self.rbox.GetStringSelection() 
  **self.t3.AppendText(str(rb).upper())** #here set text to 

def onRadioBox1(self, e):
  rb1 = self.rbox1.GetStringSelection()
  **self.t3.AppendText(str(rb1).upper())** #here

def onClear(self, e):
  self.t3.SetValue('')

def onExit(self, e):
  self.Destroy()

def onCopy(self, e):
  pyperclip.copy(self.t3.GetValue())

def onCombo(self, e):
  cbx = self.combo.GetValue()
  **self.t3.AppendText(str(cbx).upper())**  #here

def onCombo1(self, e):
  cbx1 = self.combo1.GetValue()
  **self.t3.AppendText(str(cbx1).upper())** #here

def onHelp(self, e):
  msgbox = wx.MessageBox('Feito por Â²David Gesrob Â® 2016-09-04', 'About...', wx.ICON_INFORMATION | wx.STAY_ON_TOP)


ex = wx.App() 
Ementor(None,'Ementor') 
ex.MainLoop()
</code></pre>

<p>You can use <code>e.GetEventObject()</code> to get access to widget which send event.</p>

<p>And then you can use <code>isinstance</code> to recognize widget type.</p>

<pre><code>def onSelect(self, e):

  widget = e.GetEventObject()

  if isinstance(widget, wx.RadioBox):
      self.t3.AppendText(str(widget.GetStringSelection()).upper())
  elif isinstance(widget, wx.ComboBox):
      self.t3.AppendText(str(widget.GetValue()).upper())
</code></pre>

<p>Now you can use it with any RadioBox and ComboBox</p>

python wxpython