Thank you for your continuous support.
Using Python 2.7's Tkinter, the GUI app scrolls
You can do it (scroll the whole thing like when you look at a browser)
I want to add a function.
I tried to refer to various sites, but I couldn't solve it.
I want to be able to scroll vertically first, but
What should I do?
I would appreciate it if you could explain without using the class.
Sorry for the inconvenience, but I appreciate your cooperation.
python python2 tkinter gui
It doesn't say what kind of Widget you want to deploy, so it's assumed, but if you want CanvasWidget to have Scroll Bar, for example,
Set Scroll Range in Canvas.config(scrollregion=())
Canvas.config (yscrollcommand=Scrollbar.set)
to notify Scrollbar of Canvas' range of motionwill work on the .
#-*-coding:utf-8-*-
import Tkinter as tk
root=tk.Tk()
root.geometry ("400x200")
# Generate and deploy Canvas Widget
canvas=tk.Canvas(root)
canvas.pack (side=tk.LEFT, fill=tk.BOTH)
# Generate and deploy Scrollbar
bar=tk.Scrollbar(root, orient=tk.VERTICAL)
bar.pack (side=tk.RIGHT, fill=tk.Y)
# Added action to notify Canvas of Scrollbar control
bar.config(command=canvas.yview)
# Set the Scroll Range for Canvas
canvas.config(scrollregion=(0,0,400,400))
# Added action to notify Screoobar of Canvas range
canvas.config (yscrollcommand=bar.set)
# write a suitable figure on Canvas
id=canvas.create_oval(10,10,370,370)
canvas.itemconfigure(id,fill='red')
root.mainloop()
Unfortunately, FrameWidget does not support Scrollbar, but I think we can do so by placing FrameWidget on CanvasWidget with Scrollbar above.
#-*-coding:utf-8-*-
import Tkinter as tk
root=tk.Tk()
root.geometry ("400x200")
# Generate Canvas Widget
canvas=tk.Canvas(root)
canvas.pack (side=tk.LEFT, fill=tk.BOTH)
# Generate and deploy Scrollbar
bar=tk.Scrollbar(root, orient=tk.VERTICAL)
bar.pack (side=tk.RIGHT, fill=tk.Y)
# Added action to notify Canvas of Scrollbar control
bar.config(command=canvas.yview)
# Set the Scroll Range for Canvas
canvas.config(scrollregion=(0,0,400,400))
# Added action to notify Screoobar of Canvas range
canvas.config (yscrollcommand=bar.set)
# Generate Frame Widget
frame = tk.Frame(canvas)
# Place Frame Widget on Canvas Widget
canvas.create_window(0,0), window=frame, anchor=tk.NW, width=canvas.cget('width')))
# Place appropriate content on Frame
tk.Label(frame, text="Hello World!!", font=(",24)) .pack()
root.mainloop()
600 GDB gets version error when attempting to debug with the Presense SDK (IDE)
890 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
568 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.