def __init__( self, parent = tk.Tk(), aBunchOfLogs = mm.BunchOfLogs() ): """ Creates a 'BunchOfLogs' object that contains the log information chosen by the caller through a GUI dialog. """ self.numberOneSon = tk.Toplevel( parent ) # tk window under the parent from calling routine self.aBunchOfLogs = aBunchOfLogs # BunchOfLogs object from calling function self.lasPath = str(mm.findFileGui()).split("'")[1] # GUI to find las file and return it's path if self.lasPath == "": # If no file selected, exit the process mm.myStdErrorMessage( "Read LAS error", "No file was select so will exit process.") sys.exit() self.lasFileName = self.ladPath.split("/") # Retreive the LAS filename self.lasFileName = self.lasFileName[len(self.lasFileName)-1]..replace(".LAS", "").replace(".las", "") self.logsAvailableInFile = mm.CurvesInfoLAS() # Retreive available log names in LAS file self.logsAvailableInFile = mm.ReadLogTypesFromLasFile( self.lasPath ) self.logChoiceNumber = IntVar( master = self.numberOneSon ) self.logChoiceNumber.set( 0 ) # Initialize radio button choice to first log curve self.theLog = mm.Log() # Container for a particular log curve self.aBunchOfLogs.setnumLogs( self.logsAvailableInFile.numCurves ) self.aBunchOfLogs.setlogType( self.logsAvailableInFile.logMnemonic ) def readAllLogsFromLasFile( self , filePath ): """ Attempts to read all detected logs in a LAS file pointed to by 'filePath' into the 'aBunchOfLogs' object """ self.lasFile = open( self.lasPath, "r") self.flag = 0 for self.i in range( self.logsAvailableInFile.numCurves ): self.aBunchOfLogs.theLog[ self.i ].ValueUnit = self.logsAvailableInFile.logUnit[ self.i ] for self.lasRow in self.lasFile: if self.lasRow[0] == '~A': self.flag = 1 if self.flag == 1: for i in range( self.logsAvailableInFile.numCurves ): self.aBuchOfLogs.TheLog[i].Value.append( float( self.lasRow.split()[ self.i ] ) )
def crossplotLogs(aBunchOfLogs=mm.BunchOfLogs()): branch = tk.Tk() branch.wm_title("Cross plotting logs") branch.withdraw class simPlotXY: def __init__(self, X=[], Y=[]): self.Z = zip(self.X, self.Y) self.plt = SimPlot() plt.plotLine(self.Z) plt.mainloop() class set_X_VariablesIn: def __init__(self, aBunchOfLogs=mm.BunchOfLogs, logNum=-999): mainCrossplotFrame.xIdVariable.set( str(aBunchOfLogs.MyLogLabel[LogNum])) mainCrossplotFrame.xTypeVariable.set( str(aBunchOfLogs.LogType[LogNum])) mainCrossplotFrame.xLog = aBunchOfLogs.TheLog[LogNum].Value class set_Y_VariablesIn: def __init__(self, aBunchOfLogs=mm.BunchOfLogs, logNum=-999): mainCrossplotFrame.yIdVariable.set( str(aBunchOfLogs.MyLogLabel[LogNum])) mainCrossplotFrame.yTypeVariable.set( str(aBunchOfLogs.LogType[LogNum])) mainCrossplotFrame.yLog = aBunchOfLogs.TheLog[LogNum].Value class getXLog: def __init__(self, myParent, aBunchOfLogs=mm.BunchOfLogs()): self.getXLogFrame = tk.Frame(myParent) if aBunchOfLogs.NumLogs == 0: self.rowCounter = 0 self.noLogsLabel = tk.Label( self.getXLogFrame, text=" There appears to be no logs for this session ", font=("Comic Sans MS", 16), fg="Blue") self.noLogsLabel.grid(row=self.rowCounter, column=0) self.rowCounter += 1 self.exitButton = tk.Button(self.getXLogFrame, text="Exit", font=("Comic Sans MS", 14), fg="Red", command=myParent.destroy) self.exitButton.grid(row=self.rowCounter, columnspan=3, stick=E + W) else: self.rowCounter = 0 self.pickLogLabel = tk.Label( self.getXLogFrame, text="Pick a log from the list below.", font=("Comic Sans MS", 16), fg="Blue") self.pickLogLabel.grid(row=self.rowCounter, columnspan=3) self.rowCounter += 1 self.idLabel = tk.Label(self.getXLogFrame, text="Log ID", font=("Comic Sans MS", 14), fg="Green") self.idLabel.grid(row=self.rowCounter, column=0) self.typeLabel = tk.Label(self.getXLogFrame, text="Log Type", font=("Comic Sans MS", 14), fg="Green") self.typeLabel.grid(row=self.rowCounter, column=1) self.unitLabel = tk.Label(self.getXLogFrame, text="Log Unit", font=("Comic Sans MS", 14), fg="Green") self.unitLabel.grid(row=self.rowCounter, column=2) self.rowCounter += 1 for self.i in range(aBunchOfLogs.NumLogs): self.LogIdLabel = tk.Label( self.getXLogFrame, text=str(aBunchOfLogs.MyLogLabel[self.i]), font=("Comic Sans MS", 14), fg="Black") self.LogTypeRadioButton = tk.Radiobutton( self.getXLogFrame, text=str(aBunchOfLogs.LogType[self.i]), font=("Comic Sans MS", 14), fg="Black", command=lambda: set_X_VariablesIn( aBunchOfLogs, self.i)) self.LogUnitLabel = tk.Label( self.getXLogFrame, text=str(aBunchOfLogs.TheLog[self.i].ValueUnit), font=("Comic Sans MS", 14), fg="Black") self.rowCounter += 1 self.exitButton = tk.Button(self.getXLogFrame, text="Exit", font=("Comic Sans MS", 14), fg="Red", command=myParent.destroy) self.exitButton.grid(row=self.rowCounter, columnspan=3, stick=E + W) class getYLog: def __init__(self, myParent, aBunchOfLogs=mm.BunchOfLogs()): self.getYLogFrame = tk.Frame(myParent) if aBunchOfLogs.NumLogs == 0: self.rowCounter = 0 self.noLogsLabel = tk.Label( self.getYLogFrame, text=" There appears to be no logs for this session ", font=("Comic Sans MS", 16), fg="Blue") self.noLogsLabel.grid(row=self.rowCounter, column=0) self.rowCounter += 1 self.exitButton = tk.Button(self.getYLogFrame, text="Exit", font=("Comic Sans MS", 14), fg="Red", command=myParent.destroy) self.exitButton.grid(row=self.rowCounter, columnspan=3, stick=E + W) else: self.rowCounter = 0 self.pickLogLabel = tk.Label( self.getYLogFrame, text="Pick a log from the list below.", font=("Comic Sans MS", 16), fg="Blue") self.pickLogLabel.grid(row=self.rowCounter, columnspan=3) self.rowCounter += 1 self.idLabel = tk.Label(self.getYLogFrame, text="Log ID", font=("Comic Sans MS", 14), fg="Green") self.idLabel.grid(row=self.rowCounter, column=0) self.typeLabel = tk.Label(self.getYLogFrame, text="Log Type", font=("Comic Sans MS", 14), fg="Green") self.typeLabel.grid(row=self.rowCounter, column=1) self.unitLabel = tk.Label(self.getYLogFrame, text="Log Unit", font=("Comic Sans MS", 14), fg="Green") self.unitLabel.grid(row=self.rowCounter, column=2) self.rowCounter += 1 for self.i in range(aBunchOfLogs.NumLogs): self.LogIdLabel = tk.Label( self.getYLogFrame, text=str(aBunchOfLogs.MyLogLabel[self.i]), font=("Comic Sans MS", 14), fg="Black") self.LogTypeRadioButton = tk.Radiobutton( self.getYLogFrame, text=str(aBunchOfLogs.LogType[self.i]), font=("Comic Sans MS", 14), fg="Black", command=lambda: set_Y_VariablesIn( aBunchOfLogs, self.i)) self.LogUnitLabel = tk.Label( self.getYLogFrame, text=str(aBunchOfLogs.TheLog[self.i].ValueUnit), font=("Comic Sans MS", 14), fg="Black") self.rowCounter += 1 self.exitButton = tk.Button(self.getYLogFrame, text="Exit", font=("Comic Sans MS", 14), fg="Red", command=myParent.destroy) self.exitButton.grid(row=self.rowCounter, columnspan=3, stick=E + W) class mainCrossplotFrame: def __init__(self, myParent, aBunchOfLogs): """ The main definitions of a cross-plotting object """ # setting up the main variables for this class of object mainCrossplotFrame.xIdVariable = tk.StrVar() mainCrossplotFrame.xIdVariable.set("None") mainCrossplotFrame.xTypeVariable = tk.StrVar() mainCrossplotFrame.xTypeVariable.set("None") mainCrossplotFrame.xLog = [] mainCrossplotFrame.yIdVariable = tk.StrVar() mainCrossplotFrame.yIdVariable.set("None") mainCrossplotFrame.yTypeVariable = tk.StrVar() mainCrossplotFrame.yTypeVariable.set("None") mainCrossplotFrame.yLog = [] self.xplotFrame = tk.Frame(myParent) self.xplotFrame.pack() self.rowCounter = 0 self.mainXplotLabel = tk.Label(self.xplotFrame, text="Log (x,y) plotting function", font=("Comic Sans MS", 16), fg="Blue") self.mainXplotLabel.grid(row=self.rowCounter, columnspan=3, sticky=E + W) self.rowCounter += 1 self.clickLable = tk.Label(self.xplotFrame, text="Click button below", font=("Comic Sans MS", 14), fg="Green") self.clickLable.grid(row=self.rowCounter, column=0) self.idLable = tk.Label(row=self.rowCounter, text="Log ID", font=("Comic Sans MS", 14), fg="Green") self.idLable.grid(row=self.rowCounter, column=1) self.typeLable = tk.Label(row=self.rowCounter, text="Log ID", font=("Comic Sans MS", 14), fg="Green") self.typeLable.grid(row=self.rowCounter, column=2) self.rowCounter += 1 self.xLogChooseButton = tk.Button( self.xplotFrame, text="Choose X Log", font=("Comic Sans MS", 14), fg="Black", command=lambda: getXLog(myParent, aBunchOfLogs)) self.xLogChooseButton.grid(row=self.rowCounter, column=0) self.xLogIdLable = tk.Label(self.xplotFrame, textvariable=self.xIdVariable, font=("Comic Sans MS", 14), fg="Black") self.xLogIdLable.grid(row=self.rowCounter, column=1) self.xLogTypeLable = tk.Label(self.xplotFrame, textvariable=self.xIdVariable, font=("Comic Sans MS", 14), fg="Black") self.xLogTypeLable.grid(row=self.rowCounter, column=2) self.rowCounter += 1 self.yLogChooseButton = tk.Button( self.xplotFrame, text="Choose Y Log", font=("Comic Sans MS", 14), fg="Black", command=lambda: getYLog(myParent, aBunchOfLogs)) self.yLogChooseButton.grid(row=self.rowCounter, column=0) self.yLogIdLable = tk.Label(self.xplotFrame, textvariable=self.yIdVariable, font=("Comic Sans MS", 14), fg="Black") self.yLogIdLable.grid(row=self.rowCounter, column=1) self.yLogTypeLable = tk.Label(self.xplotFrame, textvariable=self.yIdVariable, font=("Comic Sans MS", 14), fg="Black") self.yLogTypeLable.grid(row=self.rowCounter, column=2) self.rowCounter += 1 self.submitPlotButton = tk.Button( self.xplotFrame, text="Submit", font=("Comic Sans MS", 14), fg="Black", command=lambda: simPlotXY(self.xLog, self.yLog)) self.submitPlotButton.grid(row=self.rowCounter, columnspan=3, sticky=E + W) self.rowCounter += 1 self.exitButton = tk.Button(self.xplotFrame, text="Exit", font=("Comic Sans MS", 14), fg="Red", command=myParent.destroy) self.exitButton.grid(row=self.rowCounter, columnspan=3, stick=E + W) self.rowCounter += 1
def __init__(self, myParent, aBunchOfLogs=mm.BunchOfLogs()): self.getXLogFrame = tk.Frame(myParent) if aBunchOfLogs.NumLogs == 0: self.rowCounter = 0 self.noLogsLabel = tk.Label( self.getXLogFrame, text=" There appears to be no logs for this session ", font=("Comic Sans MS", 16), fg="Blue") self.noLogsLabel.grid(row=self.rowCounter, column=0) self.rowCounter += 1 self.exitButton = tk.Button(self.getXLogFrame, text="Exit", font=("Comic Sans MS", 14), fg="Red", command=myParent.destroy) self.exitButton.grid(row=self.rowCounter, columnspan=3, stick=E + W) else: self.rowCounter = 0 self.pickLogLabel = tk.Label( self.getXLogFrame, text="Pick a log from the list below.", font=("Comic Sans MS", 16), fg="Blue") self.pickLogLabel.grid(row=self.rowCounter, columnspan=3) self.rowCounter += 1 self.idLabel = tk.Label(self.getXLogFrame, text="Log ID", font=("Comic Sans MS", 14), fg="Green") self.idLabel.grid(row=self.rowCounter, column=0) self.typeLabel = tk.Label(self.getXLogFrame, text="Log Type", font=("Comic Sans MS", 14), fg="Green") self.typeLabel.grid(row=self.rowCounter, column=1) self.unitLabel = tk.Label(self.getXLogFrame, text="Log Unit", font=("Comic Sans MS", 14), fg="Green") self.unitLabel.grid(row=self.rowCounter, column=2) self.rowCounter += 1 for self.i in range(aBunchOfLogs.NumLogs): self.LogIdLabel = tk.Label( self.getXLogFrame, text=str(aBunchOfLogs.MyLogLabel[self.i]), font=("Comic Sans MS", 14), fg="Black") self.LogTypeRadioButton = tk.Radiobutton( self.getXLogFrame, text=str(aBunchOfLogs.LogType[self.i]), font=("Comic Sans MS", 14), fg="Black", command=lambda: set_X_VariablesIn( aBunchOfLogs, self.i)) self.LogUnitLabel = tk.Label( self.getXLogFrame, text=str(aBunchOfLogs.TheLog[self.i].ValueUnit), font=("Comic Sans MS", 14), fg="Black") self.rowCounter += 1 self.exitButton = tk.Button(self.getXLogFrame, text="Exit", font=("Comic Sans MS", 14), fg="Red", command=myParent.destroy) self.exitButton.grid(row=self.rowCounter, columnspan=3, stick=E + W)
def __init__(self, parent=tk.Tk(), aBunchOfLogs=mm.BunchOfLogs()): """ Sets up the main control panel for the cross plot """ print "+---------------------------------------------+" print "| |" print "| Start of log cross-ploting function |" print "| |" print "+---------------------------------------------+" self.parent = parent self.localBunchOfLogs = aBunchOfLogs print "\n Currently you have (" + str( self.localBunchOfLogs.numLogs) + ") logs available.\n" self.bigBrother = tk.Toplevel(self.parent) self.bigBrother.wm_title("Cross plotting logs function") if self.localBunchOfLogs.numLogs < 2: print " You need at least 2 logs to make a cross-plot" self.rowCounter = 0 #=================================================================== self.mainXplotLabel = tk.Label( self.bigBrother, text="Need 2 logs to cross-plot. You have (" + str(self.localBunchOfLogs.numLogs) + ") Please clik Exit button.", font=("Comic Sans MS", 18), fg="Blue") self.mainXplotLabel.grid(row=self.rowCounter, columnspan=3, sticky=tk.E + tk.W, padx=20, pady=10) self.rowCounter += 1 #--------------------------------------------------------- self.exitButton = tk.Button(self.bigBrother, text="Exit", font=("Comic Sans MS", 16), fg="Red", command=self.bigBrother.destroy) self.exitButton.grid(row=self.rowCounter, column=1, sticky=tk.E + tk.W, padx=20, pady=10) self.rowCounter += 1 #--------------------------------------------------------- else: self.xIdVariable = tk.StringVar(self.bigBrother) self.xIdVariable.set("None") self.xTypeVariable = tk.StringVar(self.bigBrother) self.xTypeVariable.set("None") self.xLogNumber = tk.IntVar(self.bigBrother) self.xLogNumber.set(0) self.xLog = [] self.yIdVariable = tk.StringVar(self.bigBrother) self.yIdVariable.set("None") self.yTypeVariable = tk.StringVar(self.bigBrother) self.yTypeVariable.set("None") self.yLogNumber = tk.IntVar(self.bigBrother) self.yLogNumber.set(1) self.yLog = [] self.rowCounter = 0 #=================================================================== self.mainXplotLabel = tk.Label(self.bigBrother, text="Log (x,y) plotting function", font=("Comic Sans MS", 18), fg="Blue") self.mainXplotLabel.grid(row=self.rowCounter, columnspan=3, sticky=tk.E + tk.W, padx=20, pady=10) self.rowCounter += 1 #--------------------------------------------------------- self.clickLabel = tk.Label(self.bigBrother, text="Click button below", font=("Comic Sans MS", 16), fg="Green") self.clickLabel.grid(row=self.rowCounter, column=0, padx=10, pady=5) self.idLabel = tk.Label(self.bigBrother, text="Log ID", font=("Comic Sans MS", 16), fg="Green") self.idLabel.grid(row=self.rowCounter, column=1, padx=10, pady=5) self.typeLabel = tk.Label(self.bigBrother, text="Log Type", font=("Comic Sans MS", 16), fg="Green") self.typeLabel.grid(row=self.rowCounter, column=2, padx=10, pady=5) self.rowCounter += 1 #--------------------------------------------------------- self.xLogChooseButton = tk.Button(self.bigBrother, text="Choose X Log", font=("Comic Sans MS", 14), fg="Black", command=self.getXLog) self.xLogChooseButton.grid(row=self.rowCounter, column=0) print " Current chosen x-log ID : " + str(self.xIdVariable.get()) self.xLogIdLabel = tk.Label(self.bigBrother, textvariable=self.xIdVariable, font=("Comic Sans MS", 14), fg="Black") self.xLogIdLabel.grid(row=self.rowCounter, column=1) print " Current chosen x-log Type: " + str( self.xTypeVariable.get()) + "\n" self.xlogTypeLabel = tk.Label(self.bigBrother, textvariable=self.xTypeVariable, font=("Comic Sans MS", 14), fg="Black") self.xlogTypeLabel.grid(row=self.rowCounter, column=2) self.rowCounter += 1 #--------------------------------------------------------- self.yLogChooseButton = tk.Button(self.bigBrother, text="Choose Y Log", font=("Comic Sans MS", 14), fg="Black", command=self.getYLog) self.yLogChooseButton.grid(row=self.rowCounter, column=0) print " Current chosen y-log ID : " + str(self.yIdVariable.get()) self.yLogIdLabel = tk.Label(self.bigBrother, textvariable=self.yIdVariable, font=("Comic Sans MS", 14), fg="Black") self.yLogIdLabel.grid(row=self.rowCounter, column=1) print " Current chosen y-log Type: " + str( self.yTypeVariable.get()) + "\n" self.ylogTypeLabel = tk.Label(self.bigBrother, textvariable=self.yTypeVariable, font=("Comic Sans MS", 14), fg="Black") self.ylogTypeLabel.grid(row=self.rowCounter, column=2) self.rowCounter += 1 #--------------------------------------------------------- self.plotType = tk.StringVar(self.bigBrother) self.plotType.set("line") self.plotTypeLabel = tk.Label(self.bigBrother, text="Choose a plot type below", font=("Comic Sans MS", 16), fg="Green") self.plotTypeLabel.grid(row=self.rowCounter, columnspan=3, sticky=tk.E + tk.W, padx=20, pady=10) self.rowCounter += 1 #--------------------------------------------------------- self.lineButton = tk.Radiobutton(self.bigBrother, text="Line graph", variable=self.plotType, value="line", font=("Comic Sans MS", 14), fg="Black") self.lineButton.grid(row=self.rowCounter, column=0, sticky=tk.W + tk.E, padx=20) self.pointButton = tk.Radiobutton(self.bigBrother, text="Scatter plot", variable=self.plotType, value="point", font=("Comic Sans MS", 14), fg="Black") self.pointButton.grid(row=self.rowCounter, column=1, sticky=tk.W + tk.E, padx=20) self.stepButton = tk.Radiobutton(self.bigBrother, text="Step graph", variable=self.plotType, value="step", font=("Comic Sans MS", 14), fg="Black") self.stepButton.grid(row=self.rowCounter, column=2, sticky=tk.W + tk.E, padx=20) self.rowCounter += 1 #--------------------------------------------------------- self.axisScaleLabel = tk.Label( self.bigBrother, text= "Use sliders below to set relative scale of x and y axis (pixels)", font=("Comic Sans MS", 16), fg="Green") self.axisScaleLabel.grid(row=self.rowCounter, columnspan=3, sticky=tk.E + tk.W, padx=20, pady=10) self.rowCounter += 1 #--------------------------------------------------------- self.ySlideLabel = tk.Label(self.bigBrother, text="Y-axis slider", font=("Comic Sans MS", 14), fg="Black") self.ySlideLabel.grid(row=self.rowCounter, column=0, sticky=tk.E + tk.W) self.xSlideLabel = tk.Label(self.bigBrother, text="X-axis slider", font=("Comic Sans MS", 14), fg="Black") self.xSlideLabel.grid(row=self.rowCounter, column=1, sticky=tk.E + tk.W) self.rowCounter += 1 #--------------------------------------------------------- self.minNumberOfPixels = 100 self.maxNumberOfPixels = 1000 self.xScale = tk.IntVar(self.bigBrother) self.xScale.set(500) self.yScale = tk.IntVar(self.bigBrother) self.yScale.set(500) self.yScaleSlider = tk.Scale(self.bigBrother, variable=self.yScale, from_=self.minNumberOfPixels, to=self.maxNumberOfPixels) self.yScaleSlider.set(500) self.yScaleSlider.grid(row=self.rowCounter, column=0, sticky=tk.E + tk.W, padx=20) self.xScaleSlider = tk.Scale(self.bigBrother, variable=self.xScale, from_=self.minNumberOfPixels, to=self.maxNumberOfPixels, orient=tk.HORIZONTAL) self.xScaleSlider.set(500) self.xScaleSlider.grid(row=self.rowCounter, column=1, sticky=tk.E + tk.W + tk.S, padx=20) self.rowCounter += 1 #--------------------------------------------------------- self.submitPlotButton = tk.Button(self.bigBrother, text="Submit", font=("Comic Sans MS", 16), fg="Black", command=self.pyPlotXY) self.submitPlotButton.grid(row=self.rowCounter, column=1, sticky=tk.E + tk.W, padx=20, pady=5) self.rowCounter += 1 #--------------------------------------------------------- self.exitButton = tk.Button(self.bigBrother, text="Exit", font=("Comic Sans MS", 16), fg="Red", command=self.bigBrother.destroy) self.exitButton.grid(row=self.rowCounter, column=1, sticky=tk.E + tk.W, padx=20, pady=10) self.rowCounter += 1 #--------------------------------------------------------- self.bigBrother.mainloop()