#π I would like to change the selectedSAMPLE's value...
18 messages Β· Page 1 of 1 (latest)
@nova bramble
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
When you do this: py def my_func(): x = 1 x is treated as a local variable, even if there's an x variable in the global scope
If you want to change the global x variable, you need to add a global declaration
def my_func():
global x
x = 1
in general don't use global, it makes your code hard to read and debug, and causes all sorts of issues that are challenging to debug unless you have mastered python already and are capable of explaining in detail why global is ok in this specific instance.
command = lambda x=selectedSAMPLE: select(x) is None, so every button will get None as the default argument. Even if/when you make changes to it later, it'll always be None.
also that
so.... how do i fix this?
hello, im still not clear on how to fix this......
As mentioned already, avoid unnecessary globals, and make sure your lambda is properly updating the buttons.
but.... i dont know how tho...
i want to make it update the variable and i dont know how to
https://youtu.be/mop6g-c5HEY This is a long video, but a lot of it is making different apps. The first hour or so goes over all the basics, with variables... getting and setting widgets, passing arguments to lambda functions... all which you're stuck at right now.
This tutorial covers everything you need to know about user interfaces in Python. I will go over all of tkinter, Python's default GUI framework, cover all the basics and then create a BMI app, a calculator and a photoshop style image editor.
If you enjoy this course, consider buying the tutorial that covers 7 additional apps: A responsive weat...
does that work with customtkinter too?
Yeah, ctk just wraps tk, with some improvements.
the video does actually use customtkinter
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.