1
私は再びPythonを書く上でいくつかの問題に遭遇し、私の助けを求めています。リストボックスウィジェットを構築していますが、スクロールバーを設定することはできません。私は右の位置にスクロールバーを置くことができますが、上下は動きませんし、 "Object()はパラメータを取らない"というエラーをポップアップします。誰もそれを修正する方法をアドバイスできますか?参考のために以下のコードを添付しました。tkinter.Listboxスクロールバーyview
import tkinter
from tkinter import *
def test():
root = tkinter.Tk()
lst = ['1', '2', ' 3', '4', '5', ' 6', '7', '8', ' 9', '10']
a = MovListbox(root, lst)
a.grid(row=0, column=0, columnspan=2, sticky=tkinter.N)
root.mainloop()
class MovListbox(tkinter.Listbox):
def __init__(self, master=None, inputlist=None):
super(MovListbox, self).__init__(master=master)
# Populate the news category onto the listbox
for item in inputlist:
self.insert(tkinter.END, item)
#set scrollbar
s = tkinter.Scrollbar(master, orient=VERTICAL, command=tkinter.YView)
self.configure(yscrollcommand=s.set)
s.grid(row=0, column=2, sticky=tkinter.N+tkinter.S)
if __name__ == '__main__':
test()
に基づいてコードを修正しました。 –
クイックコメントありがとうございます。私はそれを試みましたが、 "MoveListboxオブジェクトには属性YViewがありません"というエラーが表示されます –
'YView'!=' yview' ... –