I've just installed Anaconda and tries to run a script that worked fine before when just using Python 2.7. Now, I cannot initialize a root widget in tkinter. I've tried several expressions but none work so far. For example:
1.
import tkinter as tk
root = tk.Tk()
2.
from tkinter import *
root = Tk()
which I guess should work according to the answer in: Tkinter doesn't work with Python 3.5 which says that I don't need to call the module (tkinter) when importing everything from it.
Anyway, what I get is the following message:
2016-04-28 17:58:16.168 python[1808:507] -[NSApplication _setup:]: unrecognized selector sent to instance 0x10a5270d0
2016-04-28 17:58:16.172 python[1808:507] An uncaught exception was raised
2016-04-28 17:58:16.172 python[1808:507] -[NSApplication _setup:]: unrecognized selector sent to instance 0x10a5270d0
2016-04-28 17:58:16.172 python[1808:507] (
0 CoreFoundation 0x00007fff8f5d925c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8ef5ee75
.
.
.
27 python 0x0000000100000cc4 start + 52
28 ??? 0x0000000000000002 0x0 + 2
According to this question module 'tkinter' has no attribute 'Tk' with python 3.5 it seems like there is a file somewhere that I'm supposed to delete.
I should also tell that I can still create use tk.Tk() directly in Terminal but when I run it in the script it won't work.
import tkinter as tkwithprint(tk.__file__). On Windows, you should see something like.../python35/Lib/tkinter/__main__.py. - Terry Jan Reedyprint(dir(tk), len(dir(tk))). Does it containTkand other widget classes? I get 165 for the len (200 with 2.7) and believe it should be the same for you. The result should be subset of names in the 2.7 list. - Terry Jan Reedy-[NSApplication _setup:]: unrecognized selector sent to instanceis Mac-specific but generic within Macs. You might try searching for an explanation. - Terry Jan Reedy