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 webar1.get_tk_widget().grid(column=2, row=3, rowspan=20, sticky="nesw")
the result is:
the first result
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
the question is how do i can fix the toolbar?
this is the full code link: my full code
Advertisement
Answer
since I don’t see your the rest of ur codes, here is my assumption:
- if you want to stack the picture on top of each other use .pack()
- you can use .place(x=100, y=100) to set an exact position.
- if you use grid, make sure you don’t left any grid empty. For example: suppose that you have a grid 3×3, you need to have nine components (using columnspan or rowspan can reduce the numbers of the components). Based on your picture, you have only two images, so you have 2 choices:
# 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)