r/pyqt5 • • May 21 '21

Help me Learn(I'm intermediate to Advanced Programmer)

1 Upvotes

I wanna learn QThreadPool in PyQt5 and implement it in my project(Intermediate). I tried reading the documentation but I failed to understand it. So, Can someone help me out with this? If u can teach me it'll be too good either via chat or via Zoom. I'm ready to learn anyhow. Do help me out!


r/pyqt5 • • May 11 '21

Get the size of a widget

1 Upvotes

Hi,

is there a way to get the size of a nested qwidget (or another element) put inside a QMainWindow?

The size of the window is explicitly specified with self.resize(1000, 800), the dimensions of the other elements is not defined.
Can I get them at runtime?

Thank you


r/pyqt5 • • May 12 '21

How do the tab widget signals work?

1 Upvotes

Hello! I'm trying to make all my tabs display the same content, so I put my content in a function and called with the parameter being whichever tab(s) are present, here is a simple version of my snippet:

                     ______________snippet_______________

self.tabWidget = QtWidgets.QTabWidget()
self.tab1 = QtWidgets.QWidget()
self.tab2 = QtWidgets.QWidget()

self.page_content(self.tab1)
self.page_content(self.tab2)

self.tabWidget.addWidget(self.tab1, "Tab2")
self.tabWidget.addWidget(self.tab2, "Tab2")

def page_content(self, tab):
    self.a_Button = QtWidgets.QPushButton(tab)


def retranslateUi(self, MainWindow):
    self.a_Button.setText(_translate("MainWindow", "Press me!"))

                        ______________snippet_______________

but the problem is that the text within the widgets appears only in tab2 not in tab1. So I tried using signals such as tabBarClicked() and currentChanged() but I don't know how to use them because I am a beginner. I hope you understand my problem.

Thanks


r/pyqt5 • • May 09 '21

How can I redirect terminal output in a textbox over a Qt widget ?

1 Upvotes

r/pyqt5 • • May 15 '21

How to add more tabs in the tab widget and add content in it?

1 Upvotes

Hello! with yet another question. I want to be able to add more tabs and add content in it, just like Chrome or Firefox. So far I created a function for my content and the parameter it takes is the parent widget. I also have a "add tab" button set in the corner of the tab widget. Here is a simpler version of a snippet in my code:

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *

class MainWindow(object):
    def setupUi(self, MainWindow):
        
        self.add = QtWidgets.QPushButton()
        self.add.setText("+")
        self.add.clicked.connect(self.add_tabs)
        self.tabWidget = QtWidgets.QTabWidget()
        self.tabWidget.setCornerWidget(self.add, Qt.TopRightCorner)
        self.tabWidget.currentChanged.connect(self.onChange)
        self.tab1 = QtWidgets.QWidget()
        self.tab2 = QtWidgets.QWidget()
        self.tabWidget.addTabs(self.tab1,"Search")
        self.tabWidget.addTabs(self.tab2,"Search")
        content = Conetent()
        content.page(self.tab1)
   def onChange(self, i):
       if i == 1:
           self.p.search_page_content(self.tab2)

       if i == 2:
           self.p.search_page_content(self.tab3)

    def add_tabs(self):
         tab3= QtWidgets.QWidget()
         self.tabWidget.addTab(self.tab3, "Search")

class Content():
    def page(tab):
        aButton = QtWidgets.QPushButton(tab)

______________________________________snippet_______________________________________

I am aware of the problem in my code but I couldn't find a way to get past it. How do I make every tab have a different variable name and then pass that variable into my content.page()?

I hope you understand my struggle as a beginner.

Thanks in adavance


r/pyqt5 • • May 31 '21

trim videos with pyqt

2 Upvotes

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?

https://i.imgur.com/9hvcZzV.png

https://github.com/pawnhearts/qtrimvid


r/pyqt5 • • May 08 '21

How to set background image for tab widget?

3 Upvotes

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 • • May 16 '21

Trying to embed urxvt terminal in pyqt5 gui

1 Upvotes

I'm a pyqt5 noob. I want to modify this code such that class Window(QWidget): is removed and the urxvt terminal is displayed on Ui_MainWindow. Right now it is launched in different window.

Please help.Please forgive if thats really bad or wrong way to do it. But somehow I have to embed terminal in pyqt gui.


r/pyqt5 • • May 11 '21

All Tabs Closed = Exit Main Window

1 Upvotes

I've been able to close tabs using:

self.tabWidget.tabCloseRequested.connect(lambda index: self.tabWidget.removeTab(index))

But I want the Main Window to quit if all tabs are closed, how do I do that?

Any comment or suggestion is well appreciated.


r/pyqt5 • • Jun 10 '21

uic not found

1 Upvotes

I'm watching a tutorial on PyQt5 but when I try to import PyQt5.uic it doesn't know what uic is and gives an error. from PyQt5.uic import loadUi has a bunch of red underlines


r/pyqt5 • • May 21 '21

Modifying drop-down of QComboBox

1 Upvotes

I want to modify the contents of the drop down according to the input in the editable combo box. The problem is it has prediction on, and hence it takes the predicted value and not what the user typed. Can anything be done for this?


r/pyqt5 • • Jun 02 '21

Highlight an element of a QTreeView

1 Upvotes

Is there a way to highlight an element of QTreeView without clicking on it?
I've a QTreeView composed by QStandardItem.
I've searched online but I cannot understand if this is possible.

Thank you.


r/pyqt5 • • May 13 '16

How to emit rightClick and wheel events in PyQt5?

Thumbnail
stackoverflow.com
1 Upvotes

r/pyqt5 • • Jan 23 '18

PyQt5 and EGLFS on Raspberry Pi

1 Upvotes

I'm trying to get a PyQt5 app to run on the framebuffer (without Xwindows and a desktop manager). Supposedly this is doable, but when I attempted it on an RPi I got a "qxcbconnection: could not connect to display" error. Has anyone had success with this?

Thanks in advance for your help.


r/pyqt5 • • Oct 22 '19

Need help with PyInstaller need to bundle the app and have QProcess do it’s work.

1 Upvotes

Need help with PyInstaller need to bundle the app and have QProcess do it’s work. Here’s the setup I have packed Meson-ui as an app but when I tried to use it as a app that can be clicked it did not do anything with both the console output window and background process where not calling Meson to do totally normal Meson things.

How can I make this work?


r/pyqt5 • • Aug 23 '19

How can have the QFileDialog not open two times.

2 Upvotes

So. I'm currently trying to add a feature where the user can open one folder from a QFileDialog to set the values of both build and source directories. The problem I stumbled on is where the dialog opens two times when I only call the function one time. Why is it so and how can I fix this?

@pyqtSlot()
def on_click_open_dir(self):
    dir_path = str(QFileDialog.getExistingDirectory(self, 'Open source dir.',QDir.homePath()))

    if dir_path != '':
       self.source_dir.setText('{}'.format(dir_path))
       self.build_dir.setText('{}{}build'.format(dir_path, os.sep))
       self.push_build.setEnabled(True)

r/pyqt5 • • Aug 25 '19

Never wrote a CI for a PyQt5 GUI app before.

2 Upvotes

So yea. I never wrote a ether Travis-ci or AppVeyor files that automatically checks if a PyQt app build is OK, I have written Travis-ci and AppVeyor files for command line tools.

How can I write a Travis-ci or AppVeyor for a GUI app using PyQt5


r/pyqt5 • • May 05 '22

How to resize a Window as per the client screen?

1 Upvotes

I have created a PyQt5 Main Window Screen, with dimensions as 700 x 500. The screen displays different in different dimensional screens. How can I make the ratio of the Main Window dynamic with respect to every client screen size?


r/pyqt5 • • May 13 '22

Remembering user selection Qcombobox

2 Upvotes

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 • • May 13 '22

Issues installing PyQt5-tools

3 Upvotes

When I run

pip install pyqt5-tools

I 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 • • May 29 '22

MDI Subwindows scaling strangely.

2 Upvotes

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)

