程序运行正常(但在执行过程中没有更新)。在这种情况下,当模拟运行时,窗口显示没有响应,并且无法更新直到整个程序结束。直到我添加这些行正常工作。 任何线索?接下来是即使它们被执行的功能也不会反映在父窗口中。 非常感谢您提前
from Tkinter import *
from tkMessageBox import *
from PIL import ImageTk, Image
import tkFont
import math
import time
#Global variables
global W1, W2, xf, dim, xc_target, N_iteration, error, sub, Wmax
global path_sol_mag, img_sol_mag, imagen_mag, path_sol_pha, imagen_pha, img_sol_pha, path_sol_legend, imagen_legend, img_sol_legend
def Update_solution_window(fin):
var_iterations.set(N_iteration)
var_error.set(error)
print xf[0]
print xf[1]
var_l1_final.set(xf[0])
var_l2_final.set(xf[1])
if (fin==1):
s3=Label(root, text='Final Layout (solution)',fg="red", font=helv14, width=15).grid(row=10, column=9, columnspan=4, sticky=W+E+N+S)
Grafica()
#-------------------------------------------------------------------------------
def refresh_window():
print "Refresco"
boton_default.grid_forget()
boton_new.grid_forget()
## Refreshing vector
dim[2]=W1
dim[3]=W2
#Resize parent window
root.geometry("1280x410+50+50")
## Refreshing root
var_W1_in.set(W1)
var_W2_in.set(W2)
fi_l1=Label(root, text='l1[mm]', font=helv12, width=6).grid(row=8, column=9, sticky=E)
fi_l2=Label(root, text='l2[mm]', font=helv12, width=6).grid(row=8, column=11, sticky=E)
var_l1_in.set(xf[0])
var_l2_in.set(xf[1])
en_l1_in=Entry(root, textvariable=var_l1_in).grid(row=8, column=10, sticky=E)
en_l2_in=Entry(root, textvariable=var_l2_in).grid(row=8, column=12, sticky=E)
#--------------------------------------------------------------------------------
s3=Label(root, text='Current Layout (solution)',fg="red", font=helv14, width=15).grid(row=10, column=9, columnspan=4, sticky=W+E+N+S)
s4=Label(root, text='Iter. No.', font=helv12, width=7).grid(row=11, column=11, sticky=E)
var_iterations.set(" ")
s5=Label(root, text='Error[%]', font=helv12, width=7).grid(row=12, column=11, sticky=E)
var_error.set(" ")
en_iter=Entry(root, textvariable=var_iterations).grid(row=11, column=12, sticky=E)
en_error=Entry(root, textvariable=var_error).grid(row=12, column=12, sticky=E)
fo_w1=Label(root, text='W1[mm]', font=helv12, width=7).grid(row=13, column=9, sticky=E)
var_W1_final.set(W1)
en_W1_final=Entry(root, textvariable=var_W1_final).grid(row=13, column=10, sticky=W)
fo_l2=Label(root, text='W2[mm]', font=helv12, width=7).grid(row=13, column=11, sticky=E)
var_W2_final.set(W2)
en_W2_final=Entry(root, textvariable=var_W2_final).grid(row=13, column=12, sticky=E)
fo_l1=Label(root, text='l1[mm]', font=helv12, width=6).grid(row=14, column=9, sticky=E)
var_l1_final.set(" ")
en_l1_final=Entry(root, textvariable=var_l1_final).grid(row=14, column=10, sticky=W)
fo_l2=Label(root, text='l2[mm]', font=helv12, width=6).grid(row=14, column=11, sticky=E)
var_l2_final.set(" ")
en_l2_final=Entry(root, textvariable=var_l2_final).grid(row=14, column=12, sticky=E)
salir.grid_forget()
salir.grid(row=15, rowspan=2, column=9, columnspan=4, sticky=W+E+N+S)
答案 0 :(得分:0)
我会想象你在运行模拟时打断了主循环。如果你想同时做两件事,你可能需要考虑让你的程序多线程化,以便mainloop和你的模拟可以同时运行。