Tag:pyqt5

  • An example of pyqt5 scaling the picture

    Time:2019-11-7

    As follows: def shrinkImage(self): ”’ Zooms in :return: ”’ Scale = 0.8 × 20% reduction each time IMG = qimage (self. Path) × create picture instance mgnWidth = int(originWidth * scale) Mgnheight = int (originheight * scale) size = QSize(mgnWidth, mgnHeight) Piximg = qpixmap. Fromimage (img. Scaled (size, QT. Ignoreaspectratio)) (modify the image instance size […]

  • Pyqt5 method of forbidding window maximization and window stretching

    Time:2019-11-6

    As follows: Add in def init (self): function self.setFixedSize(self.width(), self.height()) The above pyqt5 method to disable window maximization and window stretching is all the content shared by Xiaobian. I hope it can give you a reference and support developepaer.

  • Example of pyqt5 qtable inserting pictures and updating them dynamically

    Time:2019-11-5

    Mode 1: picture + text Row = 0 × line number Col = 1 × column No Icon = qtablewidget item (qicon (“.. / image / a.png”), “waiting”) (picture + text) self.tblName.setItem(row, col, icon) # self → Ui_form #Dynamic refresh, the whole method must be placed in the main thread, and the self starting thread […]

  • Pyqt5 enables qscrollarea to support mouse drag

    Time:2019-10-31

    As follows: #!/usr/bin/evn python3 # -*- coding: utf-8 -*- import sys from PyQt5.QtWidgets import (QApplication, QWidget, QScrollArea, QLabel) from PyQt5.QtCore import QEvent class TestWindow(QWidget): def __init__(self): super(TestWindow, self).__init__() self.resize(800, 600) self.move(0, 0) # self.setMouseTracking(False) self.last_time_move = 0 self.initUI() def initUI(self): self.central_widget = QWidget(self) self.scroll_area = QScrollArea(self) self.scroll_area.setGeometry(0, 0, 400, 400) self.scroll_area.setWidgetResizable(True) self.scroll_bar = self.scroll_area.verticalScrollBar() self.scroll_contents […]

  • Pyqt5 method of opening sub window from main window

    Time:2019-10-28

    1. Design two simple windows in QT Designer 2. Convert. UI file to. Py file 3. Create a new * *. Py file #-*- coding:utf-8 -*- from PyQt5.QtWidgets import QMainWindow, QApplication from window import Ui_MainWindow from child import Ui_Child import sys class Main(QMainWindow,Ui_MainWindow): def __init__(self): super(Main, self).__init__() self.setupUi(self) class Child(QMainWindow,Ui_Child): def __init__(self): super(Child, self).__init__() self.setupUi(self) […]

  • PyQt5 installation configuration process that converts the UI file to the py file and displays an instance of the window

    Time:2019-10-24

    PyQt5 installation Enter PIP install PyQt5 under CMD to complete PyQt5 installation, When the installation is complete, you can see it in the python installation directory Configuration PyCharm PyCharm is configured to open qt designer in PyCharm and generate qt files, which are then converted into python language software files. Open Pycharm and proceed as […]

  • Pyqt5 example of realizing pop-up sub window with window designed by QT Designer

    Time:2019-10-16

    1. Write the main form with QT designer. The form type is MainWindow. It is a button on the blank window. And convert to mainwindow.py # -*- coding: utf-8 -*- # Form implementation generated from reading ui file ‘f.ui’ # # Created by: PyQt5 UI code generator 5.9 # # WARNING! All changes made in […]

  • Pyqt5 multi window connection instance

    Time:2019-10-14

    Preface Previously, I did a simple interface of pyqt to implement some operations in a MainWindow; I didn’t bother to do multi-windows and their switching functions. The call and switch of the lower window have been studied recently. There are many differences between PyQt4 and 5. When referring to other people’s cases, we took many […]

  • Use of PyQt5 Basic Window Control QMainWindow

    Time:2019-10-13

    Basic Introduction to QMain Windows The main window of QMainWindow provides an application framework for users. It has its own layout and can add controls to the layout. Introduction to Window Types In PyQt5, three main classes are used to create windows, which can be used directly or inherited and reused. QMainWindow QWidget QDialog QMainWindow […]

  • Pyqt5 Uses Buttons to Skip Interfaces

    Time:2019-10-4

    brief introduction There are two kinds of buttons to jump the interface. One is the code that does not use Qtdesigner, the other is the code that uses Qtdesigner. Code 1 import sys from PyQt5.QtWidgets import QMainWindow, QPushButton, QApplication class First(QMainWindow): def __init__(self): super().__init__() self.initUI() def initUI(self): self.btn = QPushButton(“Button”, self) self.btn.move(30, 50) self.setGeometry(300, 300, […]

  • Pyqt5’s Method of Implementing Jump Interface and Closing Current Interface

    Time:2019-10-3

    Most of the online tutorials are written to close the interface directly. I figured out a way: bind two events at the same time. Example: # Self-method self.registerButton.clicked.connect(self.register_re) # Close the interface self.registerButton.clicked.connect(login.close) The code order represents the order of progress. The previous example first runs its own function and then closes the current window. […]

  • Quickly solve the problem that the sub-threads exit at different times after the pyqt5 form closes

    Time:2019-10-2

    A main form is designed with pyqt5. When the form runs, it needs to put an infinite loop in a thread to work. After running, it is found that after closing the main creator by pressing the closing button of the main form with the mouse, the thread will not automatically terminate and is still […]