Hello,
In the course of my script, I am trying to open a visual.Window and a Tkinter gui. This goes fine when I run my program on my PC. When I try to run it on MAC, however, I get a popup window stating that “PsychoPy2 quit unexpectedly” and a long error message (see below).
The curious thing is that the program only crashes when I BOTH import visual and run the line root = tk.Tk()
. When I comment either from psychopy import visual
(and then also the win = visual.Window(...)
, of course) or root = tk.Tk()
out, the script runs to the end just fine. There is no problem with my importing Tkinter alongside visual, only when I assign Tk() to root.
I am running PsychoPy 1.83.04 with Python 2.7.10 on a MacBook Pro OS X El Capitan, version 10.11.5. My Tcl/Tk version is 8.5.
Any ideas as to how I can make this script run/suggestions for another way around the problem (for example, is there a way to create a gui within the window)?
For reference, I’ve found “similar” issues mentioned here and here, but not an answer that works for me.
Thank you in advance for your help.
My (very simplified) code:
#!/usr/bin/python2.7.10
from __future__ import absolute_import, division
from psychopy import visual
import Tkinter as tk
import os, sys
##############################
##############################
# Setup the Window
win = visual.Window(size=[1441, 900] ,fullscr=False, allowGUI=False, color = 'black', units = 'pix', monitor='testMonitor', colorSpace='rgb', name='win')
##---------------------------------------------
# Make the GUI
class AAButtons:
def __init__(self):
print("made it up to the tk.Tk")
root = tk.Tk()
print("made it past the tk.Tk")
def mainloop(self):
root.mainloop()
##---------------------------------------------
# displaying the buttons
object0 = AAButtons().mainloop()
print("we made it!!")
The error message:
####### Running: /Volumes/NO NAME/JAM 6-15/JAM Practice 6-15/testScript ########
2018-06-20 09:35:19.779 python[8275:548017] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/dy/n1wyq9t170z_pjv8wtxnchx80000gn/T/org.psychopy.PsychoPy2.savedState
made it up to the tk.Tk
2018-06-20 09:35:20.462 python[8275:548017] -[NSApplication _setup:]: unrecognized selector sent to instance 0x1011d20e0
2018-06-20 09:35:20.463 python[8275:548017] An uncaught exception was raised
2018-06-20 09:35:20.463 python[8275:548017] -[NSApplication _setup:]: unrecognized selector sent to instance 0x1011d20e0
2018-06-20 09:35:20.463 python[8275:548017] (
0 CoreFoundation 0x00007fff8d6884f2 __exceptionPreprocess + 178
1 libobjc.A.dylib 0x00007fff981edf7e objc_exception_throw + 48
2 CoreFoundation 0x00007fff8d6f21ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00007fff8d5f8571 forwarding + 1009
4 CoreFoundation 0x00007fff8d5f80f8 _CF_forwarding_prep_0 + 120
5 Tk 0x000000010adbf948 TkpInit + 476
6 Tk 0x000000010ad3aa6e Tk_Init + 1799
7 _tkinter.so 0x000000010ac1a9fd Tcl_AppInit + 77
8 _tkinter.so 0x000000010ac181e5 init_tkinter + 2037
9 Python 0x00000001000c357d PyEval_EvalFrameEx + 24829
10 Python 0x00000001000c58e3 PyEval_EvalCodeEx + 2115
11 Python 0x000000010003e230 PyClassMethod_New + 800
12 Python 0x000000010000c612 PyObject_Call + 98
13 Python 0x000000010001ec6d PyInstance_NewRaw + 1101
14 Python 0x000000010000c612 PyObject_Call + 98
15 Python 0x00000001000bc1c7 PyEval_CallObjectWithKeywords + 87
16 Python 0x0000000100021f5e PyInstance_New + 126
17 Python 0x000000010000c612 PyObject_Call + 98
18 Python 0x00000001000bf3bc PyEval_EvalFrameEx + 7996
19 Python 0x00000001000c58e3 PyEval_EvalCodeEx + 2115
20 Python 0x000000010003e230 PyClassMethod_New + 800
21 Python 0x000000010000c612 PyObject_Call + 98
22 Python 0x000000010001ec6d PyInstance_NewRaw + 1101
23 Python 0x000000010000c612 PyObject_Call + 98
24 Python 0x00000001000bc1c7 PyEval_CallObjectWithKeywords + 87
25 Python 0x0000000100021f5e PyInstance_New + 126
26 Python 0x000000010000c612 PyObject_Call + 98
27 Python 0x00000001000bf3bc PyEval_EvalFrameEx + 7996
28 Python 0x00000001000c58e3 PyEval_EvalCodeEx + 2115
29 Python 0x00000001000c5a06 PyEval_EvalCode + 54
30 Python 0x00000001000ea41e PyRun_FileExFlags + 174
31 Python 0x00000001000ea6ba PyRun_SimpleFileExFlags + 458
32 Python 0x000000010010187d Py_Main + 3101
33 python 0x0000000100000f14 python + 3860
34 ??? 0x0000000000000003 0x0 + 3
)
2018-06-20 09:35:20.463 python[8275:548017] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[NSApplication _setup:]: unrecognized selector sent to instance 0x1011d20e0’
*** First throw call stack:
(
0 CoreFoundation 0x00007fff8d6884f2 __exceptionPreprocess + 178
1 libobjc.A.dylib 0x00007fff981edf7e objc_exception_throw + 48
2 CoreFoundation 0x00007fff8d6f21ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00007fff8d5f8571 forwarding + 1009
4 CoreFoundation 0x00007fff8d5f80f8 _CF_forwarding_prep_0 + 120
5 Tk 0x000000010adbf948 TkpInit + 476
6 Tk 0x000000010ad3aa6e Tk_Init + 1799
7 _tkinter.so 0x000000010ac1a9fd Tcl_AppInit + 77
8 _tkinter.so 0x000000010ac181e5 init_tkinter + 2037
9 Python 0x00000001000c357d PyEval_EvalFrameEx + 24829
10 Python 0x00000001000c58e3 PyEval_EvalCodeEx + 2115
11 Python 0x000000010003e230 PyClassMethod_New + 800
12 Python 0x000000010000c612 PyObject_Call + 98
13 Python 0x000000010001ec6d PyInstance_NewRaw + 1101
14 Python 0x000000010000c612 PyObject_Call + 98
15 Python 0x00000001000bc1c7 PyEval_CallObjectWithKeywords + 87
16 Python 0x0000000100021f5e PyInstance_New + 126
17 Python 0x000000010000c612 PyObject_Call + 98
18 Python 0x00000001000bf3bc PyEval_EvalFrameEx + 7996
19 Python 0x00000001000c58e3 PyEval_EvalCodeEx + 2115
20 Python 0x000000010003e230 PyClassMethod_New + 800
21 Python 0x000000010000c612 PyObject_Call + 98
22 Python 0x000000010001ec6d PyInstance_NewRaw + 1101
23 Python 0x000000010000c612 PyObject_Call + 98
24 Python 0x00000001000bc1c7 PyEval_CallObjectWithKeywords + 87
25 Python 0x0000000100021f5e PyInstance_New + 126
26 Python 0x000000010000c612 PyObject_Call + 98
27 Python 0x00000001000bf3bc PyEval_EvalFrameEx + 7996
28 Python 0x00000001000c58e3 PyEval_EvalCodeEx + 2115
29 Python 0x00000001000c5a06 PyEval_EvalCode + 54
30 Python 0x00000001000ea41e PyRun_FileExFlags + 174
31 Python 0x00000001000ea6ba PyRun_SimpleFileExFlags + 458
32 Python 0x000000010010187d Py_Main + 3101
33 python 0x0000000100000f14 python + 3860
34 ??? 0x0000000000000003 0x0 + 3
)
libc++abi.dylib: terminating with uncaught exception of type NSException