Pyqt5实践:实现快捷方式软件@TOC
工具准备
Python3.x;
Python库:pyqt5
代码展示:
直接贴代码,由于工作繁忙,实在没时间写文档0.0,代码里面都有注释,有不懂评论区问。(先看看反响咋样,如果看的人多我再写具体思路。)
界面代码,使用QtDesigner画的,再通过pyuic转换的。
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'Form.ui'
#
# Created by: PyQt5 UI code generator 5.13.0
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(250, 500)
Form.setStyleSheet("#Form{\n"
" border-top-left-radius:10px;\n"
" border-bottom-left-radius:10px;\n"
"\n"
"}\n"
"QGroupBox{\n"
"border-top:0px solid rgb(190, 190, 190);\n"
"border-right:0px solid rgb(190, 190, 190);\n"
"border-bottom:2px solid rgb(190, 190, 190);\n"
"border-left:0px solid rgb(190, 190, 190);\n"
"font: 75 10pt \"微软雅黑\";\n"
"}")
self.verticalLayout = QtWidgets.QVBoxLayout(Form)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setSpacing(0)
self.verticalLayout.setObjectName("verticalLayout")
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.choose_exe_btn = QtWidgets.QPushButton(Form)
self.choose_exe_btn.setObjectName("choose_exe_btn")
self.horizontalLayout.addWidget(self.choose_exe_btn)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.verticalLayout.addLayout(self.horizontalLayout)
self.scrollArea = QtWidgets.QScrollArea(Form)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.scrollArea.sizePolicy().hasHeightForWidth())
self.scrollArea.setSizePolicy(sizePolicy)
self.scrollArea.setMinimumSize(QtCore.QSize(250, 475))
self.scrollArea.setMaximumSize(QtCore.QSize(250, 475))
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea")
self.main_widget = QtWidgets.QWidget()
self.main_widget.setGeometry(QtCore.QRect(0, 0, 248, 473))
self.main_widget.setMinimumSize(QtCore.QSize(240, 470))
self.main_widget.setStyleSheet("#main_widget{\n"
" background-color:rgb(68, 68, 68);\n"
"}\n"
"\n"
"QPushButton{\n"
" border:1px solid lightgray;\n"
" background:rgb(255, 255, 255);\n"
"}\n"
"QPushButton::hover{\n"
" border-color:rgb(0, 170, 255);\n"
" background:transparent;\n"
"}")
self.main_widget.setObjectName("main_widget")
self.main_layout = QtWidgets.QVBoxLayout(self.main_widget)
self.main_layout.setContentsMargins(0, 0, 0, 6)
self.main_layout.setObjectName("main_layout")
spacerItem1 = QtWidgets.QSpacerItem(20, 464, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.main_layout.addItem(spacerItem1)
self.scrollArea.setWidget(self.main_widget)
self