5 Star 3 Fork 1

刘建平/360安全卫士界面

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
SearchLineEdit.py 2.82 KB
一键复制 编辑 原始数据 按行查看 历史
刘建平 提交于 2018-06-16 11:38 . first commit
from PyQt5.QtWidgets import QWidget,QLineEdit,QToolButton,QHBoxLayout
from PyQt5 import QtWidgets
from PyQt5 import QtGui
from PyQt5 import QtCore
from PyQt5.QtCore import QPoint
from PyQt5.QtGui import QPaintEvent,QMouseEvent,QPainter,QPolygon,QColor,QPen,QLinearGradient,QGradient,QFont
import FormWidgetimage
class SearchLineEdit(QLineEdit):
signalSearchContent = QtCore.pyqtSignal(str)
def __init__(self,parent=None):
super(SearchLineEdit, self).__init__(parent)
self.initForm()
self.initConnect()
self.translator()
def initForm(self):
self.setFixedSize(260,24)
self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.tbnSearch = QToolButton(self)
self.tbnSearch.setFixedSize(25,24)
self.tbnSearch.setAutoRaise(True)
self.tbnSearch.setCursor(QtCore.Qt.PointingHandCursor)
self.tbnSearch.setStyleSheet("QToolButton{border-image:url(:/image/search_dark.png);"
"background:transparent;}")
mainLayout = QHBoxLayout()
mainLayout.addStretch()
mainLayout.addWidget(self.tbnSearch)
self.setTextMargins(0,0,20,0)
self.setContentsMargins(0,0,0,0)
mainLayout.setContentsMargins(2,2,4,0)
self.setLayout(mainLayout)
self.setStyleSheet("height:24px;border:1px ;border-radius:6px;"
"background-color:#E1DDDD");
def initConnect(self):
self.tbnSearch.clicked.connect(self.slotSendSearchContent)
self.returnPressed.connect(self.slotSendSearchContent)
def translator(self):
self.setPlaceholderText("请输入要查找的内容")
self.setToolTip("查找内容")
self.tbnSearch.setToolTip("查找")
def focusInEvent(self, e: QtGui.QFocusEvent):
super(SearchLineEdit, self).focusInEvent(e)
self.clear()
self.setPlaceholderText("")
self.setStyleSheet("height:24px;border:1px ;border-radius:6px;"
"background-color:#CCC000");
self.tbnSearch.setStyleSheet("QToolButton{border-image:url(:/image/search_dark.png);"
"background:transparent;}");
def focusOutEvent(self, e: QtGui.QFocusEvent):
super(SearchLineEdit, self).focusOutEvent(e)
self.setPlaceholderText("请输入要查找的内容");
self.setStyleSheet("height:24px;border:1px ;border-radius:6px;"
"background-color:#CCC7C7");
self.tbnSearch.setStyleSheet("QToolButton{border-image:url(:/image/search_dark.png);"
"background:transparent;}");
def slotSendSearchContent(self):
str = ""
if self.text() == "":
str = self.placeholderText()
else:
str = self.text()
self.signalSearchContent.emit(str)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/baiqilinux/360_security_guard_interface.git
[email protected]:baiqilinux/360_security_guard_interface.git
baiqilinux
360_security_guard_interface
360安全卫士界面
master

搜索帮助