文章目录
- 一.前言
- 二.展示
- 1.主界面
- 2.设置页面
- 3.更换了壁纸且切换桌面页面
- 三.项目分享
- 1.项目代码结构
- 2.组件代码分享
- 四.总结
文件大小25.5M,欢迎下载体验!点击下载
一.前言
今天给大家推荐我用PyQt5开发的模仿安卓桌面的应用,整体的样式和风格模仿安卓的UI,本软件与安卓系统无关,仅供学习交流。
二.展示
大家可以通过安装包来安装软件
1.主界面
启动后主界面就是下图的效果
2.设置页面
大家可以点击底部中间设置图标到设置页面,所有的设置项都是有具体功能的,用户可以选择指定的开关功能对其进行设置,亦可切换桌面壁纸样式,设置成功后底部会弹出个性化toast提示,三秒后消失。
3.更换了壁纸且切换桌面页面
我们在设置页面且换了壁纸后,回到桌面即可看到更换了的桌面壁纸效果,通过左右滑动或者滚轮上下滚动能够切换桌面页面。
三.项目分享
1.项目代码结构
从前几篇开始,笔者开始加入项目结构这个模块,原因是有的读者私聊我,让我介绍一下项目结构,在此我截图贴一下我的代码结构。
2.组件代码分享
这里分享一下设置页面的开关组件代码~
把代码放到自己项目即可获得同款开关组件
class SwitchButton(QWidget):"""调整大小的开关组件"""switch_status_changed = pyqtSignal(bool)def __init__(self, parent=None):super().__init__(parent)self.setFixedSize(36, 22)self.checked = Falseself.setCursor(Qt.PointingHandCursor)self.animation = QVariantAnimation()self.animation.setDuration(80) # 动画持续时间self.animation.setStartValue(0)self.animation.setEndValue(14)self.animation.valueChanged.connect(self.update)self.animation.finished.connect(self.onAnimationFinished)def setChecked(self, check):self.checked = checkself.animation.setDirection(QVariantAnimation.Forward if self.checked else QVariantAnimation.Backward)self.animation.start()def paintEvent(self, event):painter = QPainter(self)painter.setRenderHint(QPainter.Antialiasing)painter.setPen(Qt.NoPen)if self.checked:painter.setBrush(QColor('#07c160')) # 选中颜色else:painter.setBrush(QColor('#d5d5d5')) # 未选中颜色# 绘制外框painter.drawRoundedRect(QRect(0, 0, self.width(), self.height()), 11, 11)# 按钮位置offset = self.animation.currentValue()# 绘制按钮painter.setBrush(QColor(255, 255, 255))painter.drawEllipse(QPoint(11 + offset, 11), 8, 8)def mouseReleaseEvent(self, event) -> None:if event.button() == Qt.LeftButton:self.checked = not self.checkedself.animation.setDirection(QVariantAnimation.Forward if self.checked else QVariantAnimation.Backward)self.animation.start()def onAnimationFinished(self):self.switch_status_changed.emit(self.checked)
四.总结
本次和大家分享了我开发的PyQt5模仿安卓桌面软件,所有的图标、背景图片资源均来自于网络,欢迎大家下载体验!需要代码的同学可以私聊我,软件开发不易!
最后,能给个三连么?