Python wx 模块,CallAfter() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用wx.CallAfter()

项目:fmc-dialer    作者:sguron    | 项目源码 | 文件源码
def makeCall(self):
        if self.wxapp.phonenum:
            wx.CallAfter(self.wxapp.pstnCall)
            self.make_call = False

            self.flag_bitmap.ChangeSource(u'images/flags/%s.png' % self.wxapp.phonecountry[1].lower())
            self.m_staticText5.UpdateLabel(u"00:00:00")
            codelen = len(self.wxapp.phonecountry[3])
            if self.wxapp.phonecountry[3]:
                self.m_staticText6.UpdateLabel(u"+%s %s" % ( self.wxapp.phonecountry[3], self.wxapp.phonenum[codelen:]))
            else:
                self.m_staticText6.UpdateLabel(self.wxapp.phonenum)

            #self.presencepanel.Refresh()

            self.call_btn.ChangeButtonImages(u"images/keypad/normal/end-call.png")
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def testClassify(self):
        cap = self.src.getEEGSecs(time.time() - self.testTime)
        self.testTime = time.time()

        cap = self.bandpass(cap)
        seg = cap.segment(start=self.windowStart, end=self.windowEnd)
        seg = self.downsample(seg)

        # if verbose XXX - idfah
        #wx.LogMessage('nSeg: %d' % seg.getNSeg())
        assert seg.getNSeg() == len(self.choices)

        stim = [self.markToStim(m) for m in seg.getMarkers()]

        x = self.standardizer.apply(seg.chanEmbed())

        dv = self.classifier.discrim(x)
        choice = stim[np.argmax(dv, axis=0)[0]]

        if self.pieMenu.growBar(choice, amount=1.0/self.nTestTrial):
            wx.CallAfter(self.controlPlayer, choice)
        else:
            wx.CallLater(1000.0*self.isi, self.runTestEpoch)
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def testDecision(self, probs):
        for i,choice in enumerate(self.choices):
            self.pieMenu.growBar(choice, self.gain*(probs[i]-self.loss), refresh=False)
        self.pieMenu.refresh()

        self.curDecision += 1

        finalSelection = self.pieMenu.getSelection()

        if finalSelection is None:
            wx.CallAfter(self.runTestEpoch)

        else:
            self.pieMenu.clearAllHighlights(refresh=False)
            self.pieMenu.highlight(finalSelection, style='jump', secs=self.pauseSecs)
            finalLabel = self.choices.index(finalSelection)
            self.src.incrementMarker(finalLabel+1)
            self.confusion[finalLabel, self.choices.index(self.curChoice)] += 1.0

            wx.CallLater(1000.0*self.pauseSecs, self.testClearTrial)
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def testClassify(self):
        cap = self.src.getEEGSecs(time.time() - self.testTime)
        self.testTime = time.time()

        cap = self.decimate(cap)
        seg = cap.segment(start=self.windowStart, end=self.windowEnd)

        assert seg.getNSeg() == len(self.choices)

        stim = [self.markToStim(m) for m in seg.getMarkers()]

        x = self.standardizer.apply(seg.chanEmbed())

        dv = self.classifier.discrim(x)
        choice = stim[np.argmax(dv, axis=0)[0]]

        if self.pieMenu.growBar(choice, amount=1.0/self.nTestTrial):
            wx.CallAfter(self.moveRobot, choice)
        else:
            wx.CallLater(1000.0*self.isi, self.runTestEpoch)
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def set_and_get_xy_limits(self):
        canvas_size = self.canvas.GetSize()
        num_x_pixels = canvas_size.x
        halfsize = (num_x_pixels / 2.0) / self.ztv_frame.zoom_factor
        xlim = (self.center.x - halfsize, self.center.x + halfsize)
        self.axes.set_xlim(xlim)
        num_y_pixels = canvas_size.y
        halfsize = (num_y_pixels / 2.0) / self.ztv_frame.zoom_factor
        ylim = (self.center.y - halfsize, self.center.y + halfsize)
        self.axes.set_ylim(ylim)
        self.figure.canvas.draw()  # bulk of time in method is spent in this line: TODO: look for ways to make faster
        send_change_message = True
        if xlim == self.xlim and ylim == self.ylim:
            send_change_message = False
        self.xlim, self.ylim = xlim, ylim
        if send_change_message:
            wx.CallAfter(pub.sendMessage, 'primary-xy-limits-changed', msg=None)
        return {'xlim':xlim, 'ylim':ylim}
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def set_cmap(self, msg):
        """
        Verify that requested cmap is in the list (or it's reversed equivalent) and set it

        msg is tuple:  (pause_redraw_image, new_cmap)
        """
        pause_redraw_image, new_cmap = msg
        old_cmap = self.cmap
        lower_available_cmaps = [a.lower() for a in self.available_cmaps]
        if new_cmap.lower() in lower_available_cmaps:
            self.cmap = self.available_cmaps[lower_available_cmaps.index(new_cmap.lower())]
            self.set_cmap_inverted(((pause_redraw_image or self._pause_redraw_image), False))
        elif new_cmap.replace('_r', '').lower() in lower_available_cmaps:
            self.cmap = self.available_cmaps[lower_available_cmaps.index(new_cmap.lower().replace('_r', ''))]
            self.set_cmap_inverted(((pause_redraw_image or self._pause_redraw_image), True))
        elif (new_cmap.lower() + '_r') in lower_available_cmaps:
            self.cmap = self.available_cmaps[lower_available_cmaps.index(new_cmap.lower() + '_r')]
            self.set_cmap_inverted(((pause_redraw_image or self._pause_redraw_image), True))
        else:
            sys.stderr.write("unrecognized cmap ({}) requested\n".format(new_cmap))
        if self.cmap != old_cmap:
            wx.CallAfter(pub.sendMessage, 'cmap-changed', msg=None)
            if not (pause_redraw_image or self._pause_redraw_image):
                wx.CallAfter(pub.sendMessage, 'redraw-image', msg=False)
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def set_clim(self, msg):
        """
        msg is tuple:  (pause_redraw_image, (clim[0], clim[1]))
        """
        pause_redraw_image, clim = msg
        old_clim = self.clim
        if clim[0] is None:
            clim[0] = self.clim[0]
        if clim[1] is None:
            clim[1] = self.clim[1]
        if clim[0] > clim[1]:
            self.clim = [clim[1], clim[0]]
            self.set_cmap_inverted(((pause_redraw_image or self._pause_redraw_image), not self.is_cmap_inverted))
        else:
            self.clim = clim
        if old_clim != self.clim:
            wx.CallAfter(pub.sendMessage, 'clim-changed', msg=((pause_redraw_image or self._pause_redraw_image),))
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def run(self):
        latest_mtime = 0.0
        while self.keep_running:
            filename_to_open = None
            possible_matches = glob.glob(self.source_panel.autoload_match_string)
            if len(possible_matches) > 0:
                for cur_match in possible_matches:
                    cur_match_mtime = os.path.getmtime(cur_match)
                    if cur_match_mtime > latest_mtime:
                        filename_to_open = cur_match
                        latest_mtime = cur_match_mtime
                if filename_to_open is not None:
                    wx.CallAfter(pub.sendMessage, 'load-fits-file', msg=filename_to_open)
            time.sleep(self.source_panel.autoload_pausetime)
            if self.source_panel.autoload_mode != 'file-match':
                self.keep_running = False
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def load_sky_subtraction_to_process_stack(self):
        """
        Load sky subtraction into image processing stack
        If sky image is 3-d ([n,x,y]), then collapse to 2-d ([x,y]) by doing a median on axis=0
        """
        self.unload_sky_subtraction_from_process_stack()
        if self.sky_hdulist is not None:
            if self.sky_hdulist[0].data.ndim == 2:
                process_fxn = ImageProcessAction(np.subtract, self.sky_hdulist[0].data)
            elif self.sky_hdulist[0].data.ndim == 3:
                process_fxn = ImageProcessAction(np.subtract, np.median(self.sky_hdulist[0].data, axis=0))
            else:
                raise UnrecognizedNumberOfDimensions("Tried to load sky image with {} dimensions, " + 
                                                     "when can only handle 2-d or 3-d".format(
                                                     self.sky_hdulist[0].data.ndim))
            # assume that sky subtraction should always be first in processing stack.
            self.ztv_frame.image_process_functions_to_apply.insert(0, ('sky-subtraction', process_fxn))
            wx.CallAfter(pub.sendMessage, 'image-process-functions-to-apply-changed', 
                         msg=(self.ztv_frame._pause_redraw_image,))
            wx.CallAfter(pub.sendMessage, 'set-window-title', msg=None)
        self.sky_checkbox.SetValue(True)
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def set_and_get_xy_limits(self):
        canvas_size = self.canvas.GetSize()
        num_x_pixels = canvas_size.x
        halfsize = (num_x_pixels / 2.0) / self.ztv_frame.zoom_factor
        xlim = (self.center.x - halfsize, self.center.x + halfsize)
        self.axes.set_xlim(xlim)
        num_y_pixels = canvas_size.y
        halfsize = (num_y_pixels / 2.0) / self.ztv_frame.zoom_factor
        ylim = (self.center.y - halfsize, self.center.y + halfsize)
        self.axes.set_ylim(ylim)
        self.figure.canvas.draw()  # bulk of time in method is spent in this line: TODO: look for ways to make faster
        send_change_message = True
        if xlim == self.xlim and ylim == self.ylim:
            send_change_message = False
        self.xlim, self.ylim = xlim, ylim
        if send_change_message:
            wx.CallAfter(pub.sendMessage, 'primary-xy-limits-changed', msg=None)
        return {'xlim':xlim, 'ylim':ylim}
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def set_clim(self, msg):
        """
        msg is tuple:  (pause_redraw_image, (clim[0], clim[1]))
        """
        pause_redraw_image, clim = msg
        old_clim = self.clim
        if clim[0] is None:
            clim[0] = self.clim[0]
        if clim[1] is None:
            clim[1] = self.clim[1]
        if clim[0] > clim[1]:
            self.clim = [clim[1], clim[0]]
            self.set_cmap_inverted(((pause_redraw_image or self._pause_redraw_image), not self.is_cmap_inverted))
        else:
            self.clim = clim
        if old_clim != self.clim:
            wx.CallAfter(pub.sendMessage, 'clim-changed', msg=((pause_redraw_image or self._pause_redraw_image),))
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def run(self):
        latest_mtime = 0.0
        while self.keep_running:
            filename_to_open = None
            possible_matches = glob.glob(self.source_panel.autoload_match_string)
            if len(possible_matches) > 0:
                for cur_match in possible_matches:
                    cur_match_mtime = os.path.getmtime(cur_match)
                    if cur_match_mtime > latest_mtime:
                        filename_to_open = cur_match
                        latest_mtime = cur_match_mtime
                if filename_to_open is not None:
                    wx.CallAfter(pub.sendMessage, 'load-fits-file', msg=filename_to_open)
            time.sleep(self.source_panel.autoload_pausetime)
            if self.source_panel.autoload_mode != 'file-match':
                self.keep_running = False
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def load_sky_subtraction_to_process_stack(self):
        """
        Load sky subtraction into image processing stack
        If sky image is 3-d ([n,x,y]), then collapse to 2-d ([x,y]) by doing a median on axis=0
        """
        self.unload_sky_subtraction_from_process_stack()
        if self.sky_hdulist is not None:
            if self.sky_hdulist[0].data.ndim == 2:
                process_fxn = ImageProcessAction(np.subtract, self.sky_hdulist[0].data)
            elif self.sky_hdulist[0].data.ndim == 3:
                process_fxn = ImageProcessAction(np.subtract, np.median(self.sky_hdulist[0].data, axis=0))
            else:
                raise UnrecognizedNumberOfDimensions("Tried to load sky image with {} dimensions, " + 
                                                     "when can only handle 2-d or 3-d".format(
                                                     self.sky_hdulist[0].data.ndim))
            # assume that sky subtraction should always be first in processing stack.
            self.ztv_frame.image_process_functions_to_apply.insert(0, ('sky-subtraction', process_fxn))
            wx.CallAfter(pub.sendMessage, 'image-process-functions-to-apply-changed', 
                         msg=(self.ztv_frame._pause_redraw_image,))
            wx.CallAfter(pub.sendMessage, 'set-window-title', msg=None)
        self.sky_checkbox.SetValue(True)
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def OnClickStopAction(self, event):
    if self.pipeline_started == True:
        if self.citer_flow[1] == 1:
            self.sequence_timer.Start(1000)
            self.ancestor.GetPage(4).data_poll_timer.Start(1000)
            if self.total_iter > 0:
                self.ancestor.GetPage(2).data_poll_timer.Start(1000)
        if self.citer_flow[1] < 2:
            self.citer_flow[1] = 2
            self.pipeline_started = False
            self.button_pause.SetBitmapLabel(getpause48Bitmap())
            self.ancestor.GetPage(1).button_pause.SetBitmapLabel(getpauseBitmap())
            self.citer_flow[3] = 0
            self.citer_flow[4] = 0
            self.citer_flow[5] = 0
            def ThreadClean(self):
                while len(enumerate()) > 2:
                    sleep(0.1)
                wx.CallAfter(self.OnClickFinal,)
            self.thread = threading.Thread(target=ThreadClean, args=(self,))
            self.thread.daemon = True
            self.thread.start()
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def Sequence_Scale_Array(\
    self,
    pipelineitem
    ):
    if self.pipeline_started == True:
        title = "Sequence " + pipelineitem.treeitem['name']
        self.ancestor.GetPage(0).queue_info.put("Preparing scaled Numpy array...")
        filename_in = pipelineitem.input_filename.objectpath.GetValue()
        filename_out = pipelineitem.output_filename.objectpath.GetValue()
        factor = float(pipelineitem.scale.value.GetValue())
        try:
            array = LoadArray(self, filename_in)
        except:
            msg = "Could not load array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
        array2 = factor*array
        try:
            SaveArray(self, filename_out, array2)
        except:
            msg = "Could not save array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def Sequence_Transpose_Array(\
    self,
    pipelineitem
    ):
    if self.pipeline_started == True:
        title = "Sequence " + pipelineitem.treeitem['name']
        self.ancestor.GetPage(0).queue_info.put("Preparing transpose Numpy array...")
        filename_in = pipelineitem.input_filename.objectpath.GetValue()
        filename_out = pipelineitem.output_filename.objectpath.GetValue()
        try:
            array = LoadArray(self, filename_in)
        except:
            msg = "Could not load array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
        array2 = array.transpose((2,1,0))
        try:
            SaveArray(self, filename_out, array2)
        except:
            msg = "Could not save array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def Sequence_Array_to_Memory(\
    self,
    pipelineitem
    ):
    if self.pipeline_started == True:
        title = "Sequence " + pipelineitem.treeitem['name']
        self.ancestor.GetPage(0).queue_info.put("Preparing array in memory...")
        filename_in = pipelineitem.input_filename.objectpath.GetValue()
        filename_out = pipelineitem.output_filename.objectpath.GetValue()
        try:
            array = LoadArray(self, filename_in)
        except:
            msg = "Could not load array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
        try:
            SaveArray(self, filename_out, array)
        except:
            msg = "Could not save array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def Sequence_Memory_to_Array(\
    self,
    pipelineitem
    ):
    if self.pipeline_started == True:
        title = "Sequence " + pipelineitem.treeitem['name']
        self.ancestor.GetPage(0).queue_info.put("Saving array in memory...")
        filename_in = pipelineitem.input_filename.objectpath.GetValue()
        filename_out = pipelineitem.output_filename.objectpath.GetValue()
        try:
            array = LoadArray(self, filename_in)
        except:
            msg = "Could not load array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
        try:
            SaveArray(self, filename_out, array)
        except:
            msg = "Could not save array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def Sequence_Load_PSF(\
    self,
    pipelineitem
    ):
    if self.pipeline_started == True:
        title = "Sequence " + pipelineitem.treeitem['name']
        self.ancestor.GetPage(0).queue_info.put("Preparing PSF in memory...")
        filename_in = pipelineitem.input_filename.objectpath.GetValue()
        try:
            array = LoadArray(self, filename_in)
        except:
            msg = "Could not load array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
        try:
            self.psf = array
            self.ancestor.GetPage(0).queue_info.put("done.")
        except:
            msg = "Could not save array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def Sequence_Wrap(\
    self,
    pipelineitem
    ):
    if self.pipeline_started == True:
        title = "Sequence " + pipelineitem.treeitem['name']
        self.ancestor.GetPage(0).queue_info.put("Preparing wrapped array...")
        filename_in = pipelineitem.input_filename.objectpath.GetValue()
        filename_out = pipelineitem.output_filename.objectpath.GetValue()
        direction = pipelineitem.rbdirection.GetStringSelection()
        try:
            array = LoadArray(self, filename_in)
        except:
            msg = "Could not load array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
        if direction == "Forward":
            arrayfinal = WrapArray(array)
        else:
            arrayfinal = WrapArray(array, direction=-1)
        SaveArray(self, filename_out, arrayfinal)
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def Sequence_Save_Residual(\
    self,
    pipelineitem
    ):
    if self.pipeline_started == True:
        title = "Sequence " + pipelineitem.treeitem['name']
        self.ancestor.GetPage(0).queue_info.put("Saving residual data...")
        filename_out = pipelineitem.output_filename.objectpath.GetValue()
        try:
            data_length = self.citer_flow[0]
            x = numpy.arange(data_length)
            y = self.residual[:data_length]
            xy = numpy.vstack((x,y)).T
            numpy.savetxt(filename_out, xy, delimiter=',')
        except:
            msg = "Could not save array."
            wx.CallAfter(self.UserMessage, title, msg)
            self.pipeline_started = False
            return
