-
Notifications
You must be signed in to change notification settings - Fork 763
Description
Environment
- Pythonnet version: Python 3.0.3
- Python version: Python 3.8
- Operating System: Window 11 (64-bit)
- .NET Runtime: 4.8
Details
I am getting the following message when trying to run a Python script invoking tkinter using the Exec method on PyScope object:
Traceback (most recent call last):
File "C:\Program Files\Python38\Lib\tkinter_init_.py", line 351, in del
if self._tk.getboolean(self._tk.call("info", "exists", self._name)):
RuntimeError
:
main thread is not in main loop
I am not spawning any threads in my script invoking tkinter. I get the crash if I click the Quit button or close the tkinter window with the 'X' in the top-right hand corner. The crash only happens after running the script and closing the window at least 7 or 8 times. I do not have to click the "Make Features" button to make the crash happen.
Here is the script text:
import tkinter as tk
from tkinter import ttk
allfeatures = ["Point","Line","Plane","Circle","Ellipse","Slot","Cylinder","Sphere","Cone","Torus","Paraboloid"]
#create window
window = tk.Tk()
global netfeaturetype
global numberval
def featurepress():
global netfeaturetype
global netnumberval
global netdoubleval
netfeaturetype = str(combo_feature_entry.get())
print("Want to create a " + netfeaturetype + " feature")
netnumberval = int(numberval.get())
print("Number entered: " + str(netnumberval))
netdoubleval = float(doubleval.get())
print("Double used: " + str(netdoubleval))
#set background color of window
window.configure(background="wheat1")
#set the title of window
window.title("Make Features")
#set window size
window.geometry("350x90")
featuretype = tk.StringVar()
numberval = tk.IntVar()
doubleval = tk.DoubleVar()
netfeaturetype = ""
netnumberval = 99
netdoubleval = 10.5
feature_label = tk.Label(window, text='Feature Type', background="wheat1").place(x=120, y=5)
combo_feature_entry = ttk.Combobox(window)
combo_feature_entry['values'] = allfeatures
combo_feature_entry.place(x=200, y=5)
combo_feature_entry.current(3)
number_label = tk.Label(window, text='Number', background="wheat1").place(x=120, y=40)
number_entry = tk.Entry(window, width=7, textvariable=numberval).place(x=200, y=40)
create_button = tk.Button(window, text='Create Feature', command= lambda: featurepress(),
height=2, width=11).place(x=5, y=5)
create_button = tk.Button(window, text='Quit', command=window.destroy,
height=1, width=9).place(x=5, y=50)
#start the GUI
window.mainloop()
Traceback (most recent call last):
File "C:\Program Files\Python38\Lib\tkinter_init_.py", line 351, in del
if self._tk.getboolean(self._tk.call("info", "exists", self._name)):
RuntimeError
:
main thread is not in main loop