Re: [wxpython-users] Py works, EXE doesn't here is stripped program, someone else verify please.
by Steve Freedenburg other posts by this author
Jul 18 2008 11:35PM messages near this date
Re: [wxpython-users] Py works, EXE doesn't here is stripped program, someone else verify please.
|
Re: [wxpython-users] Py works, EXE doesn't here is stripped program, someone else verify please.
Ok Tim,
I think I'm getting it. What you have there is a list, and in that list
are x amount of dictionairies.
x = the number of chat containers I have, in my case it's 6... could be 10,
or 50....
and the way you have the dictionairies set up, would help in creating
the instance in a given
frame. One class or method that creates 6 frames.... instead of 6 classes
that create a frame each, and the
construction of the frames is pretty much identical.
And how this gets rid of global variables is by creating those lists
with the self.List in a given method
in a given class, this list can be accessed from anywhere in the class. As
far as how to access a list from another
class I'm not 100% on, however if the class is called MyClass, then I can
access that class from another class
by defining it as self.MyClass = MyClass(class specific attribs here if any)
so something like this:
Class X()
self.ClassY = ClassY()
ClassY()
self.searchstringtuple = ['x', 'y', 'z']
with something like that, anything defined as self in ClassY is also
available in ClassX because ClassY is defined as self there too?
Wow... I hope I'm not wrong because THAT there is what is holding me back
in Python. My "understanding"
of inheritance (right? inheritance) is slanted. Not so much I couldn't
get around in
----- Original Message -----
From: "Tim Roberts" <timr@[...].com>
To: <wxpython-users@[...].org>
Sent: Friday, 18 July, 2008 14:16
Subject: Re: [wxpython-users] Py works, EXE doesn't here is stripped
program, someone else verify please.
> Steve Freedenburg wrote:
> >
> > I will attach the py file, the configuration file that TopiView makes
> > when the user
> > sets it up, so you can see that too, the "help" file which is as close
> > to a __doc__
> > as could be, and a short wav file that will play when TopiView matches a
> > search string. Small files really, maybe 85kb.
>
> But, can't you see how wasteful this code is? If you want to add a 7th
> string, you have to make modifications ALL over the file. Wouldn't it be
> obviously better to make this all a data structure:
>
> SearchStuff = [
> {
> 'font': '0;-13;0;0;0;400;0;0;0;0;3;2;1;34;Arial',
> 'color': wx.BLACK,
> 'label': 'Your Label Here',
> 'search': 'Search String',
> 'soundpath': 'Not specified',
> 'soundfile': Not specified
> },
> {
> 'font': '0;-13;0;0;0;400;0;0;0;0;3;2;1;34;Arial',
> 'color': wx.BLACK,
> 'label': 'Your Label Here',
> 'search': 'Search String',
> 'soundpath': 'Not specified',
> 'soundfile': Not specified
> },
> ...
> ]
>
> Now, instead of doing everything 6 times, you can do things once, in a
> loop:
> for stuff in SearchStuff:
> stuff['container'] = wx.MenuItem( Containers, -1, stuff['name'],
> 'View or hide', wx.ITEM_CHECK );
> Containers.AppendItem( stuff['container'] )
>
> and so on.
>
> If it were me, I would actually create a new class to hold all of this
> information, and create six instances of the class. That would make it
> even cleaner.
>
> ANY time you find yourself writing the same code more than once, you need
> to think about how a data structure could help that.
>
> --
> Tim Roberts, timr@[...].com
> Providenza & Boekelheide, Inc.
>
> _______________________________________________
> wxpython-users mailing list
> wxpython-users@[...].org
> http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
>
_______________________________________________
wxpython-users mailing list
wxpython-users@[...].org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Thread:
Steve Freedenburg
Werner F. Bruhin
Steve Freedenburg
Steve Freedenburg
Steve Freedenburg
Werner F. Bruhin
Steve Freedenburg
Werner F. Bruhin
Steve Freedenburg
Tim Roberts
|