Python Tkinter 学习笔记

//创建一个列表

 1 from Tkinter import *           # Importing the Tkinter (tool box) library 
 2 root = Tk()                     # Create a background window
 3                                 # Create a list
 4 li = 'Carl Patrick Lindsay Helmut Chris Gwen'.split()
 5 listb = Listbox(root)           # Create a listbox widget
 6 for item in li:                 # Insert each item within li into the listbox
 7     listb.insert(0,item)
 8 
 9 listb.pack()                    # Pack listbox widget
10 root.mainloop()                 # Execute the main event handler

OUTPUT:

转载于:https://www.cnblogs.com/peng-vfx/p/5034168.html

你可能感兴趣的:(python)