当不需要时,我需要有关自动隐藏 tkinter 滚动条的帮助。我从 effbot.org 找到了这段代码,它自动隐藏滚动条,但仅限于网格几何。在我的情况下,我没有使用网格几何。这是我的代码。
import Tkinter as tk
from Tkinter import *
import tkFont
class AutoScrollbar(Scrollbar):
# a scrollbar that hides itself if it's not needed. only
# works if you use the grid geometry manager.
def set(self, lo, hi):
if float(lo) <= 0.0 and float(hi) >= 1.0:
# grid_remove is currently missing from Tkinter!
self.tk.call("grid", "remove", self)
else:
self.grid()
Scrollbar.set(self, lo, hi)
def pack(self, **kw):
raise TclError, "cannot use pack with this widget"
def place(self, **kw):
raise TclError, …Run Code Online (Sandbox Code Playgroud)