Ver Mensaje Individual
  #4 (permalink)  
Antiguo 26/07/2010, 14:42
IamEdo
 
Fecha de Ingreso: enero-2010
Mensajes: 21
Antigüedad: 14 años, 10 meses
Puntos: 0
Respuesta: Problema con combobox

talvez asi se entienda mejor
la idea es poder cambiar las imagenes de los botones, pero solo logro mostrar las imagenes sueltas y no acomodadas en la grilla

Código Python:
Ver original
  1. import wx
  2. class MyFrame(wx.Frame):
  3.    
  4.     cmbox=1
  5.     def __init__(self, *args, **kargs):
  6.         wx.Frame.__init__(self, *args, **kargs)
  7.        
  8.         topsizer = wx.BoxSizer( wx.HORIZONTAL )
  9.         menusizer = wx.BoxSizer( wx.VERTICAL )
  10.         contentsizer = wx.BoxSizer( wx.VERTICAL )
  11.        
  12.         self.asdf = wx.GridBagSizer()
  13.  
  14.        
  15.         self.picture = wx.StaticBitmap(self)
  16.        
  17.         imageFile = "images/%d.jpeg"%(self.cmbox)
  18.         image1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
  19.         n1 = wx.BitmapButton(self, -1, bitmap=image1,size = (image1.GetWidth()-30, image1.GetHeight()-30))
  20.         imageFile = "images/2.jpeg"
  21.         image1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
  22.         n2 = wx.BitmapButton(self, -1, bitmap=image1,size = (image1.GetWidth()-30, image1.GetHeight()-30))
  23.         imageFile = "images/3.jpeg"
  24.         image1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
  25.         n3 = wx.BitmapButton(self, -1, bitmap=image1,size = (image1.GetWidth()-30, image1.GetHeight()-30))
  26.         imageFile = "images/4.jpeg"
  27.         image1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
  28.         n4 = wx.BitmapButton(self, -1, bitmap=image1,size = (image1.GetWidth()-30, image1.GetHeight()-30))
  29.         imageFile = "images/5.jpeg"
  30.         image1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
  31.         n5 = wx.BitmapButton(self, -1, bitmap=image1,size = (image1.GetWidth()-30, image1.GetHeight()-30))
  32.         imageFile = "images/6.jpeg"
  33.         image1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
  34.         n6 = wx.BitmapButton(self, -1, bitmap=image1,size = (image1.GetWidth()-30, image1.GetHeight()-30))
  35.         imageFile = "images/7.jpeg"
  36.         image1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
  37.         n7 = wx.BitmapButton(self, -1, bitmap=image1,size = (image1.GetWidth()-30, image1.GetHeight()-30))
  38.         imageFile = "images/8.jpeg"
  39.         image1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
  40.         n8 = wx.BitmapButton(self, -1, bitmap=image1,size = (image1.GetWidth()-30, image1.GetHeight()-30))
  41.         imageFile = "images/9.jpeg"
  42.         image1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
  43.         n9 = wx.BitmapButton(self, -1, bitmap=image1,size = (image1.GetWidth()-30, image1.GetHeight()-30))
  44.        
  45.         sampleList = ['uno', 'dos', 'tres', 'cuatro']
  46.  
  47.         combo1 = wx.ComboBox(self, 500, "elementos", (90, 80),
  48.                          (350, -1), sampleList,
  49.                          wx.CB_DROPDOWN
  50.                          )
  51.  
  52.         self.Bind(wx.EVT_COMBOBOX, self.EvtComboBox, combo1)
  53.        
  54.         self.asdf.Add(n1, (13, 1))
  55.         self.asdf.Add(n2, (13, 2))
  56.         self.asdf.Add(n3, (13, 3))
  57.         self.asdf.Add(n4, (14, 1))
  58.         self.asdf.Add(n5, (14, 2))
  59.         self.asdf.Add(n6, (14, 3))
  60.         self.asdf.Add(n7, (15, 1))
  61.         self.asdf.Add(n8, (15, 2))
  62.         self.asdf.Add(n9, (15, 3))
  63.        
  64.  
  65.         menusizer.Add(self.asdf, 0)
  66.         topsizer.Add(menusizer, 0)
  67.         self.SetSizer(topsizer)
  68.        
  69.     def EvtComboBox(self, evt):
  70.        
  71.         print "estoy en el evento"
  72.         if evt.GetString() == 'uno':
  73.             self.cmbox = 1;
  74.         if evt.GetString() == 'dos':
  75.             self.cmbox = 2;
  76.         if evt.GetString() == 'tres':
  77.             self.cmbox = 3;
  78.         if evt.GetString() == 'cuatro':
  79.             self.cmbox = 4;
  80.         self.picture.SetBitmap(wx.Bitmap('images/%d.jpeg'%self.cmbox))
  81.         print self.cmbox
  82.        
  83. app = wx.App()
  84. frame = MyFrame(None, title="asdf")
  85. frame.Show(True)
  86. app.MainLoop()

alguna idea???
saludos

Última edición por IamEdo; 28/07/2010 a las 13:34