[wxpython-users] another problem with size (and fullscreen window)

wxPython user mailing list, post #18,444
Author:
Date:
Subject:
 Jacek Poplawski
 2008-07-17 17:31:48
 [wxpython-users] another problem with size (and fullscreen window)
I want to:

1) open window in fullscreen
2) create panel in it (or anything else)
3) get size of the object inside window

I tried with and without sizers, but I just can't do it, please look at
following code:

==========================================================
#!/usr/bin/python
import wx

class ViewerWindow(wx.Frame):

def __init__(self, parent):
wx.Frame.__init__(self, parent, -1, "viewer")
panel = ViewerPanel(self)
self.ShowFullScreen(True)
print "size in wx.Frame:",panel.GetClientSize()

class ViewerPanel(wx.Panel):

def __init__(self, parent):
wx.Panel.__init__(self, parent, wx.ID_ANY)
self.Bind(wx.EVT_SIZE, self.OnSize)

def OnSize(self, event):
size = event.GetSize()
print "OnSize",size

app = wx.PySimpleApp()
frame = ViewerWindow(None)
frame.Show(True)
app.MainLoop()
==========================================================

(if you run it you will need to kill window, because it opens in fullscreen)
the output (in Linux) is:

OnSize (400, 250)
OnSize (400, 250)
OnSize (400, 250)
size in wx.Frame: (400, 250)
OnSize (1280, 1024)
OnSize (1280, 1024)
OnSize (1280, 1024)

Of course the fullscreen resolution is 1280x1024.
The problem is, that window extends to fullscreen after a while.... in the
constructor window is only 400x250. Why?
I want to create something in the __init__ and I want to know its size.

I tried to use sizer and call Layout() but it didn't help.

Could you tell me how to receive 1280x1024 size in the __init__ in given
example code?

--
Free Software - find interesting programs and change them
NetHack - meet interesting creatures, kill them and eat their bodies
Usenet - meet interesting people from all over the world and flame them
Decopter - unrealistic helicopter simulator, get it from
http://decopter.sf.net
<div dir="ltr">I want to:<br><br>1) open window in fullscreen<br>2) create panel in it (or anything else)<br>3) get size of the object inside window<br><br>I tried with and without sizers, but I just can&#39;t do it, please look at following code:<br>
<br>==========================================================<br>#!/usr/bin/python<br>import wx<br><br>class ViewerWindow(wx.Frame):<br><br>&nbsp;&nbsp;&nbsp; def __init__(self, parent):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wx.Frame.__init__(self, parent, -1, &quot;viewer&quot;)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; panel = ViewerPanel(self)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.ShowFullScreen(True)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;size in wx.Frame:&quot;,panel.GetClientSize()<br><br>class ViewerPanel(wx.Panel):<br><br>&nbsp;&nbsp;&nbsp; def __init__(self, parent):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wx.Panel.__init__(self, parent, wx.ID_ANY)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.Bind(wx.EVT_SIZE, self.OnSize)<br><br>&nbsp;&nbsp;&nbsp; def OnSize(self, event):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; size = event.GetSize()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;OnSize&quot;,size<br><br>app = wx.PySimpleApp()<br>frame = ViewerWindow(None)<br>frame.Show(True)<br>
app.MainLoop()<br>==========================================================<br><br>(if you run it you will need to kill window, because it opens in fullscreen)<br>the output (in Linux) is:<br><br>OnSize (400, 250)<br>OnSize (400, 250)<br>
OnSize (400, 250)<br>size in wx.Frame: (400, 250)<br>OnSize (1280, 1024)<br>OnSize (1280, 1024)<br>OnSize (1280, 1024)<br><br>Of course the fullscreen resolution is 1280x1024.<br>The problem is, that window extends to fullscreen after a while.... in the constructor window is only 400x250. Why?<br>
I want to create something in the __init__ and I want to know its size.<br><br>I tried to use sizer and call Layout() but it didn&#39;t help.<br><br>Could you tell me how to receive 1280x1024 size in the __init__ in given example code?<br>
<br clear="all">-- <br>Free Software - find interesting programs and change them<br>NetHack - meet interesting creatures, kill them and eat their bodies<br>Usenet - meet interesting people from all over the world and flame them<br>
Decopter - unrealistic helicopter simulator, get it from <a href="http://decopter.sf.net">http://decopter.sf.net</a><br>
</div>
_______________________________________________
wxpython-users mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Author:
Date:
Subject:
 Tim Roberts
 2008-07-17 09:59:47
 Re: [wxpython-users] another problem with size (and fullscreen window)
