Hello Robin,
thanks for the quick reply.
Can you do it without the wxYieldIfNeeded? Can you reduce it
Yep -- but no success.
to a small
sample?
Here it comes:
query_queue starts a relatively long running thread which collect data
from a mail queue.
Each item collected is added to the wxListCtrl by a callback from the
thread into the main program (maybe this is the prob ???) The struct for
the sorter mixin is build up in parallel.
路路路
-----------------------------
#
# The following stuff is taken from main()
# All things start here.
#
def query_queue(self):
self.listctrl.Freeze()
self.listctrl_cnt = 0
self.listctrl_sorter = {}
self.itemDataMap = self.listctrl_sorter
wxColumnSorterMixin.__init__(self,self.listctrl.GetColumnCount())
tcnt = threadlib.Counter()
# Starts thread which does a callback for each element
# added to the list
#
# If I do a self.Server.queue.query2(self.listadd),
# then everything runs stable -- but this blocks my GUI.
#
t = TRun(tcnt, self.Server.queue.query2, self.listadd)
while tcnt.value > 0:
wxYieldIfNeeded()
self.listctrl.Thaw()
items = self.listctrl_sorter.items()
for x in range(len(items)):
key, data = items
self.listctrl.SetItemData(x,key)
#
# The callback function
# Populates the listcontrol and fillst the
# sorter struct ...
#
def listadd(self, msg):
"""
Callback function for self.Server.queue.query2
"""
# analyze spoolfile and add to listctrl
#
if msg.state == 'MESS':
self.listctrl.InsertImageStringItem(0,' MESS',self.img_mess)
#self.listctrl.InsertImageItem(0,self.img_mess)
else:
if msg.state == 'RSND':
self.listctrl.InsertImageStringItem(0,'
RSND',self.img_rsnd)
#self.listctrl.InsertImageItem(0,self.img_rsnd)
else:
if msg.state == 'FROZ':
self.listctrl.InsertImageStringItem(0,'
FROZ',self.img_froz)
#self.listctrl.InsertImageItem(0,self.img_froz)
self.listctrl.SetStringItem(0,1,msg.date)
self.listctrl.SetStringItem(0,2,msg.evlpfields['mail from'])
self.listctrl.SetStringItem(0,3,msg.evlpfields['rcpt to'])
self.listctrl.SetStringItem(0,4,msg.headfields['subject'])
self.listctrl.SetStringItem(0,5,msg.file)
# fill sorter struct
#
self.listctrl_sorter[self.listctrl_cnt] = [' ' +
msg.state,
msg.date,
msg.evlpfields['mail
from'],
msg.evlpfields['rcpt
to'],
msg.headfields['subject'],
msg.file]
self.listctrl_cnt += 1
#
# This class starts the submitted function in a seperate thread
#
class TRun(threading.Thread):
def __init__(self, cnt, function, parameter):
threading.Thread.__init__(self)
self.cnt = cnt
self.function = function
self.parameter = parameter
self.cnt.inc()
self.start()
def run(self):
self.function(self.parameter)
self.cnt.dec()
-----------------------------
All the best,
Harald