Python wx 模块,EVT_IDLE 实例源码

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

项目:pypilot    作者:pypilot    | 项目源码 | 文件源码
def m_splitter1OnIdle( self, event ):
        self.m_splitter1.SetSashPosition( 250 )
        self.m_splitter1.Unbind( wx.EVT_IDLE )
项目:pyopenvr    作者:cmbruns    | 项目源码 | 文件源码
def init_gl(self):
        print('creating Frame')
        self.window = wx.Frame ( parent=None, id=wx.ID_ANY, title=self.title,
            style=wx.DEFAULT_FRAME_STYLE|wx.WS_EX_PROCESS_IDLE )
        print('creating GLCanvas')
        self.canvas = glcanvas.GLCanvas ( self.window, glcanvas.WX_GL_RGBA )
        print('creating GLContext')
        self.context = glcanvas.GLContext(self.canvas)
        self.canvas.SetFocus()
        self.window.SetSize ( (self.renderer.window_size[0], self.renderer.window_size[1]) )
        print('showing Frame')
        self.window.Show(True)

        print('calling SetTopWindow')
        self.SetTopWindow(self.window)

        self.Bind ( wx.EVT_CHAR, self.OnChar )
        self.canvas.Bind ( wx.EVT_SIZE, self.OnCanvasSize )
        self.canvas.Bind ( wx.EVT_PAINT, self.OnCanvasPaint )

        wx.IdleEvent.SetMode ( wx.IDLE_PROCESS_SPECIFIED )
        self.Bind ( wx.EVT_IDLE, self.OnIdle )

        print('making context current')
        self.canvas.SetCurrent ( self.context )
        self.renderer.init_gl()
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def initCanvas(self):
        """Initialize a new matplotlib canvas, figure and axis.
        """
        self.plotPanel = wx.Panel(self)
        self.plotPanel.SetBackgroundColour('white')
        plotSizer = wx.BoxSizer(orient=wx.VERTICAL)
        self.plotPanel.SetSizer(plotSizer)

        self.fig = plt.Figure(facecolor='white')
        #self.canvas = FigureCanvas(parent=self, id=wx.ID_ANY, figure=self.fig)
        self.canvas = FigureCanvas(parent=self.plotPanel, id=wx.ID_ANY, figure=self.fig)

        self.ax = self.fig.add_subplot(1,1,1)
        self.ax.set_xlabel('Time (s)')
        self.ax.set_ylabel('Frequency (Hz)')

        self.cbAx = self.fig.add_axes([0.91, 0.05, 0.03, 0.93])

        #self.fig.subplots_adjust(hspace=0.0, wspace=0.0,
        #    left=0.035, right=0.92, top=0.98, bottom=0.05)

        self.adjustMargins()

        self.firstPlot()

        self.lastSize = (0,0)
        self.needsResizePlot = True
        self.canvas.Bind(wx.EVT_SIZE, self.resizePlot)
        self.canvas.Bind(wx.EVT_IDLE, self.idleResizePlot)

        ##self.plotToolbar = widgets.PyPlotNavbar(self.canvas)
        ##plotSizer.Add(self.plotToolbar, proportion=0, flag=wx.EXPAND)
        plotSizer.Add(self.canvas, proportion=1, flag=wx.EXPAND)

        #self.plotToolbar.Hide()
