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...
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
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...
Code:
from Initials import *
import wx
import os
from Wizard import *
class MainFrame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, title)
icon = wx.Icon("icon.ico", wx.BITMAP_TYPE_ICO)
self.SetIcon(icon)
### Create Main Panel & Sizer ###
self.mainPanel = wx.Panel(self)
self.mainPanel.SetBackgroundColour((225,245,255))
mainSizer = wx.BoxSizer(wx.VERTICAL)
### IMPORT VARIABLES LIST FROM INITIALS.PY ###
self.vars = VariablesData()
self.variables = self.vars.GetVariables()
### Create Various Panels ###
self.titlePanel = TitlePanel(self.mainPanel, wx.HORIZONTAL, self.variables)
self.controlPanel = ControlPanel(self.mainPanel, wx.HORIZONTAL, self.variables)
self.actionPanel = ActionPanel(self.mainPanel, wx.HORIZONTAL, self.variables)
self.CreatemenuBar()
self.CreateStatusBar()
mainSizer.Add(self.titlePanel.panel, 2, wx.ALIGN_LEFT | wx.EXPAND | wx.ALL, 5)
mainSizer.Add(self.controlPanel.panel, 5, wx.EXPAND | wx.LEFT | wx.RIGHT, 5)
mainSizer.Add(self.actionPanel.panel, 2, wx.EXPAND | wx.ALL, 5)
self.mainPanel.SetSizer(mainSizer)
mainSizer.Fit(self) # Fit frame to neccessary size
mainSizer.SetSizeHints(self) # Prevents frame from getting smaller than min.
.
.
.
class NewPanel():
def __init__(self, parent, Orientation, variables):
self.variables = variables
self.panel = wx.Panel(parent)
self.sizer = wx.BoxSizer(Orientation)
self.AddItems(self.variables)
self.panel.SetSizer(self.sizer)
self.sizer.Fit(self.panel) # Fit frame to neccessary size
self.sizer.SetSizeHints(self.panel) # Prevents frame from getting smaller than min.
.
.
.
class ControlPanel(NewPanel):
def AddItems(self, variables):
self.variables = variables
self.automaticPanel = AutomaticPanel(self.panel, wx.VERTICAL, variables)
self.modePanel = ModePanel(self.panel, wx.VERTICAL, variables)
self.manualPanel = ManualPanel(self.panel, wx.HORIZONTAL, variables)
self.sizer.Add(self.automaticPanel.panel, 6, wx.EXPAND)
self.sizer.Add(self.modePanel.panel, 3, wx.EXPAND | wx.LEFT | wx.RIGHT, 5)
self.sizer.Add(self.manualPanel.panel, 5, wx.EXPAND)
.
.
.
class ManualPanel(NewPanel):
def AddItems(self, variables):
self.variables = variables
self.box = wx.StaticBox(self.panel, -1, 'Manual Control')
self.box.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD, False))
self.sizer = wx.StaticBoxSizer(self.box, wx.HORIZONTAL)
self.bristlePanel = BristlePanel(self.panel, wx.VERTICAL, variables)
self.cylinderPanel = CylinderPanel(self.panel, wx.VERTICAL, variables)
self.sizer.Add(self.bristlePanel.panel, 1, wx.EXPAND)
self.sizer.Add(self.cylinderPanel.panel, 1, wx.EXPAND)
class BristlePanel(NewPanel):
def AddItems(self, variables):
self.variables = variables
self.bristleCheckBox = []
for x in range(0, self.variables['bristles']):
self.bristleCheckBox.insert(x, (wx.CheckBox(self.panel, -1, "Bristle %d" % (x+1))))
self.sizer.Add(self.bristleCheckBox[x], 1, wx.ALIGN_CENTER_HORIZONTAL)
class CylinderPanel(NewPanel):
def AddItems(self, variables):
self.variables = variables
self.cylinderCheckBox = []
for x in range(0, self.variables['cylinders']):
self.cylinderCheckBox.insert(x, (wx.CheckBox(self.panel, -1, "Cylinder %d" % (x+1))))
self.sizer.Add(self.cylinderCheckBox[x], 1, wx.ALIGN_CENTER_HORIZONTAL)
.
.
.
class wxPyApp(wx.App):
def OnInit(self):
frame = MainFrame(None, "DPT - Sequence Driven Controller")
self.SetTopWindow(frame)
frame.Show(True)
frame.Center(wx.BOTH)
return True
if __name__ == '__main__': # Only runs if program is being executed, not imported
app = wxPyApp(redirect=True)
app.MainLoop()
Its the Bristle & Cylinder Panels im having the issue with
Any help would be greatly appreciated!
Thanks,
Mark
Comment