473,230 Members | 1,523 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,230 software developers and data experts.

wxPython.Panel refresh / redraw / update???

Hello everyone!

Got a bit of a problem...

Two of the panels on my program contain a number of check boxes. The exact number of which is determined by a pair of variables.

I have recently implemented a Wizard which changes that number, as well as a save and load function to the program.

I know the number of being altered in memory (i added a quick check button) but what i'm struggling with is how to refresh the panel with the new number of chek boxes... very confused!



code time...

Expand|Select|Wrap|Line Numbers
  1.  
  2. from Initials import *
  3. import wx
  4. import os
  5. from Wizard import *
  6.  
  7.  
  8. class MainFrame(wx.Frame):
  9.     def __init__(self, parent, title):
  10.         wx.Frame.__init__(self, parent, -1, title)
  11.  
  12.         icon = wx.Icon("icon.ico", wx.BITMAP_TYPE_ICO)
  13.         self.SetIcon(icon)
  14.  
  15.  
  16.         ### Create Main Panel & Sizer ###
  17.         self.mainPanel = wx.Panel(self)
  18.         self.mainPanel.SetBackgroundColour((225,245,255))
  19.         mainSizer = wx.BoxSizer(wx.VERTICAL)
  20.  
  21.  
  22.         ### IMPORT VARIABLES LIST FROM INITIALS.PY ###
  23.         self.vars = VariablesData()
  24.         self.variables = self.vars.GetVariables()
  25.  
  26.  
  27.         ### Create Various Panels ###        
  28.         self.titlePanel = TitlePanel(self.mainPanel, wx.HORIZONTAL, self.variables)
  29.         self.controlPanel = ControlPanel(self.mainPanel, wx.HORIZONTAL, self.variables)
  30.         self.actionPanel = ActionPanel(self.mainPanel, wx.HORIZONTAL, self.variables)
  31.  
  32.  
  33.         self.CreatemenuBar()
  34.         self.CreateStatusBar()
  35.  
  36.  
  37.         mainSizer.Add(self.titlePanel.panel, 2, wx.ALIGN_LEFT | wx.EXPAND | wx.ALL, 5)
  38.         mainSizer.Add(self.controlPanel.panel, 5, wx.EXPAND | wx.LEFT | wx.RIGHT, 5)
  39.         mainSizer.Add(self.actionPanel.panel, 2, wx.EXPAND | wx.ALL, 5)
  40.  
  41.         self.mainPanel.SetSizer(mainSizer)
  42.         mainSizer.Fit(self)                # Fit frame to neccessary size
  43.         mainSizer.SetSizeHints(self)       # Prevents frame from getting smaller than min.
  44.  
  45. .
  46. .
  47. .
  48.  
  49. class NewPanel():
  50.     def __init__(self, parent, Orientation, variables):
  51.  
  52.         self.variables = variables
  53.  
  54.         self.panel = wx.Panel(parent)
  55.         self.sizer = wx.BoxSizer(Orientation)
  56.  
  57.         self.AddItems(self.variables)
  58.  
  59.         self.panel.SetSizer(self.sizer)
  60.         self.sizer.Fit(self.panel)                # Fit frame to neccessary size
  61.         self.sizer.SetSizeHints(self.panel)       # Prevents frame from getting smaller than min.
  62.  
  63. .
  64. .
  65. .
  66. class ControlPanel(NewPanel):
  67.  
  68.     def AddItems(self, variables):
  69.  
  70.         self.variables = variables
  71.  
  72.         self.automaticPanel = AutomaticPanel(self.panel, wx.VERTICAL, variables)
  73.         self.modePanel = ModePanel(self.panel, wx.VERTICAL, variables)
  74.         self.manualPanel = ManualPanel(self.panel, wx.HORIZONTAL, variables)        
  75.  
  76.         self.sizer.Add(self.automaticPanel.panel, 6, wx.EXPAND)
  77.         self.sizer.Add(self.modePanel.panel, 3, wx.EXPAND | wx.LEFT | wx.RIGHT, 5)
  78.         self.sizer.Add(self.manualPanel.panel, 5, wx.EXPAND)
  79. .
  80. .
  81. .
  82. class ManualPanel(NewPanel):
  83.  
  84.     def AddItems(self, variables):
  85.  
  86.         self.variables = variables
  87.  
  88.         self.box = wx.StaticBox(self.panel, -1, 'Manual Control')
  89.         self.box.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD, False))
  90.         self.sizer = wx.StaticBoxSizer(self.box, wx.HORIZONTAL)
  91.  
  92.         self.bristlePanel = BristlePanel(self.panel, wx.VERTICAL, variables)
  93.         self.cylinderPanel = CylinderPanel(self.panel, wx.VERTICAL, variables)
  94.  
  95.         self.sizer.Add(self.bristlePanel.panel, 1, wx.EXPAND)
  96.         self.sizer.Add(self.cylinderPanel.panel, 1, wx.EXPAND)
  97.  
  98.  
  99.  
  100. class BristlePanel(NewPanel):
  101.  
  102.     def AddItems(self, variables):
  103.  
  104.         self.variables = variables
  105.  
  106.         self.bristleCheckBox = []
  107.  
  108.         for x in range(0, self.variables['bristles']):
  109.             self.bristleCheckBox.insert(x, (wx.CheckBox(self.panel, -1, "Bristle %d" % (x+1))))
  110.             self.sizer.Add(self.bristleCheckBox[x], 1, wx.ALIGN_CENTER_HORIZONTAL)        
  111.  
  112.  
  113. class CylinderPanel(NewPanel):
  114.  
  115.     def AddItems(self, variables):
  116.  
  117.         self.variables = variables
  118.  
  119.         self.cylinderCheckBox = []
  120.  
  121.         for x in range(0, self.variables['cylinders']):
  122.             self.cylinderCheckBox.insert(x, (wx.CheckBox(self.panel, -1, "Cylinder %d" % (x+1))))
  123.             self.sizer.Add(self.cylinderCheckBox[x], 1, wx.ALIGN_CENTER_HORIZONTAL)
  124.  
  125. .
  126. .
  127. .
  128.  
  129.  
  130.  
  131. class wxPyApp(wx.App):
  132.     def OnInit(self):
  133.         frame = MainFrame(None, "DPT - Sequence Driven Controller")
  134.         self.SetTopWindow(frame)
  135.         frame.Show(True)
  136.         frame.Center(wx.BOTH)
  137.         return True
  138.  
  139. if __name__ == '__main__':          # Only runs if program is being executed, not imported
  140.     app = wxPyApp(redirect=True)
  141.     app.MainLoop()
  142.  
  143.  
