Advertisement
1400_SpaceCat

adj

May 12th, 2016
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1. from gi.repository import Gtk
  2. from gi.repository import Gdk
  3.  
  4. class app:
  5.     def __init__(self):
  6.         self.value = 50
  7.  
  8.         win = Gtk.Window()
  9.         win.connect("delete_event", Gtk.main_quit)
  10.         win.set_default_size(300,100)
  11.        
  12.         box = Gtk.Box()
  13.  
  14.         self.button_p = Gtk.Button(">")
  15.         self.button_p.connect("clicked",self.plus)
  16.         self.button_m = Gtk.Button("<")
  17.         self.button_m.connect("clicked",self.minus)
  18.  
  19.         self.scroll = Gtk.ScrolledWindow(None, None)
  20.         view = Gtk.Viewport(None, None)
  21.         label = Gtk.Label('''
  22.         \rsome text
  23.  
  24.  
  25.  
  26.         \rsome shit
  27.  
  28.  
  29.         \rshit''')
  30.        
  31.         view.add(label)
  32.         self.scroll.add(view)
  33.        
  34.         box.pack_start(self.button_p,True,True,0)
  35.         box.pack_start(self.button_m,True,True,0)
  36.         box.pack_start(self.scroll,True,True,0)
  37.  
  38.         win.add(box)
  39.         win.show_all()
  40.        
  41.         self.position = self.scroll.get_vadjustment()
  42.         self.position.set_value(self.value)
  43.         # self.scroll.set_vadjustment(self.position)
  44.  
  45.         Gtk.main()
  46.  
  47.     def plus(self,e):
  48.         self.value += 10
  49.         self.scroll.set_vadjustment(self.position)
  50.  
  51.     def minus(self,e):
  52.         self.value -= 10
  53.         self.scroll.set_vadjustment(self.position)
  54.  
  55. app()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement