Closed Priyansh2001here closed 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.
Sorry, I forgot to say that after doing that you need to restart Spyder.
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)
@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.
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()
Upon reviewing other codes, it appears that IPython console is somehow interfering with tkinter quit. Any luck with this issue?
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