last day (16 days later) » 

10:21
0
A: Python Tkinter - Name of objects created by function

Billal BEGUERADJThe reason behind your problem: The problem is that when this line is executed: btn = Button(command =lambda:[RandomColor()]) by the end of the loop, you get a reference only to the last button which is created. You loose reference to other buttons. Solution: You can overcome this problem if y...

I am aware that my code doesnt look good yet - im only a few hours into python, but still - thanks for the easy solution, may i ask what i would have to change if, lets say, i would only want the bottom-right button to change color upon clicking on any button? my initial question was rather generally how all of those generated buttons are "unique" as i did not generate them by, lets say, manually naming name btn1, btn2, btn3 and so on
Sorry, I do not understand your question because you did what you asked for yourself (the code in your question). Otherwise, please clarify me
with your solution, i can now recolor all buttons when clicking any button - but part of my question was "How could i address all (or one specific) buttons" and i still dont know how i can configure one specific button - lets imagine this scenario: i want to change the color of one button - lets say, the button in the bottom-right corner, when clicking on any other button. how would i do this? all i did in my original code was recolor the button i clicked, not recolor another button
Do you want a solution for the specific scenario you described?
If you have one sure, no problem if thats too much of a hastle
10:21
Check my edit, is that what you are looking for? Ask questions if you do not understand my code. @FlyingThunder
Hello
Hello @FlyingThunder
Oh sorry, didnt knew there was a chat
Did you run the solution I provided?
just wanna say thanks, i dont understand a lot about your code but i think ill figure it out soon
and yes, that was exactly what i was looking for
When you develop a graphical interface in Python, you should use the object oriented approach.
I created a class for that and each function says what it does.
yes, i notice how you created a lot of functions that were rather small for that
10:25
Small functions facilitate unittesting (something you will practice later with Python, maybe)
that makes sense, i think ill be able to sort out all parts of your code by googling
I think the most important thing in my code is to read the create_buttons() function: it shows how I keep trace for the 16 created buttons . That is why I was able to access the bottom right button you were looking for
yes, i figured i needed to pass some sort of argument or parameter to the creation function, but that is really advanced to me - thanks for the work, i think rewritten code into good format will help a lot
I just created a dictionary {key: value} where the key is the name (variable name) of the corresponding button and the value is the Button widget created.
If you do not understand something in my code, any time/any date, you can ping me and I will answer you here. Do not hesitate to ask.
thanks, ill take a look first and see if i can get an idea of the syntax for now
10:30
Ok. Have a nice day
you too, thanks again!

  last day (16 days later) »