WeChatMsg/app/ui_pc/tool/tool_window.py

83 lines
2.6 KiB
Python
Raw Normal View History

2023-11-15 20:54:27 +08:00
from random import randint
2023-11-17 23:02:40 +08:00
from PyQt5.QtCore import Qt, pyqtSignal
2023-11-15 20:54:27 +08:00
from PyQt5.QtWidgets import QWidget, QListWidgetItem, QLabel
from .pc_decrypt import DecryptControl
from .toolUI import Ui_Dialog
from ...Ui.Icon import Icon
# 美化样式表
Stylesheet = """
/*去掉item虚线边框*/
QListWidget, QListView, QTreeWidget, QTreeView {
outline: 0px;
border:none;
background-color:rgb(240,240,240)
}
/*设置左侧选项的最小最大宽度,文字颜色和背景颜色*/
QListWidget {
min-width: 400px;
max-width: 400px;
min-height: 80px;
max-height: 80px;
color: black;
border:none;
}
QListWidget::item{
height:80px;
width:80px;
}
/*被选中时的背景颜色和左边框颜色*/
QListWidget::item:selected {
background: rgb(204, 204, 204);
border-bottom: 4px solid rgb(9, 187, 7);
border-left:none;
color: black;
font-weight: bold;
}
/*鼠标悬停颜色*/
HistoryPanel::item:hover {
background: rgb(52, 52, 52);
}
"""
class ToolWindow(QWidget, Ui_Dialog):
2023-11-17 23:02:40 +08:00
get_info_signal = pyqtSignal(str)
2023-11-17 23:54:34 +08:00
load_finish_signal = pyqtSignal(bool)
2023-11-17 23:02:40 +08:00
2023-11-15 20:54:27 +08:00
def __init__(self, parent=None):
super().__init__(parent)
self.setupUi(self)
self.setStyleSheet(Stylesheet)
self.init_ui()
2023-11-17 23:54:34 +08:00
self.load_finish_signal.emit(True)
2023-11-15 20:54:27 +08:00
def init_ui(self):
self.listWidget.clear()
self.listWidget.currentRowChanged.connect(self.setCurrentIndex)
chat_item = QListWidgetItem(Icon.Chat_Icon, '解密', self.listWidget)
contact_item = QListWidgetItem(Icon.Contact_Icon, 'None', self.listWidget)
myinfo_item = QListWidgetItem(Icon.MyInfo_Icon, 'None', self.listWidget)
tool_item = QListWidgetItem(Icon.MyInfo_Icon, 'None', self.listWidget)
2023-11-17 23:02:40 +08:00
decrypt_window = DecryptControl()
decrypt_window.get_wxidSignal.connect(self.get_info_signal)
self.stackedWidget.addWidget(decrypt_window)
2023-11-15 20:54:27 +08:00
label = QLabel('我是页面', self)
label.setAlignment(Qt.AlignCenter)
# 设置label的背景颜色(这里随机)
# 这里加了一个margin边距(方便区分QStackedWidget和QLabel的颜色)
label.setStyleSheet('background: rgb(%d, %d, %d);margin: 50px;' % (
randint(0, 255), randint(0, 255), randint(0, 255)))
self.stackedWidget.addWidget(label)
self.stackedWidget.addWidget(label)
self.stackedWidget.addWidget(label)
self.listWidget.setCurrentRow(0)
self.stackedWidget.setCurrentIndex(0)
def setCurrentIndex(self, row):
print(row)
self.stackedWidget.setCurrentIndex(row)