Intro/basic GUI – PyQt with Python GUI Programming tutorial

///Intro/basic GUI – PyQt with Python GUI Programming tutorial

Intro/basic GUI – PyQt with Python GUI Programming tutorial

FavoriteLoadingAdd to favorites

PyQT is a Python wrapper around the QT GUI application development framework. To get PyQT, head to:

or:

or do:

sudo apt-get install python-qt4
if you are on mac/linux.

PyQT gives us a wrapper around the various aspects to QT, but is separated in main sections.

Some of these include:

QtCore – non GUI essentials
QtGui – gui essentials

QtNetwork – for any networking like tcp/ip
QtOpenGL – for handling OpenGL, which is pretty awesome
QtSql – for database operations
QtSvg – handling of scalable vector graphics.
QtXML – for handling XML

sample code:

source

By |2019-06-15T19:50:47+00:00June 15th, 2019|Python Video Tutorials|39 Comments

39 Comments

  1. connor schumann June 15, 2019 at 7:50 pm - Reply

    The windows binary installers are no longer available on the riverside site.

    They are available at this link
    https://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.11.4/

  2. Dano1000 June 15, 2019 at 7:50 pm - Reply

    Hey great video series! do you require a licence on Qt4 to use it? or is it only for business/commercial and not for student/learning

  3. jeffry vergara June 15, 2019 at 7:50 pm - Reply

    Hello I am using Ubuntu 18.04 but i got this error

  4. Jericho June 15, 2019 at 7:50 pm - Reply

    Some suggestions for anybody following this tuto in 2019:
    You can update to use QT5 because not much has changed.
    I would suggest you to install pyside2 instead of PyQt (pip install pyside2, at least on python 3.7 on windows installed without a hitch).
    PySide2 is LGPL while PyQt is GPL so you can't sell any software using it unless you pay licensing fees.

    Speaking of which, install QtPy (again, pip install qtpy, at least on python 3.7 on windows it installs just like that).
    QtPy allows you to code once and later decide if you want to use pyside1/2/QtPy4/QtPy5.
    You could start your app using PySide2 and only if you start making money you switch to QtPy and pay for licensing and support, all without changing a single line of code (at least that is the idea) thanks to QtPy.

    To do this you need to change two easy things on this tutorial (because QtPy uses the new PyQt5 import names):
    -Change the import "from PyQt4 import QtGui, QtCore" to "from qtpy import QtWidgets, QtGui, QtCore"
    -Whenever sentdex says to use QtGui, use QtWidgets instead, the only excepction being QtGui.QIcon if I'm not mistaken.

    That's it, you have a pretty nice quality of life update for this tutorial, amazing from sentdex, as usual.

  5. Nah Fam June 15, 2019 at 7:50 pm - Reply

    You sound like saint Snowden.

  6. Nikhil Swami June 15, 2019 at 7:50 pm - Reply

    nice tutoring bro, make full course of these things…

  7. yasir iqbal June 15, 2019 at 7:50 pm - Reply

    Fow Windows, app window opens and then closes automatically . Reason and solution
    https://stackoverflow.com/questions/31815399/pyqt-qwidget-window-closes-immediately-upon-showing

  8. Ahmed Omar June 15, 2019 at 7:50 pm - Reply

    Linux users, who's window is not showing just add this:
    app.exec_()
    at the end of the code

  9. pk G June 15, 2019 at 7:50 pm - Reply

    hi man ,how-to-pass-data-from-one-form-to-another-in-qt-python??

  10. Thomaxonal June 15, 2019 at 7:50 pm - Reply

    Great video. Would be better than if you mirrored the screen of you in the bottom right so you're looking toward to code. That, or align the screen of you at bottom right.

  11. miad abdi June 15, 2019 at 7:50 pm - Reply

    I waaaaant pyqy5

  12. abdullah said June 15, 2019 at 7:50 pm - Reply

    @sentdex your code doesn't work on pyqt 4.10. it says NameError: name 'QtGui' is not defined

    so i found someone code instead and run it perfectly
    import sys

    #from tkinter import *

    #from PyQt4 import *

    from PyQt4.QtGui import *

    from PyQt4.QtCore import *

    class WindowHello(QWidget):

    def __init__(self, parent = None):

    QWidget.__init__(self, parent)

    self.setGeometry(650, 450, 450, 380)

    self.label = QLabel("<center>Hello!<center>")

    self.box = QVBoxLayout()

    self.box.addWidget(self.label)

    self.setLayout(self.box)

    app = QApplication(sys.argv)

    op = WindowHello()

    op.setWindowTitle('LangTIME')

    #op.setWindowIcon(QtGui.QIcon('Minilogowin.png'))

    op.show()

    sys.exit(app.exec_())

    this works for me. but your code doesn't @sentdex

  13. alex margaryan June 15, 2019 at 7:50 pm - Reply

    Please, can you give me some advice, I want to build a machine learning software that can take real time data as input (image) and make predictions and then give me the type of image as a result ? I have already a keras model, but I don't know how to connect it with gui.

  14. Kyle Humphreys June 15, 2019 at 7:50 pm - Reply

    For Windows I used
    python -m pip install PyQt5
    in cmd. I think this will also work with PyQt4

  15. NaturalBornCamper June 15, 2019 at 7:50 pm - Reply

    Any chances an updated PyQt5 tutorial will appear eventually? Don't want to learn with any other youtuber haha ๐Ÿ˜›

  16. HJ W June 15, 2019 at 7:50 pm - Reply

    Great video

  17. Harry PAnnU ! June 15, 2019 at 7:50 pm - Reply

    Can anyone tell me what happened to Bucky? Why he stop making videos!! He seems to be a cool and nice guy. Hope is all good and well. Cheers

  18. Shak Os June 15, 2019 at 7:50 pm - Reply

    6:34, i dont think many people remember where that line is from

  19. Rohan Awhad June 15, 2019 at 7:50 pm - Reply

    Hey man Thanks for this playlist. I followed you along in ubuntu and it worked, but now m trying it on Windows . no luck
    It says
    file.close()

    OSError: [Errno 9] Bad file descriptor
    in save_file
    and it does not even saves
    Please Help

  20. Joseph Saber June 15, 2019 at 7:50 pm - Reply

    you should have included
    app.exec_()
    in the last line of your code for linux ( ubuntu ) users
    this code above doesn't work on ubuntu

  21. Chambers June 15, 2019 at 7:50 pm - Reply

    Thanks, man. This was really helpful.

  22. Alex June 15, 2019 at 7:50 pm - Reply

    Which version of pyQT are you using?

  23. raja george June 15, 2019 at 7:50 pm - Reply

    can i use it for my machine learning project? its about about predicting the result of football league.

  24. Voylin's life June 15, 2019 at 7:50 pm - Reply

    For people who have the same problem of being unable to install pyqt use this site
    http://pyqt.sourceforge.net/Docs/PyQt5/installation.html

    You need to have pip installed :p

  25. Rohan Rayakar June 15, 2019 at 7:50 pm - Reply

    I tried to run the script but python hangs after showing the window. I cannot resize it either. What could be the reason for it? The title shows `pythonw(NotResponding)`

  26. Alan Gifford June 15, 2019 at 7:50 pm - Reply

    It's been a while since I looked this up, but per the Qt Project's site, "Qt" is pronounced like "cute". I try to follow the creators' preferences, e.g., "My ESS-CUE-ELL" and "Sequel Server". https://youtu.be/MQpl7AxSgsE?t=39 XD

  27. Hailey Yoon June 15, 2019 at 7:50 pm - Reply

    For Mac:

    brew tap cartr/qt4
    brew tap-pin cartr/qt4
    brew install qt@4

    (source: https://github.com/cartr/homebrew-qt4)

  28. Principe Carlos June 15, 2019 at 7:50 pm - Reply

    This is a pain in the a** to install in windows.

  29. Jignesh kumar June 15, 2019 at 7:50 pm - Reply

    Guys, PyQt4 for any python version can be downloaded from here: https://www.lfd.uci.edu/~gohlke/pythonlibs/

  30. The best nigga June 15, 2019 at 7:50 pm - Reply

    These vedio are amazing but they was 2015 they benefit me much . But as it ok if i learn from these then change to PyQt5 .
    I mean -are they the seem if i learn from or there is a big different.

  31. Dylan Pham June 15, 2019 at 7:50 pm - Reply

    I am trying to build this program on my computer but every time I run it, the window opens and then closes immediately. Any know how to fix this problem?

  32. Dylan Pham June 15, 2019 at 7:50 pm - Reply

    Are there any significant advantages that pyqt5 has over pyqt4?

  33. Ihesiulo Stanley June 15, 2019 at 7:50 pm - Reply

    pie cutie๐Ÿ˜˜

  34. pancho villa June 15, 2019 at 7:50 pm - Reply

    you talk too much useless shit

  35. Tudor Cozma June 15, 2019 at 7:50 pm - Reply

    Hi mate
    I have a question.
    PyQt or tkinter, they are working on web development. with Django or Flask if not which you will recommend?
    Thank you

  36. Bhoomika Chauhan June 15, 2019 at 7:50 pm - Reply

    which ide are you using ?

  37. Ayaan's AwesomeFacts June 15, 2019 at 7:50 pm - Reply

    For windows, Install by going to https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4. Then, in command line go to wherever you installed it and then do pip install yourpyqt4file. For mac and linux do brew install cartr/qt4/pyqt

  38. TheEshaw1 June 15, 2019 at 7:50 pm - Reply

    Nice quick intro. I'm starting out with PyQt5. The only difference is that QApplication and QWidget are both QtWidgets now, so you need: from PyQt5.QtWidgets import QApplication, QWidget. Or however you want to import those. Also, I'm not sure why, but on unix systems you need sys.exit(app.exec_()) at the end otherwise the window closes immediately.

  39. Markus Scheucher June 15, 2019 at 7:50 pm - Reply

    I've installed the PyQt4-4.11.4-gpl-Py3.4-Qt5.5.0-x64.exe but I can't get the from PyQt4 import QtGui to work. I'm using PyCharm and I get "No module named PyQt4"

Leave A Comment

*