Python Forum
What units does the width parameter of a tkinter Listbox use?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What units does the width parameter of a tkinter Listbox use?
#1
I am tinkering with tkinter, trying to get the feel of it.

I make a nice window:

def myApp():
    root = Tk()
    root.title("Scrollbar Test")
    root.config(bg='light blue')
    root.geometry("640x480")
    xscrollbar = Scrollbar(root, orient=HORIZONTAL, width=20, activebackground='red', )
    yscrollbar = Scrollbar(root, orient=VERTICAL, width=20, activebackground='green', )
    xscrollbar.pack( side = BOTTOM, fill = X )
    yscrollbar.pack( side = RIGHT, fill = Y )

    # setting Listbox width = 75 makes it almost equal to the root window width of 640

    mylist = Listbox(root, xscrollcommand = xscrollbar.set, yscrollcommand = yscrollbar.set, width = 75)
    #mylist = Listbox(root, yscrollcommand = yscrollbar.set )
    for line in range(100):
       mylist.insert(END, "This is a very very long line with a line number added line number " + str(line))

    mylist.pack( side = LEFT, fill = BOTH )
    xscrollbar.config( command = mylist.xview )
    yscrollbar.config( command = mylist.yview )

    mainloop()
root.geometry is set to ("640x480")

then I set width = 75 for my Listbox.

But width = 75 is almost equal to 640 pixels!

What units does tkinter use for width parameters??
Reply
#2
It is pixels.
See page 52 of Shipman Tkinter Referemce Manual (you can get a copy here: https://users.tricity.wsu.edu/~bobl/cpts...er_nmt.pdf )
Reply
#3
Listbox width is in characters, just like Entry and other controls that are used to display or enter text.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  tkinter| listbox.insert problem Maryan 3 448 Sep-29-2020, 05:34 PM
Last Post: Yoriz
  [Tkinter] Align the width of the entrys with the column captions Particledust 0 395 Apr-23-2020, 08:32 AM
Last Post: Particledust
  Tkinter parameter question DPaul 2 550 Mar-14-2020, 09:35 AM
Last Post: DPaul
  sQlite3 output to tkinter treeview - how do I set / increase width of the output? dewijones67 5 3,191 Jan-23-2019, 08:45 AM
Last Post: Larz60+
  [Tkinter] tkinter listbox problem edoardo5782 5 3,816 Sep-10-2018, 07:10 PM
Last Post: edoardo5782
  Canvas Text Width/Height Anysja 0 2,189 Aug-20-2018, 11:11 PM
Last Post: Anysja
  How to format a list when displaying in a tkinter Listbox nortski 3 5,958 Apr-03-2018, 02:31 AM
Last Post: Larz60+
  Tkinter Listbox tab char issues ashtona 4 2,419 Mar-27-2018, 12:28 PM
Last Post: ashtona
  [Tkinter] THow to search a string in a file and display it in listbox by Tkinter mosavit 2 3,484 Jun-21-2017, 08:02 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020