#!/usr/bin/python import sys import os import sys import gtk import gtk.glade # Put the event handlers here. def on_window1_delete_event(*args): sys.exit(0) def on_thing_clicked(*args): # Get values out of the data input widgets foo_value = foo_widget.get_text() if foo_value == "": foo_value = "100" foo_widget.set_text(foo_value) foo_value = float(foo_value) # Run the calculation command. calculation_command = "PROGRAM %f > %s.dat" % (foo_value, jobname_value) os.system(iteration_command) # Generate the gnuplot commands gnuplot_filename = "%s.gplt" % jobname_value gnuplot_file = open(gnuplot_filename, "w") gnuplot_file.write(""" set style data dots set terminal png set title "foo = %f" set output "%s.png" plot "%s.dat" """ % (foo_value, jobname_value, jobname_value) ) gnuplot_file.close() # Run the gnuplot command gnuplot_command = "gnuplot %s.gplt" % jobname_value os.system(gnuplot_command) # Take the image file created and stick it in the image widget image_filename = "%s.png" % jobname_value image_widget.set_from_file(image_filename) # Main function. if __name__ == "__main__" : # Put the name of the .glade file here. global application application = gtk.glade.XML('thing.glade') # Put the names of the widgets we need to talk to directly here. global foo_widget, image_widget foo_widget = application.get_widget('foo') image_widget = application.get_widget('image') # Launch the application application.signal_autoconnect(globals()) gtk.main()