Replace g.mainloop() and g.mainquit() with g.main() and g.main_quit() as