import wx
class MyFrame(wx.Frame):
cmbox=1
def __init__(self, *args, **kargs):
wx.Frame.__init__(self, *args, **kargs)
topsizer = wx.BoxSizer( wx.HORIZONTAL )
menusizer = wx.BoxSizer( wx.VERTICAL )
contentsizer = wx.BoxSizer( wx.VERTICAL )
self.asdf = wx.GridBagSizer()
self.picture = wx.StaticBitmap(self)
imageFile = "images/%d.jpeg"%(self.cmbox)
image1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
n1 = wx.BitmapButton(self, -1, bitmap=image1,size = (image1.GetWidth()-30, image1.GetHeight()-30))
imageFile = "images/2.jpeg"
image1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
n2 = wx.BitmapButton(self, -1, bitmap=image1,size = (image1.GetWidth()-30, image1.GetHeight()-30))
imageFile = "images/3.jpeg"
image1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
n3 = wx.BitmapButton(self, -1, bitmap=image1,size = (image1.GetWidth()-30, image1.GetHeight()-30))
imageFile = "images/4.jpeg"
image1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
n4 = wx.BitmapButton(self, -1, bitmap=image1,size = (image1.GetWidth()-30, image1.GetHeight()-30))
imageFile = "images/5.jpeg"
image1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
n5 = wx.BitmapButton(self, -1, bitmap=image1,size = (image1.GetWidth()-30, image1.GetHeight()-30))
imageFile = "images/6.jpeg"
image1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
n6 = wx.BitmapButton(self, -1, bitmap=image1,size = (image1.GetWidth()-30, image1.GetHeight()-30))
imageFile = "images/7.jpeg"
image1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
n7 = wx.BitmapButton(self, -1, bitmap=image1,size = (image1.GetWidth()-30, image1.GetHeight()-30))
imageFile = "images/8.jpeg"
image1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
n8 = wx.BitmapButton(self, -1, bitmap=image1,size = (image1.GetWidth()-30, image1.GetHeight()-30))
imageFile = "images/9.jpeg"
image1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
n9 = wx.BitmapButton(self, -1, bitmap=image1,size = (image1.GetWidth()-30, image1.GetHeight()-30))
sampleList = ['uno', 'dos', 'tres', 'cuatro']
combo1 = wx.ComboBox(self, 500, "elementos", (90, 80),
(350, -1), sampleList,
wx.CB_DROPDOWN
)
self.Bind(wx.EVT_COMBOBOX, self.EvtComboBox, combo1)
self.asdf.Add(n1, (13, 1))
self.asdf.Add(n2, (13, 2))
self.asdf.Add(n3, (13, 3))
self.asdf.Add(n4, (14, 1))
self.asdf.Add(n5, (14, 2))
self.asdf.Add(n6, (14, 3))
self.asdf.Add(n7, (15, 1))
self.asdf.Add(n8, (15, 2))
self.asdf.Add(n9, (15, 3))
menusizer.Add(self.asdf, 0)
topsizer.Add(menusizer, 0)
self.SetSizer(topsizer)
def EvtComboBox(self, evt):
print "estoy en el evento"
if evt.GetString() == 'uno':
self.cmbox = 1;
if evt.GetString() == 'dos':
self.cmbox = 2;
if evt.GetString() == 'tres':
self.cmbox = 3;
if evt.GetString() == 'cuatro':
self.cmbox = 4;
self.picture.SetBitmap(wx.Bitmap('images/%d.jpeg'%self.cmbox))
print self.cmbox
app = wx.App()
frame = MyFrame(None, title="asdf")
frame.Show(True)
app.MainLoop()