1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
names = ("梅长苏","誉王","飞流","夏冬","霓凰郡主","蒙挚","萧景睿","谢玉") players = ("胡歌","黄维德","吴磊","张龄心","刘涛","陈龙","程皓枫","刘奕君")
name_list = tkinter.StringVar(value=names) player_list = tkinter.StringVar(value=players)
name_listbox = tkinter.Listbox(window, height=len(names), listvariable=name_list, selectmode='browse') player_listbox = tkinter.Listbox(window, height=len(players), listvariable=player_list, selectmode='extended')
name_listbox.grid(row=1, column=1, padx=(10,5), pady=10) player_listbox.grid(row=1, column=2, padx=(5,10), pady=10)
name_listbox.select_set(0)
for i in range(len(players)): player_listbox.itemconfig(i, fg='blue') if i%2: player_listbox.itemconfig(i, bg='#f0f0ff')
def show_msg(*args): indexs = name_listbox.curselection() index = int(indexs[0]) player_listbox.see(index) player_listbox.select_set(index) name_listbox.bind("<<ListboxSelect>>", show_msg)
|