python - Tkinter Scrollbar not showing -
so i've tried bunch of different solutions threads i've searched here. here code:
def begin(): global path, thumbpath, fullimgpath, running root = tkinter.tk() root.title("keybuilder") frame = frame(root, width = 630, height = 450) frame.pack() exitbutton = button(frame, text="exit keybuilder", width=10, command=exitprogram) exitbutton.grid(row = 0, column = 0) running = true b = button(frame, text="set directory path", width=20, command=getpath) b.grid(row = 0, column = 1) groupmenu = frame(frame, width = 150) tree = treeview(groupmenu, selectmode = 'browse') tree.pack(fill = y) tree.insert(parent = '', index = 'end', text = 'master') = tree.insert(parent = '', index = 'end', text = 'group 1') tree.insert(parent = a, index = 'end', text = 'slide 1') yscrollbar = tkinter.scrollbar(frame, orient = vertical) numimages = 0 infile in glob.glob(os.path.join(path + '/imgthumb/', '*jpg')): numimages += 1 columns = 4 image_count = 0 gallery = canvas(frame, width = columns * thumb_size, height = columns * thumb_size, yscrollcommand = yscrollbar.set)# yscrollbar.config(command = gallery.yview) infile in glob.glob(os.path.join(path + '/imgthumb/', '*.jpg')): print "filling gallery with: " + infile image_count += 1 r, c = divmod(image_count-1, columns) im = image.open(infile) tkimage = imagetk.photoimage(im) myvar = label(gallery, image=tkimage) myvar.image = tkimage gallery.create_window(c*thumb_size, r*thumb_size, anchor = nw, window = myvar) gallery.config(scrollregion=gallery.bbox(all)) yscrollbar.config(command = gallery.yview) groupmenu.grid(row = 1, column = 0) gallery.grid(row = 1, column = 1) yscrollbar.grid(row = 1, column = 2) yscrollbar.config(command = gallery.yview) root.mainloop()
and here of packages i'm using might have issue:
import pymongo import glob, os subprocess import popen import tkinter tkinter import * ttk import * pil import image, imagetk import zipfile import shutil
i've tried setting scrollbar , canvas, , populating canvas in many different orders. i've tried giving canvas specific scroll regions. can't seem scrollbar work.
thanks!
solved it. had add
sticky = ne + se
as argument to
yscrollbar.grid()
and place scroll bar in column 1 left of column holding canvas being scrolled.
i think scrollbar there grid geometry manager placed somewhere couldn't access.
Comments
Post a Comment