Always see the entire wxPython window on the screen

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • analfabete
    New Member
    • Aug 2007
    • 19

    Always see the entire wxPython window on the screen

    Hi everybody !
    When I move my windows's program, this windows can leave the screen like all program.
    But me, I would like to know how I can do to always keep all part of my windows (when I move it) visible

    I do this:
    Code:
      
         self.width = GetSystemMetrics(0)
         self.height = GetSystemMetrics(1)
    
        def OnLeftDown(self, evt):
            self.CaptureMouse()        
            pos = self.ClientToScreen(evt.GetPosition())       
            origin = self.GetPosition()       
            self.delta = wx.Point(pos.x - origin.x, pos.y - origin.y)
    
      def OnMouseMove(self, evt):
            if evt.Dragging() and evt.LeftIsDown():
                pos = self.ClientToScreen(evt.GetPosition())
                    
                newPos = (pos.x - self.delta.x, pos.y - self.delta.y)
    
                if newPos[0] > 0 and newPos[0] < (self.width-482) and newPos[1] > 0 and newPos[1] < (self.height- 68):
                    self.Move(newPos)
    
                if pos.x <= 0 :
                    newPos = (0 , pos.y - self.delta.y)
                    self.Move(newPos)
    
                if pos.x >= (self.width-468):
                    newPos = ( self.width-482 , pos.y - self.delta.y)
                    self.Move(newPos)
                    
                if pos.y <= 0:
                    newPos = (pos.x - self.delta.x ,0 )
                    self.Move(newPos)
    
                if pos.y >= (self.height- 68):
                    newPos = (pos.x - self.delta.x ,self.height- 68) 
                    self.Move(newPos)
    I have a problem on screen's corners, the scrip bug
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    Some choices:

    Modal Dialog:[CODE=python]#Boa:Dialog:Dia log1

    import wx


    [wxID_DIALOG1] = [wx.NewId() for _init_ctrls in range(1)]

    class Dialog1(wx.Dial og):
    def _init_ctrls(sel f, prnt):
    # generated method, don't edit
    wx.Dialog.__ini t__(self, id=wxID_DIALOG1 , name='', parent=prnt, pos=wx.Point(15 4, 154),
    size=wx.Size(40 0, 250), style=wx.DIALOG _MODAL | wx.DEFAULT_DIAL OG_STYLE,
    title='Dialog1' )
    self.SetClientS ize(wx.Size(394 , 225))

    def __init__(self, parent):
    self._init_ctrl s(parent)
    [/CODE]Or, a "Stay on top" frame:[CODE=python]#Boa:Frame:Fram e1

    import wx


    [wxID_FRAME1] = [wx.NewId() for _init_ctrls in range(1)]

    class Frame1(wx.Frame ):
    def _init_ctrls(sel f, prnt):
    # generated method, don't edit
    wx.Frame.__init __(self, id=wxID_FRAME1, name='', parent=prnt, pos=wx.Point(17 6, 176),
    size=wx.Size(40 0, 250), style=wx.STAY_O N_TOP | wx.DEFAULT_FRAM E_STYLE,
    title='Frame1')
    self.SetClientS ize(wx.Size(392 , 223))

    def __init__(self, parent):
    self._init_ctrl s(parent)
    [/CODE]Check out the style= parameter in each.

    Comment

    • analfabete
      New Member
      • Aug 2007
      • 19

      #3
      Hi there is a miderstanding because my english is bad
      So I have decide to draw a schema what i want:

      Comment

      • bartonc
        Recognized Expert Expert
        • Sep 2006
        • 6478

        #4
        Yep. Sorry for the mis reading on my part.

        Again, this needs work (it sticks once it hits the edge), but gives you something to go on:[CODE=python]

        def OnFrame1Motion( self, event):
        if event.m_leftDow n:
        scrnW, scrnH = wx.DisplaySize( )
        winW, winH = self.GetSizeTup le()
        left, top = self.GetPositio nTuple()
        if not ((left + winW > scrnW) or (top + winH > scrnH)):
        x, y = event.GetPositi on()
        deltaX = x - self.lastMouseP os[0]
        deltaY = y - self.lastMouseP os[1]
        self.lastMouseP os = (x, y)
        x, y = self.GetPositio n()
        self.Move((x + deltaX, y + deltaY,))
        event.Skip()[/CODE]

        Comment

        Working...