Here is a screenshot of my window at present:
My problem is that I simply cannot get the
Since you're using place
(which I don't recommend), just do some math to calculate the position of the scrollbar.
The better choice in this specific case is to use grid
, because you clearly want things organized in rows and columns. The header is row 0, and the listbox/scrollbar combination(s) are in row 1. The first header goes in columns 0 and 1, the listbox in column 0, and the scrollbar in column 1. The second header goes in column 2, and the other listbox goes in column 3.
You attached scrollbar to window
Scrollbar(window, orient="vertical")
Try to attache to listNodes
Scrollbar(listNodes, orient="vertical")
or create Frame
with Listbox
and attache scrollbar to that frame.
EDIT: example with Frame
from Tkinter import *
window = Tk()
window.geometry("680x500")
Label(window, text="Top label").pack()
frame = Frame(window)
frame.pack()
listNodes = Listbox(frame, width=20, height=20, font=("Helvetica", 12))
listNodes.pack(side="left", fill="y")
scrollbar = Scrollbar(frame, orient="vertical")
scrollbar.config(command=listNodes.yview)
scrollbar.pack(side="right", fill="y")
listNodes.config(yscrollcommand=scrollbar.set)
for x in range(100):
listNodes.insert(END, str(x))
Label(window, text="Bottom label").pack()
window.mainloop()
EDIT: frame in your code - I use grid/pack
because I prefered it.
I add some code so now lists resize when window resizes.
from Tkinter import *
def onselect(event):
w = event.widget
index = int(w.curselection()[0])
value = w.get(index)
info = find_info(value)
listSelection.delete(0, END)
listSelection.insert(END, "Node ID: " + info[0])
listSelection.insert(END, "Owner/Description: " + info[1])
listSelection.insert(END, "Last Latitude: " + info[2])
listSelection.insert(END, "Last Longitude: " + info[3])
mapNodes = "http://ukhas.net/api/mapNodes"
nodeData = "http://ukhas.net/api/nodeData"
current_id = 0
window = Tk() # create window
window.configure(bg='lightgrey')
window.title("UKHASnet Node Manager")
window.geometry("680x400")
lbl1 = Label(window, text="Node List:", fg='black', font=("Helvetica", 16, "bold"))
lbl2 = Label(window, text="Node Information:", fg='black', font=("Helvetica", 16,"bold"))
lbl1.grid(row=0, column=0, sticky=W)
lbl2.grid(row=0, column=1, sticky=W)
frm = Frame(window)
frm.grid(row=1, column=0, sticky=N+S)
window.rowconfigure(1, weight=1)
window.columnconfigure(1, weight=1)
scrollbar = Scrollbar(frm, orient="vertical")
scrollbar.pack(side=RIGHT, fill=Y)
listNodes = Listbox(frm, width=20, yscrollcommand=scrollbar.set, font=("Helvetica", 12))
listNodes.pack(expand=True, fill=Y)
scrollbar.config(command=listNodes.yview)
listSelection = Listbox(window, height=4, font=("Helvetica", 12))
listSelection.grid(row=1, column=1, sticky=E+W+N)
for x in range(100):
listNodes.insert(END, x)
for x in "ABCD":
listSelection.insert(END, x + ": ?")