11 Star 146 Fork 69

sunshe35/PySide6-codes

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
qt_QCommandLinkButton.py 1.79 KB
Copy Edit Raw Blame History
sunshe35 authored 2022-10-08 22:34 +08:00 . 修复路径问题
# -*- coding: utf-8 -*-
'''
【简介】
PySide6中QButton例子
'''
import sys
from PySide6.QtCore import *
from PySide6.QtGui import *
from PySide6.QtWidgets import *
import os
os.chdir(os.path.dirname(__file__))
class CommandLinkButtonDemo(QDialog):
def __init__(self, parent=None):
super(CommandLinkButtonDemo, self).__init__(parent)
layout = QVBoxLayout()
self.label_show = QLabel('显示按钮信息')
layout.addWidget(self.label_show)
self.button1 = QCommandLinkButton("默认按钮")
self.button1.setCheckable(True)
self.button1.toggle()
self.button1.clicked.connect(lambda: self.button_click(self.button1))
layout.addWidget(self.button1)
self.button_descript = QCommandLinkButton("描述按钮",'描述信息')
self.button_descript.clicked.connect(lambda: self.button_click(self.button_descript))
layout.addWidget(self.button_descript)
self.button_image = QCommandLinkButton('图片按钮')
self.button_image.setCheckable(True)
self.button_image.setDescription('设置自定义图片')
self.button_image.setIcon(QIcon("./images/python.png"))
self.button_image.clicked.connect(lambda: self.button_click(self.button_image))
layout.addWidget(self.button_image)
self.setWindowTitle("QCommandLinkButton demo")
self.setLayout(layout)
def button_click(self, button):
if button.isChecked():
self.label_show.setText('你按下了 ' + button.text() + " isChecked=True")
else:
self.label_show.setText('你按下了 ' + button.text() + " isChecked=False")
if __name__ == '__main__':
app = QApplication(sys.argv)
btnDemo = CommandLinkButtonDemo()
btnDemo.show()
sys.exit(app.exec())
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/sunshe35/PySide6-codes.git
git@gitee.com:sunshe35/PySide6-codes.git
sunshe35
PySide6-codes
PySide6-codes
master

Search