8000 Make add_element more general, and make sure the code complies with it. · matplotlib/matplotlib@c36a253 · GitHub
[go: up one dir, main page]

Skip to content

Commit c36a253

Browse files
committed
Make add_element more general, and make sure the code complies with it.
1 parent b442655 commit c36a253

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
@@ -2628,7 +2628,7 @@ def set_window_title(self, title):
26282628
"""
26292629
pass
26302630

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

lib/matplotlib/backend_managers.py

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

34-
self.window.add_element_to_window(self.canvas, True, True, 0, True)
34+
self.window.add_element_to_window(self.canvas, True, True, 0, 'top')
3535

3636
self.toolbar = self._get_toolbar()
3737
if self.toolbar is not None:
3838
h += self.window.add_element_to_window(self.toolbar,
39-
False, False, 0)
39+
False, False, 0, 'bottom')
4040

4141
self.window.set_default_size(w, h)
4242

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -409,15 +409,17 @@ def __init__(self, title):
409409
self.window.add(self.vbox)
410410
self.vbox.show()
411411

412-
self.window.connect('destroy', self.destroy_event) # TODO create in base
412+
self.window.connect('destroy', self.destroy_event)
413413
self.window.connect('delete_event', self.destroy_event)
414414

415-
def add_element_to_window(self, element, expand, fill, padding, from_start=False):
415+
def add_element_to_window(self, element, expand, fill, pad, side='bottom'):
416416
element.show()
417-
if from_start:
418-
self.vbox.pack_start(element, expand, fill, padding)
417+
if side == 'top':
418+
self.vbox.pack_start(element, expand, fill, pad)
419+
elif side == 'bottom':
420+
self.vbox.pack_end(element, expand, fill, pad)
419421
else:
420-
self.vbox.pack_end(element, False, False, 0)
422+
raise KeyError('Unknown value for side, %s' % side)
421423
size_request = element.size_request()
422424
return size_request.height
423425

0 commit comments

Comments
 (0)
0