tags:

views:

537

answers:

2

Hi,

I would like to remove border on a gtk.Button and also set its size fixed. How can I accomplish that? My button looks like that:

 b = gtk.Button()
 b.set_relief(gtk.RELIEF_NONE)

Thanks! p.d: I'm using pygtk

+2  A: 

You can use gtk.Widget.set_size_request to set a fixed size for the widget. Note that this is generally a bad idea, since the user may want a larger font size than you had planned for, etc.

As for removing the border, gtk.Button can often take up more space than you wish it would. You can try to set some of the style properties such as "inner-border" to 0 and see if that gets the result you want. If you need the smallest button possible, you should just gtk.Label inside a gtk.EventBox and handle clicks on the event box. That will use the least amount of pixels.

anthony
A: 

I don't think the EventBox can send button events like "activated" and "clicked".

dividebyzero
yes, you can! actually I ended using this alternative to solve my inner-border problems. To add the clicked event you have to use:eventboxobject.connect("button-press-event", callback_function)
Lucia
"Button press" is one event. I'm specifically saying "button events". "Clicked", if I am not mistaken, is a Button exclusive event, while "button press" is pretty common. Do you confirm that every Button related event is also implemented by EventBox?There are no few programs out there that avoid using Button for aesthetics, losing the benefits of the Button widget, e.g. receiving a "Clicked" event instead of "Button pressed". If that solves your problem, fine. But please pay attention to this detail.
dividebyzero