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

Skip to content

adding global variable to keep track if gtkmain has been called #2604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/matplotlib/backends/backend_gtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@ def draw_if_interactive():
if figManager is not None:
figManager.canvas.draw_idle()


gtk_main_called = False
class Show(ShowBase):
def mainloop(self):
if gtk.main_level() == 0:
global gtk_main_called
gtk_main_called = True
gtk.main()

show = Show()
Expand Down Expand Up @@ -606,7 +608,8 @@ def destroy(self, *args):

if Gcf.get_num_fig_managers()==0 and \
not matplotlib.is_interactive() and \
gtk.main_level() >= 1:
gtk.main_level() >= 1 and \
gtk_main_called:
gtk.main_quit()

def show(self):
Expand Down
6 changes: 5 additions & 1 deletion lib/matplotlib/backends/backend_gtk3.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ def draw_if_interactive():
if figManager is not None:
figManager.canvas.draw_idle()

gtk_main_called = False
class Show(ShowBase):
def mainloop(self):
if Gtk.main_level() == 0:
global gtk_main_called
gtk_main_called = True
Gtk.main()

show = Show()
Expand Down Expand Up @@ -437,7 +440,8 @@ def destroy(self, *args):

if Gcf.get_num_fig_managers()==0 and \
not matplotlib.is_interactive() and \
Gtk.main_level() >= 1:
Gtk.main_level() >= 1 and \
gtk_main_called:
Gtk.main_quit()

def show(self):
Expand Down