Posts

Showing posts with the label pyqt

PyQt5 Interface Crashes When I Try to Send&Receive List From Function

Image
Clash Royale CLAN TAG #URR8PPP PyQt5 Interface Crashes When I Try to Send&Receive List From Function I am beginner of Python. I am trying to create interface for serial communication. On my app, there are 4 variable and each one 2 bytes. And I have starter,command, source and destination bytes. So, totally 4*2+4= 12 bytes list I have. I am trying to send this list and take back. There is no console error but when I try to send list, it is crashing. ui.SendAll_Button.clicked.connect(lambda: com.send(self.newPackage)) If I send normal list, without function, it works. But newPackage is in the ValuetoHex function, it does not work. I am leaving my code here: from PyQt5 import QtCore, QtGui, QtWidgets import sys import Max2828_Window as myWindow import Max2828_WindowEdit as EditModule import serial from time import sleep import struct con = serial.Serial('COM3', 9600 , timeout = 1) error_message = [0X65, 0X72, 0X72, 0X6F, 0X72] starter_byte = 0XAA source_byte = 0X01...

matplotlib crosshair cursor in PyQt dialog does not show up

Image
Clash Royale CLAN TAG #URR8PPP matplotlib crosshair cursor in PyQt dialog does not show up I want to have a crosshair at the cursor in my matplotlib window. This works out in the example, given in the matplotlib gallery. But unfortunately, it does not work if I have the matplotlib widget in a Qt dialog window ( QDialog ). matplotlib QDialog This is my sample of code, where I want to instantiate the matplotlib.widgets.Cursor object, but nothing shows up. matplotlib.widgets.Cursor import sys from PyQt4 import QtGui from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas import matplotlib.pyplot as plt from matplotlib.widgets import Cursor class Window(QtGui.QDialog): def __init__(self, parent=None): super(Window, self).__init__(parent) self.figure = plt.figure(facecolor='white') self.canvas = FigureCanvas(self.figure) layout = QtGui.QVBoxLayout() layout.addWidget(self.canvas) self.setLayout(layout) ...

PyQt5. How to get cursor position in QTextEdit connected with ContextMenu?

Image
Clash Royale CLAN TAG #URR8PPP PyQt5. How to get cursor position in QTextEdit connected with ContextMenu? I try to get cursor position in QTextEdit : QTextEdit class CustomEdit(QTextEdit): self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.cursor = self.textCursor() self.menu = None self.customContextMenuRequested.connect(self.create_menu) def create_menu(self, pos): self.menu = QMenu() self.menu.addSeparator() func = self.menu.addAction(u'function') action = self.menu.exec_(self.viewport().mapToGlobal(pos)) if action == func: self.func() def func(self) print(self.cursor.positionInBlock()) but it doesn't work. What does it mean that it does not work? – eyllanesc 21 mins ago It returns wrong number that not...

How to use the Qt Designer individually and Ooffline doc for PyQt5 in Eric6?

Image
Clash Royale CLAN TAG #URR8PPP How to use the Qt Designer individually and Ooffline doc for PyQt5 in Eric6? pip install pyqt5 and then install eric6. pip install pyqt5 Now, when i open *.ui , tip could not found designer.I know I can install the entire Qt Creator to get support, but can I install only the Designer? *.ui Another question is how to open an offline PYQT5 help document in ERIC6? install pypi.org/project/pyqt5-tools – eyllanesc 8 mins ago This library has been abandoned. @eyllanesc – Martin Zhu 7 mins ago Where does it say that it has been abandoned ?, besides you want only the executable of Qt designer – eyllanesc 6 mi...