2020 pressed, x and y locations in pixel and
2121 :class:`~matplotlib.axes.Axes` coordinates.
2222
23+ :class:`WindowBase`
24+ The base class to display a window.
25+
26+ :class:`MainLoopBase`
27+ The base class to start the GUI's main loop.
28+
2329:class:`ShowBase`
2430 The base class for the Show class of each interactive backend;
2531 the 'show' callable is then set to Show.__call__, inherited from
@@ -2503,10 +2509,10 @@ def key_press_handler(event, canvas, toolbar=None):
25032509
25042510 # quit the figure (defaut key 'ctrl+w')
25052511 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 :
2512+ if isinstance (canvas .manager , FigureManagerBase ): # Using old figman.
25092513 Gcf .destroy_fig (canvas .figure )
2514+ else :
2515+ canvas .manager ._destroy ('window_destroy_event' )
25102516
25112517 if toolbar is not None :
25122518 # home or reset mnemonic (default key 'h', 'home' and 'r')
@@ -2589,6 +2595,14 @@ def __init__(self, name, window):
25892595
25902596
25912597class WindowBase (cbook .EventEmitter ):
2598+ """The base class to show a window on screen.
2599+
2600+ Parameters
2601+ ----------
2602+ title : str
2603+ The title of the window.
2604+ """
2605+
25922606 def __init__ (self , title ):
25932607 cbook .EventEmitter .__init__ (self )
25942608
@@ -2602,39 +2616,92 @@ def show(self):
26022616 raise NonGuiException ()
26032617
26042618 def destroy (self ):
2619+ """Destroys the window"""
26052620 pass
26062621
26072622 def set_fullscreen (self , fullscreen ):
2623+ """Whether to show the window fullscreen or not, GUI only.
2624+
2625+ Parameters
2626+ ----------
2627+ fullscreen : bool
2628+ True for yes, False for no.
2629+ """
26082630 pass
26092631
2610- def set_default_size (self , w , h ):
2632+ def set_default_size (self , width , height ):
2633+ """Sets the default size of the window, defaults to a simple resize.
2634+
2635+ Parameters
2636+ ----------
2637+ width : int
2638+ The default width (in pixels) of the window.
2639+ height : int
2640+ The default height (in pixels) of the window.
2641+ """
26112642 self .resize (w , h )
26122643
2613- def resize (self , w , h ):
2614- """"For gui backends, resize the window (in pixels)."""
2644+ def resize (self , width , height ):
2645+ """"For gui backends, resizes the window.
2646+
2647+ Parameters
2648+ ----------
2649+ width : int
2650+ The new width (in pixels) for the window.
2651+ height : int
2652+ The new height (in pixels) for the window.
2653+ """
26152654 pass
26162655
26172656 def get_window_title (self ):
26182657 """
26192658 Get the title text of the window containing the figure.
26202659 Return None for non-GUI backends (e.g., a PS backend).
2660+
2661+ Returns
2662+ -------
2663+ str : The window's title.
26212664 """
26222665 return 'image'
26232666
26242667 def set_window_title (self , title ):
26252668 """
26262669 Set the title text of the window containing the figure. Note that
26272670 this has no effect for non-GUI backends (e.g., a PS backend).
2671+
2672+ Parameters
2673+ ----------
2674+ title : str
2675+ The title of the window.
26282676 """
26292677 pass
26302678
26312679 def add_element_to_window (self , element , expand , fill , pad , side = 'bottom' ):
26322680 """ Adds a gui widget to the window.
2633- This has no effect for non-GUI backends
2681+ This has no effect for non-GUI backends and properties only apply
2682+ to those backends that support them, or have a suitable workaround.
2683+
2684+ Parameters
2685+ ----------
2686+ element : A gui element.
2687+ The element to add to the window
2688+ expand : bool
2689+ Whether the element should auto expand to fill as much space within
2690+ the window as possible.
2691+ fill : bool
2692+ If the element can expand, should it make the element bigger,
2693+ or go into extra padding? True, False respectfully.
2694+ pad : int
2695+ The extra amount of space in pixels to pad the element.
26342696 """
26352697 pass
26362698
26372699 def destroy_event (self , * args ):
2700+ """Fires this event when the window wants to destroy itself.
2701+
2702+ Note this method should hook up to the backend's internal window's
2703+ close event.
2704+ """
26382705 s = 'window_destroy_event'
26392706 event = WindowEvent (s , self )
26402707 self ._callbacks .process (s , event )
0 commit comments