Home > Back-end >  tkinter, python: Button not showing up after Listbox, and Listbox not responding at all
tkinter, python: Button not showing up after Listbox, and Listbox not responding at all

Time:10-02

I'm a tkinter newb, making slow progress. This question is about my parse_html func but I included relevant main code too. I can't figure out why the OK button isn't even showing up after the Listbox. While I do have a correct list of options showing up in my Listbox, and retval prints out the correct value, I'm stuck at this point because nothing is happening in the lbox section, and the ok_btn button is missing. I'm not even sure if one is causing the other.
Any help would truly be appreciated. Thank you!

Updates: Noticed the banner Label also disappears when the Listbox is put in. Added function get_html_source_dirs to code below, just in case it's part of the problem.

Resolved: Added a max_len of choices to use as width of Listbox per Answer below. My problem was a symptom of enter image description here

CodePudding user response:

The problem is that you're setting the listbox width to 400. That's 400 characters, not pixels. On my machine that makes it about 3600 pixels wide. Since you don't use any other options when calling grid, the label and button will be centered, meaning they will be roughly at pixel position 1800.

Change the width to something more sane and the label and button should appear.

lbox = Listbox(master=new, listvariable=choices, width=40, selectmode=SINGLE)
#                                                      ^^
  • Related