python - Visually attach Scrollbar to Listbox: TkInter -


i having issue tkinter interface whereby cannot scrollbar visually attach listbox element - see image: problem interface

here code creates , positions listbox & scrollbar:

        lblpd3 = ttk.label(mainframe,text='',font=("helvetica", 5))         lblpd3.grid(column=0, row=12, sticky=nw)         scltrn = scrollbar(mainframe, orient=vertical)         lbltrn = ttk.label(mainframe,text='select transformation',font=("helvetica", 11, "bold"))         lbltrn.grid(column=0, row=13, sticky=nw)              self.lsttrn = listbox(mainframe,selectmode=single,exportselection=0,width=62,height=4,yscrollcommand=scltrn.set,activestyle='none',selectbackground='#4a6984',selectborderwidth=3,highlightcolor='#4a6984',highlightthickness=1)         scltrn.config(command=self.lsttrn.yview)         scltrn.grid(column=0, row=14, sticky=(n,s,e))          item in self.coord:             self.lsttrn.insert(end, item)         self.lsttrn.grid(column=0, row=14, padx=0, sticky=nw)         self.lsttrn.select_set(0) 

is there simple hack use push scrollbar few pixels left - documentation seems suggest there's no padding element?

you add scrollbar widget , listbox widget own seperate frame.

then add in single 'unit'.

while dont know whole program, here's logic behind fix should like:

# declare new frame hold listbox , scroll wheel     myframe = frame.__init__(self, parent)   # make sure scrollbar part of our newly created frame "myframe" scltrn = scrollbar(myframe, orient=vertical)  # make sure listbox part of our newly created frame "myframe" self.lsttrn = listbox(myframe,selectmode=single,exportselection=0,width=62,height=4,yscrollcommand=scltrn.set,activestyle='none',selectbackground='#4a6984',selectborderwidth=3,highlightcolor='#4a6984',highlightthickness=1)  ...  #pack scrollbar , listbox in our frame in order self.lsttrn.pack() scltrn.pack()  .... # grid our frame containing both scrollwheel , listbox gui myframe.grid(column=xxx,row=xxx,padx=xxx,sticky=xxx) 

this shouldnt copy+paste fix, understand logic behind creating frame hold scrollbar , listbox, , gridding that in, rather both seperately.

hope helps! ~gunner


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -