habe ein Problem mit der Scrollbar, dazu poste ich Euch ein Beispiel zum Testen und zur Fehlerfindung.
Das Fenster vertikal, ist größer als die Bildschirmhöhe und die vertikale Scrollbar lässt sich nicht scrollen.
Code: Alles auswählen
#!/usr/bin/env python
# _*_ coding: utf_8 _*_
# For Python3.x
import tkinter as tk
from tkinter import ttk
RANGE = 45
def scroll_test():
root = tk.Tk()
# Create y- and x-scrollbar.
yscrollbar = tk.Scrollbar(root, orient=tk.VERTICAL,
bg='lightgrey', activebackground='lightsteelblue',
troughcolor='red')
yscrollbar.grid(row=0, column=1, sticky=tk.NS)
xscrollbar = tk.Scrollbar(root, orient=tk.HORIZONTAL,
bg='lightgrey', activebackground='lightsteelblue',
troughcolor='red')
xscrollbar.grid(row=1, column=0, sticky=tk.EW)
# Create y- and canvas for table or dataset.
canvas = tk.Canvas(root, bd=0, scrollregion=(0, 0, 0, 0),
xscrollcommand=xscrollbar.set, yscrollcommand=yscrollbar.set)
canvas.grid(row=0, column=0, sticky=tk.NSEW)
# Integrate scrollbar in canvas.
yscrollbar.config(command=canvas.yview)
xscrollbar.config(command=canvas.xview)
canvas.xview_moveto(0)
canvas.yview_moveto(0)
# Create widgets
frame = tk.Canvas(None, bg='yellow')
frame.grid(row=0, column=0, sticky=tk.W)
width = 40
ypos = 0
for i in range(RANGE):
value = 'Das ist Labelnummer: {}'.format(i)
var = tk.StringVar(value = value)
widget = tk.Label(canvas, width = width, textvariable = var)
widget.grid(row=i, column=0)
ypos += widget.winfo_reqheight()
xpos = widget.winfo_reqwidth()
canvas.create_window(xpos, ypos, anchor='nw', window=frame)
canvas.update_idletasks()
x, y, w, h = canvas.bbox(tk.ALL)
print(x, y, w, h)
if h > 800:
h = 800
root.geometry('{}x{}+{}+{}'.format(x, y, w, h))
root.mainloop()
scroll_test()
Grüße Nobuddy