I know the NewPanel bit isnt the prettiest...

Its the Bristle & Cylinder Panels im having the issue with


Any help would be greatly appreciated!


Thanks,


Mark
Nov 30 '06 #1
10 35764
bartonc
6,596 Expert 4TB
Have you tried calling self.Refresh()?
I noticed earlier that you don't save the parent. I always assign
self.parent = parent
just in case I need to do something that acts on all the widgets in a frame.
Or you can
parent = self.GetParent()

There is also wxUpdate() to look at.
Dec 1 '06 #2
Have you tried calling self.Refresh()?
I noticed earlier that you don't save the parent. I always assign
self.parent = parent
just in case I need to do something that acts on all the widgets in a frame.
Or you can
parent = self.GetParent()

There is also wxUpdate() to look at.
i tried self.Refresh() but it didnt seem to do much :-s

where would i include the self.parent = parent line? and also - what exactly would that do? lol

Ive got a sort of make-shift solution 1/2 working where i have a method which destroys all the frames within mainFrame and then another method rebuilds them, but for some reason it will only do this once. Try for a second time and it seems unable to cirrectly build the sizer information and places everything over the top of one another.


Mark
Dec 2 '06 #3
bartonc
6,596 Expert 4TB
i tried self.Refresh() but it didnt seem to do much :-s

where would i include the self.parent = parent line? and also - what exactly would that do? lol

Ive got a sort of make-shift solution 1/2 working where i have a method which destroys all the frames within mainFrame and then another method rebuilds them, but for some reason it will only do this once. Try for a second time and it seems unable to cirrectly build the sizer information and places everything over the top of one another.


Mark
I was thinking along the lines of
self.parent.Update()
Dec 2 '06 #4
I was thinking along the lines of
self.parent.Update()
ah... ok then... ill give that a whirl :-)


Watch this space...


mark
Dec 2 '06 #5
bartonc
6,596 Expert 4TB
ah... ok then... ill give that a whirl :-)


Watch this space...


mark
This space? This thread?
Dec 3 '06 #6
This space? This thread?
Lol...

Sorry - i got frustrated last night and just went to bed.

