POLL: wx.DC methods

Chris Barker wrote:

Robin Dunn wrote:

>>> pt = wx.Point(11,22)
>>> pt = pt + (7,0)
>>> print repr(pt)
wx.Point(18, 22)

By the way, where does that come from? in the wxWidgets docs (at least the 2.4.2 ones) wxPoint is just a simple structure.

See about half-way down this page for the C++ definition:

http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/include/wx/gdicmn.h?rev=1.79&content-type=text/vnd.viewcvs-markup

And about half-way down this one for the definifion for the Python wrappers:

http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/wxPython/src/_gdicmn.i?annotate=1.12

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Chris Barker wrote:

Jeff Grimmett wrote:

Chris Barker wrote:

I'm assuming that the docs can be and will be corrected. If not, then you have a very good point, but also if not, that's really pathetic!

I wouldn't call it 'pathetic'. I would call it 'typical for large projects'.

That was harsh, but my point is that it shouldn't take any more work to add those methods to the docs than we have just spent in this discussion. I'm a little confused, as I thought the docs were mostly auto-generated anyway,

The C++ docs are all hand-written with a subset of LaTex and converted to html and other formats by tex2rtf. The Python docs will be auto-generated.

so all the methods should be there. If someone points me to the right file to edit, I'll add the DC methods myself.

It's all in CVS. Doc patches are usually accepted without complaint.

http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/docs/latex/wx/
http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/utils/tex2rtf/

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

It's all in CVS. Doc patches are usually accepted without complaint.

http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/docs/latex/wx/
http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/utils/tex2rtf/

I've just taken a look, and see this in the doc source:

% VZ: we should really document them instead of this lame excuse, but I don't
% have time for it now, when it is done please remove this
Please note that in addition to the versions of the methods documented here,
there are also versions which accept single {\tt wxPoint} parameter instead of
two {\tt wxCoord} ones or {\tt wxPoint} and {\tt wxSize} instead of four of
them.

So at least this is a known issue....

Now I just need to find where in the source these methods are all defined, so that I can make sure I put it correctly in the docs. I can probably find them myself, but didn't on a quick look...C++ confuses the heck out of me, and this is a pretty darn complex C++ lib.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Chris Barker wrote:

Robin Dunn wrote:

It's all in CVS. Doc patches are usually accepted without complaint.

http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/docs/latex/wx/
http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/utils/tex2rtf/

I've just taken a look, and see this in the doc source:

% VZ: we should really document them instead of this lame excuse, but I don't
% have time for it now, when it is done please remove this
Please note that in addition to the versions of the methods documented here,
there are also versions which accept single {\tt wxPoint} parameter instead of
two {\tt wxCoord} ones or {\tt wxPoint} and {\tt wxSize} instead of four of
them.

So at least this is a known issue....

Now I just need to find where in the source these methods are all defined, so that I can make sure I put it correctly in the docs. I can probably find them myself, but didn't on a quick look...C++ confuses the heck out of me, and this is a pretty darn complex C++ lib.

wxWidgets/include/wx/dc*.h

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Just curious, is there any difference between wxPython calls using
TypeA (tuple argument) model and TypeB (individual arguments) model?

Specifically, does one incur more overhead than the other? Also,
is wxPython 2.5 handling this differently, compared to earlier
releases?

/Jean Brouwers
  ProphICy Semiconductor, Inc.

Chris Barker wrote:

···

Robin Dunn wrote:

It's all in CVS. Doc patches are usually accepted without complaint.

http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/docs/latex/wx/
http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/utils/tex2rtf/

I've just taken a look, and see this in the doc source:

% VZ: we should really document them instead of this lame excuse, but I don't
% have time for it now, when it is done please remove this
Please note that in addition to the versions of the methods documented here, there are also versions which accept single {\tt wxPoint} parameter instead of two {\tt wxCoord} ones or {\tt wxPoint} and {\tt wxSize}
instead of four of them.

So at least this is a known issue....

Now I just need to find where in the source these methods are all defined, so that I can make sure I put it correctly in the docs. I can probably find them myself, but didn't on a quick look...C++ confuses the heck out of me, and this is a pretty darn complex C++ lib.

-Chris

Peter Damoc wrote:

> Err, I have static class members with ids all over the
> place (the opposite of your statement). This is necessary
> to hook toolbar buttons to the same menu ids, or where I
> have widgets in HTML files that need to trigger an action.

well I don't think they are absolutely necessary :D,

I think this is far more readable, and is how my code is
actually structured:

  class FooFrame(wx.Frame):
      ID_FILE_OPEN=wx.NewId()
      ID_FILE_DELETE=wx.NewId()

      def __init__(...):
          ...
          menu.Append(self.ID_FILE_DELETE, "&Delete", "Delete the file")
          ....
          toolbar.AddLabelTool(self.ID_FILE_DELETE, "Delete", ....)
          ....
          wx.EVT_MENU(self, self.ID_FILE_DELETE, self.OnFileDelete)
          ....
          wx.EVT_BUTTON(self, self.ID_FILE_DELETE, self.OnFileDelete)
          ....

       def OnStateChange(...):
          ....
          self.GetToolBar().EnableTool(self.ID_FILE_DELETE, True)
          ....

In my HTML:

   <wxp class="Button" module="wx">
   <param name="label" value="Delete ..."/>
   <param name="id" value="gui.FooFrame.ID_FILE_DELETE"/>
   </wxp>

I could introduce all sorts of mapper classes and other funky stuff,
but way prefer the above, where it is *VERY* clear what is going
on.

Riger

···

On Thu, 22 Apr 2004 12:06:32 -0700, Roger Binns <rogerb@rogerbinns.com> > wrote:

Jean Brouwers wrote:

Just curious, is there any difference between wxPython calls using
TypeA (tuple argument) model and TypeB (individual arguments) model?

Specifically, does one incur more overhead than the other?

Only the overhead of converting a sequence to a wx.Point or wx.Size if it isn't already a point or size. Both C++ methods will then call the same DoDrawWhatever method.

Also,
is wxPython 2.5 handling this differently, compared to earlier
releases?

Handling what differently, converting sequences to the basic classes? That has been in wxPython for years. The only thing about it that changed were dealing with new-style Python classes.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin,

Previous releases of wxPython often use (*args, **kwds) for method
argument lists. Does 2.5 still use the same 'generic' style or are
the arguments spelled out? The doc samples you showed the other day
seem to indicate the latter.

Btw, those docs are outstanding!

/Jean Brouwers
  ProphICy Semiconductor, Inc.

Robin Dunn wrote:

···

Jean Brouwers wrote:

Just curious, is there any difference between wxPython calls using
TypeA (tuple argument) model and TypeB (individual arguments) model?

Specifically, does one incur more overhead than the other?

Only the overhead of converting a sequence to a wx.Point or wx.Size if it isn't already a point or size. Both C++ methods will then call the same DoDrawWhatever method.

Also,
is wxPython 2.5 handling this differently, compared to earlier
releases?

Handling what differently, converting sequences to the basic classes? That has been in wxPython for years. The only thing about it that changed were dealing with new-style Python classes.

Chris Barker wrote:

I'm assuming that the docs can be and will be corrected. If not, then you have a very good point, but also if not, that's really pathetic!

I wouldn't call it 'pathetic'. I would call it 'typical for large projects'.

That was harsh, but my point is that it shouldn't take any more work to add those methods to the docs than we have just spent in this discussion. I'm a little confused, as I thought the docs were mostly auto-generated anyway, so all the methods should be there. If someone points me to the right file to edit, I'll add the DC methods myself.

I don't think anyone took it as a slam in general, and that sort of rhetoric is common anyway, but I did want to lend some perspective to it. Having managed some moderate sized projects myself, as well as being on teams doing much larger projects, I know all to well how it can happen. I don't like it, but I know how it can. In the case of my own projects, I've beat myself up on it more than anyone else could, but with x hours in the day and x+1 hours worth of bugfixes etc to crank out, stuff like that happens.

As for editing them, I suspect that would be duly appreciated :slight_smile:

... "I believe I will take this opportunity to remove my ears."

Chris Barker wrote:

Now I just need to find where in the source these methods are all defined, so that I can make sure I put it correctly in the docs. I can probably find them myself, but didn't on a quick look...C++ confuses the heck out of me, and this is a pretty darn complex C++ lib.

I've found a good grep util with recursive searching to be an invaluable tool for this sort of thing. If you use CodeWright, it supports recursive searching of dirs natively. Much, MUCH preferable to mucking about with a file browser, I can tell you :slight_smile:

... "I've just had an apostrophe!"

Grep good, but agree that from the command-line it is annoying.
<plug>
http://pythoncard.sourceforge.net/findfiles.html
</plug>

ka

···

On Apr 23, 2004, at 5:30 PM, Jeff Grimmett wrote:

Chris Barker wrote:

Now I just need to find where in the source these methods are all defined, so that I can make sure I put it correctly in the docs. I can probably find them myself, but didn't on a quick look...C++ confuses the heck out of me, and this is a pretty darn complex C++ lib.

I've found a good grep util with recursive searching to be an invaluable tool for this sort of thing. If you use CodeWright, it supports recursive searching of dirs natively. Much, MUCH preferable to mucking about with a file browser, I can tell you :slight_smile:

I don't know about "far more readable", the way I see it if you do things dynamicaly it might reduce the number of lines, which in turn might mean that things could be easier to maintain, easier to read once you understand what happens and I think... easier to expand... BUT hey, that's only my oppinion and since I do am a newbie :smiley: chances are that I might be wrong :smiley:

···

On Fri, 23 Apr 2004 12:51:56 -0700, Roger Binns <rogerb@rogerbinns.com> wrote:

Peter Damoc wrote:

On Thu, 22 Apr 2004 12:06:32 -0700, Roger Binns <rogerb@rogerbinns.com> >> wrote:
> Err, I have static class members with ids all over the
> place (the opposite of your statement). This is necessary
> to hook toolbar buttons to the same menu ids, or where I
> have widgets in HTML files that need to trigger an action.

well I don't think they are absolutely necessary :D,

I think this is far more readable, and is how my code is
actually structured:
[...]
I could introduce all sorts of mapper classes and other funky stuff,
but way prefer the above, where it is *VERY* clear what is going
on.

Riger

--
Peter Damoc
Hacker Wannabe
http://www.sigmacore.net/about.html

Peter Damoc wrote:

I don't know about "far more readable", the way I see it if you do things
dynamicaly it might reduce the number of lines,

How? Each control creation, event binding etc still has to happen
and will be the same number of lines.

easier to expand...

How?

Roger

Peter Damoc wrote:

I don't know about "far more readable", the way I see it if you do things
dynamicaly it might reduce the number of lines,

How? Each control creation, event binding etc still has to happen
and will be the same number of lines.

well... I was talking about menus... and... well... having them built uppon a python structures like a dictionary or an array would allow for one point modification (in the declaration of the python structure)
the actual creation of the menu and the event binding would take place in a for loop.

easier to expand...

How?

well think of it like a plug-in architecture, you have the generating algorithm (the for loops) so if you want to add or remove functionality all you have to do is modify some python structures and update the interface.
Again, this is for the menus and toolbars NOT for the rest of the controls.

Roger

I came to python from java and I do hate to see that there are a lot of things that java does better.
Java's way more mature when it comes to the way GUIs are created, it benefits from good design.
I know things can be better, I've seen them done somewhere else.

···

On Sat, 24 Apr 2004 00:16:13 -0700, Roger Binns <rogerb@rogerbinns.com> wrote:

--
Peter Damoc
Hacker Wannabe
http://www.sigmacore.net/about.html

> How? Each control creation, event binding etc still has to happen
> and will be the same number of lines.

well... I was talking about menus... and... well... having them built
uppon a python structures like a dictionary or an array would allow for
one point modification (in the declaration of the python structure)
the actual creation of the menu and the event binding would take place in
a for loop.

That has absolutely nothing whatsoever to do with whether you use
-1 as the id all the time, or named ids which is what the original
discussion is about :slight_smile:

Depending on the app, its structure, i18n etc, it may choose
to write code like this:

   menu.Append(...)
   menu.Append(...)
   menu.Append(...)
   ...
   wx.EVT_MENU(...)
   wx.EVT_MENU(...)
   wx.EVT_MENU(...)

Or like this:

   for item in structure:
      menu.Append(...)
      wx.EVT_MENU(...)

Or use XRC or whatever. At some point ids are allocated no matter
what. You could do them explicitly like I did where names and
values are associated as class variables and are visible in all
the code and to external HTML.

On the other end of the spectrum you could you could do them
implicitly by passing in -1, and doing Bind with the item,
or GetId().

The former strategy is best if the same command is available
in multiple ways simultaneously, such as menu items, toolbar
buttons, HTML, XML etc, external files etc.

well think of it like a plug-in architecture, you have the generating
algorithm (the for loops) so if you want to add or remove functionality
all you have to do is modify some python structures and update the
interface.
Again, this is for the menus and toolbars NOT for the rest of the controls.

The way you create controls such as menus, toolbars and everything else
is best determined by the application author. I would expect everyone
to agree that it should be easy to maintain and update. However that
has nothing to do with whether named ids are used, or auto-allocated
ids!

I came to python from java and I do hate to see that there are a lot of
things that java does better.
Java's way more mature when it comes to the way GUIs are created, it
benefits from good design.
I know things can be better, I've seen them done somewhere else.

I also do Java. It took them many revisions to get right. Did you
ever do AWT in Java 1.0? I have also done Tk, Motif, X11, Win32, Win16,
MFC, WindowsCE, and various random forms of basic (including Visual
Basic :slight_smile:

GUI toolkits should be judged on several measures. One is completeness.
Do they offer lots of different widgets? (I had to write my own combobox
when using Tk a few years ago - not a fun experience). Do they interoperate
with the rest of the system (clipboard, drag and drop, printing)? Does
the user have to know or care what you are using? Is it well designed?
[The easiest way to tell how well designed it is is to examine how
well i18n/l10n is supported]. Lastly, how robust, bug free and well
documented is it? Oh, and if it doesn't do geometry management (aka
sizers) then run away (the exception is UI toolkits for PDAs etc
but even then the lack of geometry management bites when new models
with different sized screens come out).

