小编jod*_*gpi的帖子

使用包几何自动隐藏 Tkinter 画布滚动条

当不需要时,我需要有关自动隐藏 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)

python user-interface tkinter scrollbar

4
推荐指数
1
解决办法
2054
查看次数

标签 统计

python ×1

scrollbar ×1

tkinter ×1

user-interface ×1