项目:AppAutoViewer    作者:RealLau    | 项目源码 | 文件源码
def getFullXpath(self, evt):
        fxpath = ""
        l = []
        it = evt.GetItem()
        l.append(it)
        p = self.tree.GetItemParent(it)
        while p!=self.tree.GetRootItem():
            l.append(p) 
            p = self.tree.GetItemParent(p)
        del l[-1]
        l.reverse()
        for i in l:
            xPath = self.tree.ordeDic[i]["class"]+"["+"@index="+"\'%s\'" % self.tree.ordeDic[i]["index"]+"]" 
            fxpath += "/"+xPath

        wx.CallAfter(pub.sendMessage, "updateXPath", msg=fxpath)
项目:AppAutoViewer    作者:RealLau    | 项目源码 | 文件源码
def tellToDoSwipeOrInput(self, evt):
        operationString = self.OpeartionBox.GetStringSelection()    
        inputC = self.inputContent.GetValue()
        sX = self.swipeStartX.GetValue()
        sY = self.swipeStartY.GetValue()
        eX = self.swipeEndX.GetValue()
        eY = self.swipeEndY.GetValue()        

        if operationString=="??":
            if inputC=="":
                dlg = wx.MessageDialog(self, u"???????", u"????????", wx.OK | wx.ICON_ERROR)
                if dlg.ShowModal() == wx.ID_OK:
                    dlg.Destroy()
            else:
                keyb = self.keyboardType.GetValue()
                wx.CallAfter(pub.sendMessage, "DoSwipeOrInput", msg =inputC+"\n"+keyb)
        else:
            if sX=="" or sY=="" or eX=="" or eY=="":
                dlg = wx.MessageDialog(self, u"?????????", u"??????????????????", wx.OK | wx.ICON_ERROR)
                if dlg.ShowModal() == wx.ID_OK:
                    dlg.Destroy()
            else:
                wx.CallAfter(pub.sendMessage, "DoSwipeOrInput", msg ="??\n%d\n%d\n%d\n%d" % (sX,sY,eX,eY))
项目:magic-card-database    作者:drknotter    | 项目源码 | 文件源码
def __init__(self, parent, id=wx.ID_ANY, style=wx.ST_SIZEGRIP,
                 name="EnhancedStatusBar"):
        """Default Class Constructor.

        EnhancedStatusBar.__init__(self, parent, id=wx.ID_ANY,
                                   style=wx.ST_SIZEGRIP,
                                   name="EnhancedStatusBar")
        """

        wx.StatusBar.__init__(self, parent, id, style, name)

        self._items = {}
        self._curPos = 0
        self._parent = parent

        wx.EVT_SIZE(self, self.OnSize) 
        wx.CallAfter(self.OnSize, None)
项目:pyjam    作者:10se1ucgo    | 项目源码 | 文件源码
def run(self):
        song_urls = iter(self.song_urls)
        errors = []
        with youtube_dl.YoutubeDL(self.opts) as yt:
            while not self.is_aborted():
                try:
                    song_url = next(song_urls)
                    logger.info("Downloading audio/video from {url}".format(url=song_url))
                    try:
                        yt.download([song_url])
                    except youtube_dl.DownloadError:
                        errors.append(song_url)
                    self.downloaded += 100
                    wx.CallAfter(self.parent.download_update, message=self.downloaded)
                except StopIteration:
                    wx.CallAfter(self.parent.download_complete, errors=errors)
                    break
