from Tkinter import *
import time,sys,thread

class DataInterface:
    def __init__(self, parent, child):
        ##  TKR is required to be placed HERE  ##
        self.tkr = parent
        self.dataOut = child
        
        ##  Variable declaration  ##
        self.tvPhasePoints = BooleanVar()
        self.tvPhasePoints.set(0)
##        self.tvReturnMap = BooleanVar()
##        self.tvReturnMap.set(0)

##        self.tvFFTPlot = BooleanVar()
##        self.tvFFTPlot.set(0)
##        self.tvAnglePlot = BooleanVar()
##        self.tvAnglePlot.set(0)

##        self.tvTrackMaxMin = BooleanVar()
##        self.tvTrackMaxMin.set(0)
        ##  Variable declaration  ##

        ##  TKR appearance and widget creation  ##
        self.tkr.wm_geometry(newGeometry="300x140+680+480")   
        self.tkr.wm_title("Data Capture")
        ##
        self.tkr.topFrame = Frame(self.tkr,relief=SUNKEN, borderwidth=0)
        self.tkr.topFrame.grid(row=0, column=0, padx=0, pady=0)

        ###########################################################################
        self.tkr.toggleFrame = Frame(self.tkr.topFrame, relief=SUNKEN, borderwidth=0)
        self.tkr.toggleFrame.grid(row=0, column=0, padx=4, pady=4)
        #
        self.tkr.dataLabel = Label(self.tkr.toggleFrame, text="Toggles:").grid(row=0, column=0, sticky=W)
        #
        self.tkr.phasePointsLabel = Label(self.tkr.toggleFrame, text="Phase Points").grid(row=1, column=0, sticky=E)
        self.tkr.phasePointsWidget = Checkbutton(self.tkr.toggleFrame, text="", variable=self.tvPhasePoints, command=self.togglePhasePoints)
        self.tkr.phasePointsWidget.grid(row=1, column=1)
##        self.tkr.returnMapLabel = Label(self.tkr.toggleFrame, text="Return Map").grid(row=2, column=0, sticky=E)
##        self.tkr.returnMapWidget = Checkbutton(self.tkr.toggleFrame, text="", variable=self.tvReturnMap, command=self.toggleReturnMap)
##        self.tkr.returnMapWidget.grid(row=2, column=1)
        #
##        self.tkr.fftPlotLabel = Label(self.tkr.toggleFrame, text="FFT Plot").grid(row=1, column=2, sticky=E)
##        self.tkr.fftPlotWidget = Checkbutton(self.tkr.toggleFrame, text="", variable=self.tvFFTPlot, command=self.toggleFFTPlot)
##        self.tkr.fftPlotWidget.grid(row=1, column=3)
##        self.tkr.anglePlotLabel = Label(self.tkr.toggleFrame, text="Angle Plot").grid(row=2, column=2, sticky=E)
##        self.tkr.anglePlotWidget = Checkbutton(self.tkr.toggleFrame, text="", variable=self.tvAnglePlot, command=self.toggleAnglePlot)
##        self.tkr.anglePlotWidget.grid(row=2, column=3)
        #
##        self.tkr.tvTrackMaxMinLabel = Label(self.tkr.toggleFrame, text="Track Planarity").grid(row=1, column=4, sticky=E) 
##        self.tkr.tvTrackMaxMinWidget = Checkbutton(self.tkr.toggleFrame, text="", variable=self.tvTrackMaxMin, command=self.toggleTrackMaxMin)
##        self.tkr.tvTrackMaxMinWidget.grid(row=1, column=5)
        ###########################################################################

        ###########################################################################
        self.tkr.actionFrame = Frame(self.tkr.topFrame, relief=FLAT, borderwidth=0)
        self.tkr.actionFrame.grid(row=1, column=0, padx=4, pady=4)
        #
        self.tkr.actionLabel = Label(self.tkr.actionFrame, text="Actions:").grid(row=0, column=0, sticky=W)
        #
##        self.tkr.powerSpectraWidget = Button(self.tkr.actionFrame, text="Power Spectra", command=self.powerSpectra).grid(row=1, column=0, padx=4, pady=4)
##        self.tkr.deltaEWidget = Button(self.tkr.actionFrame, text="Energy Deltas", command=self.deltaE).grid(row=1, column=1, padx=4, pady=4)
        self.tkr.excelWidget = Button(self.tkr.actionFrame, text="Make Excel Sheet", command=self.excelSheet).grid(row=1, column=2, padx=4, pady=4)
        ###########################################################################
        ##  TKR appearance and widget creation  ##

        
##    def powerSpectra(self):
##        self.dataOut.powerSpectra()
##    def deltaE(self):
##        pass
    def excelSheet(self):
        self.dataOut.excelLog(32)
            

    def togglePhasePoints(self):
        pass
##    def toggleReturnMap(self):
##        pass
##    def toggleAnglePlot(self):
##        pass
####        self.t = 0.000
##    def toggleFFTPlot(self):
##        pass
####        self.FFTPlot.toggleWindow()
##    def togglePowerSpectrum(self):
##        pass   
##    def toggleTrackMaxMin(self):
##        pass



