예제 #1
0
    def focus(self, window_id=None):
        """Bring Panda3d to foreground, so that it gets keyboard focus.
        Also send a message to wx, so that it doesn't render a widget focused.
        We also need to say wx that Panda now has focus, so that it can notice when
        to take focus back.

        If window_id is given, that window will be focused, otherwise the one
        the pointer hovers upon. If the pointer doesn't hover over a window,
        a random window is taken. If there is no window, this function does nothing.
        """
        if window_id is None:
            window_id = self.getWindowUnderPointer()
        if window_id is None:
            for win in self.windows.values():
                window_id = win
                break
        if window_id is None:
            return
        wp = WindowProperties()
        wp.setForeground(True)
        self.windows[window_id].requestProperties(wp)
        # We request focus (and probably already have keyboard focus), so make wx
        # set it officially. This prevents other widgets from being rendered focused.
        self.messageclient.unicast(self.name + " gui",
                                   FocusWindowRequest(window_id))
예제 #2
0
파일: Editor.py 프로젝트: crempp/psg
    def OnInit(self):
        #prepare and start the p3d-wx hybrid-engine mainloop
        self.wxevt_loop = wx.EventLoop()
        self.wxevt_old_loop = wx.EventLoop.GetActive()
        wx.EventLoop.SetActive(self.wxevt_loop)
        base.taskMgr.add(self._mainLoop, "MainLoopTask")

        #instantiate and assign the wx UI object
        self.win = P3dWxWindow(size=wx.Size(640, 480))
        self.SetTopWindow(self.win)

        #show the wx window
        self.win.Show(True)
        # is essential to let make up wx window before P3D stuff
        self._mainLoop()

        #bind wx events
        self.win.Bind(wx.EVT_SIZE, self.onSize)
        self.win.Bind(wx.EVT_CLOSE, self.onClose)
        self.vetoActivate = False
        self.win.Bind(wx.EVT_ACTIVATE, self.onActivate)

        #open the p3d window undecorated to use in the wx frame window
        wp = WindowProperties().getDefault()
        wp.setUndecorated(True)
        wp.setOpen(True)
        wp.setParentWindow(self.win.getP3DSurface())
        wp.setOrigin(0, 0)
        wp.setForeground(True)
        wp.setSize(*self.win.getP3DSurfaceSize())
        print ">>>opening p3dsurface"
        assert base.openDefaultWindow(props=wp) == True
        #
        return True
예제 #3
0
파일: Editor.py 프로젝트: crempp/psg
	def OnInit(self):
		#prepare and start the p3d-wx hybrid-engine mainloop
		self.wxevt_loop = wx.EventLoop()
		self.wxevt_old_loop = wx.EventLoop.GetActive()
		wx.EventLoop.SetActive(self.wxevt_loop)
		base.taskMgr.add(self._mainLoop, "MainLoopTask")
		
		#instantiate and assign the wx UI object
		self.win = P3dWxWindow(size=wx.Size(640, 480))
		self.SetTopWindow(self.win)
		
		#show the wx window
		self.win.Show(True)
		# is essential to let make up wx window before P3D stuff
		self._mainLoop()
		
		#bind wx events
		self.win.Bind(wx.EVT_SIZE, self.onSize)
		self.win.Bind(wx.EVT_CLOSE, self.onClose)
		self.vetoActivate=False
		self.win.Bind(wx.EVT_ACTIVATE, self.onActivate)
		
		#open the p3d window undecorated to use in the wx frame window
		wp=WindowProperties().getDefault()
		wp.setUndecorated(True)
		wp.setOpen(True)
		wp.setParentWindow(self.win.getP3DSurface())
		wp.setOrigin(0,0)
		wp.setForeground(True)
		wp.setSize(*self.win.getP3DSurfaceSize())
		print ">>>opening p3dsurface"
		assert base.openDefaultWindow(props=wp) == True
		#
		return True
예제 #4
0
파일: Editor.py 프로젝트: crempp/psg
	def p3dSurfaceFocus(self):
		'''re-gain keyboard focus
		NOT
		'''
		wp=WindowProperties()
		wp.setForeground(True)
		base.win.requestProperties(wp)
		print ">>>p3d surface try to re-gain focus - do keyboard events still work?"
예제 #5
0
파일: Editor.py 프로젝트: crempp/psg
    def p3dSurfaceFocus(self):
        '''re-gain keyboard focus
		NOT
		'''
        wp = WindowProperties()
        wp.setForeground(True)
        base.win.requestProperties(wp)
        print ">>>p3d surface try to re-gain focus - do keyboard events still work?"
예제 #6
0
파일: Editor.py 프로젝트: crempp/psg
	def onSize(self, event=None):
		'''to resize P3d Surface accordingly to his wx window container and to re-gain keyboard focus
		'''
		wp0=base.win.getProperties()
		if not wp0.getOpen():
			print ">>>[app onSize] win wasn't open: lets quit!"
			return
		wp=WindowProperties()
		wp.addProperties(wp0)
		wp.setSize(*self.win.getP3DSurfaceSize())
		wp.setForeground(True)
		base.win.requestProperties(wp)
		if event != None: event.Skip()
예제 #7
0
파일: Editor.py 프로젝트: crempp/psg
    def onSize(self, event=None):
        '''to resize P3d Surface accordingly to his wx window container and to re-gain keyboard focus
		'''
        wp0 = base.win.getProperties()
        if not wp0.getOpen():
            print ">>>[app onSize] win wasn't open: lets quit!"
            return
        wp = WindowProperties()
        wp.addProperties(wp0)
        wp.setSize(*self.win.getP3DSurfaceSize())
        wp.setForeground(True)
        base.win.requestProperties(wp)
        if event != None: event.Skip()
예제 #8
0
    def focus(self, window_id=None):
        """Bring Panda3d to foreground, so that it gets keyboard focus.
        Also send a message to wx, so that it doesn't render a widget focused.
        We also need to say wx that Panda now has focus, so that it can notice when
        to take focus back.

        If window_id is given, that window will be focused, otherwise the one
        the pointer hovers upon. If the pointer doesn't hover over a window,
        a random window is taken. If there is no window, this function does nothing.
        """
        if window_id is None:
            window_id = self.getWindowUnderPointer()
        if window_id is None:
            for win in self.windows.values():
                window_id = win
                break
        if window_id is None:
            return
        wp = WindowProperties()
        wp.setForeground(True)
        self.windows[window_id].requestProperties(wp)
        # We request focus (and probably already have keyboard focus), so make wx
        # set it officially. This prevents other widgets from being rendered focused.
        self.messageclient.unicast(self.name+" gui", FocusWindowRequest(window_id))