[pygtk] Checkbutton alignment

John Finlay finlay at moeraki.com
Tue Apr 22 05:12:44 WST 2008


Joaquim Rocha wrote:
> Hi all,
>
> I got a checkbutton with a large label which is being wrapped into a 
> few lines.
> Due to the height of the label, the checkbutton aligns vertically 
> ending up set on the center of its space.
>
> Is there a way I can set the vertical alignment of the checkbutton so 
> it remains in the top of its space if its label is too big (has many 
> lines)?
>
> Here's an example.
> As you can see when you run the code, the checkbutton stays aligned 
> vertically to the center of its space.
> Can anyone help? thanks
>
> #!/usr/bin/env python
>
> import pygtk
> pygtk.require('2.0')
> import gtk
>
> class Base:
>
>     def __init__(self):
>
>         self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
>
>         self.window.show()
>
>         self.checkbox =
>         gtk.CheckButton("lalalaaskjansnajksansjkasnjkansajksnajksnajnsajkns
>         jkasna\najnsajksnaksnanjksajksnas\njkabnsjkansjkan
>         as\najibsajksa")
>
>         self.window.add(self.checkbox)
>
>         self.checkbox.show()
>
>     def main(self):
>
>         gtk.main()
>
>
> if __name__ == "__main__":
>
>     base = Base()
>
>     base.main()
>
>
> Screenshots:
> Here's what I got:
> http://neei.uevora.pt/~jay/ssGTKProblem/ss.png 
> <http://neei.uevora.pt/%7Ejay/ssGTKProblem/ss.png>
>
> Here's what I want (GIMP helped me on this):
> http://neei.uevora.pt/~jay/ssGTKProblem/ss1.png 
> <http://neei.uevora.pt/%7Ejay/ssGTKProblem/ss1.png>
>
This is the only way using the standard checkbutton. I suppose you could 
subclass checkbutton and set its do_draw_indicator method to change the 
behavior.

John


More information about the pygtk mailing list