How to set initial size of gtk.TextView window?

Chris Green cl at isbd.net
Mon Mar 13 13:58:08 EDT 2017


I have a series of data fields laid out in a Vbox, the size needs to
vary, some need to be two lines high, others four lines or more.

The code creating the fields is:-

    def __init__(self, multiline=0):
        self.multiline = multiline
        if (self.multiline):
            self.buffer = gtk.TextBuffer()
            self.view = gtk.TextView(self.buffer)
            self.widget = gtk.ScrolledWindow()
            self.widget.add(self.view)
            self.widget.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
            self.widget.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        else:
            self.widget = gtk.Entry()

As can be seen there are single line boxes and multiline ones, what I
want to be able to do is to have a parameter (or just use multiline)
to set the initial number of lines in the TextView fields.

Is it a matter of using gtk.Widget.set_size_request() or is there an
easier way?

-- 
Chris Green
·



More information about the Python-list mailing list