Tag:pyqt5

  • Pyqt5 combobox: how to get subscript, text and event selection function

    Time:2020-2-12

    As follows: Currenttext() get text Currentindex() gets the subscript Event selection function of self. ComboBox. Currentindexchanged. Connect() combobox The above pyqt5 combobox’s method of getting subscript, text and event selection function is the whole content shared by Xiaobian. I hope it can give you a reference, and I hope you can support developepaer more.

  • An example of pyqt5 using label control to display time in real time

    Time:2020-2-10

    As follows: import sys from PyQt5 import QtGui, QtCore, QtWidgets from PyQt5.QtWidgets import * from PyQt5.QtCore import * from PyQt5.QtGui import * class showTime(QDialog): def __init__(self): super(showTime, self).__init__() self.resize(500, 400) Self.setwindowtitle (“label display time”) self.label = QLabel(self) self.label.setFixedWidth(200) self.label.move(90, 80) self.label.setStyleSheet(“QLabel{background:white;}” “Qlabel {color: rgb (300300300120); font size: 10px; font weight: bold; font family: Tahoma;}” ) […]

  • Example of pyqt5 loading picture and text files

    Time:2020-2-9

    First let’s look at a set of effects After selecting picture text settings During selection Core code interpretation #This function is used to open the computer’s Explorer and select photos def loadFile(self): print(“load–file”) #QFileDialog is the type of system dialog. The first parameter is context, the second parameter is the name of the pop-up box, […]

  • The method of setting TextEdit auto scrolling in pyqt5

    Time:2020-2-1

    After the modified text, add: self.textEdit_6.moveCursor(QTextCursor.End) Example: self.textEdit_6.setPlainText(“Hello World”) The above method of setting TextEdit auto scrolling in pyqt5 is all the content shared by Xiaobian. I hope it can give you a reference and support developepaer.

  • How to use qscrollarea in pyqt5

    Time:2020-1-31

    As follows: import sys from PyQt5.QtWidgets import * class MainWindow(QMainWindow): def __init__(self,): super(QMainWindow,self).__init__() self.number = 0 w = QWidget() self.setCentralWidget(w) self.topFiller = QWidget() Self.topfiller.setminimumsize (250, 2000) set the size of the scroll bar for filename in range(20): self.MapButton = QPushButton(self.topFiller) self.MapButton.setText(str(filename)) self.MapButton.move(10,filename*40) ##Create a scroll bar self.scroll = QScrollArea() self.scroll.setWidget(self.topFiller) self.vbox = QVBoxLayout() self.vbox.addWidget(self.scroll) w.setLayout(self.vbox) […]

  • Instance of updating UI by sub thread of Python + pyqt5

    Time:2020-1-30

    The UI interface can’t be updated in the sub thread. It’s on the mobile side. Android’s UI access is unlocked. Multiple threads can access the same UI control for update operation at the same time. In other words, when accessing the UI, the controls in the Android system are not thread safe, which will lead […]

  • Detailed explanation of pyqt5 multithreading correct opening posture

    Time:2020-1-29

    As follows: # -*- coding: utf-8 -*- import sys from PyQt5.QtCore import QThread, pyqtSignal from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget, QMessageBox, \ QPushButton, QLineEdit, QLabel, QToolTip, QComboBox, QTextEdit class MyBeautifulClass(QMainWindow): def __init__(self): super(MyBeautifulClass, self).__init__() self.init_ui() def init_ui(self): self.resize(1000, 800) self.setWindowTitle(‘Demo of PyQt5 QThread’) self.btn_1 = QPushButton(‘start’, self) self.btn_1.setGeometry(100, 100, 100, 50) self.btn_1.clicked.connect(self.slot_btn_1) self.linEdit_2 = QLineEdit(self) […]

  • How to display GIF picture in pyqt5

    Time:2020-1-27

    Using qmove method to realize Import library file from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtGui import QMovie Create a window with label control, label as the display form of gif class Ui_Form(object): def setupUi(self, Form): Form.setObjectName(“Form”) Form.resize(517, 361) self.label = QtWidgets.QLabel(Form) self.label.setGeometry(QtCore.QRect(0, 0, 500, 300)) self.label.setObjectName(“label”) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) def retranslateUi(self, Form): _translate = QtCore.QCoreApplication.translate […]

  • Pyqt5 method of drawing rectangle in the picture displayed in label

    Time:2020-1-26

    When using QT to write GUI program, we often need some interactive operations, such as mouse events, keyboard events and so on. What we want to achieve today is to draw a rectangular box in the image already displayed in the label, so as to carry out the next operation (such as zooming in the […]

  • Example of playing music on pyqt5 GUI

    Time:2020-1-25

    Install Pygame pip install pygame import time import pygame pygame.init() Print (“play music 1”) Track = pygame.mixer.music.load (R “here is the path of the audio file”) pygame.mixer.music.play() time.sleep(10) pygame.mixer.music.stop() Another method, both of which are feasible pygame.init() Sound = pygame.mixer.sound (R “audio file path 1. Wav here”) sound.set_volume(1) sound.play() PyGame. Init() initializes all modules, PyGame. […]

  • Pyqt5 qlistwidget select multiple instances and return

    Time:2020-1-22

    Refer to stack overflow Python: how to query multiple selected items in qlistwidget in pyqt from PyQt5.QtGui import * from PyQt5.QtCore import * from PyQt5.QtWidgets import * listItem = [‘a’,’b’,’c’,’d’,’e’] if listItem is not None and len(listItem) > 0: self.listWidget = QListWidget(self) for item in listItem: self.listWidget.addItem(item) if multiselected: Self.listwidget.setselectionmode (qabstractitemview. Extendedselection) ා hold Ctrl […]

  • A detailed explanation of the implementation of tree structure in pyqt5

    Time:2020-1-17

    The essence of the tree is that many pieces of data are displayed in layers according to certain internal relations. Therefore, each piece of data includes data items and interrelations. The data item corresponds to the column in the tree, and the relationship corresponds to which item should be displayed. In pyqt5, there are two […]