PyQt5 Tutorial - ComboBoxes with Examples

Поділитися
Вставка
  • Опубліковано 26 жов 2024

КОМЕНТАРІ • 91

  • @TechWithTim
    @TechWithTim  5 років тому +4

    Enroll in my new course and get 50% off with the code: EARLYACCESS
    tech-with-tim.teachable.com/courses/the-fundamentals-of-programming-with-python/

    • @arbazkhan8320
      @arbazkhan8320 5 років тому +1

      It says invalid copuon

    • @TechWithTim
      @TechWithTim  5 років тому +1

      ya it expired... you can use 50K for 35% but only today!!

    • @tung-hanwu5865
      @tung-hanwu5865 2 роки тому

      Are there any coupons now?

  • @tundeo7675
    @tundeo7675 4 роки тому +3

    In case anyone was wondering, 11:11
    if xor == True: #turn everything into an int
    xor = 1
    else:
    xor = 0
    can be replaced with(for the same result as above):
    xor = bool(xor)
    Also, thanks for these videos Tim.

    • @priyanshumaity6780
      @priyanshumaity6780 5 місяців тому +1

      You can just do this:
      xor = int((x and not y) or (not x and y))
      The integer of True is 1 and of False is 0 (Based on truthy and falsy values)

  • @xgriff91
    @xgriff91 5 років тому +2

    A tutoriel on QTabWidgets would be really cool !
    Daily uploads are really appreciated Tim ;)

  • @Sklyvan
    @Sklyvan 4 роки тому +6

    def XOR(self, X, Y): return int(X != Y)

  • @anabelsa
    @anabelsa 3 роки тому

    Great tutorial, and the text-based version is of great help. Thank you very much.

  • @mighell__
    @mighell__ 3 роки тому

    thank you man you saved my night

  • @briangicharu2899
    @briangicharu2899 3 роки тому

    Thanks man you just saved me a headache

  • @NajmehParandeh
    @NajmehParandeh 2 місяці тому

    Well done!
    Thank you so much ❤

  • @ashish2099
    @ashish2099 2 роки тому

    Thank you brother. God bless you

  • @sayanghosh6996
    @sayanghosh6996 4 роки тому +2

    you can just do
    xor = x ^ y
    python (like all programming languages) has xor operator built in

  • @bibohahah2079
    @bibohahah2079 4 роки тому

    def pressed(self):
    num1 = int(self.comboX.currentText())
    num2 = int(self.comboY.currentText())
    result = num1 ^ num2
    self.label.setText(f"{num1} XOR {num2} = {result}")

  • @yuryak3551
    @yuryak3551 3 роки тому

    Thank you very much for the video, you helped me a lot

  • @plouf1969
    @plouf1969 3 роки тому +1

    Great video Tim, but I would point out that editing the python file that was generated by pyuic5 is a bad idea, because it prevents you from doing any further edits to the .ui file - as it would recreate the python file and you'd lose your changes. Instead the proper process is to import that python file and then subclass it, and add the additional features / events there.

    • @tanmaypatel4152
      @tanmaypatel4152 2 роки тому

      Man this is a really great idea. I owe you man!

    • @lucasmancini1283
      @lucasmancini1283 2 роки тому

      I thought the same as you and basically solved it like this

  • @romanthchowan1578
    @romanthchowan1578 5 років тому

    please make tutorial on Layouts in detail
    i love your videos

  • @ainpe
    @ainpe 4 роки тому +2

    Tim, how can i accomplish the same but without Submit button? I want to give me result once either of comboboxes is changed
    Thanks in advance.

  • @AliTwaij
    @AliTwaij 3 роки тому

    Brilliant Thankyou

  • @yisanhuang9298
    @yisanhuang9298 4 роки тому

    I love your tutorial, it's very cool!

  • @iaggocapitanio7909
    @iaggocapitanio7909 4 роки тому +2

    Very nice, but will be also very nice if there is a more deep approach

  • @preedapayattakool7512
    @preedapayattakool7512 4 роки тому

    this is very great video , it pretty clear explanation , do u plan to have any python with QML ? really looking forward and million thx

  • @alexandarjelenic2880
    @alexandarjelenic2880 5 років тому +2

    Tim, please consider loading the . ui files within the .py. instead of converting them.

  • @abdulhaseeb4980
    @abdulhaseeb4980 2 роки тому

    What if we have two combo boxes are radio buttons and we want to make sure that the user will be able to press submit button once we have both inputs?

  • @aditipathak9621
    @aditipathak9621 4 роки тому

    nice tut sir

  • @bekirkagankaraahmetoglu4343
    @bekirkagankaraahmetoglu4343 5 років тому

    Hey Tim! I love your videos. Can you make a C++ tutorial if you are interested in C++. I'd like to learn it from you.

  • @d-shiri
    @d-shiri 4 роки тому

    or one can just cast True or False into int and then you don't need to add those if statement like int(x and not y) | (not x & y))

  • @meltpoolmartin772
    @meltpoolmartin772 5 років тому +3

    I had an issue on mac that the text of label doesn't update after its method was called
    After inserting an self.label.repaint() the update process runs smooth

  • @aryanbhatia6992
    @aryanbhatia6992 5 років тому

    Will you be making a big project in this series ??

  • @fdffefegtetrtrg8445
    @fdffefegtetrtrg8445 4 місяці тому

    Hi, it gives to me the error "Name error. Ui_MainWindow is not defined" and then the program crushes. How is it possible resolve it? Thanks.

  • @lolko211
    @lolko211 4 роки тому

    Thanks

  • @QuarktaschemitSenf
    @QuarktaschemitSenf Рік тому

    Hey Tim mine just works one time although i implemented the code at the exact same place. Any ideas?

  • @mohitarora1701
    @mohitarora1701 3 роки тому

    I am writing command inside the qt designer so how can I make rounded drop list view. I tried and it worked but the main problem is that the background behind that rounded area is also visible.

  • @Tamer_Gomaa
    @Tamer_Gomaa 4 роки тому

    Hi Tim,
    I'm wondering how to assign "Hint text" to the combo box ? That will be disappeared when select any item from the combo box.
    Another question, is there an event for the list when dropped down?
    Thanks

    • @sanjeevkrishnaa2672
      @sanjeevkrishnaa2672 4 роки тому

      just saying, i am pretty sure he wouldn't reply to questions in a year old video

  • @thxyves8468
    @thxyves8468 3 роки тому +5

    Very, very good video just as the other stuff you make. Thanks a lot. Just a little remark, the code could be smaller by replacing the code line 73 to line 76 by : xor = x ^ y

  • @javiporras3396
    @javiporras3396 4 роки тому

    great video

  • @fdffefegtetrtrg8445
    @fdffefegtetrtrg8445 4 місяці тому

    The program says to me . Why?

  • @one-word-edu
    @one-word-edu 2 роки тому

    Hello.. How can I add multiple columns to a ComboBox and hide some of them ?

  • @sayyedrizwanali
    @sayyedrizwanali 2 роки тому

    in line 67 command has changed in new version
    "submit" is replaced by "pushButton"

  • @barunbasnet
    @barunbasnet 5 років тому +3

    You could have just used the Boolean operator '^' for XOR operation in the python instead.

  • @muni3131
    @muni3131 3 роки тому

    Very instructive and enjoyable but...
    Why do these programs not run outside an environment like Thonny on Linux ? I don't know what environment Tim is using. No problem with simple programs that use only "import os" but create no windows so I know it needs access to QT components. But how to include them?
    Edit: Answering my own question:
    enter this as first line in the .py script:
    #! /usr/bin/env python3
    and change the file permissions to make it executable
    I wonder if it will work in Windows now. I haven't tried yet.

  • @KirtiSoni12
    @KirtiSoni12 4 роки тому

    Can we use the current value of the COMBO Box to change the value in the string?
    for eg. i have a string"A,1,1,XY" this XY are the values that need to be inserted after selecting from combo box and this must be done every time the value is changed from the box.

  • @pavanmacherla1295
    @pavanmacherla1295 3 роки тому

    When I pass the " 1 " or " 0 " in the findText() function i am getting -1 as return value. Is there any other format for numbers?

  • @chinaguy101
    @chinaguy101 3 роки тому

    great!

  • @Guitarluke13
    @Guitarluke13 5 років тому

    I'm trying to do something similar but when I press my button it closes my main window, do you know what could be causing this?

  • @maryam7221
    @maryam7221 Рік тому

    Hello, can you teach us how to make a cobobox with pyqt that can search all the values ​​by entering text, for example by entering po it will show all the following parameters (hello pow) or police and so on.

  • @שחרכהן-ס7ר
    @שחרכהן-ס7ר 5 років тому

    You can pls make a gui tutorial with tkinter or other module

  • @Daniel-nn8oy
    @Daniel-nn8oy 5 років тому

    Hello can you help me?
    I inserted data from a database table into my comboBox
    Now I need to get the ID of this Table when I select the item in the ComboBox to insert in the foreign key of my second table. Can you do that?

  • @edouardbai1031
    @edouardbai1031 3 роки тому

    I used the exact same commands, how come I cannot get error: name 'pressed' is not defined.

    • @edouardbai1031
      @edouardbai1031 3 роки тому

      Oh, shoot. It is (self.pressed) instead of (self,pressed)

  • @cemrek.
    @cemrek. 4 роки тому

    you are god

  • @thomasbrocherie7543
    @thomasbrocherie7543 5 років тому

    Can you show us how to get keyboard input?

  • @MarceloSilva-rv7sm
    @MarceloSilva-rv7sm 4 роки тому

    Muito obrigado!

  • @JonSnyderfudge
    @JonSnyderfudge 2 роки тому

    For anyone wondering, Python has an xor operator using "^"
    Don't do what this guy did.

  • @sainco3036
    @sainco3036 5 років тому

    thanks.

  • @edouardbai1031
    @edouardbai1031 3 роки тому

    Now, cannot find reference 'connect' in 'function'. What should I do?

    • @edouardbai1031
      @edouardbai1031 3 роки тому

      Also, x = int(...) has error: Invalid Literal for int() with base 10:' '

  • @abdullahsaid8561
    @abdullahsaid8561 4 роки тому

    why not use bool()?

  • @navneetsrivastava688
    @navneetsrivastava688 Рік тому

    Can you just make a tutorial on pyqt5 threading

  • @user-cj3yu9nv1u
    @user-cj3yu9nv1u 5 років тому

    If we change the ui file and overwrite the python file again, won't all of your changes and methods disappear?
    Edit: How do we fix this issue? Can we inherit the class Ui_MainWindow in another py file? That is what I used to do in PyQt4
    Thanks in advance.

    • @user-cj3yu9nv1u
      @user-cj3yu9nv1u 5 років тому

      Sorry, I accidentally repeated the post.

  • @JasonLee-pr4sx
    @JasonLee-pr4sx 4 місяці тому

    why not just xor=x^y ?

  • @stefanjovanovic3382
    @stefanjovanovic3382 4 роки тому

    cant you just make variable xor a boolean and then it would always return True/False

  • @Aeztrest
    @Aeztrest 5 років тому +5

    hi Tim! i really Enjoy your videos plz heart

  • @arbazkhan8320
    @arbazkhan8320 5 років тому +1

    tim both 35% and 50% are 79$ why is it so?

    • @TechWithTim
      @TechWithTim  5 років тому +1

      You need to use the discount code at checkout

  • @bysantin
    @bysantin 5 років тому

    maybe str(bool(xor))?

  • @cunninghamb505
    @cunninghamb505 5 років тому

    Is there a way to change the style to fusion in qt5

  • @Dylanfire2
    @Dylanfire2 4 роки тому

    has anyone found any other good Qt tutorial thats complete?

  • @faisal3560
    @faisal3560 5 років тому

    How to populate it from SQL?

  • @johnz0rxxx
    @johnz0rxxx 3 роки тому

    nice nice

  • @vsp540
    @vsp540 4 роки тому +2

    No reason to use: "xor = (x and not y) or (not x and y)" just use: "xor = x ^ y"

  • @rmgburke
    @rmgburke 5 років тому

    At ua-cam.com/video/crJVzc5Ct_s/v-deo.html you can also use this: answer = ("False", "True")[(x and not y) or (not x and y)] instead of an if statement. The False/True tuple will use the index of the xor test and return "False" (index 0) or "True" (index 1). That way, you don't need the xor variable or an if statement.

  • @НикитаЗеркалёв

    Нормально, нормально

  • @roberts1849
    @roberts1849 3 роки тому

    self.label.setText("X XOR Y = " + str(int(xor))) - for lazy people like me, just use conversion on xor variable. No more TRUE & FALSE problem.

  • @Trubripes
    @Trubripes 3 роки тому

    XOR(x,y) = x!=y

  • @user-cj3yu9nv1u
    @user-cj3yu9nv1u 5 років тому

    If we change the ui file and overwrite the python file again, won't all of your changes and methods disappear?
    Edit: How do we fix this issue? Can we inherit the class Ui_MainWindow in another py file? That is what I used to do in PyQt4
    Thanks in advance.

    • @MiskoKatua
      @MiskoKatua 4 роки тому

      Separate the UI file from the Python file by importing the module uic:
      from PyQt5 import QtWidgets, uic
      Then load the UI by specifying the UI file:
      window = uic.loadUi("mainwindow.ui")
      This way you can make changes to the UI without losing the logic.