Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions OmsiGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand All @@ -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
Expand Down Expand Up @@ -322,14 +328,17 @@ 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"
tkMessageBox.showinfo("Run", msg)
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)
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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}". \
Expand Down