Update tkscrolledframe.py

This commit is contained in:
B.Jothin kumar 2021-10-08 13:23:02 +05:30 committed by GitHub
parent dc3b05c546
commit 3a36996e75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,26 +3,15 @@
"""Implementation of the scrollable frame widget."""
import sys
try:
# Python 3
import tkinter as tk
except (ImportError):
# Python 2
import Tkinter as tk
try:
try:
# Python 3
import tkinter.ttk as ttk
except (ImportError):
# Python 2
import ttk
except (ImportError):
except ImportError:
# Can't provide ttk's Scrollbar
pass
__all__ = ["ScrolledFrame"]
@ -68,7 +57,7 @@ class ScrolledFrame(tk.Frame):
if not scrollbars:
scrollbars = self._DEFAULT_SCROLLBARS
elif not scrollbars in self._VALID_SCROLLBARS:
elif scrollbars not in self._VALID_SCROLLBARS:
raise ValueError("scrollbars parameter must be one of "
"'vertical', 'horizontal', 'both', or "
"'neither'")
@ -78,17 +67,17 @@ class ScrolledFrame(tk.Frame):
# Whether to use ttk widgets if available
if "use_ttk" in kw:
if ttk and kw["use_ttk"]:
Scrollbar = ttk.Scrollbar
scrollbar = ttk.Scrollbar
else:
Scrollbar = tk.Scrollbar
scrollbar = tk.Scrollbar
del kw["use_ttk"]
else:
Scrollbar = tk.Scrollbar
scrollbar = tk.Scrollbar
# Default to a 1px sunken border
if not "borderwidth" in kw:
if "borderwidth" not in kw:
kw["borderwidth"] = 1
if not "relief" in kw:
if "relief" not in kw:
kw["relief"] = "sunken"
# Set up the grid
@ -109,10 +98,10 @@ class ScrolledFrame(tk.Frame):
c.bind("<Configure>", self._resize_interior)
# Scrollbars
xs = self._x_scrollbar = Scrollbar(self,
xs = self._x_scrollbar = scrollbar(self,
orient="horizontal",
command=c.xview)
ys = self._y_scrollbar = Scrollbar(self,
ys = self._y_scrollbar = scrollbar(self,
orient="vertical",
command=c.yview)
c.configure(xscrollcommand=xs.set, yscrollcommand=ys.set)