Files
Feeding_control_system/zjsh_mixing_sysytem/bottom_control_widget.py
2025-11-13 16:53:22 +08:00

41 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from PySide6.QtWidgets import (QWidget, QHBoxLayout, QLabel, QPushButton,
QMessageBox, QSpacerItem, QSizePolicy)
from PySide6.QtGui import QPixmap, QPainter, QFont, QPen
from PySide6.QtCore import Qt, QDateTime, QEvent, QSize
class BottomControlWidget(QWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.initUI()
def initUI(self):
# 1. 加载背景图并设置控件尺寸
bg_path = "底部背景.png"
self.bg_pixmap = QPixmap(bg_path)
if self.bg_pixmap.isNull():
print("警告:底部背景.png 加载失败,请检查路径!")
self.setFixedSize(1280, 66)
else:
self.setFixedSize(self.bg_pixmap.size())
# 2. 主布局水平布局组件间距6px
main_layout = QHBoxLayout(self)
main_layout.setContentsMargins(10, 10, 10, 10) # 适当留白避免贴边
main_layout.setSpacing(6)
def paintEvent(self, event):
"""绘制背景图"""
super().paintEvent(event)
if not self.bg_pixmap.isNull():
painter = QPainter(self)
painter.drawPixmap(0, 0, self.bg_pixmap)
if __name__ == "__main__":
import sys
from PySide6.QtWidgets import QApplication
app = QApplication(sys.argv)
widget = BottomControlWidget()
widget.show()
sys.exit(app.exec())