from PyQt4.QtGui import QAction # Create an action with a label and parent widget action = QAction("Save", parent_widget)
from PyQt4.QtGui import QAction def do_something(): # some code to execute when the action is triggered pass # Create the action action = QAction("Do something", parent_widget) # Connect the action to a function action.triggered.connect(do_something)
from PyQt4.QtGui import QAction # Create the action action = QAction("Open", parent_widget) # Create a menu item menu_item = menu.addAction(action)In summary, the PyQt4 QtGui QAction class is a useful tool for creating actions that can be triggered within a GUI application. It provides flexibility in terms of customization and can be easily connected to functions to create interactive user experiences.