Python Devlopment






Listbox



It offers a list to the user from which the user can accept any number of options.
The general syntax is:

lb = Listbox(win, option=value)
win is the parameter used to represent the parent window.

There are number of options which are used to change the format of the widget. Number of options can be passed as parameters separated by commas. Some of them are listed below.

  • highlightcolor: To set the color of the focus highlight when widget has to be focused.
  • bg: to set he normal background color.
  • bd: to set the border width in pixels.
  • font: to set the font on the button label.
  • image: to set the image on the widget.
  • width: to set the width of the widget.
  • height: to set the height of the widget.
Example:
from Tkinter import *
win=Tk()
win.title('My List Box')
win.geometry(350x252')
lb=Listbox(win)
lb,insert(1,'Python')
lb,insert(2,'Ruby')
lb,insert(3,'Java')
lb,insert(4,'C++')
lb,insert(4,'Any Other')
lb.pack()
win.mainloop()