cut 3.3.0
Loading...
Searching...
No Matches
qenumericalunitsmenu.QeNumericalUnitsMenu Class Reference

The class creates Numerical Units Menu to change displayed units in the application. More...

Public Member Functions

QAction get_menu (self, str title, *AppUnit units)
 Creates QAction that can be attached to existing QMenu.
 
 autoconfigure (self, QWidget|list[QWidget] ui_obj)
 Searches for widget of QeAngleLabel and QeAngleEditLine type and connects them to unitChanged signal.
 
 handle_unit_change (self, widget, AppUnit unit)
 Performs unit change of QeAngleLabel and QeAngleEditLine widgets.
 
 handle_dart_board_unit_change (self, widget, AppUnit unit)
 Performs unit change of QeDartBoard widgets.
 
 set_unit (self, AppUnit unit)
 Checks desired unit in the menu.
 
 on_selection_changed (self, action)
 Handles change in unit selection when unit action is toggled.
 

Detailed Description

The class creates Numerical Units Menu to change displayed units in the application.

Usage
Create class instance and invoke get_menu method to get action that can be added to existing QMenu (either top-level or as a submenu). Connect 'unitChanged' signal to custom slot for unit change handling or use 'autoconfigure' method that accepts QWidget object or list of QWidget objects as an argument. The method detects QeAngleLabel, QeAngleLineEdit and QeDartBoard widgets in it and connects them to 'unitChanged' signal. Example of use:
_numerical_units_menu = QeNumericalUnitsMenu()
# The following action should be added to existing QMenu with addAction() method
menu_action = _numerical_units_menu.get_menu("Units", AppUnit.DEGREES, AppUnit.RADIANS, AppUnit.HMS, AppUnit.DMS)
_numerical_units_menu.autoconfigure(widgets_tab_from_ui_app)
@par
For handling HMS/DMS option when some widgets change thir unit to HMS and others change the unit to DMS, 'hmsdmsRole' dynamic property should be assigned to those widgets like:
self.ui.targetPositionRaAngleLabel.setProperty(
"hmsdmsRole", "hms"
)
Then, every time HMS/DMS option is selected in the menu, the widget switches it's unit to HMS
'unitChanged' signal carries selected unit enum value

Member Function Documentation

◆ autoconfigure()

qenumericalunitsmenu.QeNumericalUnitsMenu.autoconfigure ( self,
QWidget | list[QWidget] ui_obj )

Searches for widget of QeAngleLabel and QeAngleEditLine type and connects them to unitChanged signal.

Parameters
ui_objQWidget object or list of QWidget objects from which QeAngleLabel, QeAngleLineEdit and QeDartBoard Children are retrieved and connected to 'unitChanged' so that the widgets react to unit change

◆ get_menu()

QAction qenumericalunitsmenu.QeNumericalUnitsMenu.get_menu ( self,
str title,
*AppUnit units )

Creates QAction that can be attached to existing QMenu.

:param title str title of the action :param *units sequence of units to be available in the menu

◆ handle_dart_board_unit_change()

qenumericalunitsmenu.QeNumericalUnitsMenu.handle_dart_board_unit_change ( self,
widget,
AppUnit unit )

Performs unit change of QeDartBoard widgets.

The method handles QeDartBoard class separately to provide robustness

◆ set_unit()

qenumericalunitsmenu.QeNumericalUnitsMenu.set_unit ( self,
AppUnit unit )

Checks desired unit in the menu.

Helper method to set unit programatically (mostly at application start). unitChanged signal has to be emmited explicitly here, because QActionGroup accepts only user-triggered changes, so action.setChecked(True) won't trigger QActionGroup


The documentation for this class was generated from the following file: