Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.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_Tkinter - Fatal编程技术网

Python 在Tkinter中定位画布和按钮

Python 在Tkinter中定位画布和按钮,python,tkinter,Python,Tkinter,在Tkinter中,如何将画布打包到左上角,将按钮打包到右下角?我试过使用can.pack(side=…)和button.pack(side=…),但运气不好。我想得到这样的东西。你很接近。您需要再合并一个选项: 下面是一个简单的脚本来演示: import Tkinter as tk root = tk.Tk() canvas = tk.Canvas(bg="red", height=100, width=100) canvas.pack(anchor=tk.NW) button = tk

在Tkinter中,如何将画布打包到左上角,将按钮打包到右下角?我试过使用
can.pack(side=…)
button.pack(side=…)
,但运气不好。我想得到这样的东西。

你很接近。您需要再合并一个选项:

下面是一个简单的脚本来演示:

import Tkinter as tk

root = tk.Tk()

canvas = tk.Canvas(bg="red", height=100, width=100)
canvas.pack(anchor=tk.NW)

button = tk.Button(text="button")
button.pack(side=tk.RIGHT, anchor=tk.SE)

root.mainloop()
调整窗口大小时,请注意画布如何保持在左上角,按钮如何保持在右下角