Nov-06-2018, 02:00 PM
i have a Canvas set in my root layout called "window".
Inside "window" i have a frame called "infill".
Inside "infill" i have a Canvas called "can" and a scrollBar called "Cscroll".
finally inside "can" i have a final Frame called "scrollArea".
I am tryin to resize "scrollArea" so it fills the "can" Canvas. I can confirm "can" fills "infill" perfectly fine, however "scrollArea" shrinks to fit the objects inside it.
I have tried a lot of stuff including, setting expand=1 and fill=BOTH in the pack options, setting width, using a bound <Configure> to update the width and rearanging the order of the elements to try pack the "scrollArea" last.
notes
1)self.TkUtil is just a reference to Tk()
2)self.cFrame and self.cButton are just functions that creates and packs the elements in a single line
3)holder is the "infill" Frame
4)i am trying to make this as modular as possible so im not using self.varables.
Inside "window" i have a frame called "infill".
Inside "infill" i have a Canvas called "can" and a scrollBar called "Cscroll".
finally inside "can" i have a final Frame called "scrollArea".
I am tryin to resize "scrollArea" so it fills the "can" Canvas. I can confirm "can" fills "infill" perfectly fine, however "scrollArea" shrinks to fit the objects inside it.
I have tried a lot of stuff including, setting expand=1 and fill=BOTH in the pack options, setting width, using a bound <Configure> to update the width and rearanging the order of the elements to try pack the "scrollArea" last.
notes
1)self.TkUtil is just a reference to Tk()
2)self.cFrame and self.cButton are just functions that creates and packs the elements in a single line
3)holder is the "infill" Frame
4)i am trying to make this as modular as possible so im not using self.varables.
##part of TkUtils Module im trying to create def scrollable_area(self, holder): can= self.TkUtil.Canvas(holder) can.pack(side=self.TkUtil.LEFT) self.root.update_idletasks() self.root.update() scrollArea = self.TkUtil.Frame(can, bg="red") CScroll = self.TkUtil.Scrollbar(holder, orient=self.TkUtil.VERTICAL) CScroll.config(command=can.yview) CScroll.pack(side=self.TkUtil.RIGHT, fill=self.TkUtil.Y) scrollArea.pack(side=self.TkUtil.TOP, fill=self.TkUtil.X, expand=1) can.create_window(0, 0, window=scrollArea, anchor='nw') can.config(yscrollcommand=CScroll.set) scrollArea.bind("<Configure>", lambda e=self.TkUtil.Event(), c=can, s=scrollArea: self.update_scrollregion(e, c, s)) can.bind("<Configure>", lambda e=self.TkUtil.Event(), c=can, s=scrollArea:self.OnCanvasConfigure(e, c, s)) holder.bind("<Enter>", lambda e=self.TkUtil.Event():self.set_active(e, can)) holder.bind("<Leave>", lambda e=self.TkUtil.Event():self.unset_active(e)) return scrollArea def set_active(self, event, canvas): self.active_scroll = canvas def unset_active(self, event): self.active_scroll = None def _on_mousescroll(self, event): if self.active_scroll != None: self.active_scroll.yview_scroll(-1*(event.delta/120), "units") def update_scrollregion(self, event, can, scroll): can.configure(scrollregion=can.bbox("all")) def OnCanvasConfigure(self, event, can, scroll): canvas_width = event.width can.itemconfig(scroll, width = canvas_width)