python - gtk.ScrolledWindow having gtk.TextView to display fixed first line -


i have code creates textview within scrolledwindow. want line say, "hello world", appeared inside textview first line. furthermore, how can fix line on top itself,i.e should displayed when window scrolled down. position of line should fixed,making visible after entering n number of lines in textview or scrolling way bottom

import gtk class scorewindow:    def __init__(self):     self.window = gtk.window(gtk.window_toplevel)     #self.window.set_size_request(800, 200)     self.window.set_resizable(false)     self.window.set_title("score card")     self.window.set_position(gtk.win_pos_center)     self.vb=gtk.vbox()      line="this rather long string containing\n\ several lines of text in c.\n\     note whitespace @ beginning of line is\  significant.this rather long string containing\n\ several lines of text in c.\n\     note whitespace @ beginning of line is\  significant."      self.go=gtk.label("textview\n")     self.lalign = gtk.alignment(0, 0, 0, 0)     self.label_result = gtk.label("  title")     #self.label_result.set_justify(gtk.justify_left)     self.lalign.add(self.label_result)      self.scrolled_window = gtk.scrolledwindow()     self.scrolled_window.set_border_width(10)     self.scrolled_window.set_size_request(300, 300)      self.scrolled_window.set_policy(gtk.policy_automatic, gtk.policy_always)     self.scrolled_window.show()     self.tv = gtk.textview()     self.tv.set_editable(1)     self.tv.set_cursor_visible(1)     self.tv.set_left_margin(30)     textbuffer = self.tv.get_buffer()     self.tv.show()     textbuffer.set_text(line)      self.scrolled_window.add_with_viewport(self.tv)       self.vb.pack_start(self.lalign, false, false, 0)     self.vb.pack_start(self.go, false, false, 0)     self.vb.pack_start(self.scrolled_window, true, true, 0)     color = gtk.gdk.color_parse('#ff8300')     self.window.modify_bg(gtk.state_normal, color)     self.window.add(self.vb)     self.window.show_all()    def main(self):     gtk.main()    if __name__ == "__main__": hello = scorewindow() hello.main() 

start adding gtk.entry control above scrolled window. emulate first line of text view show.

add signal handlers move focus entry control text view when pressing e.g. enter key or cursor down.

add signal handlers move focus text view entry control when pressing cursor if you're on first line.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -