rayoptics.gui.appmanager module

Lightweight manager class to connect a model+actions to windows

class ModelInfo(model, fct, args, kwargs)

Bases: tuple

args

list of fct arguments

fct

view update function, can be None

kwargs

list of fct keyword arguments

model

object associated with view update function

class AppManager(model, gui_parent=None)[source]

Bases: object

Lightweight model/view manager class

Lightweight manager class to manage connections between a model and a ui view.

The main function of AppManager is refresh_gui(). This is called after a user input to the gui to update the model and call a refresh function for each ui view of that model.

model

the model of the currently active/frontmost ui view

model is expected to respond to:

  • update_model()

  • name()

gui_parent

the top level gui manager (optional)

gui_parent is expected to implement:

  • refresh_app_ui()

view_dict

keys are ui views, values are ModelInfo tuples

view is expected to implement:

  • windowTitle() - only for debug logging

set_model(model)[source]
add_view(view, gui_hook, model_info)[source]

Add a new view and model tuple into dictionary

Parameters:
  • view – the ui view, used as a key

  • gui_hook – instance of the GUI component to be refreshed

  • model_info – instance of the ModelInfo tuple

Returns:

returns the input view

add_figure(fig)[source]

Add a new figure to be updated at refresh_gui.

Parameters:

fig – the ui figure

Returns:

returns the input figure

delete_view(view)[source]

removes view from the view dictionary

Parameters:

view – view being closed by user

close_model(view_close_fct=None)[source]

close all ui views associated with the active model

Parameters:

view_close_fct – optional fct called on each closing view, with the view as an argument. This function, if used, should call delete_view itself.

refresh_gui(**kwargs)[source]

update the active model and refresh its dependent ui views

refresh_views(**kwargs)[source]

refresh the dependent ui views of the active model

refresh_figures(**kwargs)[source]

refresh the dependent ui views of the active model

on_view_activated(view)[source]

Makes the model associated with input view the active model

Parameters:

view – view becoming the active view

sync_light_or_dark(is_dark)[source]

Tells views to update to a light or dark color scheme