diff --git a/OmsiGui.py b/OmsiGui.py index aca2118..06121cb 100644 --- a/OmsiGui.py +++ b/OmsiGui.py @@ -253,6 +253,14 @@ def copyQtoA(self): def viewPDF(self): os.system(self.pdfCmd) + def viewGraph(self): + if self.pdfCmd != None: + try: + os.system(self.pdfCmd.split(' ')[0] + " Rplots.pdf") + pass + except: + tkMessageBox.showwarning("Error with open command!") + def runProgram(self, qNum = None): self.submitAnswer() runCmd = "" @@ -267,10 +275,8 @@ def runProgram(self, qNum = None): #check if this program can be "run" fType = self.QuestionsArr[qNum].getFiletype() #file type #name of the file to be compiled - fName = "omsi_answer{0}{1}". \ - format(qNum, self.QuestionsArr[qNum].getFiletype()) + fName = "omsi_answer{0}{1}".format(qNum, fType) compileProg = self.QuestionsArr[qNum].getCompileProgram() - if compileProg == 'y': #check if executable exists (if required) execName = "omsi_answer" + str(qNum) #name of the executable @@ -322,7 +328,8 @@ def runProgram(self, qNum = None): join(outfile.readlines()) + "\n" outfile.close() os.remove("errfile") - os.remove("o_" + str(qNum)) + os.remove("o_" + str(qNum)) + else: # this question does not allow run msg = "\nNot authorised!\n" @@ -330,6 +337,8 @@ def runProgram(self, qNum = None): return False # display msg in pop-up box + # Display the image that was created here as well + # Or create a new popup fileWin = Toplevel(self.parent) text = Text(fileWin) text.insert(END,msg) @@ -531,6 +540,7 @@ def widgets(self): filemenu.add_command(label="Submit & Run", command=self.runProgram) filemenu.add_command(label="CopyQtoA", command=self.copyQtoA) filemenu.add_command(label="View PDF", command=self.viewPDF) + filemenu.add_command(label="View R graphs", command=self.viewGraph) filemenu.add_separator() @@ -599,7 +609,6 @@ def widgets(self): pWindow.pack(fill=BOTH, expand=1, pady=5) # self.loadQuestionsFromFile() - def main(): top = Tk() top.geometry("{0}x{1}". \