python - Scrollable list of frames within canvas. After deleting a frame, space is added to the end of the list -


this 1 issue can't seem figure out on own. here is:

i have scrollable list of frames put within 1 larger frame, packed within canvas. code follows:

### begin canvas/frame/picture  self.picframe = frame(self, width = 450, height = 300)  self.picframe.grid_rowconfigure(0, weight = 1) self.picframe.grid_columnconfigure(0, weight = 1) self.picframe.pack()  self.canvas = canvas(self.picframe, width = 450, height = 300) self.canframe = frame(self.canvas)  self.canvas.create_window((0,0), window = self.canframe, anchor = 'nw') self.canvas.pack(side="left") 

i create 1 frame holds goodies, , put frame self.canframe:

self.itemframe = frame(self.canframe, width = 450, height = 50) self.itemframe.grid(row = i, column = 0) self.itemframe.pack_propagate(0)  

i have methods call on canvas scroll properly. follows:

def setframe(self, event = none):     """ sets canvas dimensions , scroll area """     self.canvas.configure(scrollregion = self.canvas.bbox('all'))   def setscroll(self):     ##### part of function #######     # create frame hold scrollbar can     # use grid on scrollbar     self.scrollframe = frame(self.picframe)      # set rows , column configures can     # make scrollbar take entire row/column     self.scrollframe.rowconfigure(1, weight = 1)     self.scrollframe.columnconfigure(1, weight = 1)     self.scroll = autoscrollbar(self.scrollframe,                             orient = "vertical",                             command = self.canvas.yview)      # set scrollbar callback canvas     self.canvas.configure(yscrollcommand = self.scroll.set)      # set scrollbar height of canvas     self.scroll.grid(sticky = 'ns', row = 1, column = 0)      # set scrollbar packed on right side      self.scrollframe.pack(side="right", fill="y")      # bind picture frame canvas     self.picframe.bind("<configure>", self.setframe)  

i have list holds of frames put canvas, , within each frame checkbox, can check if box selected , whether want delete or not. when delete frame call along lines of:

self.frames[i].destroy() 

and index coorresponds itemframe want destroy holds goodies.

when delete frame feel missing resizing or removing frame widget may still 'remember' it. expands fine, when deleting itemframes when have issue. i've tried quite while figure 1 out, can't seem it. hints or pointers on go here great. apologize being code heavy post, wasn't sure needed or not. bearing me.

cheers!

edit/update:

i forgot mention using

to_del = self.frames.pop(i) to_del.destroy() 

and resetting scrollbar (to best of knowledge @ least)

self.scroll.destroy() self.scrollframe.destroy() self.setscroll()  # defined above 

does still keep reference though pop specified frame? also, go way self.picframe somehow? that's used hold canvas. if delete items in self.frames list, , try update list again, no images show up.

edit - tweaked usage of 'pack' in sentences above. shouldn't have been careless usage.

you've destroyed frame self.frames[i].destroy(), reference still exists in self.frames. remove reference list, use del self.frames[i].


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -