pyqt5界面开发-制作程序集合桌面-基本的框架
最近无事,看到了电脑桌面,又想到了最近入门的pyqt5,再看看以往的程序,想到了可不可以做一个集合了多个程序的的UI桌面
先导入pyqt5库
from PyQt5 import QtCore, QtWidgets ,QtGui
from PyQt5.QtGui import *
from PyQt5.QtWidgets import QProgressBar, QLabel, QApplication, QMainWindow,QToolTip
from PyQt5.QtCore import QBasicTimer, QThread, pyqtSignal
from PyQt5.QtWidgets import *
然后生成一个类并继承
class UI(QMainWindow,QWidget):
def __init__(self, parent=None):
super().__init__(parent)
初始化UI
def init(self):
QToolTip.setFont(QFont('SansSerif', 10))
self.resize(1000, 625) #大小
self.move(300, 300) #窗口初始位置
self.setWindowFlags(QtCore.Qt.WindowMinimizeButtonHint) #设置禁用放大缩小和退出按钮
self.setFixedSize(self.width(), self.height()) #禁止拉伸
self.setWindowTitle('TArk-Tools') #取名
self.setWindowIcon(QIcon('./resource/img/eye.webp')) #设置窗口的图标
self.setIcon("./resource/img/bg1.jpg") #这里是调用了一个函数,用于换UI背景,稍后创建
self.win_offQL = QLabel(self) #颜色文本框
self.win_offQL.setGeometry(QtCore.QRect(970, 10, 21, 21))
self.win_offQL.setStyleSheet("border-radius:10px;\n""background-color: rgb(170, 0, 0);")
self.win_offQL.setText("")
self.win_off = QPushButton(self) #退出按钮
self.win_off.setGeometry(QtCore.QRect(970, 10, 21, 21))
self.win_off