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

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

项目:cebl    作者:idfah    | 项目源码 | 文件源码
def OnCloseFloatingPage(self, event):
            event.Skip()
            frame = event.GetEventObject()
            page_title = frame.GetTitle()
            page_contents = list(frame.GetChildren())[-1]
            #self.InsertPage(frame.page_index, page_contents, page_title, select=True, bitmap=frame.bitmap, control=frame.control)
            #self.InsertPage(frame.page_index, wx.StaticText(self, label='hello world'), page_title, select=True)#, bitmap=frame.bitmap, control=frame.control)
            page_contents.Reparent(self)
            wx.Yield() # report this bug XXX - idfah
            self.InsertPage(frame.page_index, page_contents, page_title, select=True,
                    bitmap=frame.bitmap, control=frame.control)

            if frame.control:
                src_tabs, idx = self.FindTab(page_contents)
                frame.control.Reparent(src_tabs)
                frame.control.Hide()
                frame.control = None

            self.SetPageTextColour(frame.page_index, frame.text_colour)
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def draw(self, data, latticeSize, color='black', wxYield=False):
        if wxYield:
            wx.Yield()

        data = np.asarray(data)
        data = data + 1

        points = (wxplt.PolyMarker(data, colour=color),)
        gc = wxplt.PlotGraphics(points, title=self.title,
            xLabel=self.xLabel, yLabel=self.yLabel)

        if wxYield:
            wx.Yield()

        self.canvas.Draw(gc,
            xAxis=(0,latticeSize[0]+1),
            yAxis=(0,latticeSize[1]+1))
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def Start(self,event):
        self.stopmotion = False
        self.count_total = int(self.steps.value.GetValue())
        if self.count >= self.count_total:
            return
        self.gauge.SetRange(self.count_total)
        self.xstep = float(self.angle.value.GetValue())*float(self.x.value.GetValue())
        self.ystep = float(self.angle.value.GetValue())*float(self.y.value.GetValue())
        self.zstep = float(self.angle.value.GetValue())*float(self.z.value.GetValue())
        self.filename = file_ext = os.path.splitext( self.filename_path.objectpath.GetValue() )[0]
        for i in range(self.count,self.count_total):
            if self.stopmotion == False:
                self.OnTimer(None)
                sleep(float(self.delay.value.GetValue())/1000.0)
            else:
                break
            wx.Yield()
        self.count = 0
        self.count_total = 0
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def OnTimer(self, event):
        renderers = self.parent.renWin.GetRenderWindow().GetRenderers()
        renderers.InitTraversal()
        no_renderers = renderers.GetNumberOfItems()
        for i in range(no_renderers):
            renderers.GetItemAsObject(i).GetActiveCamera().Elevation(self.xstep)
            renderers.GetItemAsObject(i).GetActiveCamera().OrthogonalizeViewUp()
            renderers.GetItemAsObject(i).GetActiveCamera().Roll(self.ystep)
            renderers.GetItemAsObject(i).GetActiveCamera().Azimuth(self.zstep)
        self.panelvisual.RefreshScene()
        wx.Yield()
        if(self.chkbox_save.GetValue() == True):
            image = vtk.vtkWindowToImageFilter()
            image.SetInput(self.parent.renWin.GetRenderWindow())
            image.Update()
            writer = vtk.vtkPNGWriter()
            countstr = str(self.count).rjust(4, "0")
            writer.SetFileName(self.filename+countstr+".png")
            if self.parent.VTKIsNot6:
                writer.SetInput(image.GetOutput())
            else:
                writer.SetInputData(image.GetOutput())
            writer.Write()
        self.count = self.count +1
        self.gauge.SetValue(self.count)
