@@ -2503,10 +2503,10 @@ def key_press_handler(event, canvas, toolbar=None):
25032503
25042504 # quit the figure (defaut key 'ctrl+w')
25052505 if event .key in quit_keys :
2506- if isinstance (canvas .manager .mainloop , MainLoopBase ): # If new no Gcf.
2507- canvas .manager ._destroy ('window_destroy_event' )
2508- else :
2506+ if isinstance (canvas .manager , FigureManagerBase ): # Using old figman.
25092507 Gcf .destroy_fig (canvas .figure )
2508+ else :
2509+ canvas .manager ._destroy ('window_destroy_event' )
25102510
25112511 if toolbar is not None :
25122512 # home or reset mnemonic (default key 'h', 'home' and 'r')
@@ -2589,6 +2589,13 @@ def __init__(self, name, window):
25892589
25902590
25912591class WindowBase (cbook .EventEmitter ):
2592+ """ The base class to show a window on screen.
2593+
2594+ Parameters
2595+ ----------
2596+ title : str
2597+ The title of the window.
2598+ """
25922599 def __init__ (self , title ):
25932600 cbook .EventEmitter .__init__ (self )
25942601
@@ -2602,39 +2609,90 @@ def show(self):
26022609 raise NonGuiException ()
26032610
26042611 def destroy (self ):
2612+ """Destroys the window
2613+ """
26052614 pass
26062615
26072616 def set_fullscreen (self , fullscreen ):
2617+ """Whether to show the window fullscreen or not, GUI only.
2618+
2619+ Parameters
2620+ ----------
2621+ fullscreen : bool
2622+ True for yes, False for no.
2623+ """
26082624 pass
26092625
2610- def set_default_size (self , w , h ):
2626+ def set_default_size (self , width , height ):
2627+ """Sets the default size of the window, defaults to a simple resize.
2628+
2629+ Parameters
2630+ ----------
2631+ width : int
2632+ The default width (in pixels) of the window.
2633+ height : int
2634+ The default height (in pixels) of the window.
2635+ """
26112636 self .resize (w , h )
26122637
2613- def resize (self , w , h ):
2614- """"For gui backends, resize the window (in pixels)."""
2638+ def resize (self , width , height ):
2639+ """"For gui backends, resizes the window.
2640+
2641+ Parameters
2642+ ----------
2643+ width : int
2644+ The new width (in pixels) for the window.
2645+ height : int
2646+ The new height (in pixels) for the window.
2647+ """
26152648 pass
26162649
26172650 def get_window_title (self ):
26182651 """
26192652 Get the title text of the window containing the figure.
26202653 Return None for non-GUI backends (e.g., a PS backend).
2654+
2655+ Returns
2656+ -------
2657+ str : The window's title.
26212658 """
26222659 return 'image'
26232660
26242661 def set_window_title (self , title ):
26252662 """
26262663 Set the title text of the window containing the figure. Note that
26272664 this has no effect for non-GUI backends (e.g., a PS backend).
2665+
2666+ Parameters
2667+ ----------
2668+ title : str
2669+ The title of the window.
26282670 """
26292671 pass
26302672
26312673 def add_element_to_window (self , element , expand , fill , pad , side = 'bottom' ):
26322674 """ Adds a gui widget to the window.
2633- This has no effect for non-GUI backends
2675+ This has no effect for non-GUI backends and properties only apply
2676+ to those backends that support them, or have a suitable workaround.
2677+
2678+ Parameters
2679+ ----------
2680+ element : A gui element.
2681+ The element to add to the window
2682+ expand : bool
2683+ Whether the element should auto expand to fill as much space within
2684+ the window as possible.
2685+ fill : bool
2686+ If the element can expand, should it make the element bigger,
2687+ or go into extra padding? True, False respectfully.
2688+ pad : int
2689+ The extra amount of space in pixels to pad the element.
26342690 """
26352691 pass
26362692
26372693 def destroy_event (self , * args ):
2694+ """Fires this event when the window wants to destroy itself.
2695+ *args come from the GUI specific event mechanism."""
26382696 s = 'window_destroy_event'
26392697 event = WindowEvent (s , self )
26402698 self ._callbacks .process (s , event )
0 commit comments