pyqt

PyQt auto-space qlineedit characters

荒凉一梦 提交于 2021-01-28 01:31:59
问题 Am having a qlineedit where a user types a verification code. I want to be able to space these numbers automatically every after 5 characters just like it is when activating windows where dashes are automatically added. For example 12345 67890 12345 67890 回答1: If the number of digits is fixed the best option is to use setInputMask(), in your case: if __name__ == '__main__': app = QApplication(sys.argv) le = QLineEdit() le.setInputMask(("ddddd "*4)[:-1]) le.show() sys.exit(app.exec_()) In the

How to update the progress bar using with pyqt4

牧云@^-^@ 提交于 2021-01-27 23:36:26
问题 Here it is sample program i want to update the my progress bar using with pyqt4.and i want to show th3 30% data saving and another 60% data processing.I am executing the my program it is aborting.Can any one please help me how to update the my progress bar.Thank you in advance. Given below is my code: import sys import time from pyface.qt import QtGui, QtCore global X,Y X= 5 Y= 4 import threading class SaveWorker(QtCore.QObject): progress_update = QtCore.Signal(int) def save_file(self): while

How to render Altair / Vega in a PyQt widget

不羁的心 提交于 2021-01-27 22:07:18
问题 Is it possible to have Altair or Vega(-Lite) render to a PyQt widget, similar to Matplotlib supporting multiple backends? I know I can use a Qt WebView widget to render a web page with Vega-embed, but I want to prevent the overhead of having to serve this, even if locally. 回答1: The best option to visualize a plot with Altair is to use QWebEngineView since altair what is to create javascript code based on the instructions you set. IMHO the best solution is to obtain the html of the chart and

How to write an infinite loop for receiving UDP data?

浪尽此生 提交于 2021-01-27 21:14:52
问题 I'm trying to make an app that receives UDP data and shows the data in a list view using python (PyQt5). When I start the receiver, the app gets stuck and does not respond. How can I fix this? See code below. import sys import os import socket from PyQt5.QtGui import * from PyQt5.QtWidgets import * class udpReceiverApp(): app = QApplication (sys.argv) x = 1 ip = "192.168.1.4" port =515 server_start = True sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.bind((ip,port)) def __init_

How should I connect CheckBox clicked signals in Table Widgets in PyQt5?

我的未来我决定 提交于 2021-01-27 21:08:51
问题 I would like to add various widgets to various cells in a Table Widget, and I would like to trigger commands when those widgets' values are changed. I can get the widgets into the table as desired, but I'm having problems connecting signals so that I know which widget has generated the signal. Below is a simple example explaining the problem, using just checkboxes: from PyQt5 import QtWidgets, QtGui, QtCore class Main(QtWidgets.QMainWindow): def __init__(self, parent=None): super().__init__

How to play a specific part of a video with PyQt5

和自甴很熟 提交于 2021-01-27 20:32:50
问题 I would like to play a certain part of a video, for example, play a video from second 30 to second 33 using PyQt5. I am using the Qmultimedia widget. This is how my player code looks. Is there a way to start and end at a certain position? I've been manually clipping the video into subclips and just playing those subclips instead but that's very time consuming. Thank you! self.player = QtMultimedia.QMediaPlayer(None, QtMultimedia.QMediaPlayer.VideoSurface) file = QtCore.QDir.current().filePath

PyDev doesn't recognise PyQt5

眉间皱痕 提交于 2021-01-27 16:15:46
问题 I am following a tutorial on pyqt, and got this code: import sys from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * class Example(QWidget): def __init__(self): super(Example, self).__init__() self.initUI() def initUI(self): cb = QCheckBox('Show title', self) cb.move(20, 20) cb.toggle() cb.stateChanged.connect(self.changeTitle) self.setGeometry(300, 300, 250, 150) self.setWindowTitle('Checkbox') self.show() def changeTitle(self, state): if state == Qt.Checked:

PyDev doesn't recognise PyQt5

久未见 提交于 2021-01-27 16:11:44
问题 I am following a tutorial on pyqt, and got this code: import sys from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * class Example(QWidget): def __init__(self): super(Example, self).__init__() self.initUI() def initUI(self): cb = QCheckBox('Show title', self) cb.move(20, 20) cb.toggle() cb.stateChanged.connect(self.changeTitle) self.setGeometry(300, 300, 250, 150) self.setWindowTitle('Checkbox') self.show() def changeTitle(self, state): if state == Qt.Checked:

PyDev doesn't recognise PyQt5

偶尔善良 提交于 2021-01-27 16:11:25
问题 I am following a tutorial on pyqt, and got this code: import sys from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * class Example(QWidget): def __init__(self): super(Example, self).__init__() self.initUI() def initUI(self): cb = QCheckBox('Show title', self) cb.move(20, 20) cb.toggle() cb.stateChanged.connect(self.changeTitle) self.setGeometry(300, 300, 250, 150) self.setWindowTitle('Checkbox') self.show() def changeTitle(self, state): if state == Qt.Checked:

PyDev doesn't recognise PyQt5

╄→尐↘猪︶ㄣ 提交于 2021-01-27 16:11:09
问题 I am following a tutorial on pyqt, and got this code: import sys from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * class Example(QWidget): def __init__(self): super(Example, self).__init__() self.initUI() def initUI(self): cb = QCheckBox('Show title', self) cb.move(20, 20) cb.toggle() cb.stateChanged.connect(self.changeTitle) self.setGeometry(300, 300, 250, 150) self.setWindowTitle('Checkbox') self.show() def changeTitle(self, state): if state == Qt.Checked: