简体   繁体   English

Tkinter ~ 是否可以使用.grid() 将 Canvas 绘制到 GUI?

[英]Tkinter ~ Is Drawing a Canvas to GUI possible using .grid()?

在此处输入图像描述

Is it possible to draw lines such as the following with the Tkinter .grid() system?是否可以使用 Tkinter .grid()系统绘制如下线? Every tutorial that talks about canvas drawing uses .pack() exclusively.每个讨论canvas绘图的教程都专门使用.pack()

There are no answers for using canvas with .grid() when you search online.在线搜索时,没有使用canvas.grid()的答案。

I have tried using canvas with .grid() but my GUI got completely messed up and no lines were drawn.我曾尝试将 canvas 与.grid()一起使用,但我的 GUI 完全搞砸了,没有画线。

Is it actually possible to use canvas with .grid() ?实际上可以将 canvas 与.grid()一起使用吗?

You use neither grid nor pack for drawing items on a canvas.您既不使用grid也不使用pack在 canvas 上绘制项目。 The canvas has the following methods for drawing: canvas的绘图方法如下:

  • create_arc创建弧
  • create_bitmap创建位图
  • create_image创建图像
  • create_line创建线
  • create_oval create_oval
  • create_polygon创建多边形
  • create_rectangle创建矩形
  • create_text创建文本
  • create_window创建窗口

If you're not actually asking about drawing figures on canvas, but on adding the canvas to a window with pack or grid , you can use either.如果您实际上不是在询问在 canvas 上绘制图形,而是在将 canvas 添加到带有packgrid的 window 时,您可以使用其中任何一个。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM