简体   繁体   English

Tkinter 不能在内部使用几何管理器网格

[英]Tkinter cannot use geometry manager grid inside

Widgets works generally when running this when code below当下面的代码运行时,小部件通常可以工作

Label(window, image=photo1, bg="black").grid(row=0, column=0, sticky=E)

Code gives me the error:代码给了我错误:

_tkinter.TclError: cannot use geometry manager grid inside . which already has slaves managed by pack

I understand that this error is about using both .pack and .grid but it works without this line, which also utilises .pack and .grid together我知道这个错误是关于同时使用 .pack 和 .grid 但它在没有这条线的情况下工作,它也同时使用 .pack 和 .grid

def widgets(self):
        self.head = Label(self.master,text=" Welcome to Luxury Cruises ", font=('freesansbold', 25),pady=40)
        self.head.pack()

        self.logf = Frame(self.master, padx=10, pady=10)
        Label(self.logf, text="Username: ", font=('freesansbold', 20), padx=5, pady=10).grid(sticky=W)
        Entry(self.logf, textvariable=self.username, bd=8, font=('calibri', 15, 'bold')).grid(row=0, column=1, sticky=E)
        Label(self.logf, text="Password: ", font=('freesansbold', 20), padx=5, pady=10).grid(row=1, column=0, sticky=W)
        Entry(self.logf, textvariable=self.password, bd=8, font=('calibri', 15, 'bold'), show="*").grid(row=1, column=1,
                                                                                               sticky=E)
        Button(self.logf, text=" Login ", bd=7, font=("monaco", 15, 'bold'), padx=5, pady=5, command=self.login).grid(
            row=2)
        Button(self.logf, text=" Make Account ", bd=7, font=("monaco", 15, 'bold'), padx=5, pady=5,
               command=self.cr).grid(row=2, column=1)
        self.logf.pack()

When you are using the .pack() function, you cannot use the .grid() function.使用.pack()函数时,不能使用.grid()函数。

check out When to use pack or grid layouts in tkinter?查看何时在 tkinter 中使用包或网格布局?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Tkinter:不能在 .!frame2 中使用几何管理器网格,它已经有由包管理的从属 - Tkinter: cannot use geometry manager grid inside .!frame2 which already has slaves managed by pack 为什么我不能使用 tkinter 几何管理器网格? - Why I cannot use tkinter geometry manager grid? 无法在错误 tkinter 中使用几何管理器包 - cannot use geometry manager pack inside error tkinter 不在课堂上的任何地方使用网格仍然会出现错误“不能在里面使用几何管理器包”。 在 tkinter 中已经有由网格管理的奴隶 - Not using grid anywhere in class still gives error 'cannot use geometry manager pack inside . which already has slaves managed by grid' in tkinter _tkinter.TclError:不能在内部使用几何图形管理器网格。 这里已经有由packenter代码管理的奴隶 - _tkinter.TclError: cannot use geometry manager grid inside . which already has slaves managed by packenter code here 不在任何地方使用网格仍然会在 tkinter 中出现错误“不能使用几何管理器包 inside.frame2 已经有网格管理的从属” - Not using grid anywhere still gives error 'cannot use geometry manager pack inside .frame2 which already has slaves managed by grid' in tkinter 无法在内部使用几何管理器包 - Cannot use geometry manager pack inside Tkinter 错误:无法在 . 已经有由包管理的奴隶 - Tkintter error: cannot use geometry manager grid inside . which already has slaves managed by pack 无法在内部使用Geometry Manager网格。 已经有奴隶由包管理 - Cannot Use Geometry Manager Grid inside . which already has slaves managed by pack 不能在里面使用几何管理器包。 尽管主窗口不同,但它已经有由网格管理的从属 - cannot use geometry manager pack inside . which already has slaves managed by grid, although master windows are different
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM