gnumed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnumed-devel] sizers as requested -but I'm sure you know this alrea


From: catmat
Subject: Re: [Gnumed-devel] sizers as requested -but I'm sure you know this already
Date: Wed, 23 Feb 2005 00:51:04 +1100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041231

Richard Terry wrote:



Its around the behaviour of sizers when objects are added to them. When one is learning one has a sizer eg;

sizer = wx.BoxSizer(wx.VERTICAL)
panel1 = wx.Panel(self,ID_PANEL1)
panel2 = wx.Panel(self,D_PANEL2)
panel3 = wx.Panel(self,D_PANEL3)
panel4 = wx.Panel(self,D_PANEL4)
panel5 = wx.Panel(self,D_PANEL5)
panel6 = wx.Panel(self,D_PANEL6)

In this example, lets assume all the panels are part of an array (in the code I've just typed I've not bothered to type this) and that you want to 'overlay' or 'swap' one panel for another. To my amazement it is as simple as the code below demonstrates, which I'm sure would have to be identical to that already in gnuMed and used by Ian, however I'm a slow slow slow learner and have to do things slowly to understand them.
        
#------------------------------------------------------------------------------------
#swaps the displayed panel in and out of the central area
#called from the main toolbar EVT_CLICK
#ie: self.Bind(wx.EVT_TOOL,self.SwapPanel, id=ID_SECTION_SUMMARY) #as an example
#works on all buttons on the toolbar to display clinical sections
#------------------------------------------------------------------------------------
def SwapPanel(self,event):
    if event.GetId() <> self.CURRENT_SECTION_ID:
        self.PREVIOUS_SECTION_ID = self.CURRENT_SECTION_ID
        self.CURRENT_SECTION_ID = event.GetId()
        self.sizer_centrepanel.Hide(self.CentralPanel[self.PREVIOUS_SECTION_ID])
        self.sizer_centrepanel.Show(self.CentralPanel[self.CURRENT_SECTION_ID])
        self.sizer_centrepanel.Layout()

This is simple, however the thing that I didn't realise is that it really doesn't matter what is sitting on a sizer and is hidden, even if the panels are all different sizes and shapes or even if the object is another sizer.

For example you can remove/hide a single panel which may have composite controls stuck onto it as one would expect, but instead of having to put in it splace an identically sized single panel with multiple controls, you can put on multiple panels or sizers which will then take up the same equivalent area.

So here in the precsription section, where I have a sizer holding a section heading, editing area bla, bal, I can hide these one by one, replace with a single panel, and when finished, I can do the reverse (or if I wanted to change the order of them, or not rehide some and get a different display).
#---------------------------------------------------------
#Show dummy file of brief product information
#----------------------------------------------------------
def  ShowBriefProductInformation(self,evt):
                self.briefPI_filename ='./html/BriefPI_Losec.html'
                self.briefPI_drugname = " Losec "
                self.pi_html.LoadPage(self.briefPI_filename)
                self.pi_heading.SetCaption(self.briefPI_drugname)
                self.sizer_main.Hide(self.sectionheading)
                self.sizer_main.Hide(self.sizer_authorityarea)
                self.sizer_main.Hide(self.editarea)
                self.sizer_main.Hide(self.sizer_interactionsummary)
                self.sizer_main.Hide(self.sizer_meds)
                self.sizer_main.Show(self.sizer_briefPI)
                self.sizer_main.Layout()

thanks, I didn't know that.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]