Skip to content

Commit ebf0c57

Browse files
OceanWolftacaswell
authored andcommitted
Make add_element more general, and make sure the code complies with it.
1 parent 45c5fc2 commit ebf0c57

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2701,7 +2701,7 @@ def set_window_title(self, title):
27012701
"""
27022702
pass
27032703

2704-
def add_element_to_window(self, element, expand, fill, padding, from_start=False):
2704+
def add_element_to_window(self, element, expand, fill, pad, side='bottom'):
27052705
""" Adds a gui widget to the window.
27062706
This has no effect for non-GUI backends
27072707
"""

lib/matplotlib/backend_managers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ def __init__(self, figure, num):
4646
w = int(self.canvas.figure.bbox.width)
4747
h = int(self.canvas.figure.bbox.height)
4848

49-
self.window.add_element_to_window(self.canvas, True, True, 0, True)
49+
self.window.add_element_to_window(self.canvas, True, True, 0, 'top')
5050

5151
self.toolbar = self._get_toolbar()
5252
if self.toolbar is not None:
5353
h += self.window.add_element_to_window(self.toolbar,
54-
False, False, 0)
54+
False, False, 0, 'bottom')
5555

5656
self.window.set_default_size(w, h)
5757

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,15 +395,17 @@ def __init__(self, title):
395395
self.window.add(self.vbox)
396396
self.vbox.show()
397397

398-
self.window.connect('destroy', self.destroy_event) # TODO create in base
398+
self.window.connect('destroy', self.destroy_event)
399399
self.window.connect('delete_event', self.destroy_event)
400400

401-
def add_element_to_window(self, element, expand, fill, padding, from_start=False):
401+
def add_element_to_window(self, element, expand, fill, pad, side='bottom'):
402402
element.show()
403-
if from_start:
404-
self.vbox.pack_start(element, expand, fill, padding)
403+
if side == 'top':
404+
self.vbox.pack_start(element, expand, fill, pad)
405+
elif side == 'bottom':
406+
self.vbox.pack_end(element, expand, fill, pad)
405407
else:
406-
self.vbox.pack_end(element, False, False, 0)
408+
raise KeyError('Unknown value for side, %s' % side)
407409
size_request = element.size_request()
408410
return size_request.height
409411

0 commit comments

Comments
 (0)