-2

Can someone show me how I can add a listbox to panedWindow?

Take this code for example: can the left-hand window be made into a listbox?

from tkinter import *

m1 = PanedWindow()
m1.pack(fill=BOTH, expand=1)

left = Entry(m1, bd=5)
m1.add(left)

m2 = PanedWindow(m1, orient=VERTICAL)
m1.add(m2)

top = Scale( m2, orient=HORIZONTAL)
m2.add(top)

bottom = Button(m2, text="OK")
m2.add(bottom)

mainloop()
10
  • Did you try just changing Entry to Listbox?
    – acw1668
    Commented May 27 at 15:37
  • Did you try just changing Entry to Listbox? – acw1668 23 mins ago, #~~~~~~~~~~~~~~yes i tried that
    – NMW81
    Commented May 27 at 16:02
  • Then what is the problem actually?
    – acw1668
    Commented May 27 at 16:10
  • ill try to get the actual code up
    – NMW81
    Commented May 27 at 16:21
  • trying to put code up but getting#~~~~~~~~~~~ Your post appears to contain code that is not properly formatted as code. Please indent all code by 4 spaces using the code toolbar button or the CTRL+K keyboard shortcut. For more editing help, click the [?] toolbar icon.
    – NMW81
    Commented May 27 at 16:25

1 Answer 1

0

Can someone show me how I can add a listbox to "paneWindow"?

Take this code as an example: can the left-hand window be made into a listbox?

The problem can be fixed.

Don't use a wildcard. Use this import tkinter as tk. Then use tk. prefix.

I added some colors. So you can see panedWindow adjustment.

  • Add StringVar()
  • Add Listbox widget.

The red color is the Entry widget

The green color is the Listbox.

The aqua color is the Scale widget.

The orange color is the Button widget

You're ready to go.

Snippet re-modified.

import tkinter as tk

mainWindow = tk.Tk()

mainWindow.title("PanedWindow Example")
mainWindow.geometry('350x200')

variable_string = tk.StringVar()
variable_string.set('This is left Entry')

m1 = tk.PanedWindow(mainWindow, orient=tk.HORIZONTAL)
m1.pack(fill=tk.BOTH, expand=1)

label = tk.Entry(m1, textvariable=variable_string, bg="red", bd=5)
m1.add(label, stretch="always")

lstbox = tk.Listbox(m1,  bg="green")
m1.add(lstbox, stretch="always")

m2 = tk.PanedWindow(m1, orient=tk.VERTICAL)
m1.add(m2, stretch="never")

topScale = tk.Scale(m2, orient=tk.HORIZONTAL, bg='aqua')
m2.add(topScale)

bottom =  tk.Button(m2, text="OK", bg='orange')
m2.add(bottom)

mainWindow.mainloop()

Screenshot:

enter image description here

1
  • Thanks for the help toyata supra, seems as though i have to learn stack overflow before i can post any meaningful reply!
    – NMW81
    Commented May 28 at 17:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.