首页 > 解决方案 > tkinter rowspan 没有效果

问题描述

我有以下代码:

import Tkinter as tk
import os
from PIL import Image, ImageTk
import Tkinter, Tkconstants, tkFileDialog

    class Home(tk.Tk):
        def __init__(self, *args,**kwargs):
            tk.Tk.__init__(self, *args, **kwargs)
            self.geometry('1200x800')
            self.txt = tk.StringVar()
            self.rowconfigure(0, weight=1)
            self.columnconfigure(0, weight=1)
            self.home_frame = tk.Frame(self)
            self.home_frame.grid(row=0, column=0)
            self.home_frame.rowconfigure(0, weight=1)
            self.home_frame.columnconfigure(0, weight=1)
            self.fileEntry = tk.Entry(self.home_frame, width=100, textvariable=self.txt).grid(row=0, column=0,  sticky='sn')
            self.btn = tk.Button(self.home_frame, text='choose directory', height=1, command=self.DirDialog).grid(row=0, column=1)

现在对于 fileEntry 添加 rowspan=2 完全没有效果有什么问题?

标签: pythonpython-2.7tkinter

解决方案


您的小部件只有一行,因此跨越两行看起来就像跨越单行一样。空行的高度为零。


推荐阅读