def clear(self): self.textbox_string = '' self.__updateTextBox() self.korvai = Korvai() print 'clear pressed'
def __init__(self): # self.textbox = Tkinter.Label(justify = Tkinter.LEFT) # Tkinter.Button(row_frames[-1], text = '7').pack(side = 'left') self.button_function_ptr = [ self.button_function_0, self.button_function_1, self.button_function_2, self.button_function_3, self.button_function_4, self.button_function_5, self.button_function_6, self.button_function_7, self.button_function_8, self.button_function_9, ] rows = [] for i in range(4): rows.append(Tkinter.Frame()) button_widgets = range(10) # row 0 button_widgets[0] = self.__createButton__(rows[3], 0) button_widgets[1] = self.__createButton__(rows[2], 1) button_widgets[2] = self.__createButton__(rows[2], 2) button_widgets[3] = self.__createButton__(rows[2], 3) button_widgets[4] = self.__createButton__(rows[1], 4) button_widgets[5] = self.__createButton__(rows[1], 5) button_widgets[6] = self.__createButton__(rows[1], 6) button_widgets[7] = self.__createButton__(rows[0], 7) button_widgets[8] = self.__createButton__(rows[0], 8) button_widgets[9] = self.__createButton__(rows[0], 9) for i in range(10): button_widgets[i].pack(side = 'left') clear_button = Tkinter.Button(rows[0], text = 'AC', width = button_width, command = self.clear) clear_button.pack(side = 'left') nadai_button = Tkinter.Button(rows[1], text = 'N', width = button_width, command = self.nadai) nadai_button.pack(side = 'left') thalam_button = Tkinter.Button(rows[2], text = 'T', width = button_width, command = self.thalam) thalam_button.pack(side = 'left') diff_button = Tkinter.Button(rows[3], text = 'D', width = button_width, command = self.diff) diff_button.pack(side = 'left') place_button = Tkinter.Button(rows[3], text = 'P', width = button_width, command = self.place) place_button.pack(side = 'left') enter_button = Tkinter.Button(rows[3], text = '=', width = button_width, command = self.enter) enter_button.pack(side = 'left') self.textbox_string = '' self.textbox = Tkinter.Label() self.textbox.pack() for i in range(4): rows[i].pack() self.korvai = Korvai()
import sys from korvai import Korvai import optparse # Command line flags version_str = """\ Copyright 2005-2013 Suriya Subramanian <*****@*****.**>""" cmdline = optparse.OptionParser(version=version_str) cmdline.add_option('-n', '--nadai', help='the NADAIs to play the Korvais') cmdline.add_option('-t', '--thalam', help='the THALAM') cmdline.add_option('-p', '--place', help='the PLACE') (options, args) = cmdline.parse_args() # Do the work k = Korvai() if (options.nadai is None) or (options.thalam is None) or (options.place is None): print >> sys.stderr, "Usage: %s -h" % sys.argv[0] sys.exit(1) if ' ' in options.nadai: nadais = [[int(j) for j in i] for i in options.nadai.strip().split(' ')] k.setNadais(nadais, does_grouping=True) else: k.setNadais(options.nadai, does_grouping=False) k.setThalam(int(options.thalam)) k.setPlace(0) print 'Samam to Samam', k.getAnswer().getSet() k.setPlace(int(options.place)) print '%4s %5s' % ('Diff', 'Alavu') for d in xrange(0, 50):