ChatGPT解答:PYQT5 美化各种控件的方案和实例
button = QPushButton('按钮', self)
button.setStyleSheet('QPushButton{background-color: red; border-radius: 5px;}')
label = QLabel('标签', self)
label.setStyleSheet('QLabel{color: blue; font-size: 20px;}')
text_edit = QTextEdit(self)
text_edit.setStyleSheet('QTextEdit{background-color: yellow; border: 1px solid black;}')
self.setStyleSheet('background-color: gray;')
table_widget = QTableWidget(self)
table_widget.setStyleSheet('QTableWidget{background-color: white; border: 1px solid black;}')
combo_box = QComboBox(self)
combo_box.setStyleSheet('QComboBox{background-color: white; border: 1px solid black;}')
progress_bar = QProgressBar(self)
progress_bar.setStyleSheet('QProgressBar{background-color: white; border: 1px solid black;}')
check_box = QCheckBox('复选框', self)
check_box.setStyleSheet('QCheckBox{color: red; font-size: 20px;}')
slider = QSlider(Qt.Horizontal, self)
slider.setStyleSheet('QSlider{background-color: white; border: 1px solid black;}')
menu_bar = QMenuBar(self)
menu_bar.setStyleSheet('QMenuBar{background-color: white; border: 1px solid black;}')
以上是一些常见控件的美化方案和实例,可以根据自己的需求进行修改和调整。
更多
list_widget = QListWidget(self)
list_widget.setStyleSheet('QListWidget{background-color: white; border: 1px solid black;}')
scroll_bar = QScrollBar(self)
scroll_bar.setStyleSheet('QScrollBar{background-color: white; border: 1px solid black;}')
tab_widget = QTabWidget(self)
tab_widget.setStyleSheet('QTabWidget{background-color: white; border: 1px solid black;}')
date_edit = QDateEdit(self)
date_edit.setStyleSheet('QDateEdit{background-color: white; border: 1px solid black;}')
time_edit = QTimeEdit(self)
time_edit.setStyleSheet('QTimeEdit{background-color: white; border: 1px solid black;}')
color_picker = QColorDialog(self)
color_picker.setStyleSheet('QColorDialog{background-color: white; border: 1px solid black;}')
font_picker = QFontDialog(self)
font_picker.setStyleSheet('QFontDialog{background-color: white; border: 1px solid black;}')
file_picker = QFileDialog(self)
file_picker.setStyleSheet('QFileDialog{background-color: white; border: 1px solid black;}')
msg_box = QMessageBox(self)
msg_box.setStyleSheet('QMessageBox{background-color: white; border: 1px solid black;}')
progress_dialog = QProgressDialog(self)
progress_dialog.setStyleSheet('QProgressDialog{background-color: white; border: 1px solid black;}')
以上是更多控件的美化方案和实例,可以根据自己的需求进行修改和调整。
更多
dial = QDial(self)
dial.setStyleSheet('QDial{background-color: white; border: 1px solid black;}')
datetime_edit = QDateTimeEdit(self)
datetime_edit.setStyleSheet('QDateTimeEdit{background-color: white; border: 1px solid black;}')
progress_bar = QProgressBar(self)
progress_bar.setStyleSheet('QProgressBar{background-color: white; border: 1px solid black;} QProgressBar::chunk{background-color: red;}')
scroll_area = QScrollArea(self)
scroll_area.setStyleSheet('QScrollArea{background-color: white; border: 1px solid black;}')
menu = QMenu(self)
menu.setStyleSheet('QMenu{background-color: white; border: 1px solid black;}')
tool_bar = QToolBar(self)
tool_bar.setStyleSheet('QToolBar{background-color: white; border: 1px solid black;}')
status_bar = QStatusBar(self)
status_bar.setStyleSheet('QStatusBar{background-color: white; border: 1px solid black;}')
progress_bar = QProgressBar(self)
progress_bar.setStyleSheet('QProgressBar{background-color: white; border: 1px solid black;} QProgressBar::chunk{background-color: red;} QProgressBar::text{color: blue;}')
slider = QSlider(Qt.Horizontal, self)
slider.setStyleSheet('QSlider{background-color: white; border: 1px solid black;} QSlider::handle{background-color: red; border-radius: 5px;}')
label = QLabel('标签', self)
label.setStyleSheet('QLabel{color: blue; font-size: 20px;} QLabel::hover{color: red;}')
以上是更多控件的美化方案和实例,可以根据自己的需求进行修改和调整。
更多
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;}')
button = QPushButton('按钮', self)
button.setStyleSheet('QPushButton{background-color: red; border-radius: 5px;} QPushButton::hover{background-color: blue;}')
label = QLabel('标签', self)
label.setStyleSheet('QLabel{color: blue; font-size: 20px;} QLabel::selected{background-color: red;}')
list_widget = QListWidget(self)
list_widget.setStyleSheet('QListWidget{background-color: white; border: 1px solid black;} QListWidget::item:selected{background-color: red;}')
table_widget = QTableWidget(self)
table_widget.setStyleSheet('QTableWidget{background-color: white; border: 1px solid black;} QTableWidget::item:selected{background-color: red;}')
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;}')
button = QPushButton('按钮', self)
button.setStyleSheet('QPushButton{background-color: red; border-radius: 5px;} QPushButton::hover{background-color: blue;} QToolTip{background-color: yellow; color: black;}')
menu = QMenu(self)
menu.setStyleSheet('QMenu{background-color: white; border: 1px solid black;} QMenu::item:selected{background-color: red;}')
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;}')
status_bar = QStatusBar(self)
status_bar.setStyleSheet('QStatusBar{background-color: white; border: 1px solid black;} QStatusBar::item{background-color: blue;}')
以上是更多控件的美化方案和实例,可以根据自己的需求进行修改和调整。
更多
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;}')
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;}')
label = QLabel('标签', self)
label.setStyleSheet('QLabel{color: blue; font-size: 20px;} QLabel::hover{color: red;} QLabel::link{color: green;}')
label.setOpenExternalLinks(True)
label.setText('标签')
list_widget = QListWidget(self)
list_widget.setStyleSheet('QListWidget{background-color: white; border: 1px solid black;} QListWidget::item:hover{background-color: blue;}')
table_widget = QTableWidget(self)
table_widget.setStyleSheet('QTableWidget{background-color: white; border: 1px solid black;} QTableWidget::item:hover{background-color: blue;}')
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;}')
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('按钮')
menu = QMenu(self)
menu.setStyleSheet('QMenu{background-color: white; border: 1px solid black;} QMenu::item:hover{background-color: blue;}')
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;}')
status_bar = QStatusBar(self)
status_bar.setStyleSheet('QStatusBar{background-color: white; border: 1px solid black;} QStatusBar::item:hover{background-color: blue;}')
以上是更多控件的美化方案和实例,可以根据自己的需求进行修改和调整。
更多
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;}')
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;}')
label = QLabel('标签', self)
label.setStyleSheet('QLabel{color: blue; font-size: 20px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;}')
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;}')
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;}')
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;}')
menu = QMenu(self)
menu.setStyleSheet('QMenu{background-color: white; border: 1px solid black; font-size: 20px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;}')
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;}')
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;}')
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)
以上是更多控件的美化方案和实例,可以根据自己的需求进行修改和调整。
更多
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)
label = QLabel('标签', self)
label.setStyleSheet('QLabel{color: blue; font-size: 20px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-weight: bold;}')
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;}')
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;}')
scroll_area = QScrollArea(self)