项目:pyjam    作者:10se1ucgo    | 项目源码 | 文件源码
def download_complete(self, errors):
        if self.progress_dialog:
            logger.info("Beginning download")
            self.downloader.join()
            if errors:
                done_string = "Songs downloaded with {errors} error(s)".format(errors=len(errors))
            else:
                done_string = "All songs were downloaded succesfully!"
            logger.info(done_string)
            done_message = wx.MessageDialog(parent=self, message=done_string, caption="pyjam")
            done_message.ShowModal()
            done_message.Destroy()

            if errors:
                errors = '\n'.join(errors)
                logger.critical("Error downloading these these URLs:\n{errors}".format(errors=errors))
                error_dialog = wx.MessageDialog(parent=self, message="The following URLs caused errors\n" + errors,
                                                caption="Download Error!", style=wx.ICON_ERROR)
                error_dialog.ShowModal()
                error_dialog.Destroy()

            self.progress_dialog.Destroy()
            self.Destroy()
            wx.CallAfter(self.parent.convert, event=None, in_dir=self.out_dir.GetPath())
项目:pyjam    作者:10se1ucgo    | 项目源码 | 文件源码
def run(self):
        file_size_dl = 0
        response = requests.get(self.url, stream=True)
        data_chunks = response.iter_content(chunk_size=1024)

        if not os.path.exists('bin'):
            os.mkdir('bin')

        with open('bin/ffmpeg.7z', 'wb') as f:
            while not self.is_aborted():
                try:
                    chunk = next(data_chunks)
                    file_size_dl += len(chunk)
                    logger.info("FFmpeg downloader: Downloaded chunk: {chunk}".format(chunk=len(chunk)))
                    logger.info("FFmpeg downloader: Total downloaded so far: {total}".format(total=file_size_dl))
                    logger.info("FFmpeg downloader: Remaining: {r}".format(r=self.file_size - file_size_dl))
                    if chunk:
                        f.write(chunk)
                        f.flush()
                        # This makes the download super slow.
                        # os.fsync(f.fileno())
                    wx.CallAfter(self.parent.ff_update, message=file_size_dl)
                except StopIteration:
                    wx.CallAfter(self.parent.ff_complete)
                    break