项目:pyjam    作者:10se1ucgo    | 项目源码 | 文件源码
def __init__(self, parent, file):
        super(WaveformPlot, self).__init__(parent=parent, title="pyjam Waveform Viewer",
                                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)

        self.file = file

        self.plot = plot.PlotCanvas(self)
        self.plot.canvas.Bind(wx.EVT_LEFT_DOWN, self.lmb_down)
        self.plot.canvas.Bind(wx.EVT_LEFT_UP, self.lmb_up)
        self.plot.canvas.Bind(wx.EVT_MOTION, self.mouse_motion)
        self.plot.EnableAxesValues = (True, False, False, False)
        self.plot.EnableGrid = (True, False)
        self.plot.AbsScale = (True, False)
        self.plot.EnableAntiAliasing = True

        self.panel = WaveformPanel(self)

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(self.plot, 1, wx.EXPAND, 0)
        sizer.Add(self.panel, 0, wx.EXPAND, 0)
        self.SetSizerAndFit(sizer)
        self.SetSize(800, self.GetSize()[1])
        self.SetMinSize(self.GetSize())

        self.player = wx.media.MediaCtrl(parent=self, style=wx.SIMPLE_BORDER)

        self.volume = 25
        self.selected = np.array([0.0, 0.0])
        self.maximum = 0.0
        self.minimum = 0.0
        self.selection_drawn = False
        self.resized = False

        self.timer = wx.Timer(self)

        self.Bind(wx.EVT_SIZE, self.on_size)
        self.Bind(wx.EVT_TIMER, self.on_timer)
        self.Bind(wx.EVT_IDLE, self.on_idle)
        self.Bind(wx.EVT_CLOSE, self.on_exit)

        self.load()
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def __init__(self, parent ):
        wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, 
                            pos = wx.DefaultPosition, size = wx.Size(256,81), 
                            style = wx.TAB_TRAVERSAL )
        self.init_buf()
        self.his = None
        self.update = False
        self.x1, self.x2 = 0, 255
        self.Bind(wx.EVT_SIZE, self.on_size)  
        self.Bind(wx.EVT_IDLE, self.on_idle)
        self.Bind(wx.EVT_PAINT, self.on_paint)
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def bindEvents(self):
        for event, handler in [ \
                (wx.EVT_SIZE, self.on_size),
                (wx.EVT_MOUSE_EVENTS, self.on_mouseevent),      # Draw
                (wx.EVT_IDLE, self.on_idle),
                (wx.EVT_PAINT, self.on_paint)]: # Start drawing]:
            self.Bind(event, handler)
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, 
                            pos = wx.DefaultPosition, size = wx.Size(256,80), 
                            style = wx.SIMPLE_BORDER|wx.TAB_TRAVERSAL )
        self.init_buf()
        self.data, self.extent = [], [0,0,1,1]
        self.set_title_label('Graph', 'X-unit', 'Y-unit')
        self.update = False

        self.SetBackgroundColour( wx.Colour( 255, 255, 255 ) )
        self.Bind(wx.EVT_SIZE, self.on_size)
        self.Bind(wx.EVT_PAINT, self.on_paint)
        self.Bind(wx.EVT_IDLE, self.on_idle)
        self.Bind(wx.EVT_MOTION, self.on_move )
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def __init__(self, parent=None):
        wx.Frame.__init__ ( self, parent, id = wx.ID_ANY,
                            title = wx.EmptyString,
                            pos = wx.DefaultPosition,
                            size = wx.Size( -1,-1 ),
                            style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
        logopath = os.path.join(root_dir, 'data/logo.ico')
        self.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_3DLIGHT ) )
        self.SetIcon(wx.Icon(logopath, wx.BITMAP_TYPE_ICO))
        self.SetSizeHints( wx.Size( 560,-1 ), wx.DefaultSize )
        WindowsManager.add(self)
        print('frame added')

        self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )
        self.SetBackgroundColour( wx.Colour( 255, 255, 255 ) )

        sizer = wx.BoxSizer( wx.VERTICAL )
        self.txt_info = wx.StaticText( self, wx.ID_ANY,
                                       '500*500 pixels 173k',
                                       wx.DefaultPosition, wx.DefaultSize, 0 )
        self.txt_info.Wrap( -1 )
        sizer.Add( self.txt_info, 0, wx.ALL, 0 )

        self.canvas = Canvas(self)
        self.canvas.fit = self

        sizer.Add( self.canvas, 1, wx.EXPAND |wx.ALL, 0 )

        self.page = wx.ScrollBar( self, wx.ID_ANY,
                                  wx.DefaultPosition, wx.DefaultSize, wx.SB_HORIZONTAL)

        self.page.SetScrollbar(0,0,0,0, refresh=True)
        sizer.Add( self.page, 0, wx.ALL|wx.EXPAND, 0 )
        #self.page.Hide()
        self.SetSizer(sizer)
        self.Layout()

        self.Bind(wx.EVT_IDLE, self.on_idle)
        self.Bind(wx.EVT_SCROLL, self.on_scroll)
        self.Bind(wx.EVT_ACTIVATE, self.on_valid)
        self.Bind(wx.EVT_CLOSE, self.on_close)
        self.canvas.Bind(wx.EVT_CHAR, self.on_key)
        self.canvas.SetFocus()
        # panel.Bind(wx.EVT_CHAR, self.OnKeyDown)
        self.opage = 0
        self.Fit()

        self.SetAcceleratorTable(IPy.curapp.shortcut)
