简体   繁体   English

修复我用 tkinter 制作的工具栏

[英]fixing the toolbar i made with tkinter

i created a simple program with Tkinter but i have a small problem i have a graph and i am using .grid() to place it and we bar1.get_tk_widget().grid(column=2, row=3, rowspan=20, sticky="nesw") the result is: the first result我用 Tkinter 创建了一个简单的程序,但我有一个小问题我有一个图表,我正在使用.grid()来放置它,我们bar1.get_tk_widget().grid(column=2, row=3, rowspan=20, sticky="nesw")结果是:第一个结果

but then when i am aligning it to the left with column 0 like that bar1.get_tk_widget().grid(column=0, row=3, rowspan=20, sticky="nesw") the tool bar is centered as shown in figure 2 the second result但是当我将它与第 0 列对齐时,就像bar1.get_tk_widget().grid(column=0, row=3, rowspan=20, sticky="nesw")工具栏居中,如图2第二个结果

the question is how do i can fix the toolbar?问题是如何修复工具栏?

since I don't see your the rest of ur codes, here is my assumption:因为我没有看到你的代码的 rest,所以这是我的假设:

  • if you want to stack the picture on top of each other use.pack()如果你想将图片堆叠在一起使用.pack()
  • you can use.place(x=100, y=100) to set an exact position.您可以使用 .place(x=100, y=100) 设置精确的 position。
  • if you use grid, make sure you don't left any grid empty.如果您使用网格,请确保您没有将任何网格留空。 For example: suppose that you have a grid 3x3, you need to have nine components (using columnspan or rowspan can reduce the numbers of the components).例如:假设你有一个 3x3 的网格,你需要有 9 个组件(使用 columnspan 或 rowspan 可以减少组件的数量)。 Based on your picture, you have only two images, so you have 2 choices:根据您的图片,您只有两张图片,因此您有 2 个选择:
\\ put it on top of each other
toolbar.grid(row=0, column=0) \\ should always start with 0
graph.grid(row=1, column=0) \\ it doesn't matter how big the number you set to the row, since you have only 2 two images, you can have only 2 rows

\\ put it side by side
toolbar.grid(row=0, column=0)
graph.grid(row=0, column=1)



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

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