self.mainMenuWidget.show()

##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()

mdiwindow.show()

app.exec_()

if __name__ == '__main__':

main()

------------------------------------------------------

Thanks for any and all help!


r/pyqt5 • • Oct 23 '18

How to check if QLineEdit() is empty in #PyQt5?

1 Upvotes

i have 7 QLineEdits and i want to set a Function that checks : 1- If each QLineEdit is empty 2- if True, setStyleSheet ("background-color : red;") Thank you in advance !


r/pyqt5 • • Jan 13 '20

Case of the PyQt5.sip missing import error.

1 Upvotes

So. Here’s the setup, I wrote an app using PyQt5 and later thought hey let’s expand to Windows and then this happens. How can I fix this?


r/pyqt5 • • Jan 16 '20

PyQt5 to EXE

1 Upvotes

I recently finished an app, and I want to export it/convert it to EXE it to deploy it to windows machines.

I used PyIntaller to do the job, it does convert it to EXE but opening the EXE doesn't show anything, no output from the console or anything.

Can I get some help?


r/pyqt5 • • Jan 26 '21

how to use pyqt data model with Qlistview UI designed using Qt-designer ?

1 Upvotes

I am touching pyqt after a long time, I have forgotten how we would connect a UI designed using qt designer and load data from the QAbstractModel object into UI containig QListView.

I have converted the UI file to py using uic-qt5 as of now.