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
哇!只是這個?非常感謝! –