spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.33k stars 1.61k forks source link

cant quit gui window #11162

Closed Priyansh2001here closed 4 years ago

Priyansh2001here commented 4 years ago

Description

What steps will reproduce the problem?

i created a tkinter gui just to exit screen and it crashes

L = Button(window, text = "to quit", command = lambda:L.quit()) L.pack()

on other ide's its working fine

Versions

Dependencies

cloudpickle >=0.5.0          :  1.2.2 (OK)
pygments >=2.0               :  2.5.2 (OK)
qtconsole >=4.6.0            :  4.6.0 (OK)
nbconvert >=4.0              :  5.6.1 (OK)
sphinx >=0.6.6               :  2.3.0 (OK)
pylint >=0.25                :  2.4.4 (OK)
psutil >=0.3                 :  5.6.7 (OK)
qtawesome >=0.5.7            :  0.6.0 (OK)
qtpy >=1.5.0                 :  1.9.0 (OK)
pickleshare >=0.4            :  0.7.5 (OK)
zmq >=17                     :  18.1.0 (OK)
chardet >=2.0.0              :  3.0.4 (OK)
numpydoc >=0.6.0             :  0.9.1 (OK)
spyder_kernels >=1.8.1;<2.0.0:  1.8.1 (OK)
qdarkstyle >=2.7             :  2.7 (OK)
atomicwrites >=1.2.0         :  1.3.0 (OK)
diff_match_patch >=20181111  :  20181111 (OK)
intervaltree                 :  None (OK)
watchdog                     :  None (OK)
keyring                      :  None (OK)
pexpect >=4.4.0              :  4.7.0 (OK)
pympler                      :  None (OK)
sympy >=0.7.3                :  1.5 (OK)
cython >=0.21                :  0.29.14 (OK)
IPython >=4.0                :  7.10.2 (OK)
matplotlib >=2.0.0           :  3.1.1 (OK)
pandas >=0.13.1              :  0.25.3 (OK)
numpy >=1.7                  :  1.17.4 (OK)
scipy >=0.17.0               :  1.3.2 (OK)
pyls >=0.31.2;<0.32.0        :  0.31.2 (OK)
rtree >=0.8.3                :  0.8.3 (OK)
ccordoba12 commented 4 years ago

L = Button(window, text = "to quit", command = lambda:L.quit()) L.pack()

You need to change your graphics backend to Tk before doing this.

For that you need to go to the menu

Tools > Preferences > IPython console > Graphics

and select Tk in the Backend entry.

ccordoba12 commented 4 years ago

Sorry, I forgot to say that after doing that you need to restart Spyder.

sougatar commented 4 months ago

Changing the graphics backend to Tkinter does not solve the problem. With quit, the mainloop ends, but the GUI does not close. Need to close it manually. This is not the prescibed behavior. Works fine for other IDEs (such as sublime text)

ccordoba12 commented 3 months ago

@sougatar, could post a simple example that generates the problem you mentioned?

Also, don't forget to post your basic Spyder info: version, installation medium (Anaconda, Conda-forge, our installers, Python.org) and operating system.

sougatar commented 3 months ago

Here is the example. Spyder version is 5.5.1, installation medium Anaconda, OS: Windows 10.

  import tkinter as tk
  from tkinter import *
  from tkinter import font
  from tkinter.messagebox import askokcancel

  class Quitter(Frame):
      def __init__(self, parent=None):
          Frame.__init__(self, parent)
          self.pack()

          widget = Button(self, text='Quit', command=lambda: kill(self))
          def_font = font.nametofont('TkDefaultFont')
          def_font.configure(size=12)
          widget.configure(font=def_font)
          widget.pack(side=LEFT, expand=YES, fill=BOTH)

          def kill(self):
              ans = askokcancel('Verify exit', 'Really quit?')
              if ans:
                  self.quit()

  frame = Tk()
  Quitter(frame)
  frame.mainloop()
sougatar commented 3 months ago

Upon reviewing other codes, it appears that IPython console is somehow interfering with tkinter quit. Any luck with this issue?