0

I created some labels in Tkinter like so:

Donor1bg=tkinter.Label(frame1, text=donorid_dict["donorid1"].strip("'"), font=("Calibri", 30), bg="#000000", padx=(3), pady=(3))
Donor1bg.grid_configure(padx=(20,0), pady=(10,0))
Donor1bg.grid(column=0, row=2)
Donor1=tkinter.Label(frame1, text=donorid_dict["donorid1"].strip("'"), font=("Calibri", 30))
Donor1.grid_configure(padx=(20,0), pady=(10,0))
Donor1.grid(column=0, row=2)

Then I have a button which will use this function as a command:

 def down(startingpoint, donorid_dict):
    if donorid_dict["donorid10"]=="":
        tkinter.messagebox.showinfo(title="No Data", message="There is no more information to be displayed.")
    else:
        startingpoint=startingpoint+10
        donorid_dict, bloodtype_dict, location_dict, organname_dict = displayinformation(startingpoint)

return startingpoint, donorid_dict, bloodtype_dict, location_dict, organname_dict

In the down function, how can I alter what is displayed by the labels? I was able to change the dicts correctly, but then what?

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
LewOF04
  • 1
  • 2
  • Just in case this is the misunderstanding: `text=donorid_dict["donorid1"].strip("'")` **does not** mean "as a condition to meet at all times, the text on the label should be whatever is calculated by doing `donorid_dict["donorid1"].strip("'")`". It means "**calculate `donorid_dict["donorid1"].strip("'")` right now**, and set the label text to that, until I change it in some other way." Just like how, if you write `b = 1` and then `a = b` (so that `a` becomes `1`) and then `b = 2`, `a` stays `1` and does not become `2`. – Karl Knechtel Apr 12 '23 at 12:38
  • But if the question is just "how do I change the text on a Tkinter `Label`?", then please see the linked duplicate; and for future questions, [please try to search first](https://meta.stackoverflow.com/questions/261592). – Karl Knechtel Apr 12 '23 at 12:38
  • Aside from that, the code here does not properly explain the context. We can't see any of the other dicts besides `donorid_dict`, and have no reason why they would be relevant; and in any event simply *reassigning* `donorid_dict` (and `return`ing it) **would not change** any previously existing dict named `donorid_dict`. For future questions please also read [mre]. (And if the question is "how do I do X?", and you tried to write code to do X but it doesn't work, **only show that code if** you are specifically asking people to find a problem in the code. Just show the **context** for X.) – Karl Knechtel Apr 12 '23 at 12:44

0 Answers0