IT-Academy

Combobox wx Python

Feb 2nd, 2017
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. import wx
  2.  
  3. class Example(wx.Frame):
  4.            
  5.     def __init__(self, *args, **kw):
  6.         super(Example, self).__init__(*args, **kw)
  7.        
  8.         self.InitUI()
  9.        
  10.     def InitUI(self):  
  11.  
  12.         pnl = wx.Panel(self)
  13.        
  14.         distros = ['Ubuntu', 'Arch', 'Fedora', 'Debian', 'Mint']
  15.         cb = wx.ComboBox(pnl, pos=(50, 30), choices=distros,
  16.             style=wx.CB_READONLY)
  17.  
  18.         self.st = wx.StaticText(pnl, label='', pos=(50, 140))
  19.         cb.Bind(wx.EVT_COMBOBOX, self.OnSelect)
  20.        
  21.         self.SetSize((250, 230))
  22.         self.SetTitle('wx.ComboBox')
  23.         self.Centre()
  24.         self.Show(True)          
  25.        
  26.     def OnSelect(self, e):
  27.        
  28.         i = e.GetString()
  29.         self.st.SetLabel(i)
  30.        
  31. def main():
  32.    
  33.     ex = wx.App()
  34.     Example(None)
  35.     ex.MainLoop()    
  36.  
  37. if __name__ == '__main__':
  38.     main()
Advertisement
Add Comment
Please, Sign In to add comment