Re: [pygtk] how to adjust scrolledwindow pos

2000-03-01 Thread Frederic Gobry

Hi,

 #Now 'text' is positioned at the top; how do I set it to the bottom.
 #I looked for something like set_scroll_pos(pos), but couldn't find such.

You should have a look at the section on GtkAdjustment in the Gtk
documentation. It provides a generic class to deal with numerical ranges.
For your problem, you can do something like:

adjustment = text.get_vadjustment ()
print adjustment.upper
adjustment.set_value (adjustment.upper)

(you have to show () your widget before, or else the adjustment size won't
be correct).

Frédéric
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]



Re: [pygtk] how to adjust scrolledwindow pos

2000-03-01 Thread James Henstridge

The adjustment for the GtkText widget represents the position in the text.

You can set its value with the set_value() method.  Something like:
  adj = text.get_vadjustment()
  adj.set_value(adj.upper - adj.page_size)

This should adjust where the scrollbar thumb is positioned and the
position in the text.

James.

--
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


On Tue, 29 Feb 2000 [EMAIL PROTECTED] wrote:

 [ gtk+-1.2.6, pygtk-0.6.4, python-1.5.2 ]
 
 I create a text widget, and attach a vertical scrollbar.
 I insert a lot of text.  Now I want to programmaticaly position
 the scrollbar at the end, i.e. with the last line of text at the
 visible bottom of the window.  How is this done?
 
 vbox.pack_start(GtkLabel('Machine Log'), FALSE, FALSE)
 text = GtkText()
 text.set_editable(FALSE)
 text.set_word_wrap(TRUE)
 textbox=GtkHBox()
 textbox.pack_start(text, TRUE, TRUE, 0)
 textbox.pack_start(GtkVScrollbar(text.get_vadjustment()), FALSE, FALSE, 0)
 vbox.pack_start(textbox, TRUE, TRUE)
 
 text.delete_text(0, -1)
 text.freeze()
 for ldate,lstatus,lusr,lcomment in rslt:
 text.insert_defaults('Date: ' + ldate + '  User: ' + lusr + '  Status: ' + 
lstatus + '\n')
 text.insert_defaults(lcomment + '\n')
 text.insert_defaults('___\n')
 text.thaw()
 
 #Now 'text' is positioned at the top; how do I set it to the bottom.
 #I looked for something like set_scroll_pos(pos), but couldn't find such.
 
 Any other comments about good (or terrible) style, easier/better ways to 
 do things like this are welcome...
 
 To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
 

To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]