In case this is useful to anyone else: I was having a hard time getting the Qmessagebox to center on the main window (rather than the screen.) I fixed this by inheriting from MainWindow when defining msg like so: msg = QMessageBox(MainWindow)
You're really NOT supposed to edit the main .UI file that's generated by QT Designer. From my simple research, it's best to just import the .UI file into a new .py file instead of converting the .ui file into a .py file because you will need to continue editing the ui file or making changes to it and you don't want to keep exporting and overwriting it each time that you convert it. So the real way is to continue on by importing it instead. Then you'll be able to keep editing the main .ui file without making any changes to the main py file that you're using to import the .ui file.
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.
Why don't button match their position from msg.setStandardButtons? You typed "Cancel Retry Ignore", but in the window there are "Retry Ignore Cancel" (and "Ignore Cancel Retry" on my computer). Your "Show Details" button appears as the 3rd, mine does as the 1st. Also, my Cancel button has its letter C underlined and can be pressed with C key, and the program prints "&Cancel" in the terminal when I press it.
The return value from msg.exec_() would be the state of the button right (OK button in this case)? How else would you know if the user clicked ok or closed the window
8:10 how come when you are calling the function self.popup_button you don't need to use a lambda function in order to pass an extra parameter (the button itself) like you showed in a previous video?
Hi Tim, I am trying to do a small software for ecommerce in which will have inventory, picking, packing, despatch, users...would you recommend PyQt5 for this or have any other suggestions? Great content, keep it up (Y) !
actually the _exec() method returns an int code that shows which button was pressed .. so for each button type there is an unique code. so the x variable is there to save the returned code.
After I translate the ui file into python, and I write code in it, but how can I transform back to an ui file where I can still edit it with all my code saved?
Thanks for this video. However, it does not seem practical for this reason, especially for Questions. Wherever an issue arises (e.g. "file not found"), need to resolve that issue in a unique way Where the issue arises, not in Dialog code. Issues found elsewhere (e.g. "name is missing") have other reactions. I've seen in other languages something like "If reply == 'yes' do A, else do B". The reply is returned from Dialog box code. The reactions A and B may be different with each issue. We shouldn't need separate Dialog boxes for each issue. Does PyQt5 not have the return value or does your video not include this for some reason?
Here is sample code to use at point of issue: reply = QMessageBox.question(self, 'title', 'issue question? ',QMessageBox.Yes, QMessageBox.Cancel,) then on next line: if reply == Qtw.QMessageBox.Yes: do A. EDIT: This does not use the show_popup function in your video.
Why when I create a simple message box, run the program, box shows up and then I pressing OK and... whole program crashing. Code is similar that yours...
I did this and have small problem, when I click cancel in the popup window, the python shell prints "&Cancel", in the other buttons no problems. Thanks in advance. I have subscribed your channel
I use VScode. and 3:42 when i type 'cri...' a context menu? appears. And it recommends 'critical' not 'Critical' but when i compileed? the program. it didn't work. When 'Critical' then worked
Hi, Is it possible to add the rows and column dynamically ? Can you Please make a video about QTableView. especially for matrix operation like multiplication
Can sb explain how popup_button function "understands" where to take data for parametr clicked_button? because we don't put any parametrs when connecting this function msg.buttonClicked.connect(self.popup_button) I understand that we can't use brackets and if we like to pass parameters we should use lambda instead. But here we just do nothing and parametr is passed inside popup_button function... Confused...
Hi, i ran into the following issue when i tried to import the lib: "No name 'QMessageBox' in module 'PyQt5.QtWidgets' " Does anyone know how to fix it?
I got the same thing but then noticed a syntax error in my typing. You get that error when you paste in this line? from PyQt5.QtWidgets import QMessageBox
i copy the same text you out in this tutorial but an error message pop up says " line 10 in from PyQt5.QWidgets import QMessageBox " moduleNotFoundError: No module named 'PyQtf.QWidgets'
ERROR: Could not find a version that satisfies the requirement pyqt5-tools (from versions: none) ERROR: No matching distribution found for pyqt5-tools this is the error i am getting, when i tried to install this. I am using Ubuntu 18.04, python 3.7.3, and pip 19.1.1 i also tried to search about this problem, i came to know that, this pyqt5-tools only supports windows not for linux. Can u suggest me some other. what should i do? i am not going to windows for this. any help will be useful.
Hi Tim, I was doing a login system and I want to pop up this Qmessage if the email is not matched. The function does work, but for how many times (let's say 4) i click login button with wrong email, the function seems to remember it and once i successfully logged in, the message box will show that many times (in this case 4). Is there any way to solve this issue? Thanks
I like how he completely ignores the warning message to not edit the file :D He is going to cause a lot of people shoot themselves in the foot when they accidentally overwrite their work.
give ya a 2 thumber. Do you have / or know how to load images from url? I cant seem to find a straight forward way to do so in PyQt5. I can do it with tkinter but I want to user PyQt5 to build my interface. I really want to stick with pyqt if at all possible.
anyone having error with self.button.clicked.connect(show_popup), stating show_popup not defined? I have the method verbatim to this tutorial, but receiving error.