0
私はpythonとtkinterを初めて使いました。 このコードでは、それぞれ異なるフォントで1つ以上のラベルを配置する必要があります。 コードは私のMACで実行されています。 ラベルをさらに挿入しようとしましたが、結果が画面に表示されず、最初のラベルの1つだけが表示されます。 ご協力いただければ幸いです。ありがとう。Tkinter:1つ以上のラベルをそれぞれ異なるフォントで置きます
from Tkinter import *
import ttk
from PIL import Image, ImageTk
root = Tk()
root.title("Title")
root.geometry('800x600')
MyText="""Line 1
Line 2"""
def resize_image(event):
new_width = event.width
new_height = event.height
image = copy_of_image.resize((new_width, new_height))
photo = ImageTk.PhotoImage(image)
label.config(image = photo)
label.image = photo #avoid garbage collection
image = Image.open('pptfileteado.gif')
copy_of_image = image.copy()
photo = ImageTk.PhotoImage(image)
#label = ttk.Label(root, image = photo)
label = ttk.Label(root,
compound=CENTER,
text=MyText,
foreground='white',
justify='center',
font = "Ayres 70",
image = photo)
label.bind('<Configure>', resize_image)
label.pack(fill=BOTH, expand = YES, side="right")
root.mainloop()
あなたは1つのラベルを作成しました。あなたは何を期待しましたか? – nbro
「私のMACで」とは何を意味していますか?それはMacintosh上で動作しているのですか?もしそうなら、それは "MAC"ではなく "MAC"です。 –
あなたは正しいです。それはMac、Macintoshです。 – Manuel