-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToggleMenu.py
More file actions
79 lines (66 loc) · 2.17 KB
/
ToggleMenu.py
File metadata and controls
79 lines (66 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# -*- coding: utf-8 -*-
"""
Module implementing ToggleMenu.
"""
from PyQt5.QtCore import pyqtSlot, QPropertyAnimation, QEasingCurve
from PyQt5.QtWidgets import QWidget, QApplication, QPushButton
from Ui_ToggleMenu import Ui_ToggleMenu
class ToggleMenu(QWidget, Ui_ToggleMenu):
"""
Class documentation goes here.
"""
def __init__(self, parent=None):
"""
Constructor
@param parent reference to the parent widget (defaults to None)
@type QWidget (optional)
"""
super(ToggleMenu, self).__init__(parent)
self.setupUi(self)
@pyqtSlot()
def on_pushButton_toggle_menu_clicked(self):
"""
Slot documentation goes here.
"""
width = self.frame_left_mepu.width()
widthExtended = 155 if width == 70 else 70
self.animation = QPropertyAnimation(self.frame_left_mepu, b"minimumWidth")
self.animation.setDuration(400)
self.animation.setStartValue(width)
self.animation.setEndValue(widthExtended)
# 惯性效果
self.animation.setEasingCurve(QEasingCurve.InOutQuart)
self.animation.start()
@pyqtSlot()
def on_pushButton_home_clicked(self):
"""
Slot documentation goes here.
"""
self.resetChecked()
self.pushButton_home.setChecked(True)
self.stackedWidget.setCurrentIndex(0)
@pyqtSlot()
def on_pushButton_setting_clicked(self):
"""
Slot documentation goes here.
"""
self.resetChecked()
self.pushButton_setting.setChecked(True)
self.stackedWidget.setCurrentIndex(2)
def resetChecked(self):
for btn in ['home', 'user', 'setting']:
getattr(self, 'pushButton_{}'.format(btn)).setChecked(False)
@pyqtSlot()
def on_pushButton_user_clicked(self):
"""
Slot documentation goes here.
"""
self.resetChecked()
self.pushButton_user.setChecked(True)
self.stackedWidget.setCurrentIndex(1)
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
ui = ToggleMenu()
ui.show()
sys.exit(app.exec_())