473,511 Members | 16,730 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to add canvases to a sizer and refresh the parent frame?

Jory R Ferrell
62 New Member
I am using wxPython. I need to be able to add and remove panels/canvases on demand, but I don't know how to refresh the entire parent frame (the base starting window). I tried fooling with the Full_Repaint option, but got no where. The method I am using, to add and (hopefully) refresh the frame, Add_Canvas(), starts at line 50.

Expand|Select|Wrap|Line Numbers
  1. canvas_List = [Cone_Canvas, CubeCanvas]
  2.  
  3. class MainWindow(wx.Frame):
  4.     def __init__(self, parent = None, id = -1, title = "PyOpenGL Example 1"):
  5.         # Init
  6.         wx.Frame.__init__(
  7.                 self, parent, id, title, size = (400,200),
  8.                 style = wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE
  9.         )
  10.  
  11.         # TextCtrl
  12.         # self.control = wx.TextCtrl(self, -1, style = wx.TE_MULTILINE)
  13.  
  14.         #self.control = ConeCanvas(self)
  15.  
  16.         box = wx.BoxSizer(wx.HORIZONTAL)
  17.  
  18.     for canvas in canvas_List:
  19.         box.Add(canvas(self), 1, wx.EXPAND)
  20.  
  21.  
  22.         self.SetAutoLayout(True)
  23.         self.SetSizer(box)
  24.         self.Layout()
  25.  
  26.         # StatusBar
  27.         self.CreateStatusBar()
  28.  
  29.         # Filemenu
  30.         filemenu = wx.Menu()
  31.  
  32.         # Filemenu - About
  33.         menuitem = filemenu.Append(-1, "Add Canvas", "Add a Canvas")
  34.         self.Bind(wx.EVT_MENU, self.Add_Canvas, menuitem) # here comes the event-handler
  35.         # Filemenu - Separator
  36.         filemenu.AppendSeparator()
  37.  
  38.         # Filemenu - Exit
  39.         menuitem = filemenu.Append(-1, "E&xit", "Terminate the program")
  40.         self.Bind(wx.EVT_MENU, self.OnExit, menuitem) # here comes the event-handler
  41.  
  42.         # Menubar
  43.         menubar = wx.MenuBar()
  44.         menubar.Append(filemenu,"&File")
  45.         self.SetMenuBar(menubar)
  46.  
  47.         # Show
  48.         self.Show(True)
  49.  
  50. #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#
  51.  
  52.     # What do I call(or can I call anything at all?) to
  53.     #    repaint the entire frame? 
  54.  
  55.     def Add_Canvas(self,event):
  56.         canvas_List.append(Cube_Canvas)
  57.         Repaint_Frame() # <---- pseudo....
  58.  
  59. #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#
  60.  
  61.     def OnExit(self,event):
  62.         self.Close(True)  # Close the frame.
  63.  
Jun 9 '12 #1
3 2405
dwblas
626 Recognized Expert Contributor
I do not use Wx but know that it does have a Refresh() function. Try Google for more info.
Jun 10 '12 #2
Jory R Ferrell
62 New Member
I already tried it. Nothing happened.
Jun 11 '12 #3
Jory R Ferrell
62 New Member
Nevermind....it was a namespace conflict. I had to rename the sizer, dubbed 'box', as 'self.box'. The window was refreshing without problem, but since nothing was actually being appended to the sizer, there was no visible result to confirm the update of the window and I assumed it wasn't occurring. :P But yeh...it does work. Thanks.
Jun 11 '12 #4

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

Similar topics

1
3710
by: Hari Prasad | last post by:
I wrote an application where I am trying to kill a parent frame with out killing the child one. I have created a frame (F1) and if I click a button on F1 I am getting a new frame (F2). Now, if...
0
1274
by: sunil philip | last post by:
How do i get the id of parent frame ie. "page1frame2" from page2.aspx? I have a javascript function in page2.aspx.I need to get the id without passing 'this'. page1.aspx ------- <Frameset id...
3
10589
by: nicver | last post by:
I am working on updating a Web site with a frameset. A page opens a pop-up window in which the user uploads pictures. Once the upload is done, I would like to refresh the content of the frame which...
2
1382
by: Sidorf | last post by:
Hi there I've build a dynamic toolbar, based on xml. this toolbarClass will be instantiated in some aplication, i don't know for sure how many, for the moment. i'm looking for a way to call a...
2
23474
by: Jeronimo Bertran | last post by:
Hi, I have a page with a very data intensive grid which needs to be automatically refreshed constantly if a change is detected. In order to not refresh the complete page so often, I created an...
1
2607
by: BILL | last post by:
Hi everyone- Just want other advice as to if this is acceptable or correct. I'm looking to refresh the owner of my popup once "close" or "update", etc. is clicked on a popup window. I've decided to...
2
7772
by: Amadelle | last post by:
Hi all, I have multiple frames which I would like to get the query string from within one of the subframes. But when I do HttpContext.Current.Request.QueryString or Request.QueryString ...
1
2360
by: sasi2103 | last post by:
Hi all, Let's assume that I have index.html and I want to change this page. I can use redirect of other page and put it on onLoad in the body tag but I don't want to do so. Is there any command...
0
2040
by: dazzler | last post by:
How do I add "background text" into MDI parent frame, the text will be now erased if I move the MDI Parent frame, or I can also erase text with moving MDI Child frame, need to somehow refresh the...
0
7355
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
7423
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
7510
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
5668
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,...
1
5066
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3213
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
447
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.