【发布时间】:2017-11-12 13:08:19
【问题描述】:
我的目标是创建一个具有可以被其他窗口继承的窗口属性的默认类。
from tkinter import *
class window():
def __init__(self, Width, Height, Bg):
self.Width = Width
self.Height = Height
self.Bg = Bg
object = Tk()
frame = Frame(width=Width, height=Height, bg=Bg)
frame.pack()
class child_login(window(768, 576, "ORANGE")):
def __init__():
Label(frame, text = "Username").grid(row=0)
Label(frame, text = "Password").grid(row=1)
e1=Entry(frame)
e1.insert(10, "name")
e1.grid(row=0, column=1)
e2=Entry(frame, show = "*")
e2.grid(row=1, column=1)
Button(frame, text = "Quit", command = master.quit).grid(row=3, column=0)
Button(frame, text = "print", command = display_entry).grid(row=3, column=1)
mainloop()
child_login()
对于 child_login 类,我想要一个框架,它继承了 window() 属性,但在下面定义了标签和按钮。不幸的是,我创建了两个窗口并出现错误
tkinter.TclError: 屏幕距离错误“child_login”
【问题讨论】:
标签: python-3.x class tkinter parameters