[wxPython-users] problem with wx.Button, only caption visible.

Andrea Gavana andrea.gavana at gmail.com
Wed Jan 3 12:18:41 PST 2007


Hi krishnakant,

> it did not look like a normal button.
> the code was some thing like this
> class window(wx.Frame):
>   def __init__(self):
>      wx.Frame.__init__(self,wx.ID_ANY, ...)
>      ... code here
>      #button to be added to the frame
>      self.button = wx.Button(self,100,"the button",wx.point(1,1),
> size = (100,15))
>
>      self.Show(True)

I always think that adding controls directly to a frame can be
somewhat dangerous: usually, you have a frame, you put a panel inside
that frame (which, by default, fills all the frame client area) and
then you add all the controls to the panel.
It seems a bit strange to me that the button borders are not visible,
I don't remember such behavior... but maybe you work with a different
OS (I am on Windows XP).
Moreover, I strongly suggest you to avoid explicit positioning and
sizing of widgets, as you are doing:

>      self.button = wx.Button(self,100,"the button",wx.point(1,1),
> size = (100,15))

If you can, try to use sizers instead: they are a bit hostile at the
beginning to work with, but once you get used to them you will notice
how easy is to code with wxPython without bothering about positions
and sizes of controls.

Hope this helps.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/




More information about the wxpython-users mailing list