项目:pyjam    作者:10se1ucgo    | 项目源码 | 文件源码
def convert_update(self, message):
        progress = "{songs} out of {total}".format(songs=message // 2, total=self.num_songs)
        if self.progress_dialog and self.converter.isAlive():
            if message >= self.num_songs * 2:
                message = self.num_songs * 2 - 1
            if not self.progress_dialog.Update(value=message, newmsg="Converted: {prog}".format(prog=progress))[0]:
                self.converter.abort()
                self.converter.join()
                self.progress_dialog.Destroy()

                alert_string = "Aborted! Only {progress} songs were converted".format(progress=progress)
                alert = wx.MessageDialog(parent=self, message=alert_string, caption="pyjam", style=wx.ICON_EXCLAMATION)
                alert.ToggleWindowStyle(wx.STAY_ON_TOP)
                alert.ShowModal()
                alert.Destroy()

                logger.info("Audio conversion canceled canceled.")
                logger.info(progress)
                # wx.CallAfter(self.progress_dialog.Destroy)
项目:pyjam    作者:10se1ucgo    | 项目源码 | 文件源码
def convert_complete(self, errors):
        if self.progress_dialog:
            self.converter.join()
            if errors:
                done_string = "Songs converted with {errors} error(s)".format(errors=len(errors))
            else:
                done_string = "All songs were converted succesfully!"
            done_message = wx.MessageDialog(parent=self, message=done_string, caption="pyjam")
            done_message.ToggleWindowStyle(wx.STAY_ON_TOP)
            done_message.ShowModal()
            done_message.Destroy()

            if errors:
                errors = '\n'.join(errors)
                error_dialog = wx.MessageDialog(parent=self, message="The following files caused errors\n" + errors,
                                                caption="Conversion Error!", style=wx.OK | wx.ICON_ERROR)
                error_dialog.ShowModal()
                error_dialog.Destroy()
                logger.critical("Error converting these files\n{errors}".format(errors=errors))

            logger.info(done_string)
            wx.CallAfter(self.progress_dialog.Destroy)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def OnFindButton(self, event):
        infos = {
            "find_pattern": self.FindPattern.GetValue(),
            "wrap": self.WrapSearch.GetValue(),
            "case_sensitive": self.CaseSensitive.GetValue(),
            "regular_expression": self.RegularExpressions.GetValue(),
            "filter": "all"}

        if self.infosPrev != infos:
            self.infosPrev = infos
            message = ""
            try:
                self.criteria = infos
                CompilePattern(self.criteria)
            except Exception:
                self.criteria.clear()
                message = self.RegExpSyntaxErrMsg
            self.SetStatusText(message)
        if len(self.criteria) > 0:
            wx.CallAfter(self.ParentWindow.FindInPou,
                         {True: 1, False: -1}[self.Forward.GetValue()],
                         self.criteria)
        event.Skip()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def OnPageClose(self, event):
        """Callback function when AUINotebook Page closed with CloseButton

        :param event: AUINotebook Event.
        """
        selected = self.TabsOpened.GetSelection()
        if selected > -1:
            window = self.TabsOpened.GetPage(selected)

            if window.CheckSaveBeforeClosing():

                # Refresh all window elements that have changed
                wx.CallAfter(self._Refresh, TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU)
                wx.CallAfter(self.RefreshTabCtrlEvent)
                wx.CallAfter(self.CloseFindInPouDialog)
                event.Skip()
            else:
                event.Veto()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def __init__(self, parent, id=wx.ID_ANY, style=wx.ST_SIZEGRIP,
                 name="EnhancedStatusBar"):
        """Default Class Constructor.

        EnhancedStatusBar.__init__(self, parent, id=wx.ID_ANY,
                                   style=wx.ST_SIZEGRIP,
                                   name="EnhancedStatusBar")
        """

        wx.StatusBar.__init__(self, parent, id, style, name)

        self._items = {}
        self._curPos = 0
        self._parent = parent

        wx.EVT_SIZE(self, self.OnSize)
        wx.CallAfter(self.OnSize, None)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def GetPageSizeChangedFunction(self, spinctrl, name):
        def PageSizeChangedFunction(event):
            if self.Controller is not None:
                if self.Values is not None:
                    old_value = self.Values.get("pageSize")
                else:
                    old_value = (0, 0)
                if name == 'PageWidth':
                    new_value = (spinctrl.GetValue(), old_value[1])
                else:
                    new_value = (old_value[0], spinctrl.GetValue())
                if old_value != new_value:
                    self.Controller.SetProjectProperties(properties={"pageSize": new_value})
                    self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU,
                                               PAGETITLES, SCALING)
                    wx.CallAfter(self.RefreshView)
            event.Skip()
        return PageSizeChangedFunction
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def GetScalingChangedFunction(self, spinctrl, language, name):
        def ScalingChangedFunction(event):
            if self.Controller is not None:
                old_value = (0, 0)
                if self.Values is not None:
                    scaling = self.Values.get("scaling")
                    if scaling is not None:
                        old_value = scaling.get(language)
                if name == 'XScale':
                    new_value = (spinctrl.GetValue(), old_value[1])
                else:
                    new_value = (old_value[0], spinctrl.GetValue())
                if old_value != new_value:
                    self.Controller.SetProjectProperties(properties={"scaling": {language: new_value}})
                    self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU,
                                               PAGETITLES, SCALING)
                    wx.CallAfter(self.RefreshView)
            event.Skip()
        return ScalingChangedFunction
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def OnViewerRightUp(self, event):
        if self.GetDrawingMode() == FREEDRAWING_MODE:
            Viewer.OnViewerRightUp(self, event)
        else:
            element = self.FindElement(event)
            if element:
                if self.SelectedElement and self.SelectedElement != element:
                    self.SelectedElement.SetSelected(False)
                self.SelectedElement = element
                if self.IsWire(self.SelectedElement):
                    self.SelectedElement.SetSelectedSegment(0)
                else:
                    self.SelectedElement.SetSelected(True)
                    self.SelectedElement.OnRightUp(event, self.GetLogicalDC(), self.Scaling)
                    self.SelectedElement.Refresh()
                wx.CallAfter(self.SetCurrentCursor, 0)
        event.Skip()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def OnEnumeratedValueEndEdit(self, event):
        text = event.GetText()
        values = self.EnumeratedValues.GetStrings()
        index = event.GetIndex()
        if index >= len(values) or values[index].upper() != text.upper():
            if text.upper() in [value.upper() for value in values]:
                message = wx.MessageDialog(self, _("\"%s\" value already defined!") % text, _("Error"), wx.OK | wx.ICON_ERROR)
                message.ShowModal()
                message.Destroy()
                event.Veto()
            elif text.upper() in IEC_KEYWORDS:
                message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!") % text, _("Error"), wx.OK | wx.ICON_ERROR)
                message.ShowModal()
                message.Destroy()
            else:
                initial_selected = None
                if index < len(values) and self.EnumeratedInitialValue.GetStringSelection() == values[index]:
                    initial_selected = text
                wx.CallAfter(self.RefreshEnumeratedValues, initial_selected)
                wx.CallAfter(self.RefreshTypeInfos)
                event.Skip()
        else:
            event.Skip()
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def sizeCallback(self, event):
        wx.CallAfter(self.setViewport)
        event.Skip()
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def sizeCallback(self, event):
        wx.CallAfter(self.setViewport)
        event.Skip()
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def OnSize(self, event):
        wx.CallAfter(self.DoSetViewport)
        event.Skip()
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def sizeCallback(self, event):
        wx.CallAfter(self.setViewport)
        event.Skip()
