[pygtk] help with scrollbar

reidar reidar.hagen at gmail.com
Fri Jun 23 09:39:10 WST 2006


you had lower and upper switched on the adjustment:
try:

adj1 = gtk.Adjustment(32.0, 32.0, 212.0, 0.1, 1.0,
1.0)

http://www.pygtk.org/pygtk2reference/class-gtkadjustment.html

On Fri, 23 Jun 2006 02:36:25 +0200, Christopher Spears  
<cspears2002 at yahoo.com> wrote:

> I have been trying to teach myself PyGTK.  I decided
> to create a little GUI with a scrollbar.  Using the
> scrollbar, I can select the temperature in degrees
> Fahrenheit.  By clicking on the Convert button, the
> GUI displays the corresponding degrees Celsius.
>
> I have made a lot of progress, but for some reason,
> the thumb on the scrollbar will not move when I click
> and drag it.  I asked for help on the Python tutor
> mailing list, but there are not a lot of PyGTK experts
> on that list.  I have looked over the docs and the
> tutorial, too.  Can someone help me out?
>
> #!/usr/bin/python
>
> import pygtk
> pygtk.require('2.0')
> import gtk
>
> def convert_to_celsius(widget,data):
> 	degC = (data - 32)/1.8
> 	print "Degrees Celsius: %.2f" % degC
> 	
> def scale_set_default_values(scale):
> 	scale.set_update_policy(gtk.UPDATE_CONTINUOUS)
> 	scale.set_digits(1)
> 	scale.set_value_pos(gtk.POS_LEFT)
> 	scale.set_draw_value(True)
> 	scale.set_sensitive(True)
> 	
> class Conversion_GUI:
> 	def __init__(self):
> 		self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
> 		self.window.connect("destroy", lambda w:
> gtk.main_quit())
> 		self.window.set_title("Convert to Celsius")
> 		self.window.set_default_size(200,240)
> 		
> 		box1 = gtk.VBox(False, 0)
> 		self.window.add(box1)
> 		
> 		box2 = gtk.HBox(False, 10)
> 		box2.set_border_width(10)
> 		box1.pack_end(box2, True, True, 0)
> 		
> 		box3 = gtk.HBox(False, 10)
> 		box3.set_border_width(10)
> 		box1.pack_end(box3, True, True, 0)
> 		
> 		adj1 = gtk.Adjustment(32.0, 212.0, 32.0, 0.1, 1.0,
> 1.0)
> 		self.vscale = gtk.VScale(adj1)
> 		self.vscale.set_size_request(20, 300)
> 		scale_set_default_values(self.vscale)
> 		box1.pack_start(self.vscale, True, True, 0)
> 		
> 		quit_button = gtk.Button("Quit")
> 		quit_button.connect("clicked", lambda
> w:gtk.main_quit())
> 		convert_button = gtk.Button("Convert")
> 		convert_button.connect("clicked",
> convert_to_celsius, self.vscale.get_value())
> 		box3.pack_start(convert_button, True, True, 0)
> 		box2.pack_start(quit_button, True, True, 0)
> 		
> 		self.vscale.show()
> 		convert_button.show()
> 		quit_button.show()
> 		box3.show()
> 		box2.show()
> 		box1.show()
> 		self.window.show()
> 		
> 	def main(self):
> 		gtk.main()
> 		return 0
> 	
> if __name__ == '__main__':
> 	convert = Conversion_GUI()
> 	convert.main()
>
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


More information about the pygtk mailing list