473,324 Members | 2,254 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,324 software developers and data experts.

wxPython: panel not fully painted

Hi,

I'm new to wxpython, and the following code is my first serious
attempt:
#~ start code
import wx

class MyPanel(wx.Panel):
def __init__(self, parent, id):
wx.Panel.__init__(self, parent, id)
self.parent = parent
button = wx.Button(self, -1, "Refresh")
button.SetPosition((100, 100))
button.SetFocus()

self.Bind(wx.EVT_BUTTON, self.OnCloseMe, button)

def OnCloseMe(self, event):
self.parent.f_redraw(self)
pass
class MyFrame(wx.Frame):
def __init__(
self, parent, ID, title, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE
):

wx.Frame.__init__(self, parent, ID, title, pos, size, style)

def f_redraw(self, kill_window):
kill_window.Destroy()
MyPanel(self, -1)
#~ self.SendSizeEvent()
wxApp = wx.App()
f = MyFrame(None, -1, "App Title")
MyPanel(f, -1)
f.Show()
wxApp.MainLoop()
#~ end code
My problem is: when I press the "refresh" button, the new panel is
painted only as a 20x20 pixels square on the top right side of the
frame. If I resize the frame, the panel is repainted correctly (that's
why I inserted the self.SendSizeEvent() line - commented above).

Is there something I'm missing, or this is normal ?

I'm using python 2.4.3 and wxpython 2.8.1.1 unicode, on WinXP SP2.
Windows extensions are also installed.

Jan 24 '07 #1
3 2532
On 24 Jan 2007 13:35:51 -0800, ci*******@yahoo.com <ci*******@yahoo.comwrote:
Hi,

I'm new to wxpython, and the following code is my first serious
attempt:
#~ start code
import wx

class MyPanel(wx.Panel):
def __init__(self, parent, id):
wx.Panel.__init__(self, parent, id)
self.parent = parent
button = wx.Button(self, -1, "Refresh")
button.SetPosition((100, 100))
button.SetFocus()

self.Bind(wx.EVT_BUTTON, self.OnCloseMe, button)

def OnCloseMe(self, event):
self.parent.f_redraw(self)
pass
class MyFrame(wx.Frame):
def __init__(
self, parent, ID, title, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE
):

wx.Frame.__init__(self, parent, ID, title, pos, size, style)

def f_redraw(self, kill_window):
kill_window.Destroy()
MyPanel(self, -1)
#~ self.SendSizeEvent()
wxApp = wx.App()
f = MyFrame(None, -1, "App Title")
MyPanel(f, -1)
f.Show()
wxApp.MainLoop()
#~ end code
My problem is: when I press the "refresh" button, the new panel is
painted only as a 20x20 pixels square on the top right side of the
frame. If I resize the frame, the panel is repainted correctly (that's
why I inserted the self.SendSizeEvent() line - commented above).

Is there something I'm missing, or this is normal ?

I'm using python 2.4.3 and wxpython 2.8.1.1 unicode, on WinXP SP2.
Windows extensions are also installed.
This is expected. Note that your "redraw" is no such thing - you are
destroying the window and creating a new one.

A feature of the wx.Frame class is that if it has one and only one
child, that child is sized to fill the client area of the frame.
However, this sizing happens in response to size events of the frame
itself, so when you create the new panel, it is shown at its default
size until you resize the frame (or emulate resizing the frame via
SendSizeEvent).
Jan 24 '07 #2
On Wed, 24 Jan 2007 13:35:51 -0800, citronelu wrote:
Hi,

I'm new to wxpython, and the following code is my first serious
attempt:
#~ start code
import wx

class MyPanel(wx.Panel):
def __init__(self, parent, id):
wx.Panel.__init__(self, parent, id)
self.parent = parent
button = wx.Button(self, -1, "Refresh")
button.SetPosition((100, 100))
button.SetFocus()

self.Bind(wx.EVT_BUTTON, self.OnCloseMe, button)

def OnCloseMe(self, event):
self.parent.f_redraw(self)
pass
class MyFrame(wx.Frame):
def __init__(
self, parent, ID, title, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE
):

wx.Frame.__init__(self, parent, ID, title, pos, size, style)

def f_redraw(self, kill_window):
kill_window.Destroy()
MyPanel(self, -1)
#~ self.SendSizeEvent()
wxApp = wx.App()
f = MyFrame(None, -1, "App Title")
MyPanel(f, -1)
f.Show()
wxApp.MainLoop()
#~ end code
My problem is: when I press the "refresh" button, the new panel is
painted only as a 20x20 pixels square on the top right side of the
frame. If I resize the frame, the panel is repainted correctly (that's
why I inserted the self.SendSizeEvent() line - commented above).

Is there something I'm missing, or this is normal ?

I'm using python 2.4.3 and wxpython 2.8.1.1 unicode, on WinXP SP2.
Windows extensions are also installed.
Consider using sizers, you'll need them anyway. They do such things for
you, and many other things too.

The help file has a good chapter on this: Working with sizers.

Kind regards
Morpheus
Jan 25 '07 #3
Thank you.

Jan 28 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Curzio Basso | last post by:
Hi all, I have a problem for which I wasn't able to find an answer anywhere else, maybe someone can give me a hint... I designed with XRCed a small GUI (the code is at the bottom of the...
15
by: Grant Edwards | last post by:
Can anybody recommend a good book on wxPython? Are there any books on wxPython? I've been trying to learn wxPython and/or wax for a few weeks, and I'm just not getting it. wxWindows seems...
1
by: mdk.R | last post by:
Hello all: i'am installed wxPython 2.5 and Python2.3.4..i try execute script with wxPython but it show error: Traceback (most recent call last): File "E:\py\test.py", line 7, in ? import wx...
3
by: John Salerno | last post by:
I'm using the sample code of the file 'simple.py' and trying to make a single window with a panel in it, but I keep getting an error. Here's my code: (I know I might need something else, like a...
3
by: John Salerno | last post by:
I'd be curious to know if this works any differently on other computers/platforms or while other things are happening in the background. I can't tell if it's the Timer object that isn't keep...
9
by: zxo102 | last post by:
Hi everyone, I am using a python socket server to collect data from a socket client and then control a image location ( wxpython) with the data, i.e. moving the image around in the wxpython frame....
5
by: Che M | last post by:
Hello, I'm curious if it is easy to get panels on your wxPython apps to have backgrounds which are given by a jpg or other bitmap. I found...
9
by: Tyler | last post by:
Hello All: I am currently working on a project to create an FEM model for school. I was thinking about using wxPython to gather the 12 input variables from the user, then, after pressing the...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.