473,398 Members | 2,212 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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:
Expand|Select|Wrap|Line Numbers
  1.  
  2.      self.width = GetSystemMetrics(0)
  3.      self.height = GetSystemMetrics(1)
  4.  
  5.     def OnLeftDown(self, evt):
  6.         self.CaptureMouse()        
  7.         pos = self.ClientToScreen(evt.GetPosition())       
  8.         origin = self.GetPosition()       
  9.         self.delta = wx.Point(pos.x - origin.x, pos.y - origin.y)
  10.  
  11.   def OnMouseMove(self, evt):
  12.         if evt.Dragging() and evt.LeftIsDown():
  13.             pos = self.ClientToScreen(evt.GetPosition())
  14.  
  15.             newPos = (pos.x - self.delta.x, pos.y - self.delta.y)
  16.  
  17.             if newPos[0] > 0 and newPos[0] < (self.width-482) and newPos[1] > 0 and newPos[1] < (self.height- 68):
  18.                 self.Move(newPos)
  19.  
  20.             if pos.x <= 0 :
  21.                 newPos = (0 , pos.y - self.delta.y)
  22.                 self.Move(newPos)
  23.  
  24.             if pos.x >= (self.width-468):
  25.                 newPos = ( self.width-482 , pos.y - self.delta.y)
  26.                 self.Move(newPos)
  27.  
  28.             if pos.y <= 0:
  29.                 newPos = (pos.x - self.delta.x ,0 )
  30.                 self.Move(newPos)
  31.  
  32.             if pos.y >= (self.height- 68):
  33.                 newPos = (pos.x - self.delta.x ,self.height- 68) 
  34.                 self.Move(newPos)
I have a problem on screen's corners, the scrip bug
Aug 31 '07 #1
3 2127
bartonc
6,596 Expert 4TB
Some choices:

Modal Dialog:
Expand|Select|Wrap|Line Numbers
  1. #Boa:Dialog:Dialog1
  2.  
  3. import wx
  4.  
  5.  
  6. [wxID_DIALOG1] = [wx.NewId() for _init_ctrls in range(1)]
  7.  
  8. class Dialog1(wx.Dialog):
  9.     def _init_ctrls(self, prnt):
  10.         # generated method, don't edit
  11.         wx.Dialog.__init__(self, id=wxID_DIALOG1, name='', parent=prnt, pos=wx.Point(154, 154),
  12.                 size=wx.Size(400, 250), style=wx.DIALOG_MODAL | wx.DEFAULT_DIALOG_STYLE,
  13.                 title='Dialog1')
  14.         self.SetClientSize(wx.Size(394, 225))
  15.  
  16.     def __init__(self, parent):
  17.         self._init_ctrls(parent)
  18.  
Or, a "Stay on top" frame:
Expand|Select|Wrap|Line Numbers
  1. #Boa:Frame:Frame1
  2.  
  3. import wx
  4.  
  5.  
  6. [wxID_FRAME1] = [wx.NewId() for _init_ctrls in range(1)]
  7.  
  8. class Frame1(wx.Frame):
  9.     def _init_ctrls(self, prnt):
  10.         # generated method, don't edit
  11.         wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt, pos=wx.Point(176, 176),
  12.                 size=wx.Size(400, 250), style=wx.STAY_ON_TOP | wx.DEFAULT_FRAME_STYLE,
  13.                 title='Frame1')
  14.         self.SetClientSize(wx.Size(392, 223))
  15.  
  16.     def __init__(self, parent):
  17.         self._init_ctrls(parent)
  18.  
Check out the style= parameter in each.
Aug 31 '07 #2
Hi there is a miderstanding because my english is bad
So I have decide to draw a schema what i want:

Aug 31 '07 #3
bartonc
6,596 Expert 4TB
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:
Expand|Select|Wrap|Line Numbers
  1.  
  2.     def OnFrame1Motion(self, event):
  3.         if event.m_leftDown:
  4.             scrnW, scrnH = wx.DisplaySize()
  5.             winW, winH = self.GetSizeTuple()
  6.             left, top = self.GetPositionTuple()
  7.             if not ((left + winW > scrnW) or (top + winH > scrnH)):
  8.                 x, y = event.GetPosition()
  9.                 deltaX = x - self.lastMousePos[0]
  10.                 deltaY = y - self.lastMousePos[1]
  11.                 self.lastMousePos = (x, y)
  12.                 x, y = self.GetPosition()
  13.                 self.Move((x + deltaX, y + deltaY,))
  14.         event.Skip()
Aug 31 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: flupke | last post by:
Hi, i'm trying to convert my java console app to a python gui. Now, the only problem i seem to have at the moment are the resizers for the layout. It seems that for the purpose of what i'm...
3
by: Young H. Rhiu | last post by:
See: http://hilug.org/img/app_layout.GIF I'm implementing an album-like application with wxpython but I'm new to wxPython though I know how to program with python. The problem is that it's not...
3
by: bob | last post by:
Is there anyway to show the hourglass (busy) cursor on the entire monitor screen, not just when the cursor is within the current program's window? Thanks
2
by: Kiran | last post by:
Hello All, I am writing an app in wxPython using a grid. I need to be able to recognize what cell in the grid the user is hovering over with the mouse. How to do this? I tried XYToCell(x, y),...
1
by: Francach | last post by:
Hi, I'd like to create a very small Frame without the usual minimise and maximise icons on the top. Does anyone know how to do this with wxPython? I've tried creating a Frame with the style...
19
by: [david] | last post by:
I'd like to refresh the display before I start the main loop. I have code like this: app = App() app.Show() app.long_slow_init() app.MainLoop()
12
by: Matt Bitten | last post by:
I've got a wxPython program that needs to do some drawing on a DC on a regular basis, whether or not a paint event happens. I know how to make a ClientDC to do the drawing in, and I know what...
16
by: Andrea Gavana | last post by:
Hi Diez & All, Do you mind explaining "why" you find it *buttugly*? I am asking just out of curiosity, obviously. I am so biased towards wxPython that I won't make any comment on this thread...
12
by: icarus | last post by:
platform: windows xp professional, python 2.5, wxpython When I double-check on my program file test.py (for simplicity I'll be using this code below), I see the window just fine. But the ms-dos...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.