Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does PyQt display permanent messages in Python

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you how the PyQt in Python displays permanent messages, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

1. Add a persistent message to the status bar and use the QLabel object to save the message.

2. Add the label to the status bar through the call. AddPermanentWidget ().

This method permanently adds the given widget to the current status bar. The parent of the widget is set to the status bar.

.addPermanentWidget () takes the following two parameters:

Add the widget save widget object to the status bar. Some common widgets such as QLabel, QToolButton, QProgressBar, etc.

As the status bar grows and shrinks, stretch is used to calculate the appropriate size of the widget. It defaults to 0, which means that the widget will take up the least space.

Keep in mind that permanent widgets are not blocked or replaced by temporary messages. On the right side of the status bar, addPermanentWidget () locates the widget.

Example

Class Window (QMainWindow): # Snip... Def _ createStatusBar (self): self.statusbar = self.statusBar () # Adding a temporary message self.statusbar.showMessage ("Ready", 3000) # Adding a permanent message self.wcLabel = QLabel (f "{self.getWordCount ()} Words") self.statusbar.addPermanentWidget (self.wcLabel) these are all the contents of the article "how PyQt displays permanent messages in Python". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report