为了账号安全,请及时绑定邮箱和手机立即绑定

在图形菜单中调用函数时出现 Tkinter 错误

在图形菜单中调用函数时出现 Tkinter 错误

蝴蝶刀刀 2023-03-22 16:07:31
我有一个函数,在调用时不起作用,而同一缩进中的其他函数完美地工作这是我尝试了很多东西但它们似乎不起作用的函数import tkinter as tk from tkinter import *from tkinter import ttkfrom tkinter.ttk import Progressbarfrom tkinter import messagebox import tkinter.font as font import mysql.connector as mys import time from time import sleep def Assign():    # TE  Text Entry    # TEfn  Text Entry Flight number    # TEp Text Entry Passengers    # TEa Text Entry Airport    # TEd Text Entry Distance    def computing():        master=Tk()        master.title('AMAS')        photo=PhotoImage(file='AMAS.gif') #Image must be GIF        Label(image=photo) # Line required to prevent python's garbage dump function         Label(master,image=photo,fg='black',bg='black').grid(row=0,column=0,sticky=E)        master.resizable(0,0) # Optional line to prevent the user from resizing the window        master.mainloop()            def dwindow():        print('dwindow called')#TEMP        def saveTEd():            global Ed            Ed=TEd.get()            print(Ed)            window.destroy()    # Window Number 5 Called Below            computing()        window=Tk()        window.title("Distance")        window.configure(background='white')        photo1=PhotoImage(file='Distance.gif')        Label(image=photo1)        Label(window,image=photo1,bg='white').grid(row=0,column=0,sticky=W)        Label(window,text='Enter The Distance Travelled',bg='white',fg='black',font='none 12 bold').grid(row=1,column=0,sticky=W)        TEd=Entry(window,width=20,bg='white')        TEd.grid(row=2,column=0,sticky=W)        Button(window,text='Enter',width=6,command=saveTEd).grid(row=3,column=0,sticky=W)        mainloop()    def awindow():        print('awindow called')#TEMP        def saveDDMo(value):            global DDMo            DDMo=aoption.get()            print(DDMo)            window.destroy()我认为这可能是因为我正在导入或垃圾转储,但我似乎无法解决问题。我认为这可能是因为我正在导入或垃圾转储,但我似乎无法解决问题。我认为这可能是因为我正在导入或垃圾转储,但我似乎无法解决问题。
查看完整描述

1 回答

?
眼眸繁星

TA贡献1873条经验 获得超9个赞

这里的错误是image "pyimage2" doesn't exist

简而言之,您不能同时运行两个 Tk() 实例,您必须改用 Toplevel()。


查看完整回答
反对 回复 2023-03-22
  • 1 回答
  • 0 关注
  • 140 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号