【发布时间】:2025-12-17 21:45:02
【问题描述】:
所以,我正在学习类和方法,并试图通过在类中使用 init 方法来制作多个框架。以下是我所做的:
from tkinter import *
import random
from PIL import ImageTk, Image
win = Tk()
win.attributes('-fullscreen', True)
# Define Frame Class
class MyFrame:
def __init__(self, master):
frame = Frame(master, width = win.winfo_screenwidth(),
height = win.winfo_screenheight(),
bg='black')
frame.pack()
def FrameOne():
frameone = MyFrame(win)
def FrameTwo():
frametwo = MyFrame(win)
#Call Frame (This is where I want the following frames to have different unique attributes)
FrameOne()
FrameTwo()
win.mainloop()
我的问题是如何设置不同的Frame背景、边框和其他Frame属性,让每个Frame都有独特的属性。
【问题讨论】: