[wxPython] wxPython application template

Hi All -

I recently created a simple wxPython application template, which includes
scripts for Gordon McMillan's Installer and Inno Setup to use as a base
for several projects.

I thought it might be of use to others, so I've uploaded it to:

http://www.best1.net/~mmc/wxTemplate.zip

Questions or comments are welcome...

Miles

Thank you VERY much--if this is as useful as I imagine it will be then it'll
be a great time-saver for people like me working on a project that is yet to
be released/finalised...

Chris Fama

···

-----Original Message-----
From: wxpython-users-admin@wxwindows.org
[mailto:wxpython-users-admin@wxwindows.org]On Behalf Of Miles Clark
Sent: Saturday, 15 July 2000 10:25 AM
To: wxpython-users@wxwindows.org
Subject: [wxPython] wxPython application template

Hi All -

I recently created a simple wxPython application template, which includes
scripts for Gordon McMillan's Installer and Inno Setup to use as a base
for several projects.

I thought it might be of use to others, so I've uploaded it to:

http://www.best1.net/~mmc/wxTemplate.zip

Questions or comments are welcome...

Miles

_______________________________________________
wxPython-users mailing list wxPython-users@wxwindows.org
http://wxwindows.org/mailman/listinfo/wxpython-users

Hi all,

I'm making a little drawing canvas class (ultimately, I'd like it to
have a lot of the features of the TK canvas, but I'm starting small).
The idea is to set up a way to draw to the screen without having to
think about all the OnPaint event stuff. the canvas will store the
object that you want drawn, and handle the drawing itself, double
buffered and all. In the long run, I think this kind of high level
canvas could be very usefull, and someone might even want to port it to
C++ eventually, to get some speed advantages. If anyone wants to help
out, let me know.

In the meantime, I have an actual question:

I found myself building a dictionary of all the pens and brushes that I
need to draw the objectys, so I don't have to re-create them each time.
Then I took a closer look at the wxWin docs, and found that wxWin
allready does this, with wxTheBrushList. So the question is, when I
create a brush with wxPython, is wxBrushList::FindOrCreateBrush used, or
is it, in fact, a good idea for me to keep my own brush list. In code
form, is there any advantage to using:

# get the brush from the brush dictionary
dc.SetBrush(self.Brushlist[(FillColor,FillStyle)])

over:
# create a new brush
dc.SetBrush(wxBrush(wxColor(FillColor),wxStyle))

And, of course the same thing for pens.

Thanks, Chris

···

--
Christopher Barker,
Ph.D.
cbarker@jps.net --- --- ---
http://www.jps.net/cbarker -----@@ -----@@ -----@@
                                   ------@@@ ------@@@ ------@@@
Water Resources Engineering ------ @ ------ @ ------ @
Coastal and Fluvial Hydrodynamics ------- --------- --------
------------------------------------------------------------------------
------------------------------------------------------------------------

