Instead of creating my buttons and waiting for me to press them to
execute they are executing when I create them and won't do my callback
when I press them.. thanks for any help in advance
button[num] = Tkinter.Button( frame,text = returnstring,
command=callbac k(returnstring) )#
this line executes on creation
my output on startup is (should output when I choose an option)
1 String pad
10 Chorus
25 Reverb
30 Mixer
The buttons do label correctly.
title = 'csd instrument list'
# Import Pmw from this directory tree.
import sys
sys.path[:0] = ['../../..']
import Tkinter
import Pmw
import csoundroutines
class Demo:
def __init__(self, parent):
frame = Tkinter.Frame(p arent)
frame.pack(fill = 'both', expand = 1)
button = {}
instr = [[]]
instr = csoundroutines. csdInstrumentLi st2(sys.argv[1])
num = 0 #instr_number
buttonBox = Pmw.ButtonBox(p arent)
for i in range(0, len(instr.instr num)):
num += 1
returnstring = instr.instrnum[i] +' '+ str(instr.comme nts[i])
#printstring = zz + x[num]
button[num] = Tkinter.Button( frame,text = returnstring,
command=callbac k(returnstring) )#kinter.Button str(x[0]) + ' ' + x[1])# +
comments)
button[num].pack()
#returnstring = zz
button[num].grid(column=nu m, row =
0)#,command=cal lback(returnstr ing))
#button[num].pack()
frame.grid_rowc onfigure(3, weight=1)
frame.grid_colu mnconfigure(3, weight=1)
frame.pack()
def callback(text):
print text
############### ############### ############### ############### ##########
# Create demo in root window for testing.
if __name__ == '__main__':
global filename
filename = (sys.argv[1])
root = Tkinter.Tk()
Pmw.initialise( root)
root.title(titl e)
exitButton = Tkinter.Button( root, text = 'Exit', command =
root.destroy)
exitButton.pack (side = 'bottom')
widget = Demo(root)
root.mainloop()
http://www.dexrow.com