项目:SpatialTool    作者:JRcard    | 项目源码 | 文件源码
def setImage(self):
        if self.obj is not None:
            self.img = self.obj.getViewTable(self.GetSize(), self.begin, self.end)
            wx.CallAfter(self.Refresh)
项目:SpatialTool    作者:JRcard    | 项目源码 | 文件源码
def updatePlayCursorPos(self, pos):
        w,h = self.GetSize()
        # Function receives value between 0 and 1.0. This value needs to be converted into absolute pixels.
        pos = math.floor(pos * w)
        self.playCursorPos = pos
        wx.CallAfter(self.Refresh)
项目:SpatialTool    作者:JRcard    | 项目源码 | 文件源码
def OnSize(self, evt):
        wx.CallAfter(self.setImage)
项目:SpatialTool    作者:JRcard    | 项目源码 | 文件源码
def update(self):
        """
        Display updating method.

        This method is automatically called by the audio memory
        object (SndTable) when the table is modified.

        The method setTable(obj) must be used to register the audio
        memory object.

        """
        wx.CallAfter(self.sndview.setImage)
项目:nodemcu-pyflasher    作者:marcelstoer    | 项目源码 | 文件源码
def write(self, string):
        if string.startswith("\r"):
            # carriage return -> remove last line i.e. reset position to start of last line
            current_value = self.__out.GetValue()
            last_newline = current_value.rfind("\n")
            new_value = current_value[:last_newline + 1]  # preserve \n
            new_value += string[1:]  # chop off leading \r
            wx.CallAfter(self.__out.SetValue, new_value)
        else:
            wx.CallAfter(self.__out.AppendText, string)
