gnumed-devel
[Top][All Lists]
Advanced

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

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


From: Richard Terry
Subject: [Gnumed-devel] sizers as requested -but I'm sure you know this already
Date: Tue, 22 Feb 2005 07:57:47 +1100
User-agent: KMail/1.5.4

On Mon, 21 Feb 2005 06:59 pm, Karsten Hilbert wrote:
> > I've also learnt some interesting things about sizers and how they
> > behave, none of which is intuitive.
>
> Would you mind sharing ?

Not at all, but I suspect this is a waste of time and  nothing that you don't 
already know, nor others including Horst, or Ian who would have figured this 
out during his time doing the plugins.  It is something that never dawned on 
me and has to do with adding/deleting/hiding panels on the one sizer.

The main problem I have with programming is a conceptual one.  Because I am a 
visual person and am not terriblly good at logic or using words to describe 
things, I have to see the image of what I am doing in my head before I can 
grasp what to do. Probably why I ask so many obtuse questions and why I've 
never got into programming this language, but loved VB. I can read the same 
language reference guide over 50 times and still not understand it.

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()

So, not rocket science, something any intelligent programmer would understand 
from reading the doc's, but unfortunately not me!!!!!

Regards

Richard






reply via email to

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