Working With Qt Designer's UI Files And PyQt

Поделиться
HTML-код
  • Опубликовано: 1 ноя 2024

Комментарии • 26

  • @hexisXz
    @hexisXz Год назад +11

    This should be a series.

  • @fcolecumberri
    @fcolecumberri Год назад +9

    You don't need to connect the signal and the slot, if you name your function "on__" in this case "on_one_btn_clicked" qt connect them automatically, this is nice because enforces consistency among multiple programmers and avoid bloat on the code.

  • @jackkeifer
    @jackkeifer Год назад +1

    1st Class tutorial. Nicely done Derek! Qt & I go back well over 15 years (C++ & Qt Creator), and pyQt maybe 8 years give or take... it just never gets old!

  • @ZeStig
    @ZeStig Год назад +2

    Really nice video DT!

  • @ThrowAway-t3m
    @ThrowAway-t3m Год назад

    I like to name like this: (assuming a button) btn_button_name.
    That way if I forget what the button is called it's very easy to bring up the autocomplete and see a list of every button just by typing "btn". I find it much easier to remember the type of control I'm looking for instead of the name and once I narrow down the lists to types it's usually pretty obvious which specific buttons (or other types) I'm looking for.

  • @sausix
    @sausix Год назад +2

    Why not using PySide which is an official Qt project and probably has more maintainers? The interface and syntax is similar and even more pythonic.
    Loading ui files directly is easier. Only disadvantage is not having a py file for type hints and annotations. But do vim users even know what they're missing 😀

  • @griffon2-6
    @griffon2-6 Год назад +11

    12:14 if you are feeding script to python executable like that, chmod +x does nothing in that case

    • @DigitalMetal
      @DigitalMetal Год назад +4

      He needs to add the Shebang to his script. It drives me crazy when people don't have a shebang in their scripts.

    • @KR1ML0N
      @KR1ML0N Год назад

      ​@@DigitalMetalagreed I feel thr same

  • @merthyr1831
    @merthyr1831 Год назад +1

    If you want a python script to run in headless mode (w/o console output) you can change the extension to .pyw instead of .py. Obvs your xmonad hides that stuff anyway but might be good for hiding your script's console output from your users.

  • @rawmaterials3909
    @rawmaterials3909 Год назад +2

    I'm trying to dig into python and qt because I want to write an application. So, to sum it up... this method is preferred because:
    1) you don't generate a bloated ui file
    2) you can make changes on the fly without having to rebuild the ui file
    is that correct? so, does the method DT showed in the previous video has its advantages?
    Btw, thanks as always for your videos DT, you're the best!

    • @johanngambolputty5351
      @johanngambolputty5351 Год назад +2

      That is correct, I don't think the previous method has any advantages, you can still add custom widgets in a dynamic way if you like after loadUI. For instance, I leave empty frames in designer then I add matplotlib plots to them in init.

  • @_..-_-.._
    @_..-_-.._ Год назад +6

    u mean dtos spin not distro

  • @jcugnoni
    @jcugnoni Год назад +1

    qt designer and PyQt are great; but I don't really like using pyuic and prefer to import .ui files at runtime. Indeed, it gives a better separation between the UI and the code and is simpler to maintain over time. Of course, this is only usefull if we use Qt Designer.. Direct coding the ui in PyQt is also a option but I usually find it frustrating...

    • @ThrowAway-t3m
      @ThrowAway-t3m Год назад

      I made a separate python script that calls pyuic and compiles all the files in a specified directory into a different output directory in my project. This way the python code is available in the editor (VS code in my case) allowing it to offer autocomplete on widgets names defined within the UI. This saves me a lot of time/effort because I don't have to meticulously make sure I got the object name right, I choose it from a list and the editor makes it match verbatim!
      I usually create a controller script for each UI that handles separating the UI from the logic. The controller is also a good place to make slight tweaks to the UI that the designer doesn't allow for (like setting window flags).
      All I have to do when tweaking the UI is edit the ui file in designer then call my compile script and my app is ready to go (granted deleting things or changing object names may mean you have to make alterations to the controller but your main logic will be unaffected)

  • @leontalkdaliy5894
    @leontalkdaliy5894 Год назад +1

    you and your custom linux are fuking amazing.

  • @munir2010able
    @munir2010able Год назад

    What was the rufi them u where using for your search. Loved the sound effect too

  • @essetee
    @essetee Год назад +3

    just rename your buttons the other way. btn_one ... With intellisense when you hit bt all your buttons are grouped together to choose the one you want.

    • @ThrowAway-t3m
      @ThrowAway-t3m Год назад

      Unfortunately using the uncompiled .ui file means that no editor will actually be able to give the type hints. That said if you are using the .py compiled version starting with 'btn_' is the way to go!!!

  • @neotwenty-nineBzH
    @neotwenty-nineBzH Год назад

    Hello DT. Is your code on line on your gitlab? 😊

  • @bechirzouaoui5821
    @bechirzouaoui5821 Год назад

    what kinda OS are you using ?

  • @PANDURANG99
    @PANDURANG99 Год назад +1

    Qt designer is not free

    • @vladimirkraus1438
      @vladimirkraus1438 7 месяцев назад

      Of course it is free. It is such a crap that no one would pay for it.

  • @fir3w4lk3r
    @fir3w4lk3r Год назад

    "Python is a real language". :P :P :P