PySide6 Tutorial | Qt 6 For Python | Loading UI Files Created with Qt Designer

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ธ.ค. 2024
  • In this tutorial, we will create a basic UI layout using the included Qt Designer that comes installed with PySide6. We will then compile the file into Python code and load it into a new PySide6 project. You will also be able to use UI files generated using Qt Creator.
    Looking for more project ideas? Get a new python project idea sent directly to your inbox: weeklypython.s...

ความคิดเห็น • 34

  • @gokulrajaking
    @gokulrajaking 4 ปีที่แล้ว +3

    Great tutorial. Thanks for introducing PySide6 in YT

    • @tuxcodes
      @tuxcodes  4 ปีที่แล้ว +1

      Our pleasure!

    • @dnrbs2168
      @dnrbs2168 4 ปีที่แล้ว

      Can you help me solve the below error
      Error is pyside6-uic : The term 'pyside6-uic' is not recognized as the name of a cmdlet, function, script file, or operable
      program.
      While translating the UI file to Python file

    • @alexandarjelenic7718
      @alexandarjelenic7718 3 ปีที่แล้ว

      @@dnrbs2168 Try to just load the .ui directly.instead of converting to .py
      Class my_program(QMainWindow)
      def __init__(self):
      QMainWindow.__init__(self)
      my_ui='my_ui.ui'
      self.setWindowIcon(my_logo)
      uic.loadUi(my_ui,self)

  • @mrmartinwatson1
    @mrmartinwatson1 3 ปีที่แล้ว +3

    man this is underrated, every video i clicked on to explain pyslide6 immediately defaulted to qt and qt quick. Like i clicked for pyslide, where is it!

    • @lyleandres1510
      @lyleandres1510 3 ปีที่แล้ว

      You probably dont give a damn but does anyone know of a way to log back into an instagram account..?
      I was dumb forgot the login password. I would love any tips you can offer me.

    • @mrmartinwatson1
      @mrmartinwatson1 3 ปีที่แล้ว

      @@lyleandres1510 you may be able to request a login if you remember the gmail or phone number. Other wise ya can call up there to instagram if you have anything else like a secondary phone number or know the hidden questions if u had any.

  • @e1nste1in
    @e1nste1in 3 ปีที่แล้ว +2

    Good video! Would be great to have another one about dynamically loading the *.ui file in Python.
    I especially struggle there to get sufficient typing support from the editors.

  • @irfanhazza
    @irfanhazza 2 ปีที่แล้ว +1

    is there no continuation to this great tutorial series :(

  • @alexandarjelenic7718
    @alexandarjelenic7718 3 ปีที่แล้ว +2

    this is a nice video. But keep in mind that you are not using the uic.load() function within python. You are creating a .py output. If you really want to "load ui files created in Qt designer" then do this:
    Class my_program(QMainWindow)
    def __init__(self):
    QMainWindow.__init__(self)
    my_ui='my_ui.ui'
    self.setWindowIcon(my_logo)
    uic.loadUi(my_ui,self)
    This save the step, of converting the ui to py and that way if you change anything in the .ui you dont lose your work!

    • @tuxcodes
      @tuxcodes  3 ปีที่แล้ว

      That is a good point! I will do another video addressing that specifically. Thanks for the pointer!

    • @tuxcodes
      @tuxcodes  3 ปีที่แล้ว +1

      I would also like to point out the tradeoff between the two methods. Both are completely valid, but loading the UI file directly instead of converting with UIC adds a little memory and computation overhead to the application. For small programs this isn't an issue, but for larger applications it can cause performance issues.

    • @josys363
      @josys363 2 ปีที่แล้ว

      @@tuxcodes This is true and you also lose the automatic code completion that IDEs like PyCharm provide.

  • @Skateforeva121
    @Skateforeva121 3 ปีที่แล้ว +1

    Traceback (most recent call last):
    File "C:/Users/Bryan/PycharmProjects/FirstProject/main.py", line 3, in
    from ui_mainwindow import Ui_MainWindow
    ValueError: source code string cannot contain null bytes
    #The file converted successfully and stored inside/next to main.py but I'm receiving this error?

    • @Skateforeva121
      @Skateforeva121 3 ปีที่แล้ว +4

      This bug(?) only occurs when pyside6-uic is run in powershell and the output is redirected to a file.
      If using powershell use the -o option to specify an output file. Both methods work fine from a normal command prompt.
      pyside6-uic mainwindow.ui > ui_mainwindow.py
      Instead
      pyside6-uic mainwindow.ui -o ui_mainwindow.py

    • @Jamie_Allan
      @Jamie_Allan 3 ปีที่แล้ว

      Thank you @@Skateforeva121!

    • @naseefo
      @naseefo 2 ปีที่แล้ว

      @@Skateforeva121 Thanks, it works!

  • @AlexanderPerez-oe1gu
    @AlexanderPerez-oe1gu 3 ปีที่แล้ว +1

    Thank you for posting these tutorials! Amazing job and well explained. Will you be posting on the proper way to add logic to once you've made the connection to the UI files?

  • @flavioperini2484
    @flavioperini2484 3 ปีที่แล้ว

    this was SO useful, thanks man

  • @girlsandfunny
    @girlsandfunny 2 ปีที่แล้ว

    Hi, very appreciate about the video but when I running the code in your vedio I got error "from ui_mainwindow2 import Ui_MainWindow
    ValueError: source code string cannot contain null bytes", may I ask how to solve that. Thank you.

  • @cyrilcalmes4208
    @cyrilcalmes4208 2 ปีที่แล้ว

    It does not work on my PC. Using Python 3.9, PySide6 and Qt Designer 5.11.1. I have this error.
    File "e:\PYTHON\Qt_PYTHON\main.py", line 3, in
    from ui_mainwindow import Ui_MainWindow
    ValueError: source code string cannot contain null bytes

  •  3 ปีที่แล้ว

    Nice :) we need more definetly.

  • @codepower2935
    @codepower2935 4 ปีที่แล้ว +1

    Thanks for sharing the tutorial, was really helpful, could you make a tutorial on how the qanimationproprety works, thanks again.

    • @tuxcodes
      @tuxcodes  3 ปีที่แล้ว

      Great suggestion!

  • @dnrbs2168
    @dnrbs2168 4 ปีที่แล้ว

    Hey Thanks for Tutorial
    Getting Error while Converting the Ui file in python file
    Error is pyside6-uic : The term 'pyside6-uic' is not recognized as the name of a cmdlet, function, script file, or operable
    program.
    Plz Help

    • @tuxcodes
      @tuxcodes  4 ปีที่แล้ว +1

      Are you running it inside a venv with pyside6 installed? Or did you install pyside6 globally? Also, what operating system are you running on?

    • @dnrbs2168
      @dnrbs2168 4 ปีที่แล้ว

      @@tuxcodes Hi Thank you for response.
      It is inside a venv with pyside6 installed. On Windows10-operating system, and Editer is PyCharm CE.
      While Translating the UI file with PyCharm throwing error as
      (venv) I:\AABBCC_ENV>pyside6-uic romi.ui > ui_romi.py
      ** On entry to DGEBAL parameter number 3 had an illegal value
      ** On entry to DGEHRD parameter number 2 had an illegal value
      ** On entry to DORGHR DORGQR parameter number 2 had an illegal value
      ** On entry to DHSEQR parameter number 4 had an illegal value
      While Using PowerShell thrown the error as: pyside6-uic : The term 'pyside6-uic' is not recognized as the name of a cmdlet, function, script file, or operable
      program.

    • @dnrbs2168
      @dnrbs2168 4 ปีที่แล้ว

      @@tuxcodes I solved the problem by Uninstalling latest Numpy-1.19.4, and installed numpy-1.19.3 on Windows10.

    • @alexandarjelenic7718
      @alexandarjelenic7718 3 ปีที่แล้ว

      here is no need to convert the ui to python. If you really want to "load ui files created in Qt designer" then do this:
      Class my_program(QMainWindow)
      def __init__(self):
      QMainWindow.__init__(self)
      my_ui='my_ui.ui'
      self.setWindowIcon(my_logo)
      uic.loadUi(my_ui,self)

  • @UnbiasedYT
    @UnbiasedYT 3 ปีที่แล้ว

    Fortnite fan eh? Nice video tbh! Keep it up.