Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4df6923

Browse files
committed
GTK simplifications
1 parent e64aaf2 commit 4df6923

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -386,14 +386,14 @@ def stop_event_loop(self):
386386
FigureCanvasBase.stop_event_loop_default(self)
387387
stop_event_loop.__doc__=FigureCanvasBase.stop_event_loop_default.__doc__
388388

389-
class WindowGTK3(WindowBase):
389+
class WindowGTK3(WindowBase, Gtk.Window):
390390
def __init__(self, title):
391391
WindowBase.__init__(self, title)
392-
self.window = Gtk.Window()
392+
Gtk.Window.__init__(self)
393393
self.set_window_title(title)
394394

395395
try:
396-
self.window.set_icon_from_file(window_icon)
396+
self.set_icon_from_file(window_icon)
397397
except (SystemExit, KeyboardInterrupt):
398398
# re-raise exit type Exceptions
399399
raise
@@ -406,11 +406,11 @@ def __init__(self, title):
406406

407407
self.vbox = Gtk.Box()
408408
self.vbox.set_property('orientation', Gtk.Orientation.VERTICAL)
409-
self.window.add(self.vbox)
409+
self.add(self.vbox)
410410
self.vbox.show()
411411

412-
self.window.connect('destroy', self.destroy_event)
413-
self.window.connect('delete_event', self.destroy_event)
412+
self.connect('destroy', self.destroy_event)
413+
self.connect('delete_event', self.destroy_event)
414414

415415
def add_element_to_window(self, element, expand, fill, pad, side='bottom'):
416416
element.show()
@@ -424,34 +424,27 @@ def add_element_to_window(self, element, expand, fill, pad, side='bottom'):
424424
return size_request.height
425425

426426
def set_default_size(self, width, height):
427-
self.window.set_default_size(width, height)
427+
Gtk.Window.set_default_size(self, width, height)
428428

429429
def show(self):
430430
# show the figure window
431-
self.window.show()
431+
Gtk.Window.show(self)
432432

433433
def destroy(self):
434434
self.vbox.destroy()
435-
self.window.destroy()
435+
Gtk.Window.destroy(self)
436436

437437
def set_fullscreen(self, fullscreen):
438438
if fullscreen:
439-
self.window.fullscreen()
439+
self.fullscreen()
440440
else:
441-
self.window.unfullscreen()
441+
self.unfullscreen()
442442

443443
def get_window_title(self):
444-
return self.window.get_title()
444+
return self.get_title()
445445

446446
def set_window_title(self, title):
447-
self.window.set_title(title)
448-
449-
def resize(self, width, height):
450-
'set the canvas size in pixels'
451-
#_, _, cw, ch = self.canvas.allocation
452-
#_, _, ww, wh = self.window.allocation
453-
#self.window.resize (width-cw+ww, height-ch+wh)
454-
self.window.resize(width, height)
447+
self.set_title(title)
455448

456449

457450
class FigureManagerGTK3(FigureManagerBase):
@@ -966,4 +959,3 @@ def error_msg_gtk(msg, parent=None):
966959

967960
FigureCanvas = FigureCanvasGTK3
968961
FigureManager = FigureManagerGTK3
969-
Window = WindowGTK3

0 commit comments

Comments
 (0)