On Sun, Jan 15, 2012 at 5:22 PM, Mike Driscoll > > > > <mike@pythonlibrary.org > > > > > wrote:
>
>
> On Sun, Jan 15, 2012 at 3:49 AM, Gadget/Steve > > > > <GadgetSteve@live.co.uk> > > > > > > > > > wrote:
>>
>> On 15/01/2012 2:27 AM, Jonno wrote:
>> > Steve,
>> >
>> > This morning while driving I came to
that conclusion. The only thing
>> > I'm not sure about is that I won't
know the size of an array when I
>> > create the data object in the
parent.
>> >
>> >
>> Luckily enough since you are programming
in python that is not a
>> problem, you can either create it as an
empty array and append to it
>> when you do know, create it as an object
of type None initially and then
>> create it as an array when you know the
size or assuming it is currently
>> created by one of the child frames during
it’s initialisation you can
>> still create it in the same place but as
a member of the parent. If you
>> do either of the first two then you need
to make sure that the methods
>> that access it can cope with the
possibility that they might be called
>> before the array is populated.
>>
>> If it is not naturally a resizeable array
then you can probably also
>> move the method that determines the size
of the array to the parent as
>> well.
>>
>> You might also like to take a look at
some of the discussions in this
>> newsgroup, the python newsgroup, and
several others about the benefits
>> of separation of the user interface from
the data and methods, while it
>> seems like an obtuse subject at times it
is actually very good practice,
>> [blasphemy warning] allows for the
possibility that you may have to use
>> a different user interface model, e.g.
command line, QT, gtk, etc., at
>> some time in the future if necessary
because of customer or other
>> requirements [end blasphemy], gives a
clear separation between the data,
>> the processing and the user interface and
will often result in a better
>> design.
>>
>> Sorry to be preaching this early on a
Sunday morning, (thinking about it
>> what better time), but I have found that
the benefits are enormous from
>> following these principles. To give you
an example the current
>> Python/wxPython based project that I am
working on has multiple user
>> interfaces, (32), as multiple uses of the
code but 95% of the code is
>> common across the applications, there are
296 source files totalling 2.5
>> Megabytes but less than 60 import wx and
several of those only do so to
>> provide unit test interfaces.
>>
>> The other nice point that often arises
late in a project is when they
>> say something along the lines of "Very
nice GUI but we now need the main
>> processing to run in a
background/batch/scheduled/remote task and just
>> control it from/get the results via the
GUI" if the code and data are
>> tightly bound together this is a major
task if they are not it is
>> usually (almost) trivial.
>>
>> Gadget/Steve
>>
>>
>
> Werner and I created the MediaLocker project
to show one way to separate out
> the Model-View-Controller paradigm for
wxPython users. We use pubsub a lot
> too. You can check it out here: [http://www.medialocker.pythonlibrary.org/](http://www.medialocker.pythonlibrary.org/)
>
> --
> -----------------