Master PyQt5 part 4: Introduction to Signals and Slots

  Рет қаралды 24,267

Alan D Moore Codes

Alan D Moore Codes

Күн бұрын

Author Alan D Moore introduces you to the use of Signals and Slots, PyQt5's event handling system.
Follow Alan at www.alandmoore.com
Purchase a copy of Mastering GUI Programming with Python here: amzn.to/3Dr8cAy
Example code for this video can be found here: github.com/alandmoore/PyQt-Vi...
Previous video in this series: • Master PyQt5 part3: Ha...
Thanks for watching!

Пікірлер: 56
@gabrielcalderon9572
@gabrielcalderon9572 4 жыл бұрын
Alan, you get me with your introductions good sir 😂👌🏽
@ruudhermans4243
@ruudhermans4243 3 жыл бұрын
I am actually enjoying watching these videos from this playlist.
@KennethSDyson
@KennethSDyson 3 жыл бұрын
Thanks for these videos! You are so clear and concise. Looking forward to going through your book.
@LandNfan
@LandNfan 2 жыл бұрын
Great series of vids. I’m tackling Python and PyQt for the first time. My only previous GUI experience was a brief exposure to Visual Basic, both Windows and DOS, about 25 years ago. I don’t have any immediate need for this, just trying to keep my mind sharp at 76. BTW, perhaps one reason your lessons appeal to me is your resemblance to my late younger brother. I just picked up the Kindle format of your book to go along with the vids.
@Dimlutube
@Dimlutube 2 жыл бұрын
Alan, you are truly a great teacher. I found one of your other videos months and months ago when I was just hacking together bits of code to make a... kinda functional GUI app. It taught me specifically the stuff I needed to get the app built. This was just a bandaid fix to build a tool that we needed, I didn't care to continue learning... I really wish I did, because every video has taught me a multitude more. Your book is on my "When I can afford it" list. Not judging or anything, I'll bet it's worth every bit of the $50, it's just outside of my book budget at the moment. I'll get there. Might get the kindle version, but I digress... YOUR VIDEOS ARE AMAZING! I'm a bit saddened that it's been several months since your last release. I hope that you decide to start publishing videos again. No other videos are as clear and concise as yours are. You have a gift sir, I hope that you'll consider making more videos. I'm seriously not just saying this. I've watched so many python videos... so... many... videos... yours are the best. Anyway, thank you.
@alandmoorecodes3585
@alandmoorecodes3585 2 жыл бұрын
Thanks! I plan to get back to doing videos again sometime, I've just been swamped the last few months. Totally understand about the book price, I don't have any say in that.
@adolfosoto5614
@adolfosoto5614 3 жыл бұрын
Excellent content, wished I'd found it earlier but this is the right level. Easy to follow and with clear reasoning of why things are done in this or that way. Getting your book
@fredrikbystrom7380
@fredrikbystrom7380 3 жыл бұрын
Dude creates indents by pressing space multiple times instead of pressing tab. I choose to interpret that as this person being a true master.
@imadetheuniverse4fun
@imadetheuniverse4fun 2 жыл бұрын
loool true. i'm over here with my editor set up to automatically indent for me, maybe i need to switch to manual once in a while to keep me honest haha
@dougstrong3272
@dougstrong3272 4 жыл бұрын
Thanks for your help. I have hundreds of questions. I have been using pyqt5 for about a year. Some of your comments are really spot on. I am finding out lots new things i can use. I bought your book.
@alandmoore4306
@alandmoore4306 4 жыл бұрын
Thanks Doug!
@davmaz
@davmaz 4 жыл бұрын
This is a great video as well as the corresponding code from gibhub. The best explanation I've seen for multiple threading in PyQt. Great job Alan! I also bought the book from Packt -- it's a deal I couldn't refuse.
@davmaz
@davmaz 4 жыл бұрын
Sorry but I mistakenly added this comment to the Signal/Slots video -- I meant to put it on the PyQt5 'responsive' GUI video. They're all good!
@alandmoorecodes3585
@alandmoorecodes3585 4 жыл бұрын
@@davmaz Regardless, Thank you! I'm glad this is helping you.
@MJ-yi7ce
@MJ-yi7ce 3 жыл бұрын
The voice is so calming!
@thegbgfamily
@thegbgfamily 3 жыл бұрын
I will soon get the book. Thank you for this.
@EdwinFairchild
@EdwinFairchild 3 жыл бұрын
i think a gui driven application resembles a state machine , where the machine is idle (or doing some specific task) until some other event occurs at which point the state changes and something happens accordingly
@Karrde999
@Karrde999 4 жыл бұрын
Great job covering signals and connections! I've been working with Tkinter for a while now, and thanks to you I'm starting to get excited about exploring Qt!!! Side note, I haven't seen the next parts yet, but I'm hoping you cover functools.partial() or lambda: when needing to pass in extra data to those connections.
@alandmoorecodes3585
@alandmoorecodes3585 4 жыл бұрын
I think I covered that at some point, but if I didn't, let me know and I'll do a video on it.
@Shizostereo
@Shizostereo 4 жыл бұрын
I'm giving this video thumbs up just for explanation of self )
@ahmedomar636
@ahmedomar636 3 жыл бұрын
Thank you
@haidar901
@haidar901 4 жыл бұрын
Thank you so much sir, you are the best !
@alandmoorecodes3585
@alandmoorecodes3585 4 жыл бұрын
Thank you, glad it helped!
@mauriziomoretti5392
@mauriziomoretti5392 3 жыл бұрын
who on earth gave thumb down? greetings from Italy. Great stuff!!
@mauriziomoretti5392
@mauriziomoretti5392 3 жыл бұрын
got ur book on kindle. so I have an excuse to skip some sleep ... :D
@Pedroallesss
@Pedroallesss 3 жыл бұрын
tks a lot from brazil
@gunhwanson7770
@gunhwanson7770 3 жыл бұрын
great...! and I bought your book :)
@HAECHANEUN
@HAECHANEUN 10 ай бұрын
legend lecture
@harrischew7709
@harrischew7709 4 жыл бұрын
Hi, Thank you so much for the clear tutorial on Signals and Slots. I would like to ask if it's possible to pass back a value, like a boolean value, from a slot when a signal is emitted? Thanks!
@alandmoorecodes3585
@alandmoorecodes3585 4 жыл бұрын
You can pass a value with a signal, but you can't pass a value back from a slot. The reason is that a signal can be connected to any number of slots, so which one would be the return value? If you want two-way communication between objects, you need to create signals in both objects and connect them back to slots in the other object.
@abderrahmanesebaa7638
@abderrahmanesebaa7638 4 жыл бұрын
Thanks for the video! Loved it!! I have a question concerning the custom signals, what if I want them to be emitted when without the need for another signal to be emitted ( like in your example here, the authenticated signal can only be emitted if clicked signal is emitted first) so,if I want it to be emitted when a value in a list changes due to a change in stocks or something like that, should I use threads then ??
@alandmoorecodes3585
@alandmoorecodes3585 4 жыл бұрын
A custom signal doesn't have to be triggered by another signal directly, but in an event-driven system like Qt, there has to be some event that triggers the emission of a signal. Events are typically represented by signals (though in some cases, you might override a method that gets called under certain circumstances rather than connecting a signal). In your case, I would have a separate thread that polls your data source and emits a signal whenever a change is detected.
@abderrahmanesebaa7638
@abderrahmanesebaa7638 4 жыл бұрын
Ok, thanks a lot
@nikolastesla3840
@nikolastesla3840 2 жыл бұрын
Can you make a video about QWizard? Also how can i open QMainWindow from QWizard finish button?
@sachinbangera
@sachinbangera 4 жыл бұрын
how to get a custom signal if a combo box is dynamically created inside a table widget , which gets automatically added as the row get added?
@mahmoudboubes531
@mahmoudboubes531 4 жыл бұрын
you 're the best :) .... .keep going
@alandmoorecodes3585
@alandmoorecodes3585 4 жыл бұрын
Thanks! Hope to do more soon, I've been really busy lately, though.
@imadetheuniverse4fun
@imadetheuniverse4fun 2 жыл бұрын
Thanks for the video! Is there a particular reason that the authenticated signal had to be defined outside of the __init__?
@alandmoore4306
@alandmoore4306 2 жыл бұрын
Yes, it has to do with the way the QT objects are created behind the scenes. Signals need to be defined at the class level.
@dwightledet5857
@dwightledet5857 2 жыл бұрын
How do you do math? For instance: If I want to add one input number to another and display it elsewhere, how do I do that? I can't figure out how to get the GUI to change an input string to an integer or float.
@hbade4020
@hbade4020 3 жыл бұрын
Thank you so much for this! One question: Am I able to access my signal data OUTSIDE the QWidget Class? I am trying to return the data in the slot function and then call the slot method, but this wont work outside the QWidget class, as the slot method requires a positional argument (the signal data). However, that signal data is what I am trying to obtain, so I clearly cannot pass it to the slot outside the QWidget class! I am surely doing something wrong... seems like a bit of a catch 22 haha Please help!
@alandmoorecodes3585
@alandmoorecodes3585 3 жыл бұрын
I don't really understand your question; a signal can carry any data you want along with it, you just have to define the types when you create your signal. The slot can be any Python callable -- a method of another object, a standalone function, a callable object, an actual Qt slot, etc -- it just has to be able to receive the arguments that are going to be sent with the signal. Signal -> Slot is always a 1-way communication, though, you cannot return something back to the context where the signal originated. If you need two objects to be able to "dialog" like that, you just need to define appropriate signals and slots in each one to send and receive. Not sure if that helps, but feel free to elaborate further.
@matinebrahimkhani8038
@matinebrahimkhani8038 3 жыл бұрын
Dear Alan, I have a problem with my code, I'm writing a GUI application with pyqt5 and I need to do some processing in order to decide to add a standarditem to a table in a window or not, all the tutorials are running functions by events, but these processes shouldn't be started with events they should run separately and add rows to the table, can you please help me. thanks
@manonthedollar
@manonthedollar 3 жыл бұрын
With PySide2, if I try to create a signal (sig = QtCore.Signal() in this case, as apparently Signal() is the PySide version of pyqtSignal()), calling sig.emit() says "Object has not attribute 'emit'") Is this a difference between PySide2 and PyQt5?
@alandmoorecodes3585
@alandmoorecodes3585 3 жыл бұрын
I know that PySide2 handles signals and slots differently from PyQt5, but I'm not sure off-hand how it does it. IIRC, Signal does have an emit() method, but *only after it has been connected to a slot*. IOW, if you create a signal but don't connect it to anything, you can't call emit(). See wiki.qt.io/Qt_for_Python_Signals_and_Slots for more info.
@bennguyen1313
@bennguyen1313 3 жыл бұрын
At the 5m20s mark, it's mentioned that .exec() needs to be called, but the code doesn't show that... instead it shows the process() function, is that the same thing? Also if give a multiprocessing class, class MpClass(mp.Process): def __init__ (self, pipe,signal): self.signal = signal def run (self): while True: self.signal.emit("Hello") Can a Gui object instantiate the above, so that the mp object can update the Gui object using signal/slots? class GuiMainClass(QtWidgets.QMainWindow): authenticated = QtCore.pyqtSignal ( str ) self.authenticated.connect ( self.callback ) ... def __init__ (self, pipe): proc1 = MpClass(self.pipe, authenticated) proc1.start() def callback (self, strval): print ("World") pipe = multiprocessing.Pipe() GuiMainClass (pipe)
@peekaboo6026
@peekaboo6026 3 жыл бұрын
I need help. Pressing spacebar on my keyboard triggers a pushbutton on my GUI simple keyPressEvent doesn't seem to help either.
@amanbothra2765
@amanbothra2765 4 жыл бұрын
bing fan sir you are great ...please solve my problem sir... example....in qt window there are 4 buttons ex A, B, C, D ....by default A is always open...B, C, D have different. I want to connect with A window and when press B open B window like all....all button are interconnected in one window it is possible.
@alandmoorecodes3585
@alandmoorecodes3585 4 жыл бұрын
I'm sure it's possible, but I don't clearly understand what you are asking for from your description.
@MrDjRayner
@MrDjRayner 3 жыл бұрын
@24:10 did you forget the self. prefix or was it omitted on purpose?
@alandmoorecodes3585
@alandmoorecodes3585 3 жыл бұрын
If you mean line 8, it was omitted on purpose. Outside of an instance method, "self" has no meaning. Properties you create outside a method definition are automatically class properties, so *within a method*, you can refer to it as "self.whatever" (because the instance also has all the class properties).
@MonirKHAN-hm5wt
@MonirKHAN-hm5wt 2 жыл бұрын
Hi there, I got this error: AttributeError: 'QPushButton' object has no attribute 'textChanged'
@ismaelochoa8730
@ismaelochoa8730 3 жыл бұрын
isn't using customised signals is like creating a method who can be called by other methods? so what is the benefit of creating my own signal if this can be just a method
@alandmoorecodes3585
@alandmoorecodes3585 3 жыл бұрын
Creating custom SLOTs is like creating methods, and in most cases there is no need to create an actual slot in PyQt5 (there are a few edge cases where it solves some problems under the hood). Signals are different. They allow you to maintain loose coupling between your GUI objects. Think about a button; it's not the button's job to decide what happens when it's clicked; that's the application's job. All the button does is draw a clickable GUI widget and then broadcast a signal when it's clicked. The application has to connect that signal somewhere so that the button does something, but as far as the button is concerned, it's only job is to say "Hey, I was clicked". Because of this design, button objects are reusable. Does that make sense?
@moadhoueslati6838
@moadhoueslati6838 3 жыл бұрын
Play speed at 1.25 .Thank me later ☺
@manuelugarte4029
@manuelugarte4029 Жыл бұрын
Funny, I prefer his normal voice, I liked the way he speaks and sounds
Master PyQt5 part 5: Moving data between windows
18:46
Alan D Moore Codes
Рет қаралды 20 М.
Working with signals and slots in PySide or PyQt.
29:02
Jason Codes Qt
Рет қаралды 4,3 М.
Became invisible for one day!  #funny #wednesday #memes
00:25
Watch Me
Рет қаралды 46 МЛН
Master PyQt5 part 10: Make responsive GUIs with Threads
33:35
Alan D Moore Codes
Рет қаралды 19 М.
Tkinter vs. PyQt:  Which Python GUI framework is right for you?
38:11
Alan D Moore Codes
Рет қаралды 64 М.
bgpkit-broker bootstrap command demo
0:45
BGPKIT
Рет қаралды 116
Master PyQt5 part 6:  QMainWindow for easy apps
27:05
Alan D Moore Codes
Рет қаралды 12 М.
java lang IllegalStateException
0:45
Techdigit-z
Рет қаралды 32
Introduction to GUIs in Python with PyQt5
26:10
Clear Code
Рет қаралды 83 М.
Linux - Storage Basics
15:49
x80nix
Рет қаралды 513
PyQt5 Tutorial - Signals and Slots
16:47
Tux Codes
Рет қаралды 14 М.
Мой инст: denkiselef. Как забрать телефон через экран.
0:54
ПОКУПКА ТЕЛЕФОНА С АВИТО?🤭
1:00
Корнеич
Рет қаралды 3,6 МЛН
Неразрушаемый смартфон
1:00
Status
Рет қаралды 2,3 МЛН
YOTAPHONE 2 - СПУСТЯ 10 ЛЕТ
15:13
ЗЕ МАККЕРС
Рет қаралды 171 М.