def __init__(self, media, target_resolution=None): RasterContainer.__init__(self, media, target_resolution) self._hydrus_bitmap = None HydrusThreading.CallToThread(self.THREADRender)
def _RENDERERSetRenderToPosition( self, index ): with self._render_lock: if self._render_to_index != index: self._render_to_index = index HydrusThreading.CallToThread( self.THREADRender )
def Clipboard(self, data_type, data): # need this cause can't do it in a non-gui thread if data_type == 'paths': paths = data if wx.TheClipboard.Open(): data = wx.DataObjectComposite() file_data = wx.FileDataObject() for path in paths: file_data.AddFile(path) text_data = wx.TextDataObject(os.linesep.join(paths)) data.Add(file_data, True) data.Add(text_data, False) wx.TheClipboard.SetData(data) wx.TheClipboard.Close() else: wx.MessageBox( 'Could not get permission to access the clipboard!') elif data_type == 'text': text = data if wx.TheClipboard.Open(): data = wx.TextDataObject(text) wx.TheClipboard.SetData(data) wx.TheClipboard.Close() else: wx.MessageBox( 'I could not get permission to access the clipboard.') elif data_type == 'bmp': media = data image_container = HC.app.GetFullscreenImageCache().GetImage(media) def THREADWait(): # have to do this in thread, because the image rendered needs the wx event queue to render start_time = time.time() while not image_container.IsRendered(): if time.time() - start_time > 15: raise Exception( 'The image did not render in fifteen seconds, so the attempt to copy it to the clipboard was abandoned.' ) time.sleep(0.1) wx.CallAfter(CopyToClipboard) def CopyToClipboard(): if wx.TheClipboard.Open(): hydrus_bmp = image_container.GetHydrusBitmap() wx_bmp = hydrus_bmp.GetWxBitmap() data = wx.BitmapDataObject(wx_bmp) wx.TheClipboard.SetData(data) wx.TheClipboard.Close() else: wx.MessageBox( 'I could not get permission to access the clipboard.') HydrusThreading.CallToThread(THREADWait)
def StartFileQuery(self, query_key, search_context): HydrusThreading.CallToThread(self.THREADDoFileQuery, query_key, search_context)