项目:Gym_LineFollower    作者:Chachay    | 项目源码 | 文件源码
def run(self):
        observation = env.reset()
        for t in range(1000):
            env.render()
            print(observation)
            action = agent.act()
            observation, reward, done, info = env.step(action)
            if done:
                print("Episode finished after {} timesteps".format(t+1))
                break
            wx.Yield()

        env.monitor.close()

        print("Simulation completed\nWaiting for closing window..")
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def draw(self, data, t=None, scale=None, chanNames=None,
             colors=('black', 'red', 'violet', 'blue', 'green', 'orange'),
             #colors=('black', 'blue', 'green', 'red', 'turquoise', 'blue violet', 'maroon', 'orange'),
             wxYield=False):

        data = util.colmat(data)
        nObs, nChan = data.shape

        if t is None:
            t = np.arange(nObs)
        else:
            t = np.linspace(0,t,nObs)

        colsep = util.colsep(data, scale=scale)
        scale = colsep[1]

        yMin = scale * (-nChan + 0.5)
        yMax = scale * 0.5

        data = data - colsep

        if chanNames is None:
            chanNames = (None,) * nObs

        self.canvas.setChanNames(chanNames, scale)

        colors = util.cycle(colors, nChan)

        if wxYield:
            wx.Yield()
        data = data.T
        lines = [wxplt.PolyLine(zip(t,d), legend=chan, colour=col, width=2)
            for d,col,chan in zip(data, colors, chanNames)]
        gc = wxplt.PlotGraphics(lines, title=self.title,
            xLabel=self.xLabel, yLabel=self.yLabel)

        if wxYield:
            wx.Yield()
        self.canvas.Draw(gc,
            xAxis=(np.min(t),np.max(t)),
            yAxis=(yMin,yMax))
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def draw(self, freqs, powers, chanNames=None,
             colors = ('black', 'red', 'violet', 'blue', 'green', 'orange'),
             wxYield=False):

        if chanNames is None:
            chanNames = (None,) * powers.shape[0]

        colors = util.cycle(colors, powers.shape[1])

        powers = util.colmat(powers)
        powers = powers.T

        # cap so we don't break wxplt.PlotGraphics with inf
        # Note: we need to use finfo.max/10.0 since
        #   wxplt.PlotGraphics does some log10 processing
        #   before figuring tick marks
        finfo = np.finfo(powers.dtype)
        powers[powers < finfo.eps] = finfo.eps
        powers[powers > (finfo.max/10.0)] = (finfo.max/10.0)


        if wxYield:
            wx.Yield()
        lines = [wxplt.PolyLine(zip(freqs,p), legend=chan, colour=col, width=2)
            for p,col,chan in zip(powers, colors, chanNames)]

        #lines += [wxplt.PolyLine(( (60.0,np.min(powers)), (60.0,np.max(powers)) ), legend='60Hz', colour='black', width=1)]

        if wxYield:
            wx.Yield()
        gc = wxplt.PlotGraphics(lines, title=self.title,
            xLabel=self.xLabel, yLabel=self.yLabel)

        self.canvas.Draw(gc,
            xAxis=(freqs[0], freqs[-1]),
            yAxis=(np.min(powers), np.max(powers)))
项目:pyjam    作者:10se1ucgo    | 项目源码 | 文件源码
def on_exit(self, event):
        # For some reason, the timer still tries to play the song even after the windows is being closed.
        # (probably because window destruction is not synchronous, a wx.Yield() would probably fix it)
        # The timer function even checks to see if the player is still loaded, but apparently the player is not
        # destroyed when the window is destroyed, resulting in the player trying to play a song
        # and Python crashes with exit code -1073741819 (0xC0000005) [Windows]
        self.timer.Stop()
        self.player.Load('')  # Unload whatever is in the MediaCtrl. (prevent file lockup)
        event.Skip()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def _SetConnector(self, connector, update_status=True):
        self._connector = connector
        if self.AppFrame is not None:
            self.AppFrame.LogViewer.SetLogSource(connector)
        if connector is not None:
            if self.StatusTimer is not None:
                # Start the status Timer
                wx.Yield()
                self.StatusTimer.Start(milliseconds=500, oneShot=False)
        else:
            if self.StatusTimer is not None:
                # Stop the status Timer
                self.StatusTimer.Stop()
            if update_status:
                wx.CallAfter(self.UpdateMethodsFromPLCStatus)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def ShowSplashScreen(self):
        from wx.lib.agw.advancedsplash import AdvancedSplash
        bmp = wx.Image(self.splashPath).ConvertToBitmap()
        self.splash = AdvancedSplash(None, bitmap=bmp)

        # process all events
        # even the events generated by splash themself during showing
        if wx.Platform == '__WXMSW__':
            self.splash.Show()
            self.splash.ProcessEvent(wx.PaintEvent())
        else:
            for i in range(0, 30):
                wx.Yield()
                time.sleep(0.01)
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def figure(cls, parent, title):
        if not title in cls.frms:
            cls.frms[title] = Frame3D(parent, title)
            cls.frms[title].Show()
        # wx.Yield()
        return cls.frms[title]