Source code for applp.modules.AutoScrollbar_LP.AutoScrollbar

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Date          : 2026-02-28
# Author        : Lancelot PINCET
# GitHub        : https://github.com/LancelotPincet
# Library       : appLP
# Module        : AutoScrollbar

"""
This class adds an automatic scrollbar when necessary.
"""



# %% Libraries
from tkinter import ttk
import tkinter as tk



# %% Class
[docs] class AutoScrollbar(ttk.Scrollbar): ''' This class adds an automatic scrollbar when necessary. '''
[docs] def set(self, lo, hi): if float(lo) <= 0.0 and float(hi) >= 1.0: self.grid_remove() else: self.grid() ttk.Scrollbar.set(self, lo, hi)
[docs] def pack(self, **kw): """ Not supported for this widget. Use ``grid()`` instead. Raises ------ tk.TclError Always raised. """ raise tk.TclError('Cannot use pack with the widget ' + self.__class__.__name__)
[docs] def place(self, **kw): """ Not supported for this widget. Use ``grid()`` instead. Raises ------ tk.TclError Always raised. """ raise tk.TclError('Cannot use place with the widget ' + self.__class__.__name__)
# %% Test function run if __name__ == "__main__": from corelp import test test(__file__)