Reputation: 23
i'm building a database application, currently working on the frontend interface and encountering a problem, trying to set a "scrollbar" on a 'listbox'. what do i need to do?
i use jupyter notebook and my demonstrator uses "Atom", do i need to import a certain function? i ran a previous code an "interactive converter" and it pops up its window along with this current code, so its confusing.....
from tkinter import *
# user interface
window = Tk()
list1 = Listbox(window, height=15, width=28)
list1.grid(row=3, column=0, rowspan=6, columnspan=3)
sb1 = Scrollbar(window)
sb1.grid(row=3, column=1)
list1.configure(window, yscrollcommand=sb1.set)
sb1.configure(command=list1.yview)
window.mainloop()
Error message:
TclError Traceback (most recent call last) in 48 sb1.grid(row=3,column=1) 49 ---> 50 list1.configure(platform,yscrollcommand=sb1.set) 51 sb1.configure(command=list1.yview) 52
~\Anaconda3\lib\tkinter__init__.py in configure(self, cnf, **kw)
1483 the allowed keyword arguments call the method keys.
1484 """ -> 1485 return self._configure('configure', cnf, kw) 1486 config = configure 1487 def cget(self, key):~\Anaconda3\lib\tkinter__init__.py in _configure(self, cmd, cnf, kw) 1474 if isinstance(cnf, str): 1475 return self._getconfigure1(_flatten((self._w, cmd, '-'+cnf))) -> 1476 self.tk.call(_flatten((self._w, cmd)) + self._options(cnf)) 1477 # These used to be defined in Widget: 1478 def configure(self, cnf=None, **kw):
TclError: unknown option "-class"
Upvotes: 2
Views: 5308
Reputation: 1
My code:
mybot = Tk()
mybot.geometry("300x600")
mybot.title("MyChatBot")
pic = PhotoImage(file = "bott.jpg")
img = Label(mybot, image = pic)
img.pack(pady = 10)
mybot.mainloop()
Generates this Error:
TclError: couldn't recognize data in image file "bott.jpg" my problem .couldnot solve yet.
Upvotes: 0
Reputation: 22493
You passed window
as a parameter in list1.configure
which is not required. Also you need to specify sticky
location if you use grid
on your scrollbar.
from tkinter import *
# user interface
window = Tk()
list1 = Listbox(window, height=15, width=28)
list1.grid(row=3, column=0)
for i in range(30):
list1.insert(END,i) #dummy data
sb1 = Scrollbar(window)
sb1.grid(row=3, column=1,sticky="ns")
list1.configure(yscrollcommand=sb1.set)
sb1.configure(command=list1.yview)
window.mainloop()
Upvotes: 2