89 lines
3.2 KiB
Python
89 lines
3.2 KiB
Python
#!/usr/bin/env python
|
|
|
|
import sys
|
|
import gnuPlotData
|
|
|
|
class PyGnuplotAssistant:
|
|
'this class handles the gui for PGAss'
|
|
import os
|
|
import myGnuPlot
|
|
import time
|
|
#-- import threading
|
|
#-- t = threading.Thread(target = myGnuPlot.myGnuPlot)
|
|
|
|
#xyz = os.popen("gnuplot","w")
|
|
|
|
# debug >=1 will print messages on console
|
|
x = myGnuPlot.MyGnuPlot(debug=1)
|
|
|
|
|
|
pd = gnuPlotData.PlotData()
|
|
def __init__(self, gtkext):
|
|
# gtk is given, it has to be known in the whole class
|
|
self.gtk = gtkext
|
|
# define which gladefile to use for frontend
|
|
gladefile = "pga-gui.glade"
|
|
self.pga = self.gtk.glade.XML(gladefile)
|
|
# set button handlers
|
|
actions = { "on_bu_ok_clicked": self.clicked_ok,
|
|
"on_bu_ok_enter": self.enter_ok,
|
|
"on_bu_test_clicked": self.clicked_test,
|
|
"on_bu_test_enter": self.enter_test,
|
|
"on_bu_cancel_enter": self.enter_cancel,
|
|
"on_bu_cancel_leave": self.leave_cancel,
|
|
"on_bu_cancel_clicked": (self.gtk.mainquit) }
|
|
# connect the actions to the events
|
|
self.pga.signal_autoconnect (actions)
|
|
return
|
|
|
|
def __del__(self):
|
|
# this is unnecesseray
|
|
self.xyz.close()
|
|
|
|
#### implementation of actions
|
|
def enter_cancel(self, widget):
|
|
self.pga.get_widget("tf_status").set_text("noooo, don't do it")
|
|
def leave_cancel(self, widget):
|
|
self.pga.get_widget("tf_status").set_text("do never ever try this again")
|
|
def enter_ok(self, widget):
|
|
self.pga.get_widget("tf_status").set_text("save settings to file")
|
|
def enter_test(self, widget):
|
|
self.pga.get_widget("tf_status").set_text("start gnuplot with saved properties")
|
|
def clicked_test(self, widget):
|
|
self.pga.get_widget("tf_status").set_text("check if gnuplot is installed")
|
|
filename = self.pga.get_widget("tf_filename").get_text()
|
|
'''
|
|
self.xyz.write("load '"+ filename +"'"+ '\n')
|
|
self.pga.get_widget("tf_status").set_text("check if gnuplot is installed")
|
|
self.xyz.flush()
|
|
a = self.xyz.read()
|
|
print "gnuplot ausgabe: %s" %a
|
|
'''
|
|
self.x.send_command(filename)
|
|
self.pga.get_widget("tf_status").set_text("you should see a popup window")
|
|
|
|
def clicked_ok(self, widget):
|
|
#read the fields and save them
|
|
## important values
|
|
self.pga.get_widget("tf_status").set_text("saved to file")
|
|
title = self.pga.get_widget("tf_title").get_text()
|
|
datastyle = self.pga.get_widget("cb_datastyle").get_text()
|
|
seconds = self.pga.get_widget("sb_seconds").get_text()
|
|
filename = self.pga.get_widget("tf_filename").get_text()
|
|
readdata = self.pga.get_widget("tf_readdata").get_text()
|
|
labelx = self.pga.get_widget("tf_labelx").get_text()
|
|
labely = self.pga.get_widget("tf_labely").get_text()
|
|
## checkbox values
|
|
reread = self.pga.get_widget("cb_reread").get_active()
|
|
autoscale = self.pga.get_widget("cb_autoscale").get_active()
|
|
grid = self.pga.get_widget("cb_grid").get_active()
|
|
key = self.pga.get_widget("cb_key").get_active()
|
|
logx = self.pga.get_widget("cb_logx").get_active()
|
|
logy = self.pga.get_widget("cb_logy").get_active()
|
|
# pass them to PlotData !order is important!
|
|
self.pd.set_important_values(title, datastyle, seconds, filename, readdata, labelx, labely)
|
|
self.pd.set_checkbox_values(reread, autoscale, grid, key, logx, logy)
|
|
writeresult = self.pd.write_tofile()
|
|
self.pga.get_widget("tf_status").set_text(writeresult)
|
|
|
|
|