#๐ Can anyone help me?
37 messages ยท Page 1 of 1 (latest)
@supple geyser
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.
@supple geyser I recovered your message
I have a script that should create buttons. When I click on the created button, a file selection menu should open. After selecting a file, when I click the button again, the selected file or folder should open. And all this should be saved and not reset on reboot. But when I click the button, nothing happens. I would appreciate it if you could help me.
You can't upload files here. If you want to share your code, use a pastelink
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
Can anyone help me? I have a script that should create buttons. When I click on the created button, a file selection menu should open. After selecting a file, when I click the button again, the selected file or folder should open. And all this should be saved and not reset on reboot. But when I click the button, nothing happens. I would appreciate it if you could help me.
if button_id not in button_files:
thank you
you're checking if the button_id is in your button_files, which it always will be
button_files[button_id] = None
you do this when you add your button
using in with a dict checks if the key exists, it doesn't matter what the value is
if button_files.get(button_id) is None:
this would be a better condition to check for when you click the button
Sorry, I'm just starting out and I'm also a Python programmer, so can you just drop the part of the code that I need to replace? I'll figure out what the guy says in it and what my problem is. I'd be very grateful.
I just did
replace this with the last snippet I wrote
instead of This is it "button_files[button_id] = None" this is it "if button_files.get(button_id) is None:"
?
No, that part is correct
replace the condition that you have with the adjustment I made
I was showing you why your first condition doesn't work correctly
if button_id not in button_files: change to if button_files.get(button_id) is None:
?
yes
Thank you very much, I spent the whole day today on this and couldn't fix it. And it was such a small mistake.
and can you also tell me how you make a frame like this
And how can I make it so that when I run the program again, everything goes back to how it was?
you can do a codeblock using backticks. Give this embed a read for info
!code
There's still some logic issues with how you're storing the information of the button which won't allow you to save. You're trying to use your button id, but your button ids are out of sync
One possible solution is you can create another dict to store the button widgets and their associated IDs
can you tell me how to create it
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.