KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm new to this place and tkinter. I am stuck at making a scrollable listbox or canvas. I have tried both widgets. Within this listbox or canvas, I have several entry and label widgets. The origin point is R0,C0. I used row/columnconfigure to stretch the listbox or canvas. In the main window, I had 4 buttons on row four to column four (0,4->4,4). I placed the scrollbar on column 5. I attempted to use the grid method. The issue I am having is making the scrollbar functional. Note: Turning the mainframe into a class is only one of the ways I have tried. Packing the scrollbar on the right has worked, with the listbox/canvas packed on the left. However, the listbox/canvas widget that the scrollbar is commanded to does not scroll the listbox/canvas. Also, adding many entry boxes does not cause the listbox/canvas to scroll. Help please. from tkinter import * from tkinter.ttk import * Style().configure("B.TFrame", relief="flat", background="blue") Style().configure("R.TFrame", relief="flat", background="red") Style().configure("R.TLabel", background="red") class Application(Frame): def __init__(self, master=None): Frame.__init__(self, master, style="B.TFrame") self.grid(sticky=N+S+E+W) self.mainframe() def mainframe(self): top=self.winfo_toplevel() self.menuBar = Menu(top) top["menu"] = self.menuBar self.subMenu = Menu(self.menuBar, tearoff=0) self.subMenu2 = Menu(self.menuBar, tearoff=0) self.menuBar.add_cascade(label="File", menu=self.subMenu) self.menuBar.add_cascade(label="About", menu=self.subMenu2) self.subMenu.add_command(label="Open") self.subMenu.add_command(label="Save") self.subMenu.add_command(label="Exit") self.subMenu2.add_command(label="About") self.subMenu2.add_command(label="Help") self.data = Listbox (self, bg='red') scrollbar = Scrollbar(self.data, orient=VERTICAL)
Tags (comma-separated)
Save Edits
Cancel