ChatGPT解答:PYQT5 美化各种控件的方案和实例

ChatGPT解答:PYQT5 美化各种控件的方案和实例

  1. 修改按钮样式
button = QPushButton('按钮', self)
button.setStyleSheet('QPushButton{background-color: red; border-radius: 5px;}')
  1. 修改标签样式
label = QLabel('标签', self)
label.setStyleSheet('QLabel{color: blue; font-size: 20px;}')
  1. 修改文本框样式
text_edit = QTextEdit(self)
text_edit.setStyleSheet('QTextEdit{background-color: yellow; border: 1px solid black;}')
  1. 修改窗口样式
self.setStyleSheet('background-color: gray;')
  1. 修改表格样式
table_widget = QTableWidget(self)
table_widget.setStyleSheet('QTableWidget{background-color: white; border: 1px solid black;}')
  1. 修改下拉框样式
combo_box = QComboBox(self)
combo_box.setStyleSheet('QComboBox{background-color: white; border: 1px solid black;}')
  1. 修改进度条样式
progress_bar = QProgressBar(self)
progress_bar.setStyleSheet('QProgressBar{background-color: white; border: 1px solid black;}')
  1. 修改复选框样式
check_box = QCheckBox('复选框', self)
check_box.setStyleSheet('QCheckBox{color: red; font-size: 20px;}')
  1. 修改滑动条样式
slider = QSlider(Qt.Horizontal, self)
slider.setStyleSheet('QSlider{background-color: white; border: 1px solid black;}')
  1. 修改菜单栏样式
menu_bar = QMenuBar(self)
menu_bar.setStyleSheet('QMenuBar{background-color: white; border: 1px solid black;}')

以上是一些常见控件的美化方案和实例,可以根据自己的需求进行修改和调整。

更多

  1. 修改列表框样式
list_widget = QListWidget(self)
list_widget.setStyleSheet('QListWidget{background-color: white; border: 1px solid black;}')
  1. 修改滚动条样式
scroll_bar = QScrollBar(self)
scroll_bar.setStyleSheet('QScrollBar{background-color: white; border: 1px solid black;}')
  1. 修改标签页样式
tab_widget = QTabWidget(self)
tab_widget.setStyleSheet('QTabWidget{background-color: white; border: 1px solid black;}')
  1. 修改日期选择器样式
date_edit = QDateEdit(self)
date_edit.setStyleSheet('QDateEdit{background-color: white; border: 1px solid black;}')
  1. 修改时间选择器样式
time_edit = QTimeEdit(self)
time_edit.setStyleSheet('QTimeEdit{background-color: white; border: 1px solid black;}')
  1. 修改颜色选择器样式
color_picker = QColorDialog(self)
color_picker.setStyleSheet('QColorDialog{background-color: white; border: 1px solid black;}')
  1. 修改字体选择器样式
font_picker = QFontDialog(self)
font_picker.setStyleSheet('QFontDialog{background-color: white; border: 1px solid black;}')
  1. 修改文件选择器样式
file_picker = QFileDialog(self)
file_picker.setStyleSheet('QFileDialog{background-color: white; border: 1px solid black;}')
  1. 修改消息框样式
msg_box = QMessageBox(self)
msg_box.setStyleSheet('QMessageBox{background-color: white; border: 1px solid black;}')
  1. 修改进度对话框样式
progress_dialog = QProgressDialog(self)
progress_dialog.setStyleSheet('QProgressDialog{background-color: white; border: 1px solid black;}')

以上是更多控件的美化方案和实例,可以根据自己的需求进行修改和调整。

更多

  1. 修改滑块样式
dial = QDial(self)
dial.setStyleSheet('QDial{background-color: white; border: 1px solid black;}')
  1. 修改日期时间选择器样式
datetime_edit = QDateTimeEdit(self)
datetime_edit.setStyleSheet('QDateTimeEdit{background-color: white; border: 1px solid black;}')
  1. 修改进度条标签样式
progress_bar = QProgressBar(self)
progress_bar.setStyleSheet('QProgressBar{background-color: white; border: 1px solid black;} QProgressBar::chunk{background-color: red;}')
  1. 修改滚动区域样式
scroll_area = QScrollArea(self)
scroll_area.setStyleSheet('QScrollArea{background-color: white; border: 1px solid black;}')
  1. 修改菜单样式
menu = QMenu(self)
menu.setStyleSheet('QMenu{background-color: white; border: 1px solid black;}')
  1. 修改工具栏样式
tool_bar = QToolBar(self)
tool_bar.setStyleSheet('QToolBar{background-color: white; border: 1px solid black;}')
  1. 修改状态栏样式
status_bar = QStatusBar(self)
status_bar.setStyleSheet('QStatusBar{background-color: white; border: 1px solid black;}')
  1. 修改进度条文本样式
progress_bar = QProgressBar(self)
progress_bar.setStyleSheet('QProgressBar{background-color: white; border: 1px solid black;} QProgressBar::chunk{background-color: red;} QProgressBar::text{color: blue;}')
  1. 修改滑动条滑块样式
