Hi all,
For the life of me I cannot work out why this is occuring but whenever I try to .destroy() this widget (or its parent) my program hangs - it doesn't crash, it just stops responding so I have to force kill it.
Python 2.6.5, Windows 7
These 'user' classes are being grided under each other as they're created (tracked by user_count). Then I want to 'refresh' the list of users; which involves destroying the old objects and making new ones.
There is something going wrong on what must be a basic level of what I've created or my understanding of widget destruction.
Does anything jump out here?
Cheers
For the life of me I cannot work out why this is occuring but whenever I try to .destroy() this widget (or its parent) my program hangs - it doesn't crash, it just stops responding so I have to force kill it.
Python 2.6.5, Windows 7
Code:
def generate_list(self):
"""
Clears off current list and runs through the entire contact list again,
makes a new 'user' object for each
"""
for each in self.contacts_made:
each.clear()
#Can't get beyond here
contacts_made = []
global user_count
user_count = 1
for user in client_flags.contacts:
process_user = self.create(user)
process_user.produce()
self.contacts_made.append(process_user)
self.update()
def create(self, user_info):
return self.user(self.inner_frame, user_info)
def update(self):
"""
For ensuring the the scrollbar knows the correct/current dimensions of
the active user list - it will shrink and expand with more and less users
online
"""
self.UListBox.configure(scrollregion=(0, 0, self.inner_frame.winfo_width(), self.inner_frame.winfo_height()))
class user:
def __init__(self, parent, user_info):
self.root = parent
self.id = user_info[0]
self.nick = user_info[1]
self.status = user_info[2]
self.container = Frame(parent, bg='white', bd=1, relief=RAISED)
global user_count
self.container.grid(row=(user_count + 1), column=0, sticky=(E,W))
user_count += 1 #need to go down too
def clear(self):
self.container.destroy() #<-Hangs here
#Can't get to here
def produce(self):
global statusGreen, statusRed, verd11
self.greenCircle = Label(self.container, image=statusGreen, bg="white")
self.redCircle = Label(self.container, image=statusRed, bg="white")
lNick = Label(self.container, text=self.nick, font=verd11, bg="white", anchor=W)#, font=fFont_Nick)
bConnect = Button(self.container, text="C", font=verd11, command=self.user_connect)#having an image would be cooler than "C"
if self.status == "AVAILABLE":
self.greenCircle.grid(row=0, column=0, pady=5)#, sticky=(N,S,W))
else:
self.redCircle.grid(row=0, column=0, pady=5)#, sticky=(N,S,W))
lNick.grid(row=0, column=1, sticky=(N,S,E,W), padx=(5,0), pady=5)
bConnect.grid(row=0, column=2, sticky=(N,S,E), pady=3)
self.container.columnconfigure(0, minsize=18, weight=0)
self.container.columnconfigure(1, minsize=150, weight=0)
self.container.columnconfigure(2, minsize=18, weight=0)
self.container.rowconfigure(0, minsize=34, weight=0)
There is something going wrong on what must be a basic level of what I've created or my understanding of widget destruction.
Does anything jump out here?
Cheers
Comment