From 89a30b3b3d7f96d9ef1b953faf6d872685b7bd31 Mon Sep 17 00:00:00 2001 From: Chase Maguire Date: Sat, 9 Mar 2019 00:12:23 -0800 Subject: [PATCH 1/3] Working for linux machines --- OmsiGui.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/OmsiGui.py b/OmsiGui.py index aca2118..fd12c5a 100644 --- a/OmsiGui.py +++ b/OmsiGui.py @@ -253,6 +253,7 @@ def copyQtoA(self): def viewPDF(self): os.system(self.pdfCmd) + def runProgram(self, qNum = None): self.submitAnswer() runCmd = "" @@ -267,10 +268,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 +321,13 @@ def runProgram(self, qNum = None): join(outfile.readlines()) + "\n" outfile.close() os.remove("errfile") - os.remove("o_" + str(qNum)) + os.remove("o_" + str(qNum)) + try: + os.system("evince Rplots.pdf") + pass + except: + os.system(self.pdfCmd.split(' ')[] + " Rplots.pdf") + pass else: # this question does not allow run msg = "\nNot authorised!\n" @@ -330,6 +335,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) @@ -599,7 +606,6 @@ def widgets(self): pWindow.pack(fill=BOTH, expand=1, pady=5) # self.loadQuestionsFromFile() - def main(): top = Tk() top.geometry("{0}x{1}". \ From 2a0b4c502faa519dd235c1115e787a7a12242d06 Mon Sep 17 00:00:00 2001 From: Chase Maguire Date: Sat, 9 Mar 2019 12:05:36 -0800 Subject: [PATCH 2/3] Testing on windows --- OmsiGui.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/OmsiGui.py b/OmsiGui.py index fd12c5a..df95df3 100644 --- a/OmsiGui.py +++ b/OmsiGui.py @@ -322,12 +322,13 @@ def runProgram(self, qNum = None): outfile.close() os.remove("errfile") os.remove("o_" + str(qNum)) - try: - os.system("evince Rplots.pdf") - pass - except: - os.system(self.pdfCmd.split(' ')[] + " Rplots.pdf") - pass + if self.pdfCmd != None: + try: + os.system(self.pdfCmd.split(' ')[0] + " Rplots.pdf") + pass + except: + tkMessageBox.showwarning("Error with open command!") + else: # this question does not allow run msg = "\nNot authorised!\n" From 52448462286e4c683be95adb807a6de50137d695 Mon Sep 17 00:00:00 2001 From: Chase Maguire Date: Sat, 9 Mar 2019 12:14:15 -0800 Subject: [PATCH 3/3] Moving command to a dropdown option --- OmsiGui.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/OmsiGui.py b/OmsiGui.py index df95df3..06121cb 100644 --- a/OmsiGui.py +++ b/OmsiGui.py @@ -253,6 +253,13 @@ 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() @@ -322,12 +329,6 @@ def runProgram(self, qNum = None): outfile.close() os.remove("errfile") os.remove("o_" + str(qNum)) - if self.pdfCmd != None: - try: - os.system(self.pdfCmd.split(' ')[0] + " Rplots.pdf") - pass - except: - tkMessageBox.showwarning("Error with open command!") else: # this question does not allow run @@ -539,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()