slider = QSlider(Qt.Horizontal, self)
slider.setStyleSheet('QSlider{background-color: white; border: 1px solid black;} QSlider::handle{background-color: red; border-radius: 5px;}')
  1. 修改标签链接样式
label = QLabel('标签', self)
label.setStyleSheet('QLabel{color: blue; font-size: 20px;} QLabel::hover{color: red;}')

以上是更多控件的美化方案和实例,可以根据自己的需求进行修改和调整。

更多

  1. 修改滑动条刻度样式
slider = QSlider(Qt.Horizontal, self)
slider.setStyleSheet('QSlider{background-color: white; border: 1px solid black;} QSlider::groove:horizontal{background-color: gray;} QSlider::handle:horizontal{background-color: red; border-radius: 5px;} QSlider::sub-page:horizontal{background-color: blue;} QSlider::add-page:horizontal{background-color: green;} QSlider::tick-line:horizontal{background-color: black; width: 2px;}')
  1. 修改按钮悬停样式
button = QPushButton('按钮', self)
button.setStyleSheet('QPushButton{background-color: red; border-radius: 5px;} QPushButton::hover{background-color: blue;}')
  1. 修改标签选中样式
label = QLabel('标签', self)
label.setStyleSheet('QLabel{color: blue; font-size: 20px;} QLabel::selected{background-color: red;}')
  1. 修改列表框选中样式
list_widget = QListWidget(self)
list_widget.setStyleSheet('QListWidget{background-color: white; border: 1px solid black;} QListWidget::item:selected{background-color: red;}')
  1. 修改表格选中样式
table_widget = QTableWidget(self)
table_widget.setStyleSheet('QTableWidget{background-color: white; border: 1px solid black;} QTableWidget::item:selected{background-color: red;}')
  1. 修改滚动区域滚动条样式
scroll_area = QScrollArea(self)
scroll_area.setStyleSheet('QScrollArea{background-color: white; border: 1px solid black;} QScrollBar:vertical{background-color: blue;} QScrollBar:horizontal{background-color: red;}')
  1. 修改工具提示样式
button = QPushButton('按钮', self)
button.setStyleSheet('QPushButton{background-color: red; border-radius: 5px;} QPushButton::hover{background-color: blue;} QToolTip{background-color: yellow; color: black;}')
  1. 修改菜单项样式
menu = QMenu(self)
menu.setStyleSheet('QMenu{background-color: white; border: 1px solid black;} QMenu::item:selected{background-color: red;}')
  1. 修改工具栏按钮样式
tool_bar = QToolBar(self)
tool_bar.setStyleSheet('QToolBar{background-color: white; border: 1px solid black;} QToolButton{background-color: blue; border-radius: 5px;} QToolButton::hover{background-color: red;}')
  1. 修改状态栏标签样式
status_bar = QStatusBar(self)
status_bar.setStyleSheet('QStatusBar{background-color: white; border: 1px solid black;} QStatusBar::item{background-color: blue;}')

以上是更多控件的美化方案和实例,可以根据自己的需求进行修改和调整。

更多

  1. 修改进度条圆角样式
progress_bar = QProgressBar(self)
progress_bar.setStyleSheet('QProgressBar{background-color: white; border: 1px solid black; border-radius: 10px;} QProgressBar::chunk{background-color: red; border-radius: 10px;}')
  1. 修改滑动条刻度标签样式
slider = QSlider(Qt.Horizontal, self)
slider.setStyleSheet('QSlider{background-color: white; border: 1px solid black;} QSlider::handle:horizontal{background-color: red; border-radius: 5px;} QSlider::add-page:horizontal{background-color: gray;} QSlider::sub-page:horizontal{background-color: blue;} QSlider::tick-label:horizontal{background-color: yellow; color: black; font-size: 20px;}')
  1. 修改标签超链接样式
label = QLabel('标签', self)
label.setStyleSheet('QLabel{color: blue; font-size: 20px;} QLabel::hover{color: red;} QLabel::link{color: green;}')
label.setOpenExternalLinks(True)
label.setText('标签')
  1. 修改列表框悬停样式
list_widget = QListWidget(self)
list_widget.setStyleSheet('QListWidget{background-color: white; border: 1px solid black;} QListWidget::item:hover{background-color: blue;}')
  1. 修改表格悬停样式
table_widget = QTableWidget(self)
table_widget.setStyleSheet('QTableWidget{background-color: white; border: 1px solid black;} QTableWidget::item:hover{background-color: blue;}')
  1. 修改滚动区域滚动条悬停样式
scroll_area = QScrollArea(self)
scroll_area.setStyleSheet('QScrollArea{background-color: white; border: 1px solid black;} QScrollBar:vertical:hover{background-color: blue;} QScrollBar:horizontal:hover{background-color: red;}')
  1. 修改工具提示超链接样式
