我正在嘗試像這樣在框架內包裝框架:

但是我的代碼給了我這個結果:

我該如何解決這個問題?這是代碼:
import tkinter as tk
import pandas as pd
if __name__ == '__main__':
top = tk.Tk()
top.configure(bg='gray')
top.geometry("700x350")
table = tk.Frame(top, bg = "black")
column1 = tk.Frame(table, height = 400, width = 100, bg = "pink", borderwidth=2)
column2 = tk.Frame(table, height = 400, width = 100, bg = "yellow", borderwidth=2)
col_1_row_1 = tk.Frame(column1, height = 100, width = 100, bg = "blue", borderwidth=2)
col_1_row_2 = tk.Frame(column1, height = 100, width = 100, bg = "blue", borderwidth=2)
col_1_row_3 = tk.Frame(column1, height = 100, width = 100, bg = "blue", borderwidth=2)
col_1_row_4 = tk.Frame(column1, height = 100, width = 100, bg = "blue", borderwidth=2)
table.pack(side=tk.TOP)
column1.pack(side=tk.LEFT)
column2.pack(side=tk.LEFT)
col_1_row_1.pack(side=tk.TOP)
top.mainloop()
uj5u.com熱心網友回復:
column1 小部件的垂直位置未在代碼中的任何位置指定。只需將行替換column1.pack(side=tk.LEFT)為column1.pack(side=tk.LEFT,anchor='nw')
告訴布局管理器將此小部件放置在anchor='nw'其父框架的西北(即左上角)角。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/492007.html
上一篇:如何洗掉tkinter單選按鈕?