Couldnt get it working :-(

I know the variables are being updated as i created a push button -> change label to a variable test panel and it works fine. The problem is in actually re-building the panels... if that makes sense?


ARGH!


Mark
Dec 3 '06 #7
bartonc
6,596 Expert 4TB
Lol...

Sorry - i got frustrated last night and just went to bed.

Couldnt get it working :-(

I know the variables are being updated as i created a push button -> change label to a variable test panel and it works fine. The problem is in actually re-building the panels... if that makes sense?


ARGH!


Mark
If I get some time soon, I'll add a button to a panel dynamically so I know more about what you are going through.
Dec 3 '06 #8
If I get some time soon, I'll add a button to a panel dynamically so I know more about what you are going through.
Much appreciated! Thanks :-)


Mark
Dec 4 '06 #9
bartonc
6,596 Expert 4TB
If I get some time soon, I'll add a button to a panel dynamically so I know more about what you are going through.
The trick that I've decided to use is
Expand|Select|Wrap|Line Numbers
  1. self.thisButton.Hide()
on startup and
Expand|Select|Wrap|Line Numbers
  1. self.thisButton.Show()
when I want it visible.

The latter may work on a newly created object, as well.
Apr 15 '07 #10
bartonc
6,596 Expert 4TB
The trick that I've decided to use is
Expand|Select|Wrap|Line Numbers
  1. self.thisButton.Hide()
on startup and
Expand|Select|Wrap|Line Numbers
  1. self.thisButton.Show()
when I want it visible.

The latter may work on a newly created object, as well.
And if you are trying to show one widget on top of an other:

In the constructor, let the bottom widget be created first. Then let that widget own the (be the parent of) the floater:
Expand|Select|Wrap|Line Numbers
  1. # in __init__()
  2.  
  3.         self.grid1 = SingleRowGrid(id=wxID_SEGMENTCOVERSHEETGRID1, name='grid1', parent=self,
  4.                 pos=wx.Point(0, 0), size=wx.Size(602, 398), style=0)
  5.         self.grid1.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnGridCellLeftClick)
  6.  
  7.         self.DatePicker = wx.DatePickerCtrl(id=wxID_SEGMENTCOVERSHEETDATEPICKER,
  8.                 name='datePickerCtrl1', parent=self.grid1, pos=wx.Point(200, 31), size=wx.Size(100,
  9.                 28),
  10.                 style=wx.SIMPLE_BORDER | wx.DP_SHOWCENTURY | wx.DP_DROPDOWN)
  11.         self.DatePicker.Raise()
  12.         self.DatePicker.Hide()
Then, when you want the control shown:
Expand|Select|Wrap|Line Numbers
  1. #
  2.     def ActivateDatePicker(self):
  3.         self.DatePicker.Refresh()
  4.         self.DatePicker.Update()
  5.  
  6.     def OnDatePickerDateChanged(self, event):
  7.         date = event.GetDate().FormatDate()
  8.         self.DatePicker.Hide()
  9.         self.grid1.SetCellValue(0, 0, date)
  10.         event.Skip()
  11.  
  12.     def OnGridCellLeftClick(self, event):
  13.         row = event.GetRow()
  14.         if row == 0:
  15.             self.DatePicker.Show()
  16.             wx.FutureCall(10, self.ActivateDatePicker)
  17.         else:
  18.             self.DatePicker.Hide()
  19.             event.Skip()
Oct 10 '07 #11

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

Similar topics

0
by: Ryan Moore | last post by:
I have a Panel which I am adding a series of ActiveX images to (http://nctsoft.com/products/NCTImageStudio/), and when I put the "AutoScroll" property on, the panel does not seem to refresh...
1
by: Amy | last post by:
What's different between Controls method Refresh() and Invalidate(), Refresh() and Update()? Your help will be appreciated. Thanks.
2
by: Kevin Chandler | last post by:
I appologize in advance if this is a novice question. I don't have much ASP.Net experience. I have an NCAA tournment selection page that I use asp:button controls. The problem is that...
1
by: Christopher Shanahan | last post by:
Hello, I've built a data entry form for a survey database that appears to make the entire form flicker when I mouse over anyn of the label controls. I suspect that it has to do with the...
2
by: Ivan | last post by:
I have a class Foo which have two property. I have a thread that do some process and update class Foo int B. I have a datagridview on main form. this datagridview data source to this class Foo and...
3
by: citronelu | last post by:
Hi, I'm new to wxpython, and the following code is my first serious attempt: #~ start code import wx class MyPanel(wx.Panel):
6
by: Garima12 | last post by:
There is a update panel,gridview and update progress. fetching the data from database and filling in gridview. at the time of processing update progress is working and showing processing........ My...
3
by: asfmendes | last post by:
Hello everyone! I am creating a C# application for tablet pcs and I want to animate some strokes. I am moving the strokes and, after each move, I want to reflect that move in the screen. However,...
0
by: Souleiman | last post by:
Hello everybody, i have a script that goes to one website of mine, checks if there is a code available(using urllib2), then, by using wxpython prints the code availability status. Is there any...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.