GTK3プログラムでPythonを使ってログを実装しました。これは、TextBufferがScrolledWindow内にあるTextViewです。ルーチンでは、このログに新しい行を追加します。その後、最後の行までスクロールする必要があります。ScrollledWindow/TextViewの末尾までスクロール
def append_log(self, line):
self.textbuffer.insert(self.textbuffer.get_end_iter(), "\n"+line, -1)
# scrolling down
それは次のようになります。http://www.physik.tu-dresden.de/~s9472632/log_manual.png
しかし、それは動作しません。私は次のコードを試した。
# nothing happens
adj = self.scrolledwindow.get_vadjustment()
adj.set_value(adj.get_upper()-adj.get_page_size()) # same without subtraction (only upper or page_size)
self.scrolledwindow.set_vadjustment(adj) # with and without this line
。
# nothing happens
self.textview.scroll_to_iter(self.textbuffer.get_end_iter(), 0.0, False, 0.5, 0.5)
。
# works a bit but scroll bars cover the text (see picture below)
self.textview.scroll_to_mark(self.textbuffer.get_insert(), 0.0, False, 0.5, 0.5)
画像:http://www.physik.tu-dresden.de/~s9472632/log_scroll.png
scroll_toの*(within_margin、use_align、xalign、yalign)の最後の4つの引数は結果の影響を持っていないようです。
どのように機能しますか?
バイマークス
をネイティブスクロール機能を持つ子のaddメソッドを使用していることを確認してください。これはC APIの 'container_add'です。 – ergosys