Every time I do this it creates the buttons automatically but it will not execute the command when the button is pressed, is it possible, and if so how do I do it?
from tkinter import *
class MainWindow():
def __init__(self):
def printing():
print("This is going to print:", i)
def ButtMaker1(frame1,title,CMDVar,xLoc,yLoc):
print(title,xLoc,yLoc)
Title = title
cmdVar = CMDVar()
FrameAnchor = frame1
NewButton = Button(FrameAnchor, text = Title, command = cmdVar)
NewButton.grid(row = xLoc, column = yLoc)
window = Tk()
frame1 = Frame(window)
frame1.grid(row =1, column = 1)
for i in range(10):
print(i)
title = ("Bob is :" + str(i))
xLoc = i
yLoc = i + 1
CMDVar = printing
ButtMaker1(frame1,title,CMDVar,xLoc,yLoc)
window.mainloop()
<MainWindow()
cmdVar = CMDVar()->cmdVar = CMDVar