#๐Ÿ”’ settings button only executes code when initalizing the app and never when you click it

122 messages ยท Page 1 of 1 (latest)

flat laurelBOT
#

@hollow dagger

Python help channel opened

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.

hollow dagger
#

there we go

#

the cfg json file is needed for the script to work

thin sierra
#

I would guess the about button isn't working too?

#

in fact I think all the buttons are not working for different reasons

#

what I would try is:
MainApp.SettingsButton.clicked.connect(lambda: self.SettingsMenu())
but I'm not sure about the documentation for the .clicked.connect function

#

Likewise
GlobalVars.buttonA.clicked.connect(lambda: ButtonClicked("A"))

quick linden
#

@hollow dagger did you figure it out?

hollow dagger
quick linden
#

thats running a function upon click

thin sierra
#

you need to pass in a function

hollow dagger
#

i never had to do that

quick linden
#

what were you using before?

hollow dagger
hollow dagger
#

the buttons inside the settings menu dont

quick linden
#

gimme a second, looking up an old project

hollow dagger
#

that set the current day

#

yall wanna vc?

quick linden
#
        self.ui.nav_home_button.clicked.connect(self.nav_button_click)
#

this is the format i used

hollow dagger
#

yes

quick linden
#

let me take al ook at your code again

hollow dagger
#

i just use class definitions

#

nvm cant talk in the python vcs yet]

cobalt solar
#

i also need some help btw๐Ÿ‘

thin sierra
quick linden
#
        GlobalVars.buttonA.clicked.connect(ButtonClicked("A"))
        GlobalVars.buttonC.clicked.connect(ButtonClicked("C"))
        GlobalVars.buttonB.clicked.connect(ButtonClicked("B"))

these are wrong

hollow dagger
#

how come

#

im calling button clicked

thin sierra
#

have you tried the lambda trick

hollow dagger
#

lemme try it

thin sierra
#

put it in a function, so that there's something to call

quick linden
#

ok i changed them to lambdas

hollow dagger
#

WHAT KIND OF BLACK MAGIC SORCERY WAS THAT

quick linden
#

then the settings button worked the first time

hollow dagger
#

IT WOKRD

quick linden
#

but iti snt for the second because ....

#
Traceback (most recent call last):
  File "c:\Users\Bilal\python discord\cordless\main.py", line 171, in SettingsMenu
    Settings.__init__(self)
  File "c:\Users\Bilal\python discord\cordless\main.py", line 231, in __init__
    Settings.Layout.addWidget(GlobalVars.buttonA)
RuntimeError: Internal C++ object (PySide6.QtWidgets.QPushButton) already deleted.
hollow dagger
#

key error 7

quick linden
#

so lets take al ook at this

thin sierra
#

yeah that's probably a different problem

hollow dagger
#

that might me a you issue

#

bc im not getting it

#

i am getting it

thin sierra
#

if you just run the function now, you aren't getting the behaviour later

hollow dagger
#

my brain doesnt understand lol

cobalt solar
hollow dagger
#

is it like a order issue

#

like i need to put the func farther down the script or

thin sierra
#

It's the difference between

x = print("hello world")
# and
y = lambda: print("hello world")

In the first case x is None and it prints instantly.
In the second case y is a lambda and it prints when you call y()

#

you want the "it prints later" behaviour so you gotta put it in a lambda

hollow dagger
#

ok

#

so i cant open the settings menu a second time bc it just deltes a c++ object

#

i never had this issue

quick linden
#

yeah let me see what you're doing here

#

have you used pyside before?

hollow dagger
#

this is my first project with ti

quick linden
#

well yeah there you go

hollow dagger
#

but i had it running perfectly before i switched the config file to json

quick linden
#

its a much more mature library than tkinter imo so you have to change how your program

hollow dagger
#

ah

quick linden
#

Settings.Layout.addWidget(GlobalVars.buttonA)

#

so you need to make another button

#

not use ones that youve used elsewhere

#

i think thats the main issue

hollow dagger
#

maybe i need to define the button in settings .init

quick linden
#

mmm

hollow dagger
#

bc when i close the window it destorys evrey thing inside the window

quick linden
#

yeah so you need separate objects

#

how much time do you have for this project?

hollow dagger
#

i was only using thoes buttons for the settings menu

hollow dagger
quick linden
#

i can share you a youtube video i used a while ago to try to teach myself pyside

#

oh ok great

#

one sec

hollow dagger
#

im in high school

#

so i got plenty

quick linden
#

Beautifully animated side menu desktop app interface in Python, PySide, PyQt, and QT Designer.
The source code is available for everyone to download.

Download the full source code here(Without UI file): https://www.spinncode.com/designs/GRgxnBL4
Full Source Code With UI File:
https://www.patreon.com/posts/51228254

FREE ICONS DOWNLOAD
https://...

โ–ถ Play video
#

make a new project and run through this separately

hollow dagger
#

does it use pyside 6 or 5

#

bc i run kde 6 and would prefer pyside 6

quick linden
#

its like 75% designer 25% code

#

i did it in 6

hollow dagger
#

i dont wanna use a designer

quick linden
#

oh okay

hollow dagger
#

bc then i cant have dynamicly created elements

#

such as the labels for classes

quick linden
#

i mean you can add that functionality later

hollow dagger
#

true

quick linden
#

im just saying, look through this, follow it, there may be some slight differences between 5 and 6

#

but it should still work

hollow dagger
#

ye

#

and i need to find how to get qt designer 6

quick linden
hollow dagger
#

it shoulve updated when i switched to plasma 6

quick linden
#

oh wait thats just addons

hollow dagger
#

ye

quick linden
#

should be there with just pyside6

hollow dagger
#

i have the pyside 6 library bc KDE my Desktop Enviroment depends on QT6

quick linden
#

heres where mine lives in vscode

#

its in the venv

#

this is on windows

hollow dagger
#

neat

#

now there is ligit only one issue left

#

key error 7

#

in the json

#

its saying there is no key "7" but there is

hollow dagger
quick linden
#

sure i can help when i have time

hollow dagger
#

ye but also to have someone to show off my code to

quick linden
#

also im not getting that key error after putting in those lambdas

hollow dagger
#

as many people in my life tune out when i start talking about the app i made

quick linden
#

they dont know the work it takes ๐Ÿ˜‰

But they also have other things on their mind im sure

flat laurelBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, 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.