Python Forum
[PyQt] Signals and slots, transcending classes - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [PyQt] Signals and slots, transcending classes (/thread-20935.html)



Signals and slots, transcending classes - Saltwater - Sep-07-2019

Hi,

I'm new to Python, and using QT to create a UI and am consequently using PyCharm to connect slots and signals.

In PyCharm I have the control parameters module. And was using it to pass away values to parameters so I can use those to do math outside the module. Looking something like this.

        Parameter1 = 0
        Parameter2 = 0
        Parameter3 = 0

        self.retranslateUi(Control_Parameters)
        self.CurrentControl.sliderMoved['int'].connect(self.label_5.setNum)
        Parameter1 = self.CurrentControl.sliderMoved['int']
        Parameter1.connect(self.label_3.setNum)
        Parameter2 = self.ShiftOPP.sliderMoved['int']
        Parameter3 = Parameter2 // wanted math here not possible
        self.retranslateUi(Control_Parameters)
        Parameter3.connect(self.label_4.setNum)
        # self.ShiftOPP.sliderMoved['int'].connect(self.Parameter2)
        # self.ShiftOPP.sliderMoved['int'].connect(self.Parameter2)
        self.Offset.sliderMoved['int'].connect(self.label_4.setNum)
My problem is tho, I cant seem to do math inside the module, and whenever I try to reference the variables outside the main module I get an error. Is it possible to take them somewhere else where I can do integer arithmetic with the signals? "Not necessarily setting number boxes (passing integers), but preferrably not limitted to.


Kind Regards,


RE: Signals and slots, transcending classes - Denni - Sep-10-2019

Okay that is not a MRE (Minimal Reproducible Example) so it will be very difficult to determine what you are doing and thus very difficult to answer your question. You will get a much quicker response if you include a completely functional bit of code that allows one to copy/paste and run it to see what you are doing. Also are you using just QT or PyQt and/or are you using some kind of Designer the latter btw while based on Qt/PyQt does not actually produce Qt/PyQt code. Once you see a true version of the former you will understand why I say that about the latter.