The-ITu
May 17th, 2009, 03:07 AM
here is the code:
import os from Tkinter import * def cls(): os.system(['clear', 'cls'][os.name=='nt']) print 'This is a Tk button creater!' raw_input("press enter to continue") cls() amountOfButtons = input("how many buttons do you want? (max 10) >>> ") amountOfButtons = amountOfButtons + 1 tkTitle = raw_input('what would you like the title of the canvas to be? >>> ') while amountOfButtons > 10: print "that is an in correct value." amountOfButtons = input("how many buttons do you want? (max 10) >>> ") command1, command2, command3, command4, command5, command6, command7, command8, command9, command10 = ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' listOfComands = [command1, command2, command3, command4, command5, command6, command7, command8, command9, command10] text1, text2, text3, text4, text5, text6, text7, buton8, text9, text10 = ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' listOfButtonComands = [text1, text2, text3, text4, text5, text6, text7, buton8, text9, text10] for x in range (1, amountOfButtons): rv = str(x) listOfComands[x] = raw_input("what do you want button %s to to have writen on it? >>> " % rv) for i in range (1, amountOfButtons): rvi = str(i) listOfButtonComands[i] = raw_input("what do you want button %s to return >>> " % rvi) def pnt(num): print listOfButtonComands[num] canvasHeight = input("how high do you want your canvas? >>> ") canvasWidth = input("how wide do you want your canvas? >>> ") cls() raw_input("press enter to create!!") cls() root = Tk() root.title(tkTitle) canvas = Canvas(root, height=canvasHeight, width=canvasWidth) canvas.pack() for g in range (1, amountOfButtons): btn = Button(root, text = listOfButtonComands[g], command = pnt(g)) btn.pack() raw_input()now the problem is in line 17 and 18 where im trying to make a list of empty variables but it tell me that they are not defined. how can i get past this?is
import os from Tkinter import * def cls(): os.system(['clear', 'cls'][os.name=='nt']) print 'This is a Tk button creater!' raw_input("press enter to continue") cls() amountOfButtons = input("how many buttons do you want? (max 10) >>> ") amountOfButtons = amountOfButtons + 1 tkTitle = raw_input('what would you like the title of the canvas to be? >>> ') while amountOfButtons > 10: print "that is an in correct value." amountOfButtons = input("how many buttons do you want? (max 10) >>> ") command1, command2, command3, command4, command5, command6, command7, command8, command9, command10 = ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' listOfComands = [command1, command2, command3, command4, command5, command6, command7, command8, command9, command10] text1, text2, text3, text4, text5, text6, text7, buton8, text9, text10 = ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' listOfButtonComands = [text1, text2, text3, text4, text5, text6, text7, buton8, text9, text10] for x in range (1, amountOfButtons): rv = str(x) listOfComands[x] = raw_input("what do you want button %s to to have writen on it? >>> " % rv) for i in range (1, amountOfButtons): rvi = str(i) listOfButtonComands[i] = raw_input("what do you want button %s to return >>> " % rvi) def pnt(num): print listOfButtonComands[num] canvasHeight = input("how high do you want your canvas? >>> ") canvasWidth = input("how wide do you want your canvas? >>> ") cls() raw_input("press enter to create!!") cls() root = Tk() root.title(tkTitle) canvas = Canvas(root, height=canvasHeight, width=canvasWidth) canvas.pack() for g in range (1, amountOfButtons): btn = Button(root, text = listOfButtonComands[g], command = pnt(g)) btn.pack() raw_input()now the problem is in line 17 and 18 where im trying to make a list of empty variables but it tell me that they are not defined. how can i get past this?is