Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 用Tkinter将两个按钮相邻放置_Python_User Interface_Tkinter - Fatal编程技术网

Python 用Tkinter将两个按钮相邻放置

Python 用Tkinter将两个按钮相邻放置,python,user-interface,tkinter,Python,User Interface,Tkinter,我在用Python编写带有Tkinter库的GUI时遇到了以下问题: # DECLARATIONS labelPresentation = Label(window, text="Insert here") name = StringVar() nameEntered = Entry(window, width=25, textvariable=name) labelPresent = Label(window) research = ttk.Button(window, text="Searc

我在用Python编写带有Tkinter库的GUI时遇到了以下问题:

# DECLARATIONS
labelPresentation = Label(window, text="Insert here")
name = StringVar()
nameEntered = Entry(window, width=25, textvariable=name)
labelPresent = Label(window)
research = ttk.Button(window, text="Search", command=searchToPut)

elimination = ttk.Button(window, text="Delete", command=searchToDelete)

# POSITIONS
labelPresentation.grid(column=0, row=0)
nameEntered.grid(column=0, row=1)
labelPresent.grid(column=0, row=3)
research.grid(column=0, row=2)

elimination.grid(column=0, row=2)
我需要将“消除”和“研究”按钮放在一起,但是网格函数给我带来了问题,因为这段代码将它们一个放在另一个上面。我搜索了同样的问题,他们建议使用pack()函数,但当我尝试时,它说我不能同时使用grid和pack函数来放置按钮和标签。 提前感谢您的帮助

试试这个:

# DECLARATIONS
labelPresentation = Label(window, text="Insert here")
name = StringVar()
nameEntered = Entry(window, width=25, textvariable=name)
labelPresent = Label(window)
research = ttk.Button(window, text="Search", command = searchToPut)

elimination = ttk.Button(window, text="Delete", command =searchToDelete )

# POSITIONS
#labelPresentation.grid( row=0)
labelPresentation.place(x=50)
nameEntered.place(x=0,y=20)
labelPresent.grid( row=0)
research.grid(row=2,column=0)

elimination.grid(row=2, column = 1 , padx=0,pady = 25)
输出:


将这两个按钮放在一个框架中。@pen00能否请您共享更多的代码,以便我们可以运行和测试它?这给我带来了问题,因为此代码将它们一个放在另一个的顶部。:这是因为您使用相同的网格坐标,
Grid(column=0,row=2)