[pygtk] placing info from scrollbar into variable
I am trying to create a gui that consists of a vertical scrollbar and two buttons. I want to be able to pick a number representing degrees Fahrenheit using the scrollbar. When I click the Convert button after picking a number, the gui would convert the number into degrees Celsius and print the answer to the screen. Here is what I have written so far: #!/usr/bin/python import pygtk pygtk.require('2.0') import gtk 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 convert_to_celsius(self, adj): #print "Data: ", adj.value degC = (adj.value - 32)/1.8 return degC def print_celsius(self, widget, data=None): #degC = self.convert_to_celsius(adj1) print data 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, 32.0, 213.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) adj1.connect("value_changed",self.convert_to_celsius) quit_button = gtk.Button("Quit") quit_button.connect("clicked", lambda w:gtk.main_quit()) convert_button = gtk.Button("Convert") convert_button.connect("clicked", self.print_celsius, data) 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() Basically, the scrollbar feeds information into convert_to_celsius, which does the conversion. What I want to do is somehow store the information generated in convert_to_celsius in a variable and send it to print_celsius to print out the answer after the Convert button is pressed. I've looked at the tutorials and the docs and couldn't find anything, so I thought someone on this mailing list could give me advice. ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Updating scrolled windows
On Thu, 2006-06-22 at 17:09 -0700, N. French wrote: > I have a gtk.ScrolledWindow that I use as an interactive console (I > take entry from a gtk.Entry and display the results in a gtk.TextView > housed in a gtk.ScrolledWindow). Below is my function to write the > text to the buffer and set the ScrolledWindow's scroll bar to the end. > I want it to behave like an xterm would, new text appears at the bottom > and you scroll upwards to see old stuff. > > This basically works. My problem is it doesn't quite scroll the window > all the way to the bottom, it's always short by one line. > > Any suggestions? > > Thanks, > > Nathan French > Yeah, it doesn't always work unless you make a mark at the end of the buffer. Set the property so that any text inserted will be to the left of the mark. Then scroll_to_mark. That will scroll the text onscreen every time. -- Brian <[EMAIL PROTECTED]> ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] help with scrollbar
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 <[EMAIL PROTECTED]> 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@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/ ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] help with scrollbar
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@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Updating scrolled windows
Probably not the most insightfull reply, but using a TreeView and catching the 'row-changed' on the underlying tree-model and subsequently using TreeView.scroll_to_cell(path) is working nicely on our logger-display. I think we had trouble with trying to scroll *before* the scroll-bar had had time to update itself though, presumably something similar may be happening in your code. regards Reidar our code, GPL'ed: https://dev.scicraft.org/trac/browser/scicraft-ng/trunk/system/logger.py?format=txt On Fri, 23 Jun 2006 02:09:35 +0200, N. French <[EMAIL PROTECTED]> wrote: I have a gtk.ScrolledWindow that I use as an interactive console (I take entry from a gtk.Entry and display the results in a gtk.TextView housed in a gtk.ScrolledWindow). Below is my function to write the text to the buffer and set the ScrolledWindow's scroll bar to the end. I want it to behave like an xterm would, new text appears at the bottom and you scroll upwards to see old stuff. This basically works. My problem is it doesn't quite scroll the window all the way to the bottom, it's always short by one line. Any suggestions? Thanks, Nathan French -- def dump_text(self, text): """The interface into the scrolling command history window.""" #sys.stderr.write( '** %s' % text) i = self.dump.get_iter_at_offset(-1) self.dump.insert(i, text) self.dumpscroll.emit('scroll-child', gtk.SCROLL_END, False) # this doesn't work right __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ pygtk mailing list pygtk@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/ ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] Updating scrolled windows
I have a gtk.ScrolledWindow that I use as an interactive console (I take entry from a gtk.Entry and display the results in a gtk.TextView housed in a gtk.ScrolledWindow). Below is my function to write the text to the buffer and set the ScrolledWindow's scroll bar to the end. I want it to behave like an xterm would, new text appears at the bottom and you scroll upwards to see old stuff. This basically works. My problem is it doesn't quite scroll the window all the way to the bottom, it's always short by one line. Any suggestions? Thanks, Nathan French -- def dump_text(self, text): """The interface into the scrolling command history window.""" #sys.stderr.write( '** %s' % text) i = self.dump.get_iter_at_offset(-1) self.dump.insert(i, text) self.dumpscroll.emit('scroll-child', gtk.SCROLL_END, False) # this doesn't work right __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] Panel applets gconf
Hi, I am writing a panel applet in python. Now I want to store and retrieve some persistence data. In the C panel applets I have seen people using panel_applet_gconf_get_list, panel_applet_gconf_get_string, etc. Unfortunately, I couldn't find them in gnome-python, so I started to implement them myself (most are trivial extensions by adding a few lines to applets.def, panel_applet_gconf_get_list and panel_applet_gconf_set_list are a bit harder). However, before I continue this effort, perhaps there is another way to accomplish the same more easily and better without using these panel_applet_gconf functions. Moreover the panel_applet_gconf_* functions are poorly documented (well of I can read the source !-). On the other hand, perhaps other people are interested in my effort. Cheers, Hans. signature.asc Description: This is a digitally signed message part ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/