Hallo,
Ich möchte eine Scrollbar einrichten die für das ganze Fenster gilt. Also, dass wenn im Fenster Buttons und Labels sind, die dann auch von der Scollbar "erfasst" werden. Weiß da jemand weiter Schonmal danke im voraus.
Scrollbar auf ganzem Fenster für jedes Widget beziehen
@Duardo: Man kann Scrollbars für das `Canvas`-Widget setzen und man kann beliebige Widgets auf einem Canvas darstellen. Also zum Beispiel einen `Frame` mit dem Fensterinhalt.
Ein anderes Beispiel ...
Code: Alles auswählen
''' tix_ScrolledWindow102.py
explore the tix.ScrolledWindow
(vertical and horizontal scroll bars appear as needed)
Tkinter extension module tix comes with Python27 and Python31+
Tix imports Tkinter so you only need to import tix
'''
from functools import partial
try:
# Python27
import Tix as tix
except ImportError:
# Python31 and higher
import tkinter.tix as tix
def do_command(k):
app.title("Button {} clicked".format(k))
app = tix.Tk()
app.title('tix.ScrolledWindow')
scr_win = tix.ScrolledWindow(app, width=280, height=100)
scr_win.pack()
# needs frame to behave properly
sframe = scr_win.window
# create button 0 to 18 using a list comprehension
button_list = [tix.Button(sframe, width=20,
text='button {0}'.format(k),
command=partial(do_command, k)) \
for k in range(19)]
# lay out the buttons
for but in button_list:
#print(but) # test
but.pack(pady=3)
app.mainloop()
Atomkraftwerkaktienbesitzer