Jacek Poplawski wrote:
> I want to:
>
> 1) open window in fullscreen
> 2) create panel in it (or anything else)
> 3) get size of the object inside window
>
> I tried with and without sizers, but I just can't do it, please look
> at following code:
>
> ==========================================================
> #!/usr/bin/python
> import wx
>
> class ViewerWindow(wx.Frame):
>
> def __init__(self, parent):
> wx.Frame.__init__(self, parent, -1, "viewer")
> panel = ViewerPanel(self)
> self.ShowFullScreen(True)
> print "size in wx.Frame:",panel.GetClientSize()

It is way too easy to forget that Windows is an event-driven system.
The window is not yet created and visible at the time your constructor
runs, and ShowFullScreen does not force it to be displayed. All those
things do is queue up messages that cause actions to be scheduled for
later. The actions won't actually be taken until you call MainLoop and
the message loop starts dispatching. That's when stuff really happens

If you need to know the final size, you'll have to trigger some other
event that will be caught after drawing and resizing is complete. The
OnSize event is a good one. CallAfter should also work, I believe.

--
Tim Roberts, [email protected]
Providenza & Boekelheide, Inc.

_______________________________________________
wxpython-users mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Author:
Date:
Subject:
 Jacek Poplawski
 2008-07-17 21:46:39
 Re: [wxpython-users] another problem with size (and fullscreen window)
On Thu, Jul 17, 2008 at 6:59 PM, Tim Roberts <[email protected]> wrote:

> If you need to know the final size, you'll have to trigger some other event
> that will be caught after drawing and resizing is complete. The OnSize
> event is a good one. CallAfter should also work, I believe.


The problem is that I don't know when exactly the size is final. If you see
output of my program on Linux you will notice that OnSize returns smaller
size first, then bigger size later.

--
Free Software - find interesting programs and change them
NetHack - meet interesting creatures, kill them and eat their bodies
Usenet - meet interesting people from all over the world and flame them
Decopter - unrealistic helicopter simulator, get it from
http://decopter.sf.net
<div dir="ltr">On Thu, Jul 17, 2008 at 6:59 PM, Tim Roberts &lt;<a href="mailto:timr@probo.com">timr@probo.com</a>&gt; wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
If you need to know the final size, you&#39;ll have to trigger some other event that will be caught after drawing and resizing is complete. &nbsp;The OnSize event is a good one. &nbsp;CallAfter should also work, I believe.</blockquote>
<div><br>The problem is that I don&#39;t know when exactly the size is final. If you see output of my program on Linux you will notice that OnSize returns smaller size first, then bigger size later.<br clear="all"></div></div>
<br>-- <br>Free Software - find interesting programs and change them<br>NetHack - meet interesting creatures, kill them and eat their bodies<br>Usenet - meet interesting people from all over the world and flame them<br>Decopter - unrealistic helicopter simulator, get it from <a href="http://decopter.sf.net">http://decopter.sf.net</a><br>

</div>
_______________________________________________
wxpython-users mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Author:
Date:
Subject:
 Robin Dunn
 2008-07-18 12:11:59
 Re: [wxpython-users] another problem with size (and fullscreen window)
Jacek Poplawski wrote:
> On Thu, Jul 17, 2008 at 6:59 PM, Tim Roberts <[email protected]
> <mailto:[email protected]>> wrote:
>
> If you need to know the final size, you'll have to trigger some
> other event that will be caught after drawing and resizing is
> complete. The OnSize event is a good one. CallAfter should also
> work, I believe.
>
>
> The problem is that I don't know when exactly the size is final. If you
> see output of my program on Linux you will notice that OnSize returns
> smaller size first, then bigger size later.

So write your code to be able to adapt to any size, and then redo the
layout or the drawing or whatever when the size changes. If that is not
possible then you can always get the size of the display and compare to
the size of the panel.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

_______________________________________________
wxpython-users mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users