I'm making a tkinter based text widget and I'm trying to implement a new window function in it. But every time I click on the new window button I get this error in IDLE : RuntimeError: Calling Tcl from different appartment
Here's my code :
#!/usr/bin/env python
from Tkinter import *
from tkSimpleDialog import askstring
from tkFileDialog import asksaveasfilename
from tkFileDialog import askopenfilename
from tkMessageBox import askokcancel
import Tkinter as tk
import ttk
import threading
from ScrolledText import ScrolledText
Window = Tk()
Window.title("TekstEDIT")
/..CODE.../
class newWindowThread(threading.Thread):
def __init__(self, choosen=""):
threading.Thread.__init__(self)
self.choosen = choosen
def run(self):
if self.choosen == "":
root = Tk()
newEditor = SimpleEditor(root)
root.mainloop()
else:
root = Tk()
newEditor = SimpleEditor(root, self.choosen)
root.mainloop()
/...CODE.../
wFile = Menu(menubar, tearoff=0,relief="raised")
wFile.add_command(label="New", accelerator="Ctrl+N", command=self.onNew)
wFile.add_command(label="New Window", accelerator="Ctrl+Shift+N", command=self.onNewWindow)
/...CODE.../
def onNewWindow(self):
t=newWindowThread()
t.start()
What's the source of the problem? How can I solve it?
Source Code: http://ideone.com/npWuYD
Thanks.