I am trying to make a simple GUI application that uses VPython for visualization. I am successful in doing so. However, when I close the VPython window, all of my other windows (which I made using Tkinter) closes as well thereby ending the processes of the whole program. I already tried scene.exit = False but id doesn't seem to work.
Please someone help me
from Tkinter import *
import Tkinter as tk
from visual import *
import serial
root = Tk()
root.wm_title("MultiSense(Desktop Version)")
root.resizable(width=False, height=False)
root.geometry('400x500')
ser = serial.Serial('COM5', 9600)
def dist_window():
windist = tk.Toplevel(root)
windist.wm_title("Distance Sensor")
windist.resizable(width=False, height=False)
windist.geometry('100x150')
def senseDist():
scene.title = "Visualization"
scene.fullscreen = True
scene.visible = False
objDist = cylinder(display=scene, length=20, color=color.green, raduis=1, pos=(-20, 0, 0))
while (1 == 1):
rate(20)
if (ser.inWaiting() > 0):
myData = ser.readline()
distance = float(myData)
objDist.length = distance
btnStart = Button(windist, text="Calculate distance", command=senseDist)
btnStart.pack(side=LEFT, fill=X)
def doNothing():
print 'Nothing'
# ******** Main Window ********** #
menu = Menu(root)
root.config(menu=menu)
fileMenu = Menu(menu)
menu.add_cascade(label="File", menu=fileMenu)
subMenu1 = Menu(fileMenu)
subMenu1.add_command(label="Distance Sensor", command=dist_window)
fileMenu.add_cascade(label='Go to ...', menu=subMenu1, underline=0)
fileMenu.add_separator()
fileMenu.add_command(label="Exit", command=root.quit)
helpMenu = Menu(menu)
menu.add_cascade(label="Help", menu=helpMenu)
helpMenu.add_command(label="How to use MultiSense", command=doNothing)
helpMenu.add_separator()
helpMenu.add_command(label="About MultiSense", command=doNothing)
root.wm_iconbitmap('windowicon.ico')
root.mainloop()
I'm very new to python. I am using Arduino to send the serial data. There are really no errors with this code. I just want to close only the VPython window but it always end up closing the entire program.