项目:py3_project    作者:tjy-cool    | 项目源码 | 文件源码
def setupMenuBar(self, parent):
        # ?????
        self.t1 = wx.TextCtrl(parent, size=(550, 260),
                              pos=(15, 10), style=wx.TE_MULTILINE)
        # ????
        self.find_button = wx.Button(
            parent, -1, u"??(B)...", (16, 280), (80, 30))    # size = (70,25),
        self.clear_button = wx.Button(
            parent, -1, u"??(L)", (16 + 96, 280), (80, 30))
        self.copy_button = wx.Button(
            parent, -1, u"??(C)", (16 + 96 * 2, 280), (80, 30))
        self.save_button = wx.Button(
            parent, -1, u"??(S)", (16 + 96 * 3, 280), (80, 30))
        self.stop_button = wx.Button(
            parent, -1, u"??(T)", (16 + 96 * 4, 280), (80, 30))
        # ??????
        self.version_box = wx.CheckBox(parent, -1, u"??(V)", (500, 280))
        self.time_box = wx.CheckBox(parent, -1, u"??(D)", (500, 280 + 20))
        self.md5_box = wx.CheckBox(parent, -1, u"MD5(M)", (500, 280 + 20 * 2))
        self.sha1_box = wx.CheckBox(
            parent, -1, u"SHA1(H)", (500, 280 + 20 * 3))
        self.crc32_box = wx.CheckBox(
            parent, -1, u"CRC32(R)", (500, 280 + 20 * 4))
        # ?????
        self.static1 = wx.StaticText(
            parent, -1, '??', pos=(20, 320), size=(50, 25))
        self.static2 = wx.StaticText(
            parent, -1, '??', pos=(20, 350), size=(50, 25))
        self.sigle_gauge = wx.Gauge(parent, -1, 100, (60, 320), (420, 20))
        self.totle_gauge = wx.Gauge(parent, -1, 100, (60, 350), (420, 20))
        # self.gauge.SetBezelFace(3)
        # self.gauge.SetShadowWidth(3)
        # ?????
        self.version_box.SetValue(True)
        self.time_box.SetValue(True)
        self.md5_box.SetValue(True)
        self.sha1_box.SetValue(True)
        self.crc32_box.SetValue(True)
        self.stop_button.Enable(False)

        # ????
        self.Bind(wx.EVT_CLOSE, self.closewindows)
        self.Bind(wx.EVT_BUTTON, self.find_file, self.find_button)
        self.Bind(wx.EVT_BUTTON, self.clear_text, self.clear_button)
        self.Bind(wx.EVT_BUTTON, self.copy_text, self.copy_button)
        self.Bind(wx.EVT_BUTTON, self.save_file, self.save_button)
        self.Bind(wx.EVT_BUTTON, self.stop_calc, self.stop_button)

        # self.Bind(wx.EVT_IDLE, self.onidle)
        self.file_cnt = 0
        self.deal_file_cnt = 0
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def PostInit(self):
        self.splitter = wx.SplitterWindow(self, -1)
        self.dvc = self.create_data_view_ctrl()

        self.splitter.Initialize(self.dvc)
        self.splitter.SetSashPosition(400)

        self.splitter.Bind(wx.EVT_SPLITTER_DOUBLECLICKED, self._OnSplitterDclick)

        self.Sizer = wx.BoxSizer(wx.VERTICAL) 
        self.Sizer.Add(self.splitter, 1, wx.EXPAND|wx.ALL, border=10)

        button_add_track = wx.Button(self, label="Add Object")
        self.Bind(wx.EVT_BUTTON, self.on_add_track_object, button_add_track)
        button_delete_track = wx.Button(self, label="Delete Object")
        self.Bind(wx.EVT_BUTTON, self.on_delete_track_object, 
                                              button_delete_track
        )
        btnbox = wx.BoxSizer(wx.HORIZONTAL)
        btnbox.Add(button_add_track, 0, wx.LEFT|wx.RIGHT, 5)
        btnbox.Add(button_delete_track, 0, wx.LEFT|wx.RIGHT, 5)

        self.Sizer.Add(btnbox, 0, wx.TOP|wx.BOTTOM, 5)

        """
        UIM = UIManager()
        controller = UIM.get(self._controller_uid)
        model = controller._get_real_model()
        lpe_ctrl_uid = UIM._getparentuid(self._controller_uid) 
        logplot_ctrl_uid = UIM._getparentuid(lpe_ctrl_uid)
        all_tracks = UIM.list('track_controller', logplot_ctrl_uid)

        for track in all_tracks:     
            print 'expanding:', track.uid
            item = model.ObjectToItem(track)
            print item
            self.dvc.Expand(item)
            print self.dvc.IsExpanded(item)
            #model.Resort()
            #print self.dvc.IsExpanded(item)
        """
        #self.dvc.Bind(dv.EVT_DATAVIEW_ITEM_START_EDITING, self.OnItemStartEditing)        
        #self.dvc.Bind(dv.EVT_DATAVIEW_ITEM_EDITING_STARTED, self.OnItemEditingStart)
        #self.dvc.Bind(dv.EVT_DATAVIEW_ITEM_EDITING_DONE, self.OnItemEditingDone)
        self.dvc.Bind(dv.EVT_DATAVIEW_SELECTION_CHANGED, self.OnSelectionChanged)

        ###
        #sizer_grid_panel = wx.BoxSizer(wx.VERTICAL)
        #sizer_grid_panel.Add(self.splitter, 1, wx.EXPAND|wx.ALL, border=10)
        self.SetSizer(self.Sizer)
        self._get_lpeview_notebook().AddPage(self, "Objects", True)


        #self.dvc.Bind(wx.EVT_IDLE, self._dvc_idle)

    #def _dvc_idle(self, event):
    #    print 'DVC IDLE'
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def __init__(self, parent, *args, **kwargs):#id=-1,
                 #pos = wx.DefaultPosition, size = wx.DefaultSize,
                 #style = 0, name="multiSplitter", borderSize = 2,
            #    borderColor=(0,0,0), sashColor=(0,0,0)):

        # always turn on tab traversal
        style = wx.TAB_TRAVERSAL
        # and turn off any border styles
        style &= ~wx.BORDER_MASK
        style |= wx.BORDER_NONE

        # initialize the base class
        wx.Panel.__init__(self, parent, *args, **kwargs)#id, pos, size, style, name)
        self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)

        # initialize data members
        self._windows = []
        self._sashes = []
        self._permitUnsplitAlways = self.HasFlag(wx.SP_PERMIT_UNSPLIT)

        self._dragMode = wx.SPLIT_DRAG_NONE
        self._working_sash = -1
        self.__absolute_sash_pos = 0
        self._oldY = 0
        self._checkRequestedSashPosition = False
        self._minimumPaneSize = 0

        self._sashCursorWE = wx.Cursor(wx.CURSOR_SIZEWE)

        self._needUpdating = False
        self._isHot = False
        self._drawSashInBackgroundColour = False

        # Bind event handlers
        self.Bind(wx.EVT_PAINT,        self._OnPaint)
        self.Bind(wx.EVT_IDLE,         self._OnIdle)
        self.Bind(wx.EVT_SIZE,         self._OnSize)
        self.Bind(wx.EVT_MOUSE_EVENTS, self._OnMouse)

        # Novas variaveis
        #self._old_size = (0,0)
        self._sash_size = self._border_size = 1
        self.borderColor = (0,0,0)
        self.sashColor = (0,0,0)
        #self.selectedWindowColor = 'green'
        self.trackerCanvas = None
        self.fit = False
        self._ajustes = []
        self._proporcao = []
        self.ajustado = False

        # Tom de azul para sashTrcker
        self.sashTrackerColor = 'blue' #(4, 20, 164)