python的工具栏怎么调出_PyQt如何使工具栏按钮显示为按下

我想让PyQt工具栏中的一个特定按钮显示为按下(蓝色背景)。假设当我点击工具栏按钮时,我希望它显示为按下import sys

from PyQt4 import QtGui, QtCore

from PyQt4.QtGui import *

from PyQt4.QtCore import *

class Window(QtGui.QMainWindow):

def __init__(self):

super(Window, self).__init__()

self.setGeometry(50, 50, 700, 700)

self.setWindowTitle('Rich Text Editor')

self.statusBar = QStatusBar()

self.textEdit = QtGui.QTextEdit()

self.setCentralWidget(self.textEdit)

self.setStatusBar(self.statusBar)

self.home()

def home(self):

changeBoldActionTB = \

QtGui.QAction(QtGui.QIcon('bold-text-option.png'),

'Make the text bold', self)

changeBoldActionTB.triggered.connect(self.changeBold)

self.formatbar = QToolBar()

self.addToolBar(Qt.TopToolBarArea, self.formatbar)

self.formatbar.addAction(changeBoldActionTB)

self.show()

def changeBold(self):

pass

#I think this does't matter

def run():

app = QtGui.QApplication(sys.argv)

GUI = Window()

sys.exit(app.exec_())

run()

我有两个工具栏,我计划使用cursorPositionChanged来实现这一点,但PyQt中还有一种方法可以做到这一点

OEHve.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值