pyqt5

PyQt5: Draw a line by clicking QPushButton

风流意气都作罢 提交于 2021-02-08 09:37:05
问题 I am trying to make it such that when I click a QPushButton a line is drawn. However the code I have right now makes the line at the beginning when the code is initiated and not after . The QPushButton doesn't seem to do any drawing. I also don't quite understand why when drawing you need an 'event' argument in the function. import sys from PyQt5 import QtCore, QtWidgets from PyQt5.QtWidgets import QMainWindow, QGridLayout,QPushButton, QApplication, QWidget from PyQt5.QtCore import QSize,

How to display 2 SQLite tables with one to many relation into one QTableWidget

主宰稳场 提交于 2021-02-08 08:23:09
问题 I have following two tables in Db, with one to many relationship: self.c.execute("CREATE TABLE IF NOT EXISTS dispatch(" "id_dispatch INTEGER PRIMARY KEY AUTOINCREMENT," "d_date TEXT," "d_mill TEXT," "d_buyer TEXT," "d_addFreight INTEGER," "d_subFreight INTEGER," "d_amount INTEGER," "d_cd INTEGER," "d_comm INTEGER," "d_netAmount INTEGER)") self.c.execute("CREATE TABLE IF NOT EXISTS dispatch_products(" "dispatch_id INTEGER NOT NULL REFERENCES DISPATCH(id_dispatch)," "product INTEGER," "quantity

How to display 2 SQLite tables with one to many relation into one QTableWidget

左心房为你撑大大i 提交于 2021-02-08 08:22:48
问题 I have following two tables in Db, with one to many relationship: self.c.execute("CREATE TABLE IF NOT EXISTS dispatch(" "id_dispatch INTEGER PRIMARY KEY AUTOINCREMENT," "d_date TEXT," "d_mill TEXT," "d_buyer TEXT," "d_addFreight INTEGER," "d_subFreight INTEGER," "d_amount INTEGER," "d_cd INTEGER," "d_comm INTEGER," "d_netAmount INTEGER)") self.c.execute("CREATE TABLE IF NOT EXISTS dispatch_products(" "dispatch_id INTEGER NOT NULL REFERENCES DISPATCH(id_dispatch)," "product INTEGER," "quantity

GUI Freezing with QThreading and QProcess

回眸只為那壹抹淺笑 提交于 2021-02-08 07:39:40
问题 I'm attempting to write some software that will process large amounts of images collected from some crystallography experiments. The data process involves the following steps: User Input to determine the number of images to batch together. A directory containing the images is selected, and the total number of images is calculated. A nested for loop is used to batch images together, and construct a command and arguments for each batch which is processed using a batch file. The following code

PyQt5: Questions about QGraphicsScene's itemAt() and focusItemChanged()

房东的猫 提交于 2021-02-08 06:54:23
问题 I have two questions: what does QTransform() mean in itemAt()? The sentence below is what it says in Qt doc, but I can't understand: deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations. why focusItemChanged signal is not working? Here is my code: import sys from PyQt5.QtGui import QTransform from PyQt5.QtWidgets import QApplication, QGraphicsItem, QGraphicsScene, QGraphicsView class Demo(QGraphicsView

How to create a file dialog that returns file paths for both selected files AND directories?

守給你的承諾、 提交于 2021-02-08 06:34:24
问题 I'm trying to use QFileDialog to get a list of the paths of selected folders AND directories. I know how to do one or the other using QFileDialog.getOpenFileNames and QFileDialog.getExistingDirectory , but not both at the same time. The C++ docs and other questions elsewhere didn't seem to help me no matter how much I googled. I am using PyQt5 5.14.2 and Python 3.8.2 on Windows. Edit: I've managed to conjure up the following solution not using the native Windows dialog and it works but seems

How to add notification number to a button icon?

自古美人都是妖i 提交于 2021-02-08 05:15:40
问题 I am trying to make a GUI with PyQt5. It will have a notification button with an icon. I want to add a small bubble with the number of notifications on the icon. If a number is not possible, I would like to use a red dot as a backup method. But how should I keep track of the new notifications (like a listener for notification) and change the icon while the window is running? I have been googling about this problem, but only mobile development stuff and non-PyQt5 related results come up.

How to add notification number to a button icon?

别来无恙 提交于 2021-02-08 05:07:04
问题 I am trying to make a GUI with PyQt5. It will have a notification button with an icon. I want to add a small bubble with the number of notifications on the icon. If a number is not possible, I would like to use a red dot as a backup method. But how should I keep track of the new notifications (like a listener for notification) and change the icon while the window is running? I have been googling about this problem, but only mobile development stuff and non-PyQt5 related results come up.

How to get cursor click position in QGraphicsItem coordinate system?

淺唱寂寞╮ 提交于 2021-02-07 20:57:51
问题 I have a QGraphicsScene with QGraphicsItem added to it. Suppose I clicked on a map image ( QGraphicsItem ) where green circle is drawn. How to get click position in terms of this QGraphicsItem and not QGraphicsScene coordinate system. P.S. Please, don't write code with mouse event handling. Just how to map click position correctly. Thanks in advance. 回答1: The idea is to convert the coordinate with respect to the scene to a coordinate with respect to the item. - Override mousePressEvent in

How to get cursor click position in QGraphicsItem coordinate system?

天大地大妈咪最大 提交于 2021-02-07 20:56:50
问题 I have a QGraphicsScene with QGraphicsItem added to it. Suppose I clicked on a map image ( QGraphicsItem ) where green circle is drawn. How to get click position in terms of this QGraphicsItem and not QGraphicsScene coordinate system. P.S. Please, don't write code with mouse event handling. Just how to map click position correctly. Thanks in advance. 回答1: The idea is to convert the coordinate with respect to the scene to a coordinate with respect to the item. - Override mousePressEvent in