In this PyQT4 tutorial, we cover how to create our own button functions and methods.
sample code: http://pythonprogramming.net
http://hkinsley.com
Tweets by Sentdex
http://sentdex.com
http://seaofbtc.com
In this PyQT4 tutorial, we cover how to create our own button functions and methods.
sample code: http://pythonprogramming.net
http://hkinsley.com
Tweets by Sentdex
http://sentdex.com
http://seaofbtc.com
Is there a right click event listener?
If anyone is having "Argument type has unexpected type 'NoneType' " on btn.clicked.connect(self.close_application) , use:
btn.clicked.connect(lambda: self.close_application())
can somebody please explain to me why is 'btn.clicked.connect(self.close_application)' instead of 'btn.clicked.connect(self.close_application())' ? I thought we needed the () to call a method
bro! too much coffee in your system .. try tea for a change. LOL!
I don't really understand how calling the run() method is able to work. Inside the run() method, I see that an instance of Window() is made and called "GUI", but I don't see "GUI" being called…how come the window still pops up when the program is run?
thanks dude!! really appreciate your videos
hi, thank you for this great tutorials! qt its awesome! i was wondring how is possible to use the connect function with a parametrized function, if my mainwindow instance name is window, then something like:
btn.clicked.connect(window.change_size(parameter1,parameter2)), calling this in the main and no in the class?
hope u answer
thanks in advice
Hi sentdex I m really learning lot from your tuts, they are so helpful.
There one problem which I am facing is, I am not able to create additional button in same script can you explain that as well ?? how we create multiple buttons ??
Im doing this in jupyter notebook and when i click the quit button, it displays message that the kernel has died and will restart…
Somehow when i tried using the setWindowTitle(stirng) within the close_application() method, it gave me an error message saying:
btn.clicked.connect(self.close_application())
TypeError: connect() slot argument should be a callable or a signal, not 'NoneType'
How come it worked in your case and it didn't for me?
Thanks for the amazing tutorials by the way.
This question has been commented already, but none of them have been answered:
How do you trigger a function when a button is pressed, *with PyQt4.5*?
(Since the QPushButton.clicked.connect([function]) has been deprecated)
That's like, a really essential thing..
Figured, it's this, for the video:
QtCore.QObject.connect(btn, QtCore.SIGNAL('clicked()'), self.close_application)
replacing
btn.clicked.connect(self.close_application)
Why doesn't he use pycharm?
how to change the positions and sizes of the buttons and other stuff relative to the size of window rather than to edge of the window
i am using PyQT4 on linux mint and when ever i run my code a simple window pops up in which title bar is missing and icon is also not visible.
Hi, my kernel dies automatically after code is run, any thoughts why this is happening?
In tutorial 4 within the method "home" you call the method close.application without brackets:
Why that ? And why doesn't it work when I add brackets ?
"Now, I understand, you're probably like 'whoa, but we already had something that could quit, this is stupid!'"
I was actually thinking "Wow, if you could have just passed 'sys.exit()' in the first place, why did you pass 'QtCore.QCoreApplication.instance().quit'?"
I have ported the lesson1 to lesson15 to PyQt5 you can find it https://github.com/kenwaldek/pythonprogramming
It's a pity you did not elaborate on binding button events to functions with parameters. To anyone interested, add 'lambda:' before the function name with parameter in the connect method, to make it an anonymous function.
what I was trying to do it have a main file for the main window while have a separate file for calling when a button is triggered. in the other file I try to change the window title when the button is pressed e.g. for button compute, the title goes "computing…" but it throws up error, it doesn't throw error when I place all of them in a single file. why?
how does the size change automatically ? if we change size of window
Thanx for all your tuts! very great job :))
When I click on quit button the application freezes and close my Python. Any idea…?
Also if I add def run() the app won't load
Is there anyway to make the same thing without the class?
hello, how can we make a button who's not rectanglar ? For exemple, how can I make a triangular button ?
what is the difference between closing with sys.close() and QtCore.QCoreApplication.instance().quit ? It seems to me that sys.exit() might be more unexpected/traumatic to pyQt. Is it?
Thanks for the video =)
Is it possible to add text to the window above the buttons? As in, to ask, "Which option would you like?" and then have a button for option1, and a button for option2?