Changeset 9c9fae1 in sasview for src/sas/sasgui


Ignore:
Timestamp:
Apr 6, 2017 10:03:48 AM (8 years ago)
Author:
Tim Snow <tim.snow@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
d70f6d2
Parents:
07b50df9
Message:

Threaded plot drawing

However, need a status update as it looks like the plot has hung

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/fitting/basepage.py

    r9c0f3c17 r9c9fae1  
    1212import logging 
    1313import traceback 
     14 
     15from Queue import Queue 
     16from threading import Thread 
    1417 
    1518from collections import defaultdict 
     
    239242        self.set_layout() 
    240243 
     244        # Putting matplotlib in the background so as not to hang the interface 
     245        self.threadedDrawQueue = Queue() 
     246 
     247        self.threadedDrawWorker = Thread(target = self._threaded_draw_worker, args = (self.threadedDrawQueue,)) 
     248        self.threadedDrawWorker.setDaemon(True) 
     249        self.threadedDrawWorker.start() 
     250 
     251 
    241252    def set_index_model(self, index): 
    242253        """ 
     
    16911702        :param chisqr: update chisqr value [bool] 
    16921703        """ 
    1693         wx.CallAfter(self._draw_model_after, update_chisqr, source) 
     1704        self.threadedDrawQueue.put([update_chisqr, source]) 
     1705 
     1706    def _threaded_draw_worker(self, threadedDrawQueue): 
     1707        while True: 
     1708            inputVariables = threadedDrawQueue.get() 
     1709            self._draw_model_after(inputVariables[0], inputVariables[1]) 
     1710            self.threadedDrawQueue.task_done() 
    16941711 
    16951712    def _draw_model_after(self, update_chisqr=True, source='model'): 
Note: See TracChangeset for help on using the changeset viewer.