@@ -1656,7 +1656,61 @@ def __init__(self, name, canvas, key, x=0, y=0, guiEvent=None):
1656
1656
self .key = key
1657
1657
1658
1658
1659
- class FigureCanvasBase (object ):
1659
+ class ExpandableBase (object ):
1660
+ """
1661
+ Base class for GUI elements that can expand to fill the area given to them
1662
+ by the encapsulating container (e.g. the main window).
1663
+
1664
+ At the moment this class does not do anything apart from mark such classes,
1665
+ but this may well change at a later date, PRs welcome.
1666
+ """
1667
+ pass
1668
+
1669
+ class FlowBase (object ):
1670
+ """
1671
+ Base mixin class for all GUI elements that can flow, aka laid out in
1672
+ different directions.
1673
+
1674
+ The MPL window class deals with the manipulation of this mixin, so users
1675
+ don't actually need to interact with this class.
1676
+
1677
+ Classes the implement this class must override the _update_flow method.
1678
+ """
1679
+ flow_types = ['horizontal' , 'vertical' ]
1680
+
1681
+ def __init__ (self , flow = 'horizontal' , flow_locked = False , ** kwargs ):
1682
+ super (FlowBase , self ).__init__ (** kwargs )
1683
+ self .flow_locked = flow_locked
1684
+ self .flow = flow
1685
+
1686
+ @property
1687
+ def flow (self ):
1688
+ """
1689
+ The direction of flow, one of the strings in `flow_type`.
1690
+ """
1691
+ return FlowBase .flow_types [self ._flow ]
1692
+
1693
+ @flow .setter
1694
+ def flow (self , flow ):
1695
+ if self .flow_locked :
1696
+ return
1697
+
1698
+ try :
1699
+ self ._flow = FlowBase .flow_types .index (flow )
1700
+ except ValueError :
1701
+ raise ValueError ('Flow (%s), not in list %s' % (flow , FlowBase .flow_types ))
1702
+
1703
+ self ._update_flow ()
1704
+
1705
+ def _update_flow (self ):
1706
+ """
1707
+ Classes that extend FlowBase must override this method.
1708
+ You can use the internal property self._flow whereby
1709
+ flow_types[self._flow] gives the current flow.
1710
+ """
1711
+ raise NotImplementedError
1712
+
1713
+ class FigureCanvasBase (ExpandableBase ):
1660
1714
"""
1661
1715
The canvas the figure renders into.
1662
1716
@@ -2717,7 +2771,7 @@ def set_window_title(self, title):
2717
2771
"""
2718
2772
pass
2719
2773
2720
- def add_element (self , element , expand , place ):
2774
+ def add_element (self , element , place ):
2721
2775
""" Adds a gui widget to the window.
2722
2776
This has no effect for non-GUI backends and properties only apply
2723
2777
to those backends that support them, or have a suitable workaround.
@@ -2726,9 +2780,6 @@ def add_element(self, element, expand, place):
2726
2780
----------
2727
2781
element : A gui element.
2728
2782
The element to add to the window
2729
- expand : bool
2730
- Whether the element should auto expand to fill as much space within
2731
- the window as possible.
2732
2783
place : string
2733
2784
The location to place the element, either compass points north,
2734
2785
east, south, west, or center.
@@ -3479,51 +3530,6 @@ def remove_toolitem(self, name):
3479
3530
raise NotImplementedError
3480
3531
3481
3532
3482
- class FlowBase (object ):
3483
- """
3484
- Base mixin class for all GUI elements that can flow, aka laid out in
3485
- different directions.
3486
-
3487
- The MPL window class deals with the manipulation of this mixin, so users
3488
- don't actually need to interact with this class.
3489
-
3490
- Classes the implement this class must override the _update_flow method.
3491
- """
3492
- flow_types = ['horizontal' , 'vertical' ]
3493
-
3494
- def __init__ (self , flow = 'horizontal' , flow_locked = False , ** kwargs ):
3495
- super (FlowBase , self ).__init__ (** kwargs )
3496
- self .flow_locked = flow_locked
3497
- self .flow = flow
3498
-
3499
- @property
3500
- def flow (self ):
3501
- """
3502
- The direction of flow, one of the strings in `flow_type`.
3503
- """
3504
- return FlowBase .flow_types [self ._flow ]
3505
-
3506
- @flow .setter
3507
- def flow (self , flow ):
3508
- if self .flow_locked :
3509
- return
3510
-
3511
- try :
3512
- self ._flow = FlowBase .flow_types .index (flow )
3513
- except ValueError :
3514
- raise ValueError ('Flow (%s), not in list %s' % (flow , FlowBase .flow_types ))
3515
-
3516
- self ._update_flow ()
3517
-
3518
- def _update_flow (self ):
3519
- """
3520
- Classes that extend FlowBase must override this method.
3521
- You can use the internal property self._flow whereby
3522
- flow_types[self._flow] gives the current flow.
3523
- """
3524
- raise NotImplementedError
3525
-
3526
-
3527
3533
class ToolbarBase (ToolContainerBase , FlowBase ):
3528
3534
pass
3529
3535
0 commit comments