[pygtk] gtk.TextView changing size.

Neil Dugan pygtk at butterflystitches.com.au
Fri Nov 9 09:50:15 WST 2007


Yuri Pimenov wrote:
> 1. use gtk.POLICY_AUTOMATIC for horizontal scrolling
> or
> 2. scrolledwindow.set_size_request(width, -1)

Thanks, that worked.  I am wondering why you need to set the minimum 
size for the gtk.ScrolledWindow() to stop it expanding when you type 
in the gtk.TextView(), and why a minimum size isn't already set.


> 
> On 07/11/2007, Neil Dugan <pygtk at butterflystitches.com.au> wrote:
> 
>>Hi,
>>
>>
>>When you type in the one of the textview widgets in the app. below the
>>size of the textview changes.  I would like to stop this.
>>
>>
>>-------------- cut ---------------------
>>#!/usr/bin/env python
>>
>>import gtk
>>
>>class window():
>>        def __init__(self):
>>                window = gtk.Window(gtk.WINDOW_TOPLEVEL)
>>                window.set_border_width(10)
>>                window.set_default_size(400,300)
>>                window.connect("destroy", lambda wid: gtk.main_quit())
>>                window.connect("delete_event", lambda a1,a2:gtk.main_quit())
>>
>>                hbox = gtk.HBox()
>>                window.add(hbox)
>>                hbox.add(self.create_textview())
>>                hbox.add(self.create_textview())
>>                window.show_all()
>>
>>        def create_textview(self) :
>>                scrolledwindow = gtk.ScrolledWindow()
>>                scrolledwindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
>>                textview = gtk.TextView()
>>                scrolledwindow.add(textview)
>>                textview.set_wrap_mode(gtk.WRAP_WORD)
>>                return scrolledwindow
>>
>>        def main(self):
>>            gtk.main()
>>            return 0
>>
>>if __name__ == "__main__":
>>        test = window()
>>        test.main()
>>-------------- cut ---------------------




More information about the pygtk mailing list