r/pyqt5 • u/[deleted] • Jan 23 '21
r/pyqt5 • u/Chaitanya00Kumar • Jun 20 '22
Anyone want be my buddy for PyQt5?
Well I am looking for a person who knows about PyQt5 and could help me and maybe mentor me when learning or creating PyQt5 applications. This could help me a lot since there aren't many people out there to help in the topic of PyQt5.
r/pyqt5 • u/reywaz_ • Jun 07 '22
PyQt5 Close Window on Condition
Hello, I didn't find any answer so I ask this question here. Here is my login window:
https://www.codepile.net/pile/4g0dnagw
And here is my signup window:
https://www.codepile.net/pile/W0XMqg7K
I would like to close the signup window by clicking on "Create" button only when the criterias are met (if taken_username == False and invalid_password == False and not_same_password == False
). My problem is that I don't know how to make an action on a button only when a condition is met.
I tried by writing "Signup_Dialog.close()" in the condition (in the function create), but it doesn't work.
It also doesn't work by writing a condition in the function setupUi (like creating a variable set to 0 by default and calling "Signup_Dialog.close()" if the variable is 1, and change it to 1 in the function create if the criterias are met).
How can I do that? Thank you in advance for you answer!
r/pyqt5 • u/Skenderbeu • Nov 16 '20
Welcome to PYQT5!
All,
I'll be moderating this community sparingly and since it seems the number of readers is growing I'm looking for alternate moderators. If you're a Pythonista and looking to engage the reddit community send me a PM and I'll evaluate your profile.
Enjoy your stay here!
r/pyqt5 • u/pesterone • Jul 12 '22
QDialog problem
Hello r/pyqt5, I've got myself into a pickle here. I'm making a GUI application and when I tick a checkBox in my main GUI window I want to open a dialog box that has a text field inside of it and when i click OK inside that dialog window I want to do some operations with that text and close the dialog window, for some reason i can't call self.close()
When I click the button it should call a method inside of my Ui_Dialog class and it should do the operation i want and close the window after that, all of the following code is auto-generated by QtDesigner
from PySide2.QtCore import (QCoreApplication, QMetaObject, QObject, QPoint,
QRect, QSize, QUrl, Qt)
from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QCursor, QFont,
QFontDatabase, QIcon, QLinearGradient, QPalette, QPainter, QPixmap,
QRadialGradient)
from PySide2.QtWidgets import *
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
class Ui_Dialog(QDialog):
drugeLok = ''
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(400, 300)
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(10, 0, 261, 21))
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label.setFont(font)
self.label.setObjectName("label")
self.lokDialogText = QtWidgets.QPlainTextEdit(Dialog)
self.lokDialogText.setGeometry(QtCore.QRect(10, 20, 381, 251))
self.lokDialogText.setObjectName("lokDialogText")
self.lokOKButton = QtWidgets.QPushButton(Dialog)
self.lokOKButton.setGeometry(QtCore.QRect(170, 270, 75, 23))
self.lokOKButton.setObjectName("lokOKButton")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
self.lokOKButton.clicked.connect(self.takeText)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Druge lokalizacije upisati uredno ovde!"))
self.lokOKButton.setText(_translate("Dialog", "OK"))
def takeText(self):
self.drugeLok = self.lokDialogText.toPlainText()
self.close()How I call the creation of the Dialog is like this:
def apscesiDialog(self):
if(self.apscesDrugoCheckBox.isChecked()):
apscDialog = QtWidgets.QDialog()
ui = Ui_apscDialog()
ui.setupUi(apscDialog)
apscDialog.show()
self.apscesDrugoCheckBox.setChecked(False)
apscDialog.exec_()This part is inside of the main GUI.py file
r/pyqt5 • u/Noah_j4 • May 13 '22
Issues installing PyQt5-tools
When I run
pip install pyqt5-toolsI get the following:
Collecting pyqt5-tools
Using cached pyqt5_tools-5.15.4.3.2-py3-none-any.whl (29 kB)
Collecting pyqt5==5.15.4
Using cached PyQt5-5.15.4.tar.gz (3.3 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [29 lines of output]
Traceback (most recent call last):
File "C:\Users\Noah\Desktop\Python_Programme\IOS\Hefte\venv\lib\site-packages\pip_vendor\pep517\in_process_in_process.py", line 156, in prepare_metadata_for_build_wheel
hook = backend.prepare_metadata_for_build_wheel
AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Noah\Desktop\Python_Programme\IOS\Hefte\venv\lib\site-packages\pip_vendor\pep517\in_process_in_process.py", line 363, in <module>
main()
File "C:\Users\Noah\Desktop\Python_Programme\IOS\Hefte\venv\lib\site-packages\pip_vendor\pep517\in_process_in_process.py", line 345, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "C:\Users\Noah\Desktop\Python_Programme\IOS\Hefte\venv\lib\site-packages\pip_vendor\pep517\in_process_in_process.py", line 160, in prepare_metadata_for_build_wheel
whl_basename = backend.build_wheel(metadata_directory, config_settings)
File "C:\Users\Noah\AppData\Local\Temp\pip-build-env-1bzp5pc4\overlay\Lib\site-packages\sipbuild\api.py", line 51, in build_wheel
project = AbstractProject.bootstrap('pep517')
File "C:\Users\Noah\AppData\Local\Temp\pip-build-env-1bzp5pc4\overlay\Lib\site-packages\sipbuild\abstract_project.py", line 83, in bootstrap
project.setup(pyproject, tool, tool_description)
File "C:\Users\Noah\AppData\Local\Temp\pip-build-env-1bzp5pc4\overlay\Lib\site-packages\sipbuild\project.py", line 594, in setup
self.apply_user_defaults(tool)
File "C:\Users\Noah\AppData\Local\Temp\pip-install-howerjbz\pyqt5_346057b3605441ceb75a2e818ebc703e\project.py", line 63, in apply_user_defaults
super().apply_user_defaults(tool)
File "C:\Users\Noah\AppData\Local\Temp\pip-build-env-1bzp5pc4\overlay\Lib\site-packages\pyqtbuild\project.py", line 70, in apply_user_defaults
super().apply_user_defaults(tool)
File "C:\Users\Noah\AppData\Local\Temp\pip-build-env-1bzp5pc4\overlay\Lib\site-packages\sipbuild\project.py", line 241, in apply_user_defaults
self.builder.apply_user_defaults(tool)
File "C:\Users\Noah\AppData\Local\Temp\pip-build-env-1bzp5pc4\overlay\Lib\site-packages\pyqtbuild\builder.py", line 67, in apply_user_defaults
raise PyProjectOptionException('qmake',
sipbuild.pyproject.PyProjectOptionException
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.r/pyqt5 • u/Waveparticle44 • May 08 '21
How to set background image for tab widget?
I want to set the background image of my tab widget in PyQt5 designer. I tried QTabWidget#name{background-image: url(path\to\my\image)} but it didn't work. I tried it for other widgets but none of them changed background. Am I doing something wrong? or is there some other way to do this in pyqt5 designer?
r/pyqt5 • u/ashleyjacq • Apr 19 '21
Do you know project based tutorial?
Hey, i am a python developer and i want to learn pyqt5. I am searching project based tutorial but did not find yet. Do you know any?
r/pyqt5 • u/kaoru44 • Mar 22 '21
onClick with QAbstractTableView
Hi Everyone,
I just started my own deployment with Python and PyQT5, I currently have an QAbtractTableView class, what I would like to ask for help is how can I implement an onClick method for this table? or is there any documentation that I can follow to move forward?
r/pyqt5 • u/asquidfarts • Aug 10 '19
How would I go about structuring my PyQt5 app
So I just wrote an app using PyQt5. I am wondering if there is a proven method of structuring an app so it can be easy to grow as new features are added.
r/pyqt5 • u/I_nzui • Jul 14 '22
Rotate Movie?
Hi,
How would one rotate a movie within a label? I'd like to have a gif rotated.
Thanks a lot!
r/pyqt5 • u/[deleted] • Jul 08 '22
Basic PyQT5 Question... Can I change a widget's properties from a different class?
I've been asking multiple sites this question and can't come up with an answer. I wouldn't have need to do this typically but I've got a lot of event handling occurring that needs to be managed by a seperate class and I would like to then edit a widget, in a seperate, mainwindow class but I am struggling to find a way to reference the widget....
Any tips?
r/pyqt5 • u/Quartz_manbun • May 29 '22
MDI Subwindows scaling strangely.
I'm working on a gui tool-- I'm building it with Pyqt5. I'm speifically NOT using QT designer. I'm using an MDI widget to keep everyhing a bit tidier. Furthermore, so that my code is more crisp and less redundant, I'm building out each child window in a separate window in the same directory and then just importing the appropriate class from the individual files. The problem is, whenver I import the subwindows, the are scaled up in the MDI subwindow. I am at a loss as to how I can address this. Has anyone expierenced something similar? I've added simplied code for my MDI subwindow below, followed by the code for one of the subwindows thta I'm importing. Any assistance would be greatly appreciated.
class MDIWindow(QMainWindow):
count = 0
htntoolcount = 0
copdcount = 0
def __init__(self):
super().__init__()
self.mdi = QMdiArea()
self.setCentralWidget(self.mdi)
self.setStyleSheet('font-size: 10pt; font-family: Times;')
self.setStyleSheet("QPushButton{font-size: 10pt;}")
self.setStyleSheet("QLabel{font-size: 10pt;}")
self.mdi.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
self.mdi.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
#####Setting up main Menu Labels and Buttons#####
self.mainMenuWidget = QWidget(self)
self.mmWidgetLayout = QVBoxLayout()
self.mainMenuWidget.setLayout(self.mmWidgetLayout)
self.mainMenuWidget.setWindowTitle("Main Menu")
self.mmButton1 = QPushButton("Note Setup Tool", self)
self.mmButton2 = QPushButton("Lab Entry Tool", self)
self.mmButton3 = QPushButton("Follow Up Tools", self)
self.mmButton4 = QPushButton("ROS Generator", self)
self.mmButton5 = QPushButton("Physical Exam Generator", self)
self.mmButton6 = QPushButton("Cardon Matrix", self)
self.mmButton7 = QPushButton("Trilogy Matrix", self)
self.mmButton8 = QPushButton("ASC Matrix", self)
self.mmButton9 = QPushButton("Proactive Email", self)
self.mmWidgetLayout.addWidget(self.mmButton1)
self.mmWidgetLayout.addWidget(self.mmButton2)
self.mmWidgetLayout.addWidget(self.mmButton3)
self.mmWidgetLayout.addWidget(self.mmButton4)
self.mmWidgetLayout.addWidget(self.mmButton5)
self.mmWidgetLayout.addWidget(self.mmButton6)
self.mmWidgetLayout.addWidget(self.mmButton7)
self.mmWidgetLayout.addWidget(self.mmButton8)
self.mmWidgetLayout.addWidget(self.mmButton9)
self.mdi.addSubWindow(self.mainMenuWidget)
##adding actions to main menu buttons##
self.mmButton1.clicked.connect(self.noteSetupFunc)
self.mmButton2.clicked.connect(self.admissionTool)
self.mmButton3.clicked.connect(self.COPDToolFunc)
self.setWindowTitle("Proactive Charting Tool")
def noteSetupFunc(self):
self.noteSUButtFuncWidget = NOTEWindow()
self.mdi.addSubWindow(self.noteSUButtFuncWidget)
self.noteSUButtFuncWidget.show()
Subwindow code below.
class NOTEWindow(QWidget):
def __init__(self):
super().__init__()
self.notemdi = QWidget()
self.setStyleSheet('font-size: 10pt; font-family: Times;')
self.setStyleSheet("QPushButton{font-size: 10pt;}")
self.setStyleSheet("QLabel{font-size: 10pt;}")
#Setting MAin Menu Widget for this nested MDI#
self.NOTEmainMenuWidget = QWidget(self)
self.noteMMWidgetLayout = QVBoxLayout()
self.NOTEmainMenuWidget.setLayout(self.noteMMWidgetLayout)
self.NOTEmainMenuWidget.setWindowTitle("Note Menu")
self.mmButton1 = QPushButton("Note Setup Tool", self)
self.mmButton2 = QPushButton("Lab Entry Tool", self)
self.mmButton3 = QPushButton("Follow Up Tools", self)
self.mmButton4 = QPushButton("ROS Generator", self)
self.mmButton5 = QPushButton("Physical Exam Generator", self)
self.mmButton6 = QPushButton("Cardon Matrix", self)
self.mmButton7 = QPushButton("Trilogy Matrix", self)
self.mmButton8 = QPushButton("ASC Matrix", self)
self.mmButton9 = QPushButton("Proactive Email", self)
self.noteMMWidgetLayout.addWidget(self.mmButton1)
self.noteMMWidgetLayout.addWidget(self.mmButton2)
self.noteMMWidgetLayout.addWidget(self.mmButton3)
self.noteMMWidgetLayout.addWidget(self.mmButton4)
self.noteMMWidgetLayout.addWidget(self.mmButton5)
self.noteMMWidgetLayout.addWidget(self.mmButton6)
self.noteMMWidgetLayout.addWidget(self.mmButton7)
self.noteMMWidgetLayout.addWidget(self.mmButton8)
self.noteMMWidgetLayout.addWidget(self.mmButton9)
self.NOTEmainMenuWidget.show()
def main():
app = QApplication(sys.argv)
font = QFont('Times', 10)
app.setFont(font)
mdiwindow = NOTEWindow()
app.exec_()
if __name__ == '__main__':
main()
------------------------------------------------------
Thanks for any and all help!
r/pyqt5 • u/Ridge9909 • May 13 '22
Remembering user selection Qcombobox
Hi all,
I need some help with Pyqt. I'm still relatively new I've been working with it on and off for around 2 years.
I have a qcombobox with a couple of items and I perform an action based on the selection when a qpushbutton is clicked, the window closes after the button is clicked. So what I'm struggling with is saving the last index of the qcombobox and applying it to the UI when the window is opened again.
I've tried saving the index as a var and setting the index globally when the window is launched but no luck. Has anyone ever tried to do something like this? any help or advice would be greatly appricated.
r/pyqt5 • u/RiverHorsesArePurple • Jan 20 '22
Testing guidance
I've joined on to a project with a massive PyQt5 app that's near completion and in need of testing. I'm aware of pytest-qt and unittest, but am struggling hard to actually implement any working tests. The examples I'm finding all seem to include a # grab your element here aside, and this is exactly what I can't figure out.
How to I grab a widget, or form box, or a tab, or anything, so I can then test its label, or contents, or try to interact with it?
Are there resources or more thorough documentation I could be looking at for help?
- Much appreciation
r/pyqt5 • u/rkarl7777 • Jan 17 '22
Where should the bulk of our Python code go after setting a pyqt5 UL?
All the pyqt5 examples I have seen show a small amount of code being executed when a button (signal) triggers an action method (slot). But what if you have a huge amount of code that gets executed once the user clicks the OK button?
Imagine you have an entire banking system with a pyqt5 UI. The user interacts with the UI and finally clicks OK. Now we're in the UI button clicked method. Now what? Do we instantiate a Bank class and do everything right within the button clicked method? What's the proper way to do this? Thanks!
r/pyqt5 • u/rkarl7777 • Jan 10 '22
Can I set the stylesheet for ALL my buttons at once, instead of individually?
I know how to set up a single button to look and behave a certain way. But now I want to have 20 buttons that look and behave exactly the same, except for a slight difference in the .clicked.connect() routines. Setting the stylesheet individually for each button 20 times is a lot of code.
Is there some way to set the stylesheet for all my buttons at once?
Thought: They could even share the same connect routine, if the routine knew which button had triggered it.
[Edit: Thank you, everyone. I have now figured out how to create a stylesheet that solves my problem.]
r/pyqt5 • u/Riffle_X • Dec 08 '21
How do I display an array in gui format?
So I have an array with the name + a link what I am trying to do is display the array as a text thing and then have it so that I can click on the text to open the link, how would I do this? are there any tutorials for this?
r/pyqt5 • u/[deleted] • Nov 22 '21
Changing mouse sensitivity for a widget/scene/view
Hi, I need to change mouse sensitivity for different widgets.
I have found that there is a Qt3DInput .QMousedevice with a setSensitivity() method.
I can instantiate a mouse object and set its sensitivity, but how do I get this to actually change the mouse pointer sensitivity. Is it like the QCursor where I have to run a cursor override from QApplication, once I have set up a qcursor object?
r/pyqt5 • u/aadilbacha • Oct 05 '21
Can we allow only one widget to layout?
I have a situation where I want to make a graph (matplotlib)..When I push button, it takes data from qlineedits and make a graph in UI which contain qwidget->scroll->vboxlayout.. When I press button it makes graph.. but when I edit data instead of updating my graph it adds another graph.. So I want one edited graph.. how can i do this?
r/pyqt5 • u/robotnaoborot • May 31 '21
trim videos with pyqt
Not sure in which subreddit to post. I've made a small app - simple video player and buttons to invoke ffmpeg to trim video without re-encoding. Might be useful to desktop linux users?
r/pyqt5 • u/zeyrie2574 • Apr 23 '21
Which is better?
Hi guys, I am new to pyqt5, and I noticed that after we use the designer, we have an option to either use the .ui file directly with the help of a loader, or to convert it to a .py file and add it. My question is which method has a better performance after converting the code to a executable file? Using the loader or using the py file.
r/pyqt5 • u/Waveparticle44 • Apr 17 '21
How to display images from the web
Hello! I'm new to programming and I decided to start with a Manga search engine/reader. The basic premise is that the search engine scraps data from Manga sites and the reader shows the images. How do I make it so that I don't have to download the images to display them? Can't I just use the image links to display them? and How can I reduce or increase the size of the images keeping the ratio?
r/pyqt5 • u/[deleted] • Mar 01 '21
How to embed a webview inside main window?
How can I get my current working codes result (which launches a WebEngine View of a page, google in this instance) to sit inside a main window?
‘’’ """ Python version - 3.7.3 PyQt5 5.15.3 PyQt5-Qt 5.15.2 PyQt5-sip 12.8.1 PyQtWebEngine 5.15.3 PyQtWebEngine-Qt 5.15.2 """
import sys
from PyQt5.QtWebEngineWidgets import QWebEnginePage from PyQt5.QtWidgets import QApplication from PyQt5.QtCore import QUrl from PyQt5.QtWebEngineWidgets import QWebEngineView
url = 'https://google.com'
app = QApplication(sys.argv)
QWebEngineView
browser = QWebEngineView() browser.load(QUrl(url)) browser.show()
sys.exit(app.exec_()) ‘’’
