#!/usr/bin/env python #RockTest #Programming Competition Team Console, "rt_team", V1.3 #Last modification: January 1, 2005 #RockTest consists primarily of two GUI programs: RockTest Team Console, # and RockTest Judge's Console. There are also a spreadsheet for # tabulation and help files. #Copyright 2003, 2004, 2005 #Michael P. Conlon, Ph.D. #Computer Science Department #Slippery Rock University of Pennsylvania #Slippery Rock, Pennsylvania 16057 #Email: michael.conlon@sru.edu #724-738-2143 #No warranty; distribution and modification is permitted #under the Gnu General Public License, V2 (or later). #See http://www.gnu.org/copyleft/gpl.html for details. #Design Objectives # 1) Make something more dependable than PC^2 (Programming Contest # Control) software in Java from CSUS. # 2) Automate the most common, error-prone, and time-consuming # functions of a computer programming contest. # Thus, file names and working directories are determined by RockTest. # Starting an editor, compiling, and running are reduced to clicks # of command buttons. #Bugs # There must be some! However, even under contest conditions, none have # surfaced. #To do: # Too much hardcoded data. Available programming languages, editors, # and perhaps other things ought to be read from the environment or an # initialization file. # In version 1.3, number of contestants and number of problems are # read from /usr/local/etc/rocktest/rocktest.conf. # Needs automated program submission, ideally via Internet using # strong encryption. # Needs automated notification of judges' decisions. # Needs automated method of submitting problem-clarification requests # to the judges, and an automated means of receiving the responses. # SRU "Rock" icon from Tkinter import * from sys import * from string import * import os import commands import threading root = Tk() COLOR="#c5ffc5" COLOR2="#ffffcc" FALSE=0 TRUE=1 def truncate(text, lines): #Truncate all but "lines" lines from the text. count = 0 i = 0 while i= 0: loc = find(text, '\r') if loc >= 0: text = text[:loc] + text[loc+1:] return text class setup_class: #Creates setup window and initializes variables. def close(self): #Close the "Setup" dialog box. self.set_fns() main_win.enable_all() #That enables too many widgets. Disable the command buttons. main_win.disable() #main_win.set_compile_button() self.win.destroy() def set_fns(self): #Set names of program and data files. self.data_fn.set("program"+self.prob_no.get()+".dat") if self.lang.get()=="BASIC": self.ext = "bas" elif self.lang.get()=="C": self.ext = "c" elif self.lang.get()=="C++": self.ext = "cpp" elif self.lang.get()=="FORTRAN": self.ext = "for" elif self.lang.get()=="Java": self.ext = "java" elif self.lang.get()=="Pascal": self.ext = "pas" elif self.lang.get()=="Python": self.ext = "py" else: print "Unknown language. This shouldn't happen." sys.exit(1) self.prog_fn.set("program"+self.prob_no.get()+"."+self.ext) return def setup(self): #Create dialog box. #First, disable the buttons in the main window. main_win.disable_all() self.win=Toplevel(root, bg=COLOR) self.win.transient(root) self.win.title("RockTest Client Setup") self.main_frame=Frame(self.win, bg=COLOR, width=500) #Display menu of available editors. self.ed_frame = Frame(self.main_frame, relief=RIDGE,\ borderwidth=3, bg=COLOR2) pathvar = split(os.environ["PATH"].replace(":", " ")) Label(self.ed_frame, text="Choose your editor:", bg=COLOR2,\ fg="darkgreen").grid(row=0, column=0, columnspan=2) row_no=-1 for ed in self.editors: #print "ed = ", ed found=FALSE for path in pathvar: # print "Looking for ", path+"/"+ed[0] if os.path.exists(path+"/"+ed[0]): found=TRUE break if found: #print "Found ", ed[1] row_no = row_no + 1 Radiobutton(self.ed_frame, text=ed[1], variable=self.editor, \ bg=COLOR2, value=ed[1]).grid(row=row_no, column=0, sticky=W) Label(self.ed_frame, text=ed[2], bg=COLOR2).grid(row=row_no, column=1, sticky=W) self.ed_frame.pack(side=TOP) #self.db_frame=Frame(self.main_frame, relief=RIDGE, borderwidth=3, # bg=COLOR) #Label(self.db_frame, text="Choose your debugger:", bg=COLOR)\ # .grid(row=0, column=0, columnspan=2, sticky=W) #self.b5=Radiobutton(self.db_frame, text="Kdbg", variable=self.debugger, \ # bg=COLOR2, value="Kdbg").grid(row=1, column=0, sticky=W) #self.l5=Label(self.db_frame, text="Easy-to-use GUI debugger", bg=COLOR)\ # .grid(row=1, column=1, sticky=W) #self.b6=Radiobutton(self.db_frame, text="Gdbg", variable=self.debugger, \ # bg=COLOR2, value="Gdbg").grid(row=2, column=0, sticky=W) #self.l6=Label(self.db_frame, text="Warning: not for newbies", bg=COLOR)\ # .grid(row=2, column=1, sticky=W) #self.b7=Radiobutton(self.db_frame, text="none", variable=self.debugger, \ # bg=COLOR2, value="").grid(row=3, column=0, sticky=W) #self.l7=Label(self.db_frame, text="I don't use debuggers.", bg=COLOR)\ # .grid(row=3, column=1, sticky=W) #self.db_frame.grid(row=0, column=2, sticky=W+N) self.l_frame = Frame(self.main_frame, relief=RIDGE, borderwidth=3, \ bg=COLOR2) Label(self.l_frame, text="Choose your programming language:", bg=COLOR2, \ fg="darkgreen").grid(row=0, column=0, columnspan=3) lang_no = -1 for lang in self.avail_langs: lang_no = lang_no + 1 Radiobutton(self.l_frame, text=lang, variable=self.lang, bg=COLOR2, \ value=lang).grid(row=1+lang_no/4, column=lang_no%4) self.l_frame.pack(side=TOP, expand=YES, fill=X) self.kill_frame = Frame(self.main_frame, relief=RIDGE, borderwidth=3, \ bg=COLOR2) Label(self.kill_frame, text="Maximum runtime per program\n" +\ "(10 seconds is usually best):", bg=COLOR2, \ fg="darkgreen").grid(row=0, column=0, columnspan=4) self.bk1 = Radiobutton(self.kill_frame, text="10 sec", variable= self.runlimit, bg=COLOR2, value="10").grid(row=1, column=0) self.bk2 = Radiobutton(self.kill_frame, text="30 sec", variable= self.runlimit, bg=COLOR2, value="30").grid(row=1, column=1) self.bk3 = Radiobutton(self.kill_frame, text="1 min", variable= self.runlimit, bg=COLOR2, value="60").grid(row=1, column=2) self.bk4 = Radiobutton(self.kill_frame, text="5 min", variable= self.runlimit, bg=COLOR2, value="300").grid(row=1, column=3) self.kill_frame.pack(side=TOP, expand=YES, fill=X) self.ok_button=Button(self.main_frame, text="OK",\ command=self.close).pack(side=TOP, expand=YES) self.main_frame.pack(padx=20, pady=20) return def __init__(self): #Get program parameters. #Is there a configuration file? try: #if 1: #If there is, get parameters from the file. fd = open('/usr/local/etc/rocktest/rocktest.conf') self.data = fd.readlines() #print self.data #sys.exit(1) for self.line in self.data: self.line = self.line[:-1] #print "Line:", self.line if self.line[:13] == "problem_count": self.prob_count = atoi(self.line[14:]) elif self.line[:7]=="printer": self.printer=self.line[8:] #elif self.line[:15] == "language_count": #self.language_ct = atoi(self.line[16:]) #for i in range(self.language_ct): #pass fd.close() #print "File closed." #sys.exit(1) #else: except: #print "Error processing initialization file." self.prob_count = 10 self.printer = "ECBITLAB" self.prob_list = () for i in range(1, self.prob_count+1): self.prob_list = self.prob_list + (str(i),) self.runlimit = StringVar() self.runlimit.set("10") #10-second default maximum program run time #Get team name from $USER environment variable. self.team = os.environ["USER"] self.team = self.team[4:] root.title("RockTest: Team #" + self.team) self.editor = StringVar() self.debugger = StringVar() self.lang = StringVar() self.prog_fn = StringVar() self.data_fn = StringVar() self.prob_no = StringVar() self.editor.set("KWrite") self.debugger.set("Kdbg") self.lang.set("C++") self.prog_fn.set("program1.cpp") self.prob_no.set("1") self.data_fn.set("program1.dat") self.has_debugger = ("C", "C++", "Pascal") self.avail_langs = "BASIC", "C", "C++", "FORTRAN", "Java", "Pascal", "Python" self.lang_dict = {"BASIC":"bas", "C":"c", "C++":"cpp", "FORTRAN":"for", \ "Java":"java", "Pascal":"pas", "Python":"py"} self.editors = (("dtpad", "DTPad", "Powerful, Easy-to-use GUI editor"), ("kwrite", "KWrite", "Powerful easy-to-use GUI editor"), ("kedit", "KEdit", "Easy-to-use GUI editor"), ("pico", "Pico", "Easy-to-use text-based editor"), ("vi", "Vi", "Warning: not for newbies"), ("emacs", "Emacs", "Warning: not for newbies"), ("xedit", "XEdit", "Simple GUI editor")) return class info_box_class: def __init__(self, parent, name, text, but_text, just): self.msg=StringVar() self.msg.set(text) self.parent = parent self.name = name self.button_text = but_text self.just = just def close(self): #Close the info box. self.info_box.destroy() def create(self): #Create the dialog box. self.info_box=Toplevel(self.parent, bg=COLOR2) self.info_box.title(self.name) self.abt_msg=Message(self.info_box, textvariable=self.msg, justify=self.just, aspect=300, width=400, bg=COLOR2).pack(side=TOP) self.ok_button=Button(self.info_box, text=self.button_text) self.ok_button.configure(command=lambda obj=self: obj.close()) self.ok_button.pack(side=BOTTOM) #Create "About RockTest" info box. box_name="About RockTest" but_text="Close" msg="""RockTest Team Console, V. 1.3 Copyright 2003-2005 Michael P. Conlon, Ph.D., Computer Science Department, Slippery Rock University Email: michael.conlon@sru.edu No warranty; distribution and modification is permitted under the Gnu General Public License, V2 (or later). See http://www.gnu.org/copyleft/gpl.html for details.""" about_info_box=info_box_class(root, box_name, msg, but_text, CENTER) #Create "Printing" info box. box_name="Printing" but_text="Close" msg=""" Your file has been submitted for printing. A proctor should deliver your printout shortly, or you could ask a proctor to check the printer for your printout. """ printing_file_box=info_box_class(root, box_name, msg, but_text, CENTER) #Create "Printing failure" info box. box_name="Printing Failure" but_text="Close" msg=""" Printing failure. Unable to print your file. No diagnosis available. """ printing_failure_box=info_box_class(root, box_name, msg, but_text, CENTER) #Create "No program file" info box. box_name="No program file" but_text="Close" msg=""" The program file that you have attempted to process does not exist. Click on "Edit" in the "Program File" pane to create the file. It is also possible that the program file exists, but you have the incorrect "Language" setting. """ no_prog_file_box=info_box_class(root, box_name, msg, but_text, CENTER) #Create "No data file" info box. box_name="No data file" but_text="Close" msg=""" The data file that you have attempted to process does not exist. Click on "Edit" in the "Data File" pane to create the file. If the current program does not require data, create an empty data file. This version of RockTest always expects a data file. """ no_data_file_box=info_box_class(root, box_name, msg, but_text, CENTER) #Create "No machine language file" info box. box_name="No machine language file" but_text="Close" msg=""" The machine language program file that you have attempted to run does not exist. Assuming the source code file for this problem exists, click on "Compile" in the "Program File" pane to compile your source code file. """ no_ml_file_box=info_box_class(root, box_name, msg, but_text, CENTER) #Create "Editor window already open" info box. box_name="Editor window already open" but_text="Close" msg=""" There is already a running editor that is editing this file. You should not have two editors editing the same file. Find the existing editor window and continue editing the file in that window. """ dup_editor_req_box=info_box_class(root, box_name, msg, but_text, CENTER) #Create "Excessive run time" info box. box_name="Runtime Limit Exceeded" but_text="Close" msg=""" Your program has exceeded the allowable run time. Check your program for endless loops or other causes of inefficient execution. You may adjust the runtime limit in the "Setup" dialog. Click on File/Setup to reopen the Setup dialog.""" excess_run_time_box=info_box_class(root, box_name, msg, but_text, CENTER) #Create "Help" info box. box_name="Help" but_text="Close" msg=""" 1) If you have not already done so, choose an editor and programming language by clicking on File-->Setup. Click on the "OK" button when done. The "Setup" dialog box will close. 2) Choose the number of the problem on which you wish to work. Change the programming language if you wish. Click "OK". (You must click on "OK" after changing either the "Problem #" or "Language" at any time.) 3) In the "Program File" pane, click on "Edit" to create or edit your program. In the "Data File" pane, click on "Edit" to create or edit your test data file. This version of RockTest requires that every program have a data file. If a problem doesn't need data, create an empty data file. 4) In the "Program File" pane, click on "Compile" or "Run" to compile or run your program. The "Compile" button is unavailable (and unnecessary) when you use an interpreted language such as BASIC or Python. When your program runs, it will automatically use the data file indicated in the "Data File" pane as standard input. 5) Repeat the steps above as appropriate. 6) To obtain a printout of your program or data file, click on "File/Print program file" or "File/Print data file". Java Programmers: the class enclosing the "main" method must have the same name as the program file, minus the ".java", for each program! E.g., for file "program3.java" the class must be called "program3", or the program will not compile. """ help_box=info_box_class(root, box_name, msg, but_text, LEFT) def edit_data(): #Some editors won't save an empty file (e.g., KWrite). try: if not (config.data_fn.get() in os.listdir("~")): os.system("touch %s" % config.data_fn.get()) except OSError: os.system("touch %s" % config.data_fn.get()) #Check to see whether the editor is already running. #For some reason, commands.getstatus() won't work for the following: status, output = commands.getstatusoutput( #For Linux 'ps -axo user,args | grep ^team%s| grep -i "%s %s" | grep -v grep' #For Solaris #'ps -eo user,args | grep ^team%s| grep -i "%s %s" | grep -v grep' % (config.team, config.editor.get(), config.data_fn.get())) if status == 0: dup_editor_req_box.create() return #Launch editor. command = lower(config.editor.get()) #Vi and Emacs need to be launched inside a console window. if config.editor.get() in ("Vi", "Emacs"): command = "konsole -e " + command command = command + " " + config.data_fn.get() + "&" #print "Command is:" + command os.system(command) def edit_program(): #Create file so ownerships are correct. try: if not (config.prog_fn.get() in os.listdir("~")): os.system("touch %s" % config.prog_fn.get()) except OSError: os.system("touch %s" % config.prog_fn.get()) os.system("whoami") #Check to see whether the editor is already running. #For some reason, commands.getstatus() won't work for the following: status, output = commands.getstatusoutput( #For Linux 'ps -axo user,args | grep ^team%s| grep -i "%s %s" | grep -v grep' #For Solaris #'ps -eo user,args | grep ^team%s| grep -i "%s %s" | grep -v grep' % (config.team, config.editor.get(), config.prog_fn.get())) if status == 0: dup_editor_req_box.create() return #Launch editor. command = lower(config.editor.get()) #Vi and Emacs need to be launched inside a console window. if config.editor.get() in ("Vi", "Emacs"): command = "konsole -e " + command command = command + " " + config.prog_fn.get() + "&" #print "Command is:" + command os.system(command) def compile_program(): lang = config.lang.get() pn = config.prob_no.get() fn = config.prog_fn.get() #Does program file exist? if fn not in os.listdir("."): no_prog_file_box.create() return #Set group ownership and permissions. #Eventually, this should move to a "submit" section. os.system("chmod 660 %s" % fn) #This may not be necessary. main_win.textbox.delete(1.0, END) try: os.remove(fn[:find(fn,'.')]) #Delete old executable. except: pass if lang=="C": status, output = commands.getstatusoutput("gcc -lm -o %s %s" % \ (fn[:find(fn,'.')], fn)) if status == 0 and output == "": output = output + "Compile successful.\n" elif lang=="C++": status, output = commands.getstatusoutput("g++ -lm -o %s %s" % \ (fn[:find(fn,'.')], fn)) if status == 0 and output == "": output = output + "Compile successful.\n" elif lang=="FORTRAN": status, output = commands.getstatusoutput("f77 -o %s %s" % \ (fn[:find(fn,'.')], fn)) if status == 0 and output == "": output = output + "Compile successful.\n" elif lang=="Java": status, output = commands.getstatusoutput("gcj --main=%s -o %s %s" % \ (fn[:find(fn,'.')], fn[:find(fn,'.')], fn)) if status == 0 and output == "": output = output + "Compile successful.\n" elif lang == "Pascal": status, output = commands.getstatusoutput( "fpc -Co -Cr -o%s -Se10 -vew %s" % (fn[:find(fn,'.')], fn)) if status == 0 or output == "": output = output + "Compile successful.\n" #Using fpc compiler. main_win.textbox.delete(1.0, END) main_win.textbox.insert(END, output) def kill_program(pfn): #print "Entering 'kill_program()'" #Kill a user program that's been running too long. #First, find the pid of the running program. #Actually, there are several processes to kill. for proc in os.popen( #This works in RedHat Linux 'ps -axo pid,user,args | grep team%s | grep -i \"%s\" | grep -v grep' % (config.team, pfn)).readlines(): #This should work in Solaris #'ps -eo pid,user,args | grep team%s | grep -i \"%s\" | grep -v grep' % (config.team, #pfn)).readlines(): pid = split(proc)[0] #Now kill it! os.system("kill -9 %s" % pid) excess_run_time_box.create() return class Execute(threading.Thread): def run(self): lang = config.lang.get() dfn = config.data_fn.get() pfn = config.prog_fn.get() #Convert runlimit to milliseconds, and to an int. runlimit = atoi(config.runlimit.get()) * 1000 #Set a limit timer to stop runaway programs. id = root.after(runlimit, kill_program, pfn[:find(pfn, '.')]) if lang == "BASIC": output = commands.getoutput("nice -19 bwbasic %s < %s" % (pfn, dfn)) #Remove carriage returns from BwBASIC's output. output = strip_cr(output) #Remove BWBASIC: prompt from last line of output. loc = rfind(output, '\n') output = output[:loc+1] #Remove "? " prompt from input statement's output. loc = 99999 while loc >=0: loc = find(output, '\n? ') if loc >=0: output = output[:loc] + output[loc+3:] #For JDK Java #elif lang == "Java": #output = commands.getoutput("nice -19 java %s < %s" % (pfn[:find(pfn, '.')], dfn)) #For gcj java and other compiled languages elif lang in ("C", "C++", "FORTRAN", "Java", "Pascal"): output = commands.getoutput("nice -19 ./%s < %s" % (pfn[:find(pfn, '.')], dfn)) elif lang == "Python": output = commands.getoutput("nice -19 python %s < %s" % (pfn, dfn)) else: print "Error. Undefined programming language." sys.exit(1) #Cancel program-kill if the program completes in a timely fashion. root.after_cancel(id) main_win.textbox.insert(END, output) def run_program(): lang = config.lang.get() dfn = config.data_fn.get() pfn = config.prog_fn.get() #Does program file exist? if pfn not in os.listdir("."): no_prog_file_box.create() return #Does data file exist? if dfn not in os.listdir("."): no_data_file_box.create() return #Does machine code file exist? #For JDK Java #if lang == "Java": #if not ((pfn[:find(pfn,".")] + ".class") in os.listdir(".")): #print "Class file not found." #no_ml_file_box.create() #return #elif (Remove "if" from next line if uncommenting this.) if not (lang in ("BASIC", "Python")): if not pfn[:find(pfn,".")] in os.listdir("."): no_ml_file_box.create() return #Clear previous output. main_win.textbox.delete(1.0, END) #Execute the program as a separate thread. Execute().start() class main_win_class: def __init__(self, root): root.minsize(467, 350) w=760 h=50 #Build menubar and drop-down menus. self.menubar = Menu(root, relief=SUNKEN) #Create a pulldown file menu, and add it to the menu bar. self.file_menu=Menu(self.menubar, tearoff=0) self.file_menu.add_command(label="Setup...", command=config.setup) self.file_menu.add_separator() self.file_menu.add_command(label="Print program file", command=self.print_pf) self.file_menu.add_command(label="Print data file", command=self.print_df) self.file_menu.add_separator() self.file_menu.add_command(label="Quit", command=root.quit) self.menubar.add_cascade(label="File", menu=self.file_menu) #Create a pulldown help menu, and add it to the menu bar. self.help_menu=Menu(self.menubar, tearoff=0) self.help_menu.add_command(label="Help...", command=help_box.create) self.help_menu.add_command(label="About RockTest...", command=about_info_box.create) self.menubar.add_cascade(label="Help", menu=self.help_menu) root.config(menu=self.menubar) self.setup_frame = Frame(root, bg=COLOR, borderwidth=3,\ relief=RIDGE, height=h, width=w) self.text1_1= Label(self.setup_frame, text="Problem #", bg=COLOR)\ .place(anchor=W, x=0, rely=0.5) self.prob_opt = OptionMenu(self.setup_frame, config.prob_no, *config.prob_list) self.prob_opt.bind('', lambda event, obj=self: \ obj.disable(), '+') self.prob_opt.place(anchor=W, x=70, rely=0.5) self.text1_2 = Label(self.setup_frame, text="Language", bg=COLOR) self.text1_2.place(anchor=W, x=139, rely=0.5) self.lang_opt = OptionMenu(self.setup_frame, config.lang, *config.avail_langs) #self.lang_opt = OptionMenu(self.setup_frame, config.lang, "BASIC", \ # "C", "C++", "FORTRAN", "Java", "Pascal", "Python") self.lang_opt.bind('', lambda event, obj=self: \ obj.disable(), '+') self.lang_opt.place(anchor=W, x=200, rely=0.5) self.okay_but = Button(self.setup_frame, text="OK", command=self.okay) self.okay_but.place(anchor=E, relx=1.0, rely=0.5) self.file_frame = Frame(root, bg=COLOR, height=h, width=w) self.prog_frame = Frame(self.file_frame, borderwidth=3,\ relief=RIDGE, bg=COLOR) self.prog_fn_label = Label(self.prog_frame, text = "Program File", \ bg=COLOR).grid(row=0, column=0) self.prog_fn_entry = Label(self.prog_frame, width=12, relief=SUNKEN, bg=COLOR2) self.prog_fn_entry.grid(row=1, column=0) self.pedit_but = Button(self.prog_frame, text="Edit", width=4, \ command=edit_program) self.pedit_but.grid(row=0, column=1, rowspan=2) self.compile_but = Button(self.prog_frame, text="Compile", width=4, \ command=compile_program) self.compile_but.grid(row=0, column=2, rowspan=2) self.run_but = Button(self.prog_frame, text="Run", width=4, \ command=run_program) self.run_but.grid(row=0, column=3, rowspan=2) self.prog_frame.place(anchor=W, x=0, rely=0.5) self.data_frame = Frame(self.file_frame, borderwidth=3,\ relief=RIDGE, bg=COLOR) self.data_fn_label = Label(self.data_frame, text="Data File",\ bg=COLOR).grid(row=0, column=0) self.data_fn_entry = Label(self.data_frame, width=12, relief=SUNKEN, bg=COLOR2) self.data_fn_entry.grid(row=1, column=0) self.dedit_but = Button(self.data_frame, text="Edit", width=4, \ command=edit_data) self.dedit_but.grid(row=0, column=2, rowspan=2) self.data_frame.place(anchor=W, x=300, rely=0.5) self.action_frame=Frame(root, bg=COLOR2, borderwidth=3,\ relief=RIDGE, height=300) self.textbox = Text(self.action_frame, wrap=WORD, width=81, height=20, font=("Courier", 10), bg=COLOR2) self.vscroll = Scrollbar(self.action_frame, command=self.textbox.yview) self.textbox.configure(yscrollcommand=self.vscroll.set) self.vscroll.place(anchor=NE, relx=1.0, y=0, width=17, relheight=0.68) self.textbox.place(x=0, y=0, relwidth=0.96, relheight=0.68) self.setup_frame.place(x=0, y=0, relwidth=1.0, height=h+2) self.file_frame.place(x=0, y=h+2, relwidth=1.0, height=h+2) self.action_frame.place(x=0, y=2*h+4, relwidth=1.0, relheight=1.0) self.disable() def disable(self): self.pedit_but.configure(state = DISABLED) self.compile_but.configure(state = DISABLED) self.run_but.configure(state = DISABLED) self.dedit_but.configure(state = DISABLED) def disable_all(self): self.disable() self.prob_opt.configure(state = DISABLED) self.lang_opt.configure(state = DISABLED) self.okay_but.configure(state = DISABLED) def enable(self): self.pedit_but.configure(state = NORMAL) self.compile_but.configure(state = NORMAL) self.run_but.configure(state = NORMAL) self.dedit_but.configure(state = NORMAL) def enable_all(self): self.enable() self.prob_opt.configure(state = NORMAL) self.lang_opt.configure(state = NORMAL) self.okay_but.configure(state = NORMAL) def set_compile_button(self): if config.lang.get() in ("BASIC", "Python"): self.compile_but.configure(state = DISABLED) else: self.compile_but.configure(state = NORMAL) def okay(self): config.set_fns() os.system("touch %s" % config.data_fn.get()) self.enable() self.set_compile_button() def print_pf(self): global msg banner = " ******** Printed for Team %s ********\n\n" % \ config.team #Command for gnu echo: command = 'echo -e "%s" > rt_temp' % banner #Command for Solaris' echo: #command = 'echo "%s" > rt_temp' % banner os.system (command) command = 'cat %s >> rt_temp' % config.prog_fn.get() os.system(command) #Print command for Berkeley lpr: status, output = commands.getstatusoutput("lpr -P %s rt_temp" % config.printer) #Print command for Solaris (SysV?) lp: #status, output = commands.getstatusoutput("lp rt_temp") if status == 0: printing_file_box.create() else: msg = output printing_failure_box.create() return def print_df(self): global msg banner = " ******** Printed for Team %s ********\n\n" % \ config.team #Command for gnu echo: command = 'echo -e "%s" > rt_temp' % banner #Command for Solaris (SysV?) echo: #command = 'echo -e "%s" > rt_temp' % banner os.system (command) command = 'cat %s >> rt_temp' % config.data_fn.get() os.system(command) #Print command for Berkeley lpr: status, output = commands.getstatusoutput("lpr -P %s rt_temp" % config.printer) #Print command for Solaris (SysV?) lp: #status, output = commands.getstatusoutput("lp rt_temp") if status == 0: printing_file_box.create() else: msg = output printing_failure_box.create() return config = setup_class() main_win = main_win_class(root) #Configure widgets with dependencies on other objects. main_win.prog_fn_entry.configure(textvariable = config.prog_fn) main_win.data_fn_entry.configure(textvariable = config.data_fn) config.setup() root.mainloop()