Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tkinter mainloop() function logs me out of my mac

The below code logs me out of my Mac. Once I logged in again, the Anaconda navigator is not visible, but the process is running in the background. I have to run a 'killall python' command in terminal before starting anaconda navigator again.

I tried running in Spyder and also in the Python terminal. The same issue exists.

 from tkinter import Tk
 root = Tk()
 Title = root.title("sample")
 root.mainloop()

Not sure what I am missing here. Help me to understand this strange issue.

like image 825
Duvaragesh Avatar asked Aug 20 '19 08:08

Duvaragesh


2 Answers

Pythonw solved my issue.

We need to change the PATH_TO_INTERPRETER for the one where pythonw is in our OS. eg. In spyder, Preferences---> Python Interpreter -> Choose 'use the following Python interpreter' radio button and choose the path to pythonw

like image 54
Duvaragesh Avatar answered Oct 25 '22 07:10

Duvaragesh


Changing interpreter to pythonw solved my "running python with tkinter root.mainloop() and logging me out of macOS" problem

(10.14.6 macOS) Python 3 tkinter root.mainloop()

like image 24
Brandon Avatar answered Oct 25 '22 08:10

Brandon