[pygtk] Re: howto create border around widget?

Michael Baranov michael.baranov at gmail.com
Mon Oct 15 22:47:40 WST 2007


Thanks!
Indeed I can achieve some border effects with it!

skip wrote:
>     Michael> IMO. For example it looks [GtkFrame] will never allow me to
>     Michael> have, say, 2px-wide red border around a widget with 0px
>     Michael> distance between the widget and the border.
>
> Here's a way to do it using gtk.Frame:
>
>     import gtk
>
>     def exit(*args):
>         raise SystemExit
>
>     def main():
>         w = gtk.Window()
>         w.connect("destroy", exit)
>         f = gtk.Frame()
>         b = gtk.Button("Hello World!")
>         b.connect("clicked", exit)
>         f.set_border_width(2)
>         f.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(65535))
>         f.add(b)
>         w.add(f)
>         w.show_all()
>         gtk.main()
>
>     if __name__ == "__main__":
>         main()
>
> Certainly not the most elegant thing, but it seems to work for the most
> part.  I'm sure you can improve it.
>
> Skip
>
>   

-- 
Michael Baranov



More information about the pygtk mailing list