0
我建立一个小项目,其中涉及有他们单独的功能4个Python文件。但是,有一个main.py
文件通过导入它们来使用所有其他文件。连接相同的GUI到两个或更多的Python文件
现在,我已经建立了这个项目,我是main.py
文件中建立一个GUI。我的问题是,一些其他的文件具有print
控制台,当整个项目的运作上,我要上的GUI print
这些功能,而不是功能。那么,如何打印在主文件中创建一个Text
字段从其他文件中的文本。
main.py
import second as s
from tkinter import *
def a():
field.insert(END, "Hello this is main!")
root = Tk()
field = Text(root, width=70, height=5, bd=5, relief=FLAT)
button1 = Button(root, width=20, text='Button-1', command=a)
button2 = Button(root, width=20, text='Button-2', command=s.go)
root.mainloop()
second.py
def go():
print("I want this to be printed on the GUI!")
#... and a bunch of other functions...
我只是想,当用户按下按钮-2,则函数go()
打印文本上field
哇!只是这个?非常感谢! –