项目:gopro-organizer    作者:angusmacdonald    | 项目源码 | 文件源码
def AddMessage(self, message):
        lock.acquire()

        try:
            logging.debug("Incoming message: {}".format(message))

            newStatus = "{}\n".format(message)

            wx.CallAfter(self.statusUpdates.AppendText, newStatus)



        finally:
            lock.release() # release lock, no matter what
项目:PandasDataFrameGUI    作者:bluenote10    | 项目源码 | 文件源码
def on_left_down(self, event):
        if self.HitTest(event.GetPosition()) != wx.NOT_FOUND:
            index = self.HitTest(event.GetPosition())
            self.selected_items[index] = not self.selected_items[index]
            # doesn't really work to update selection direclty (focus issues)
            # instead we wait for the EVT_LISTBOX event and fix the selection
            # there...
            # self.update_selection()
            # TODO: we could probably use wx.CallAfter
        event.Skip()
项目:PandasDataFrameGUI    作者:bluenote10    | 项目源码 | 文件源码
def on_tab_change(self, event):
        self.page2.list_box.SetFocus()
        page_to_select = event.GetSelection()
        wx.CallAfter(self.fix_focus, page_to_select)
        event.Skip(True)
项目:CSB    作者:csb-toolbox    | 项目源码 | 文件源码
def _invoke(self, callable, *args):

        wx = self._wx
        wx.CallAfter(callable, *args)
项目:FestEngine    作者:Himura2la    | 项目源码 | 文件源码
def _fade_sync(self, vol_range, delay):
        window_exists = self.window_exists()
        if window_exists:
            wx.CallAfter(lambda: self.window.vol_slider.Enable(False))

        vol_msg = ''
        for i in vol_range:
            self.player.audio_set_volume(i)
            vol_msg = 'Vol: %d' % self.player.audio_get_volume()
            wx.CallAfter(lambda: self.parent.set_bg_player_status('Fading %s... %s' %
                                                                  ('in' if vol_range[0] < vol_range[-1] else 'out',
                                                                   vol_msg)))
            if window_exists:
                def ui_upd():
                    self.window.vol_slider.SetValue(i)
                    self.window.vol_label.SetLabel("FAD: %d" % i)
                wx.CallAfter(ui_upd)
            time.sleep(delay)

        wx.CallAfter(lambda: self.parent.set_bg_player_status(vol_msg))

        if window_exists:
            def ui_upd():
                self.window.vol_slider.Enable(True)
                self.window.vol_label.SetLabel("VOL: %d" % i)
            wx.CallAfter(ui_upd)