I don't want to discourage you, but have you checked out piddle
[http://piddle.sourceforge.net/\]. It seems like it would do a lot of what you
want. At the very least you could probably steal some ideas from it....

Oh, and in case you didn't notice, I have no useful information on brush
lists.

-tim

···

On Tue, 22 Aug 2000, you wrote:

Hi all,

I'm making a little drawing canvas class (ultimately, I'd like it to
have a lot of the features of the TK canvas, but I'm starting small).
The idea is to set up a way to draw to the screen without having to
think about all the OnPaint event stuff. the canvas will store the
object that you want drawn, and handle the drawing itself, double
buffered and all. In the long run, I think this kind of high level
canvas could be very usefull, and someone might even want to port it to
C++ eventually, to get some speed advantages. If anyone wants to help
out, let me know.

In the meantime, I have an actual question:

I found myself building a dictionary of all the pens and brushes that I
need to draw the objectys, so I don't have to re-create them each time.
Then I took a closer look at the wxWin docs, and found that wxWin
allready does this, with wxTheBrushList. So the question is, when I
create a brush with wxPython, is wxBrushList::FindOrCreateBrush used, or
is it, in fact, a good idea for me to keep my own brush list. In code
form, is there any advantage to using:

# get the brush from the brush dictionary
dc.SetBrush(self.Brushlist[(FillColor,FillStyle)])

over:
# create a new brush
dc.SetBrush(wxBrush(wxColor(FillColor),wxStyle))

And, of course the same thing for pens.

Thanks, Chris

--

regards,

Tim Hochberg

Hochberg & Associates | (tim.hochberg@ieee.org)|

Then I took a closer look at the wxWin docs, and found that wxWin
allready does this, with wxTheBrushList. So the question is, when I
create a brush with wxPython, is wxBrushList::FindOrCreateBrush used, or
is it, in fact, a good idea for me to keep my own brush list.

wxPython uses the builtin lists and FindOrCreate methods for pens, brushes
and fonts.

In code
form, is there any advantage to using:

# get the brush from the brush dictionary
dc.SetBrush(self.Brushlist[(FillColor,FillStyle)])

over:
# create a new brush
dc.SetBrush(wxBrush(wxColor(FillColor),wxStyle))

There could be some (maybe minor) advantages in keeping your own dictionary.
I expect that searching the dictionary by hash code will be faster than
searching a linear list as is done in the C++ code. Also you will save the
creation of a new Python shadow object.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com
http://wxpython.org Java give you jitters?
http://wxpros.com Relax with wxPython!

I'll second the piddle recommendation. It's very useful for doing drawing operations and has the added advantage of allowing (for free!) exports to PS, PDF, PIL, etc.

-greg

···

At 11:14 AM 8/22/2000 +0000, Tim Hochberg wrote:

I don't want to discourage you, but have you checked out piddle
[http://piddle.sourceforge.net/\]. It seems like it would do a lot of what you
want. At the very least you could probably steal some ideas from it....

----
greg Landrum (greglandrum@earthlink.net)
Software Carpenter/Computational Chemist

Greg Landrum wrote:

>I don't want to discourage you, but have you checked out piddle
>[http://piddle.sourceforge.net/\]. It seems like it would do a lot of what you
>want. At the very least you could probably steal some ideas from it....

I'll second the piddle recommendation. It's very useful for doing drawing
operations and has the added advantage of allowing (for free!) exports to
PS, PDF, PIL, etc.

Feel free to discourage me, if what I want is already in existance, I
don't want to re-write it!

I have checked out Piddle, and it doesn't seem to be what I want. As far
as I can tell, it is designed to allow drawing to a number of devices
with the same calls, which is a pretty nice feature, but doesn't allow
other high level things that I'm looking for, such as keeping the
drawing objects around so that they can be changed, deleted, etc. I may
be wrong about this, I'll look at it some more!

In a way, wxOGL is closer to what I want, but seems oriented towards
drawing a particular type of diagram, not drawing in general.

In the long run, I'd like my drawing canvas to have features like
allowing any units, rather than pixels, and the ability to group
objects, etc.

I havn't tried it, but can't you use the wxPostscriptDC to write
postscript, and there must be a way to get a MemoryDC into PIL.

Anyway, I'll take a closer look at Piddle. I am interested in Graphite
as well, which used Piddle, so I have other reasons to check it out.

-Chris

···

--
Christopher Barker,
Ph.D.
cbarker@jps.net --- --- ---
http://www.jps.net/cbarker -----@@ -----@@ -----@@
                                   ------@@@ ------@@@ ------@@@
Water Resources Engineering ------ @ ------ @ ------ @
Coastal and Fluvial Hydrodynamics ------- --------- --------
------------------------------------------------------------------------
------------------------------------------------------------------------

Robin Dunn wrote:

wxPython uses the builtin lists and FindOrCreate methods for pens, brushes
and fonts.

> In code
> form, is there any advantage to using:
>
> # get the brush from the brush dictionary
> dc.SetBrush(self.Brushlist[(FillColor,FillStyle)])
>
> over:
> # create a new brush
> dc.SetBrush(wxBrush(wxColor(FillColor),wxStyle))
>
>

There could be some (maybe minor) advantages in keeping your own dictionary.
I expect that searching the dictionary by hash code will be faster than
searching a linear list as is done in the C++ code. Also you will save the
creation of a new Python shadow object.

how big a process is it to create a shadow object? and if I create
another Pen that is the same, do I get another shadow object, or a
reference to one that exists?

As it turns out, I've now got the code stroing a reference to the pen in
the object, so I don't even have to do a look-up when I draw. This may
be unneeded effort, but it seems clean to me, and should be as fast as
possible, even if it makes little difference.

-Chris

···

--
Christopher Barker,
Ph.D.
cbarker@jps.net --- --- ---
http://www.jps.net/cbarker -----@@ -----@@ -----@@
                                   ------@@@ ------@@@ ------@@@
Water Resources Engineering ------ @ ------ @ ------ @
Coastal and Fluvial Hydrodynamics ------- --------- --------
------------------------------------------------------------------------
------------------------------------------------------------------------

I'm making a little drawing canvas class (ultimately, I'd like it to
have a lot of the features of the TK canvas, but I'm starting small).

As an FYI, the same day you sent this message there was some talk on
wx-devel about creating a canvas-like object for wxWindows. You can read
the thread starting here:
http://wxwindows.org/pipermail/wx-devel/2000-August/005574.html

It was suggested to look at GtkCanvas for ideas,

It would certainly be a cool thing to have, and would squash the last big
complaint from Tkinter converts.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com
http://wxpython.org Java give you jitters?
http://wxpros.com Relax with wxPython!

how big a process is it to create a shadow object?

Compared to dictionary access it is fairly expensive. An allocation for the
instance object, an allocation for its namespace dictionary, calling the
__init__ method, etc.

and if I create
another Pen that is the same, do I get another shadow object, or a
reference to one that exists?

A new one.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com
http://wxpython.org Java give you jitters?
http://wxpros.com Relax with wxPython!

Robin Dunn wrote:

> how big a process is it to create a shadow object?

Compared to dictionary access it is fairly expensive. An allocation for the
instance object, an allocation for its namespace dictionary, calling the
__init__ method, etc.

> and if I create
> another Pen that is the same, do I get another shadow object, or a
> reference to one that exists?

A new one.

Thanks,

This makes it sound like it is a good idea to create my own Brush and
Pen lists. It might make a difference when there are a lot of objects to
draw.

Hopefully, I can drop this whole thing, and we will get a
wxCanvas...YEAHH. I'll go check that list. Maybe it's time for me to
join wx-devel.

-Chris

···

--
Christopher Barker,
Ph.D.
cbarker@jps.net --- --- ---
http://www.jps.net/cbarker -----@@ -----@@ -----@@
                                   ------@@@ ------@@@ ------@@@
Water Resources Engineering ------ @ ------ @ ------ @
Coastal and Fluvial Hydrodynamics ------- --------- --------
------------------------------------------------------------------------
------------------------------------------------------------------------