为什么无法识别 columnspan? (Tiknter) 按钮大小不变

时间:2021-06-26 20:19:07

标签: python tkinter

我想知道为什么当我在 .grid() 函数中使用 columnspan 参数时,按钮不会改变大小。它不应该跨越框架内的所有列吗?下面我有我的代码和输出。谢谢大家。

# Import Modules
from tkinter import ttk
import tkinter as tk
import os


# Basic Structure
root = tk.Tk()
root.minsize(600, 700)
root.maxsize(600, 700)
root.title("Training HUB")
root.config(bg="slategray")



# Create Frames - Title, Left and Right Frames
title_frame = tk.Frame(root, width=580, height=50, bg='white', highlightbackground="black", highlightthickness=1)
title_frame.grid(row=0, columnspan=2, padx=10, pady=5)
left_frame = tk.Frame(root, width=280, height=550, bg='white', highlightbackground="black", highlightthickness=1)
left_frame.grid(row=1, column=0, padx=10, pady=5)
left_frame.grid_propagate(0)
right_frame = tk.Frame(root, width=280, height=550, bg='white', highlightbackground="black", highlightthickness=1)
right_frame.grid(row=1, column=1, padx=10, pady=5)
right_frame.grid_propagate(0)



# Buttons
button1 = ttk.Button(right_frame, text="Run Processing").grid(
    row=0, column=0, columnspan = 2, padx=5, pady=5, sticky = 'ew')



# Run Application
root.mainloop()

Tkinter 输出:

0 个答案:

没有答案
相关问题