button = QPushButton('按钮', self)
button.setStyleSheet('QPushButton{background-color: red; border-radius: 5px;} QPushButton::hover{background-color: blue;} QToolTip{background-color: yellow; color: black;} QToolTip::link{color: green;}')
button.setToolTip('按钮')
  1. 修改菜单项悬停样式
menu = QMenu(self)
menu.setStyleSheet('QMenu{background-color: white; border: 1px solid black;} QMenu::item:hover{background-color: blue;}')
  1. 修改工具栏按钮悬停样式
tool_bar = QToolBar(self)
tool_bar.setStyleSheet('QToolBar{background-color: white; border: 1px solid black;} QToolButton{background-color: blue; border-radius: 5px;} QToolButton::hover{background-color: red;} QToolButton::menu-indicator{image: none;}')
  1. 修改状态栏标签悬停样式
status_bar = QStatusBar(self)
status_bar.setStyleSheet('QStatusBar{background-color: white; border: 1px solid black;} QStatusBar::item:hover{background-color: blue;}')

以上是更多控件的美化方案和实例,可以根据自己的需求进行修改和调整。

更多

  1. 修改进度条文本位置样式
progress_bar = QProgressBar(self)
progress_bar.setStyleSheet('QProgressBar{background-color: white; border: 1px solid black;} QProgressBar::chunk{background-color: red;} QProgressBar::text{color: blue; font-size: 20px; top: 5px;}')
  1. 修改滑动条刻度标签位置样式
slider = QSlider(Qt.Horizontal, self)
slider.setStyleSheet('QSlider{background-color: white; border: 1px solid black;} QSlider::handle:horizontal{background-color: red; border-radius: 5px;} QSlider::add-page:horizontal{background-color: gray;} QSlider::sub-page:horizontal{background-color: blue;} QSlider::tick-label:horizontal{background-color: yellow; color: black; font-size: 20px; top: 20px;}')
  1. 修改标签字体样式
label = QLabel('标签', self)
label.setStyleSheet('QLabel{color: blue; font-size: 20px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;}')
  1. 修改列表框字体样式
list_widget = QListWidget(self)
list_widget.setStyleSheet('QListWidget{background-color: white; border: 1px solid black; font-size: 20px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;}')
  1. 修改表格字体样式
table_widget = QTableWidget(self)
table_widget.setStyleSheet('QTableWidget{background-color: white; border: 1px solid black; font-size: 20px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;}')
  1. 修改滚动区域字体样式
scroll_area = QScrollArea(self)
scroll_area.setStyleSheet('QScrollArea{background-color: white; border: 1px solid black; font-size: 20px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;}')
  1. 修改菜单字体样式
menu = QMenu(self)
menu.setStyleSheet('QMenu{background-color: white; border: 1px solid black; font-size: 20px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;}')
  1. 修改工具栏字体样式
tool_bar = QToolBar(self)
tool_bar.setStyleSheet('QToolBar{background-color: white; border: 1px solid black; font-size: 20px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;}')
  1. 修改状态栏字体样式
status_bar = QStatusBar(self)
status_bar.setStyleSheet('QStatusBar{background-color: white; border: 1px solid black; font-size: 20px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;}')
  1. 修改进度条文本格式样式
progress_bar = QProgressBar(self)
progress_bar.setStyleSheet('QProgressBar{background-color: white; border: 1px solid black;} QProgressBar::chunk{background-color: red;} QProgressBar::text{color: blue; font-size: 20px; format: "%v/%m";}')
progress_bar.setMaximum(100)
progress_bar.setValue(50)

以上是更多控件的美化方案和实例,可以根据自己的需求进行修改和调整。

更多

  1. 修改滑动条刻度标签格式样式
slider = QSlider(Qt.Horizontal, self)
slider.setStyleSheet('QSlider{background-color: white; border: 1px solid black;} QSlider::handle:horizontal{background-color: red; border-radius: 5px;} QSlider::add-page:horizontal{background-color: gray;} QSlider::sub-page:horizontal{background-color: blue;} QSlider::tick-label:horizontal{background-color: yellow; color: black; font-size: 20px; format: "%v";}')
slider.setMinimum(0)
slider.setMaximum(100)
slider.setTickInterval(10)
slider.setTickPosition(QSlider.TicksBelow)
  1. 修改标签字体粗细样式
label = QLabel('标签', self)
label.setStyleSheet('QLabel{color: blue; font-size: 20px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-weight: bold;}')
  1. 修改列表框字体粗细样式
list_widget = QListWidget(self)
list_widget.setStyleSheet('QListWidget{background-color: white; border: 1px solid black; font-size: 20px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-weight: bold;}')
  1. 修改表格字体粗细样式
table_widget = QTableWidget(self)
table_widget.setStyleSheet('QTableWidget{background-color: white; border: 1px solid black; font-size: 20px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-weight: bold;}')
  1. 修改滚动区域字体粗细样式
scroll_area = QScrollArea(self)

你可能感兴趣的:(python,PYQT5,ChatGPT,css,前端)