I have written the below code for displaying some content on GUI window. Some of the code I have removed from between which was not needed here. _print(text) function is used to print the content on the gui screen. Can someone tell me how I can make this function globally accessible so that _print statements in other functions of the same class also get updated on the GUI.
I cannot move this _print function outside of GUI() function.
def GUI(): ***def _print(text): tex.insert(END, text + '\n') tex.see("end")*** window = Tk() if not window: sys.exit(-1) window.geometry("500x500") window.resizable(0,0) window.configure(bg="grey90") window.title("Reference Model") topFrame = Frame(window, width= 300,height= 100, padx=10, background='grey') topFrame1 = Frame(topFrame, width = 500, height=50, padx=10, background='grey') exit_button = Button(topFrame, text='Quit', command=window.destroy) exit_button.pack(side="right") topFrame1.pack(side=TOP,fill=X, expand=1, anchor=N) topFrame.pack(side=TOP,fill=X,expand=1,anchor=N,padx=10,pady=10) tex = Text(window,width=80, height=40, font=('arial',10,'bold'), wrap=WORD) tex.pack(side=TOP, fill=X,padx=10,pady=5) messagebox.showinfo("","Waiting") _print('xvdgfd...')
https://stackoverflow.com/questions/67238839/python-tkinter-window-display-message April 24, 2021 at 10:36AM
没有评论:
发表评论