diff --git a/opencsp/common/lib/render/figure_management.py b/opencsp/common/lib/render/figure_management.py index 60a194352..0f7352e3c 100644 --- a/opencsp/common/lib/render/figure_management.py +++ b/opencsp/common/lib/render/figure_management.py @@ -235,6 +235,12 @@ def _setup_figure( window.move(x, y) # qt else: window.geometry(f"+{x}+{y}") # tkinter + if figure_control.maximize: + window = fig.canvas.manager.window + if hasattr(window, "showMaximized"): + window.showMaximized() # qt + else: + window.state("zoomed") # tkinter # Copying this command, as from Randy, which suppresses duplicate axes in tile_figure(). ~ BGB plt.axis('off') diff --git a/opencsp/common/lib/render/test/test_figure_management.py b/opencsp/common/lib/render/test/test_figure_management.py index fe2d80197..c282576f1 100644 --- a/opencsp/common/lib/render/test/test_figure_management.py +++ b/opencsp/common/lib/render/test/test_figure_management.py @@ -127,6 +127,26 @@ def test_upper_left_xy_no_exception(self): fig_record.view.show() fig_record.close() + def test_maximize_no_exception(self): + """ + Verify that figure_management._setup_figure() with the figure control + parameter "maximize" set doesn't raise an exception. + """ + # TODO how to test that the window has actually been maximized? + axis_control = rca.meters() + figure_control = rcfg.RenderControlFigure(tile=False, maximize=True) + view_spec_2d = vs.view_spec_xy() + fig_record = fm.setup_figure( + figure_control, + axis_control, + view_spec_2d, + title=self.test_name, + code_tag=f"{__file__}.{self.test_name}", + equal=False, + ) + fig_record.view.show() + fig_record.close() + def test_save_figsize(self): """Verify that the size of the saved figure is as given in the save parameters.""" # create and save the figure with pixel sizes: diff --git a/opencsp/common/lib/render_control/RenderControlFigure.py b/opencsp/common/lib/render_control/RenderControlFigure.py index 357858670..909c927ae 100644 --- a/opencsp/common/lib/render_control/RenderControlFigure.py +++ b/opencsp/common/lib/render_control/RenderControlFigure.py @@ -17,6 +17,7 @@ def __init__( figsize=(6.4, 4.8), # inch. upper_left_xy=None, # pixel. (0,0) --> Upper left corner of screen. grid=True, + maximize=False, ): # Whether or not to draw grid lines. """Set of controls for how to render figures. @@ -53,6 +54,9 @@ def __init__( grid : bool, optional Whether or not to draw grid lines. Note: this value seems to be inverted. Default True + maximize : bool, optional + Whether the figure should be maximized (made full screen) as soon as + it is made visible. Ignored if tile is True. Default False. """ super(RenderControlFigure, self).__init__() @@ -66,6 +70,7 @@ def __init__( # Figure size and placement. self.figsize = figsize self.upper_left_xy = upper_left_xy + self.maximize = maximize # Axis control. self.x_label = 'x (m)'