I'll briefly comment on the problem:
I would like to design a GUI that consists of a window of a given size (say 500x600 pixels) and inside it in descending order we would have two rows one under the other with a label and a text box (where to enter data, but that's covered), a text box to dump information and under this last element three buttons.
I have not handled much with Sizers but I think I understand 'more or less' how they work ... However, I can not resize the window initially and the buttons are disproportionate. I have attached my code to see if you can help me:
import wx
class GUI(wx.Frame):
def __init__(self,*args,**kwargs):
#Iniciamos el frame
wx.Frame.__init__(self,*args,**kwargs)
#creamos los sizers
#-----------------------------------------------
#para la seccion principal
self.sizerB=wx.BoxSizer(wx.VERTICAL)
#para la seccion de los botones
self.sizerButtons=wx.BoxSizer(wx.HORIZONTAL)
#para la seccion de Mensaje y Comando
self.sizerGrid=wx.FlexGridSizer(rows=2,cols=2,vgap=5,hgap=5)
#------------------------------------------------
#creamos las etiquetas
#------------------------------------------------
self.Mensaje=wx.StaticText(self,wx.ID_ANY,"Mensaje")
self.Comando=wx.StaticText(self,wx.ID_ANY,"Comando")
#-------------------------------------------------
#Cajas de texto
#-------------------------------------------------
self.CajaM=wx.TextCtrl(self,wx.ID_ANY)
self.CajaC=wx.TextCtrl(self,wx.ID_ANY)
#-------------------------------------------------
#creamos los botones(x3)
#-------------------------------------------------
self.SendM=wx.Button(self,wx.ID_ANY,"Enviar Mensaje")
self.SendC=wx.Button(self, wx.ID_ANY, "Enviar Comando")
self.Exit=wx.Button(self,wx.ID_ANY,"Salir")
#--------------------------------------------------
#Agregamos sizers(configurarlos despues)
#--------------------------------------------------
#agregaremos el flexigridsizer para las dos primeras cajas y etiquetas
for obj in [self.Mensaje,self.CajaM,self.Comando,self.CajaC]:
self.sizerGrid.Add(obj,1,wx.EXPAND | wx.ALL,2)
self.sizerGrid.AddGrowableCol(1)
#Ahora le toca a los botones
for obj in [self.SendM,self.SendC,self.Exit]:
self.sizerButtons.Add(obj,1,wx.EXPAND|wx.ALL)
self.SetInitialSize((600,500))
#---------------------------------------------------
#Configuramos los sizers
#---------------------------------------------------
self.sizerB.Add(self.sizerGrid,2,1,wx.EXPAND|wx.ALL,5)
self.sizerB.Add(self.sizerButtons,2,1,wx.EXPAND|wx.ALL,5)
self.SetSizer(self.sizerB)
#----------------------------------------------------
self.Centre(True)
self.Show()
if __name__=="__main__":
app=wx.App()
fr=GUI(None,-1,"Aplicacion",size=(300,200))
app.MainLoop()