Get the App
SLTechnology News&Howtos  ›  Development  › 

How to fill the toolbar with actions by PyQt in python

Shulou Source: shulou.com Published: 2022-06-03 17:34:24 10月05日 Update

I would like to share with you how PyQt fills the toolbar with actions in python. I believe most people don't know much about it, so share this article for your reference. I hope you can learn a lot after reading this article. Let's learn about it together.

1. To add options or buttons to the toolbar, you need to call .addAction ().

2. Call .addAction () as a parameter, which allows you to share actions between menus and toolbars.

When you create a toolbar, you are usually faced with the problem of deciding which options to add. Usually, you only want to add the most commonly used actions to the toolbar.

Example

Class Window (QMainWindow): # Snip... Def _ createActions (self): # File actions self.newAction = QAction (self) self.newAction.setText ("& New") self.newAction.setIcon (QIcon (": file-new.svg") self.openAction = QAction (QIcon (": file-open.svg"), "& Open...", self) self.saveAction = QAction (QIcon (": file-save.svg"), "& Save" Self) self.exitAction = QAction ("& Exit", self) # Edit actions self.copyAction = QAction (QIcon (": edit-copy.svg"), "& Copy", self) self.pasteAction = QAction (QIcon (": edit-paste.svg"), "& Paste", self) self.cutAction = QAction (QIcon (": edit-cut.svg"), "C&ut", self) # Snip... The above is all the content of the article "how PyQt fills the toolbar with actions 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!

Tags: Tools toolbars articles actions content not much between parameters most examples regular meetings commonly used buttons more knowledge menus industries information information channels questions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Docker macOS Shulou Technology vpn