0
我在寫我的第一個編程代碼。我想知道是否可以在框架內添加文本和圖像標籤。我創建了一個畫布並添加了兩個框架,然後嘗試添加圖像和文本文件(要顯示在畫布的頂部),但文字和圖片不顯示。當我運行沒有框架的程序時,它確實顯示。下面是代碼:如何在Python中使用tkinter在框架中添加文本和圖像
#from tkinter import *
from tkinter import ttk
root = Tk()
root.title ('iMedic')
canvas = Canvas(root, width = 1600, height = 800)
panewindow = ttk.Panedwindow(canvas, orient = VERTICAL)
panewindow.pack(fill = BOTH, expand = True)
paitents_frame = ttk.Frame(panewindow, width = 1600, height = 400, relief = RAISED)
prescription_frame = ttk.Frame(panewindow, width = 1600, height = 300, relief = RAISED)
panewindow.add(paitents_frame, weight = 1)
panewindow.add(prescription_frame, weight = 1)
canvas.grid(row = 0, column = 0)
photo = PhotoImage(file = './logo.gif')
canvas.create_image(55, 55, image=photo)
canvas.create_text(600, 155, text = 'Welcome', font = ('Helvetica', 72, 'bold'), justify = 'center', fill='blue')
canvas.update
root.mainloop()
#
有沒有辦法可以解決這個問題?我會假設另一種方法是將圖片和文字置於頂部,然後在其下方添加框架,但我不知道如何去做。謝謝!