wxWidgets/wxPython scores very highly. Recent Swing does as well.
I don't think there are major mistakes in either.

Roger

I agree with almost everything you said, I do not criticize the way you do it, what I wanted to point out is that things could be simpler. You do it your way BUT I should be able to doit my way too.
when I create something I want to be able to code only the minimum. Why can't I just declare a Button like this:
button = Button()
why does it need to know its parent? It could receive a parent when it's added to a container. Why does it HAS TO HAVE an ID ? why does it need a string? maybe all I want is a 2px wide button from top to bottom.

button.Bind(wx.EVT_BUTTON, self.OnMyButton) is a step in the right direction BUT
button.SetAction(self.OnMyButton) would have been better, after all EVT_BUTTON is the main reason for its existance so it could be assumed.

···

On Sat, 24 Apr 2004 01:55:37 -0700, Roger Binns <rogerb@rogerbinns.com> wrote:

[...]
GUI toolkits should be judged on several measures. One is completeness.
Do they offer lots of different widgets? (I had to write my own combobox
when using Tk a few years ago - not a fun experience). Do they interoperate
with the rest of the system (clipboard, drag and drop, printing)? Does
the user have to know or care what you are using? Is it well designed?
[The easiest way to tell how well designed it is is to examine how
well i18n/l10n is supported]. Lastly, how robust, bug free and well
documented is it? Oh, and if it doesn't do geometry management (aka
sizers) then run away (the exception is UI toolkits for PDAs etc
but even then the lack of geometry management bites when new models
with different sized screens come out).

wxWidgets/wxPython scores very highly. Recent Swing does as well.
I don't think there are major mistakes in either.

Roger

--
Peter Damoc
Hacker Wannabe
http://www.sigmacore.net/about.html

Peter Damoc wrote:

when I create something I want to be able to code only the minimum. Why
can't I just declare a Button like this:
button = Button()
why does it need to know its parent? It could receive a parent when it's
added to a container. Why does it HAS TO HAVE an ID ? why does it need a
string? maybe all I want is a 2px wide button from top to bottom.

wxWidgets as a philosophy uses the underlying platform widgets if at
all possible. Other toolkits (such as Swing and QT) do everything
themselves.

Consequently some of what the underlying systems require will leak
through into the API for wxWidgets. While it could in theory be
possible to make wxWidgets work the way you describe, it would become
horrendously complex under the hood.

In general wxWidgets supplies default arguments for most things.
You can supply defaults (-1, "") for some as well.

If you are interested in this kind of stuff, I would recommend
writing simple programs using the various native toolkits out
there (win32, MFC, Xlib, Mac, GTK, PDA etc). Once you understand
all of them and their constraints, come up with an API design
that you can provide on top of them. The wxWidgets author pretty
much did that in the very early 90's and IMHO did a very good
job.

Some choices today may be a little different from over 10
years ago, but I don't think they would be that much different.

Roger

Jean Brouwers wrote:

Robin,

Previous releases of wxPython often use (*args, **kwds) for method
argument lists. Does 2.5 still use the same 'generic' style or are
the arguments spelled out? The doc samples you showed the other day
seem to indicate the latter.

The actual functions/methods still use (*args, **kwargs) which are extracted by SWIG in the C layer, but one of the changes I've made to SWIG is to embed the real function signature (and some type info) into the docstring. I've also changed epydoc to always check the docstring for the function signature. (Previously it only did it for the builtin functions, and always used introspection for python functions.)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Well, ... I was hoping that 2.5 would improve this. The
new documentation is of even greater value now.

But it would be even better if Python printed the accurate
argument names in error messages, etc.

Would it be possible to generate the exact same signature
for wxPython methods as the C++ ones (ignoring the naming
issue for overloaded methods)?

/Jean Brouwers
  ProphICy Semiconductor, Inc.

Robin Dunn wrote:

···

Jean Brouwers wrote:

Robin,

Previous releases of wxPython often use (*args, **kwds) for method
argument lists. Does 2.5 still use the same 'generic' style or are
the arguments spelled out? The doc samples you showed the other day
seem to indicate the latter.

The actual functions/methods still use (*args, **kwargs) which are extracted by SWIG in the C layer, but one of the changes I've made to SWIG is to embed the real function signature (and some type info) into the docstring. I've also changed epydoc to always check the docstring for the function signature. (Previously it only did it for the builtin functions, and always used introspection for python functions.)

Jean Brouwers wrote:

Would it be possible to generate the exact same signature
for wxPython methods as the C++ ones (ignoring the naming
issue for overloaded methods)?

It's doing a cleaned up version of the signature that is in the .i files given to SWIG. By cleaned up I mean that things dealing with const-ness, pointers and references are dropped. Take a look at the docstrings in 2.5 to see what I mean.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!