I'm not entirely sure how to phrase my question in one sentence. I am using python to create a calendar with the ability to log mileage for athletes. I have a calendar made that contains a 7x4 grid containing the number of the month in the upper left corner and a button in the center that says "log today's workout."
The button is supposed to open a new window, allow for the user to enter mileage ran and how quickly, and when the user presses "log" at the bottom of the new window, it should display the mileage and pace on the day that the button was pressed.
My problem is that I cannot figure out how to replace only the specific day that was clicked with the information. because I didn't want to make a button for every day of the month, I have the same button (along with the same command) in every day. I need the button to know where in the grid it is, and be able to tell the label where to be placed with the mileage and pace.
I have tried researching lambda to see if it would help, but to no avail. here are relevant bits of my code (still fairly new to python, probably a bit sloppy, I apologize).
count = 0 #Code for button on every day in the month
dayCounter = numDays[0]
rowCount = 3
while (numDays[1] > count):
count = count + 1
logButton = Button(self, text=("Log Today's Workout"), command = self.log)
logButton.grid(column=dayCounter, row=rowCount)
if dayCounter == 6:
rowCount = rowCount + 1
if dayCounter <= 5:
dayCounter = dayCounter + 1
else:
dayCounter = 0
def calculate(self):
displayPace = Label(self, text= paceMin + ":" + formattedSec + " a mile.")
displayPace.grid(column=???, row=???)
I have omitted a lot of code. What is displayed is the code to put a button on every day, and the code to place the pace on the calendar. I have tried some things to place in row and column. I mostly get error messages, or it places the same label in every single box. I need to know how to change the button or what to put in row and column to only replace the button clicked. If anything else is needed I'll be checking this very frequently and will update often.