hola a todos, primero que todo soy un poco nuevo en python asi que no se a que nivel me estoy equivocando, bueno lo que pasa es que estoy escribiendo un script que me muestre un set de imagenes por cada valor del combobox, ponerlos en una grilla
el problema pasa despues de llegar a la funcion del combobox no logro hacer que las imagenes cambien
aqui el codigo
en este ejemplo trato de modificar de a 1 sola imagen pero logrando eso, la logica tendria que ser la misma para cambiar el set completo de imagenes
alguna idea???
Código Python:
Ver originalimport 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.CreateStatusBar()
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;
print self.cmbox
if evt.GetString() == 'dos':
self.cmbox = 2;
print self.cmbox
if evt.GetString() == 'tres':
self.cmbox = 3;
print self.cmbox
if evt.GetString() == 'cuatro':
self.cmbox = 4;
print self.cmbox
app = wx.App()
frame = MyFrame(None, title="asdf")
frame.Show(True)
app.MainLoop()