【发布时间】:2017-10-28 14:41:23
【问题描述】:
附加是我在 Tkinter 中使用画布构建的 GUI 的一部分,因此可以在背景中插入图像。 当我调用函数 Relay_1: 结果被发送到 Python shell 窗口。 我想要的是画布中的文本框,并在画布上而不是在外壳中显示结果(即打印结果)。 任何想法将不胜感激。
import Tkinter
#Function
def Relay_1():
arduinoData.write(b'1')
print ("This is a test\n")
class ProgramGUI:
def __init__(self):
# Creates the Main window for the program
self.main = tkinter.Tk()
# Change Default ICON
self.main.iconbitmap(self,default = 'test.ico')
# Create title, window size and make it a non re sizable window
self.main.title('Test')
self.main.resizable(False, False)
self.main.geometry('680x300')
self.canvas = tkinter.Canvas(self.main, width = 680, height = 300)
self.canvas.pack()
self.logo = tkinter.PhotoImage(file = 'test.png')
self.canvas.create_image(0,0,image = self.logo, anchor = 'nw')
# Create 3 Frame to group the widgets
self.top = tkinter.Frame(self.main)
self.middle = tkinter.Frame(self.main)
self.bottom = tkinter.Frame(self.main)
等等等等
【问题讨论】:
-
我设置了一行代码如下
标签: python-3.x tkinter