[wxPython] app framework - XML resource issues

I played with wxDesigner some more this evening. While it has an Advanced
tab to make additional settings for font, foreground and background color,
tooltip, etc. for a control, the only settings that appear in the resource
file are for the colors <fg> and <bg>. As a side note, wxDesigner is
actually extremely limited in the font and color settings you can make.

This may just be a wxDesigner issue and the XML format may actually support
a large set of parameters that can be set after the initial widget is
constructed (two-step initialization). I need to see a complete DTD for the
XML or some sort of description about what parameters it supports.

Again, rather than inventing our own resource format, it would be better to
have the same format for the whole wxWindows community. However, in the
meantime, we might want to adapt the resource format and initialization
scheme used by PythonCard in addition to the "standard" XML format.
PythonCard uses nested dictionaries and lists and a spec to validate the
resource as it is read in. We could write some routines to convert between
Python dictionaries and lists and XML; I think I even saw a cookbook entry
for that once.

This doesn't need to be done immediately, but it is an issue to keep in
mind. Again, the goal is to be able to store all layout and associated info
such as tooltips separate from the program logic.

ka

Kevin Altis wrote:

This may just be a wxDesigner issue and the XML format may actually support
a large set of parameters that can be set after the initial widget is
constructed (two-step initialization). I need to see a complete DTD for the
XML or some sort of description about what parameters it supports.

I can't find *any* documentation of the XRC format -- that's the one we're
talking about, right? I've been casting around for a good DTD for dialog
definition for some time already.

Can anybody provide a URL here?

Michael

This may just be a wxDesigner issue and the XML format may actually

support

a large set of parameters that can be set after the initial widget is
constructed (two-step initialization). I need to see a complete DTD for

the

XML or some sort of description about what parameters it supports.

http://cvs.wxwindows.org/cgi-bin/viewcvs.cgi/wxWindows/contrib/src/xrc/FORMA
T.txt?rev=1.1&content-type=text/vnd.viewcvs-markup

Is there anything beyobd this Vaclav? Is it up to date?

···

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

Kevin Altis wrote:

> This may just be a wxDesigner issue and the XML format may actually

support

> a large set of parameters that can be set after the initial widget is
> constructed (two-step initialization). I need to see a complete DTD for

the

> XML or some sort of description about what parameters it supports.

I can't find *any* documentation of the XRC format -- that's the one we're
talking about, right? I've been casting around for a good DTD for dialog
definition for some time already.

Can anybody provide a URL here?

The source is the ultimate documentation! <wink>

Kevin Altis wrote:

> This may just be a wxDesigner issue and the XML format may actually

support

> a large set of parameters that can be set after the initial widget is
> constructed (two-step initialization). I need to see a complete DTD for

the

> XML or some sort of description about what parameters it supports.

I can't find *any* documentation of the XRC format -- that's the one we're
talking about, right? I've been casting around for a good DTD for dialog
definition for some time already.

Can anybody provide a URL here?

The source is the ultimate documentation! <wink>

http://cvs.wxwindows.org/cgi-bin/viewcvs.cgi/wxWindows/contrib/src/xrc/

There is also a README there.

···

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

Kevin Altis wrote:

While it has an Advanced
tab to make additional settings for font, foreground and background color,
tooltip, etc. for a control, the only settings that appear in the resource
file are for the colors <fg> and <bg>.

This sounds like a bug or missing feature. Robert does label the XML
format as experimental...

As a side note, wxDesigner is
actually extremely limited in the font and color settings you can make.

Yes, it is, but that is probably deliberate, and I think, a good thing.
You don't want people to be able to use any font or color that will not
be available on all platforms. From my limited experience with
wxDesigner, the number of fonts ios just fine with me, but the the
colors are more li ited that I would expect. I can't think of any reason
why you shouldn't be able to use all the colors pre-defined in
wxNamedColour, although I wonder what you would get with 16 color video
(does anyone stull use that?)

Again, rather than inventing our own resource format, it would be better to
have the same format for the whole wxWindows community.

I agree. If there is an important feature missing from the wxWindows xml
format, it should be added. Is there anything you'd want for the
framework that people wouldn't want for C++ wx?

-Chris

···

--
Christopher Barker,
Ph.D.
ChrisHBarker@home.net --- --- ---
http://members.home.net/barkerlohmann ---@@ -----@@ -----@@
                                   ------@@@ ------@@@ ------@@@
Oil Spill Modeling ------ @ ------ @ ------ @
Water Resources Engineering ------- --------- --------
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------

The source is the ultimate documentation! <wink>

That of course is the fundamental problem with wxWindows/wxPython for Python
programmers. The source is C++ making it difficult for a non-C/C++
programmer to read and find problems, let alone write. A C++ programmer
needs to make modifications, and because of the nature of C/C++ that
programmer has to deal with all the different platform issues, header files,
includes, compiler options, make files, etc. Not to mention that there is
really only one team member for wxPython, and Robin can only do so much. In
other words, argh! I wish I could do more like fix wxFont, but I am not
going back to programming in C/C++.

wxPython is certainly the most powerful option for Python programmers today,
but I sure do wish the documentation didn't have to be the source and I wish
there was a better way to get fixes and additions done than whining on
wx-dev. Somedays I find myself thinking about just using Jython and the JDK.

Vent off,

ka

Hear, hear! In addition to what you wrote, I want to mention that I
know several people who have learned (are learning) Python as their
first language. I dare say many have no intention of learning C++
just so they can use routines that they believe to be Python routines.
(Though Python's not my first language by any stretch, I've never
written any C++.)

Kudos to all the folks who produce all this wonderful stuff. I'm
definitely grateful for all the things that Linux, Python and wxPython,
PostgreSQL, PHP, et al have enabled me to do. I just want to be counted
among those who say "Well, I learned Python and wxPython so that I
*WOULDN'T* have to learn C++ and Java. If I have to learn them, what's
the point of using Python and wxPython?"

···

On Fri, 26 Oct 2001, Kevin Altis wrote:

> The source is the ultimate documentation! <wink>

That of course is the fundamental problem with wxWindows/wxPython for Python
programmers. The source is C++ making it difficult for a non-C/C++
programmer to read and find problems, let alone write. A C++ programmer
needs to make modifications, and because of the nature of C/C++ that
programmer has to deal with all the different platform issues, header files,
includes, compiler options, make files, etc. Not to mention that there is
really only one team member for wxPython, and Robin can only do so much. In
other words, argh! I wish I could do more like fix wxFont, but I am not
going back to programming in C/C++.

wxPython is certainly the most powerful option for Python programmers today,
but I sure do wish the documentation didn't have to be the source and I wish
there was a better way to get fixes and additions done than whining on
wx-dev. Somedays I find myself thinking about just using Jython and the JDK.

Vent off,

ka

> The source is the ultimate documentation! <wink>

That of course is the fundamental problem with wxWindows/wxPython for

Python

programmers.

I know, I was joking! (See the <wink>?)

···

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

> > The source is the ultimate documentation! <wink>
>
> That of course is the fundamental problem with wxWindows/wxPython for
Python
> programmers.

I know, I was joking! (See the <wink>?)

I know, but the humor wore off long ago. You should probably just say
TSITUDW from now on. Also :wink:

ka
ps. The situation is even worse for building GUIs with Jython. Yes you have
Swing, yes the documentation is fairly complete, but there is no decent way
of building layouts and Swing is fairly complicated.

From: Chris Barker

> As a side note, wxDesigner is
> actually extremely limited in the font and color settings you can make.

Yes, it is, but that is probably deliberate, and I think, a good thing.
You don't want people to be able to use any font or color that will not
be available on all platforms. From my limited experience with
wxDesigner, the number of fonts ios just fine with me, but the the
colors are more li ited that I would expect. I can't think of any reason
why you shouldn't be able to use all the colors pre-defined in
wxNamedColour, although I wonder what you would get with 16 color video
(does anyone stull use that?)

This is part of the fix I want for wxFont. You should be able to specify a
font list like CSS (Garamond, Times, Times Roman) with a font-family (serif,
sansSerif, monospace, script, decorative) as a last resort. Decorative is
probably an exception since if you're using something like Zapf Dingbats the
characters won't match up at all in a different font. I was going to
implement CSS-like font selection for PythonCard, but there is currently no
way in wxWindows to get a list of fonts based on family, nor is there a way
to determine the family given a face name, so I can't even wrap up the
functionality.

I think about the only time you see 16 color video is on a server with
default PCI video and you don't generally run GUI apps on those boxes. 256
colors should be a minimum, but 16-bit is probably a more sensible minimum
these days. Of course, I also wish wxWindows didn't bother trying to support
Windows 3.1 or even Windows 95, but that's just me. I'm having a bad
cross-platform day.

On a related note, even if you use sizers, it seems that in order for a
layout to be usable you need to be able to vary the font size based on a
user setting. Different themes, screen resolutions on various monitor sizes,
etc. can make using a default size either too big or too small. I don't know
if this is such a problem on the Mac or Windows where most users tend to use
the default, but Linux users seem to have all sorts of different settings. I
don't know what the real solution is, but a two-step initialization that
allows the font size for each control to be changed prior to creating the
controls inside a panel or frame seems like a good first step.

Obviously, it gets much more complicated once you try and use specific fonts
and sizes or relative sizes. We should have a reasonable way of at least
doing layouts equivalent to simple HTML.

> Again, rather than inventing our own resource format, it would
be better to
> have the same format for the whole wxWindows community.

I agree. If there is an important feature missing from the wxWindows xml
format, it should be added. Is there anything you'd want for the
framework that people wouldn't want for C++ wx?

The needs should be the same.

ka

Kevin Altis wrote:

wxPython is certainly the most powerful option for Python programmers today,
but I sure do wish the documentation didn't have to be the source and I wish
there was a better way to get fixes and additions done than whining on
wx-dev. Somedays I find myself thinking about just using Jython and the JDK.

I share a lot of your frustration, but I have a few comments:

The documentation doesn't have to be the source, any one of us could do
a lot more writing!

What better way could there possibly be to getting fixes and additions?
What would you do if you wanted a fix or addition to Swing? or MFC, or
Apple Cocoa? you'd be totally dead in the water if you aren't a very
large and influential corporation.

BTW, there is another way to get fixes and additions: pay someone to do
it. I don't have any money for this either, but at least it is an
option, which it wouldn't be with a propriatary product.

Remember, you don't need to know C++ to use wxPython, you only need to
know it to improve wxPython. I've never written a line of C++ in my life
(if you don't count C with // comments), and it took me very little time
to understand the wxWindows docs. The wxWindows source is another
matter, but I hae yet to need to look at them. I would if I wanted to
now how a new experimental feature worked, but that's about developing
wxPython, not using it, and expecting to be able to develop a
programming framework without working at a fairly low level is a pretty
high expectation indeed!

This is not to say that there aren't features I would like, and I have
no way to get them, but I don't see any other way of working that would
be better.

Frankly, given the wxWindows was designed from the beginning to be a C++
toolkit, not a Python one, I Python users have gotten a huge amount of
support from the wxWindows developers!

-Chris

···

--
Christopher Barker,
Ph.D.
ChrisHBarker@home.net --- --- ---
http://members.home.net/barkerlohmann ---@@ -----@@ -----@@
                                   ------@@@ ------@@@ ------@@@
Oil Spill Modeling ------ @ ------ @ ------ @
Water Resources Engineering ------- --------- --------
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------

Whatever happened to the DrawStuffList() code that Tim and Robin were
working on?

Is there anything for a C++ neophyte to check out?

-Chris

···

--
Christopher Barker,
Ph.D.
ChrisHBarker@home.net --- --- ---
http://members.home.net/barkerlohmann ---@@ -----@@ -----@@
                                   ------@@@ ------@@@ ------@@@
Oil Spill Modeling ------ @ ------ @ ------ @
Water Resources Engineering ------- --------- --------
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------

Kevin Altis wrote:

This is part of the fix I want for wxFont. You should be able to specify a
font list like CSS (Garamond, Times, Times Roman) with a font-family (serif,
sansSerif, monospace, script, decorative) as a last resort.

<snip>

there is currently no
way in wxWindows to get a list of fonts based on family, nor is there a way
to determine the family given a face name, so I can't even wrap up the
functionality.

Is there a way to do that on any platform other than X-windows?? If
you're going to support it in wxWindows, it needs to be supported by the
platforms it runs on.

On a related note, even if you use sizers, it seems that in order for a
layout to be usable you need to be able to vary the font size based on a
user setting. Different themes, screen resolutions on various monitor sizes,
etc. can make using a default size either too big or too small.

What is the default now? wouldn't it be the default that is currently
active in whatever toolkit is being used? That would mean that it would
use whatever theme is being used by GTK, and it would use"big fonts" or
"small fonts" on windows, depending on the user settings. Isn't that
exactly what you would want?

On a related note, I am currently working on a UI, using wxDesigner, and
have found that the default button size is larger than I want. The
problem is that if I give the buttons a defined size in pixels, I have
no idea whether it will work on other platforms, with other fonts.

If I find out later that I have made the buttons too small, I'll have to
go it and change them all by hand, which would be a pain. Has anyone
come up with a nifty solution to this?

I think what I want is to set a size, but have the button stretch itself
if the text on it is too large for the size I have set. Is there any way
to do that??

-Chris

···

--
Christopher Barker,
Ph.D.
ChrisHBarker@home.net --- --- ---
http://members.home.net/barkerlohmann ---@@ -----@@ -----@@
                                   ------@@@ ------@@@ ------@@@
Oil Spill Modeling ------ @ ------ @ ------ @
Water Resources Engineering ------- --------- --------
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------

Whatever happened to the DrawStuffList() code that Tim and Robin were
working on?

Is there anything for a C++ neophyte to check out?

DrawPontList and DrawLineList are in the current beta. You can see it in
the demo named "DrawXXXList," (sorry, XXX doesn't stand for porn...) The
initial delay you see when you run it is Python generating 3000 random
points and 1500 random lines. After that the refreshes when sizing or
unobscuring are pretty speedy. Of course it could be optimized even more by
using a clipping region and double-buffering, etc. but that's not what this
demo is showing off...

···

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

Robin Dunn wrote:

> Whatever happened to the DrawStuffList() code that Tim and Robin were
> working on?
>
> Is there anything for a C++ neophyte to check out?

DrawPontList and DrawLineList are in the current beta.

Great. I'll check it out when I can find a little time.

-Chris

···

--
Christopher Barker,
Ph.D.
ChrisHBarker@home.net --- --- ---
http://members.home.net/barkerlohmann ---@@ -----@@ -----@@
                                   ------@@@ ------@@@ ------@@@
Oil Spill Modeling ------ @ ------ @ ------ @
Water Resources Engineering ------- --------- --------
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------

Kevin Altis:

I think about the only time you see 16 color video is on a server
with default PCI video and you don't generally run GUI apps on
those boxes. 256 colors should be a minimum, but 16-bit is
probably a more sensible minimum these days. Of course, I
also wish wxWindows didn't bother trying to support Windows
3.1 or even Windows 95, but that's just me. I'm having a bad
cross-platform day.

   Some PDAs are monochrome and there are other embedded devices that a
truly cross-platform kit will want to support. I see this lasting for
another 10 years. There are people that want Scintilla to support character
cell (as in terminal) displays!

On a related note, even if you use sizers, it seems that in order for a
layout to be usable you need to be able to vary the font size based on a
user setting. Different themes, screen resolutions on various monitor

sizes,

etc. can make using a default size either too big or too small. I don't

know

if this is such a problem on the Mac or Windows where most users tend to

use

the default, but Linux users seem to have all sorts of different settings.

I

don't know what the real solution is, but a two-step initialization that
allows the font size for each control to be changed prior to creating the
controls inside a panel or frame seems like a good first step.

   Windows users can bugger this up if they try hard enough. I have large
fonts set and that causes problems in many apps, including Excel. Move to a
custom font magnification or use font substitution, as is sometimes done for
localised systems, and you will see a lot of display issues.

   Does anyone with a copy of Windows XP know if the themes feature can
upset font selection and thus drawing?

   Neil

From: Chris Barker

Kevin Altis wrote:

> This is part of the fix I want for wxFont. You should be able
to specify a
> font list like CSS (Garamond, Times, Times Roman) with a
font-family (serif,
> sansSerif, monospace, script, decorative) as a last resort.

<snip>

>there is currently no
> way in wxWindows to get a list of fonts based on family, nor is
there a way
> to determine the family given a face name, so I can't even wrap up the
> functionality.

Is there a way to do that on any platform other than X-windows?? If
you're going to support it in wxWindows, it needs to be supported by the
platforms it runs on.

Good question, but I don't know the answer. However, I believe I've been
thinking about this problem bass ackwards. wxFont currently requires the
point size, family, style, and weight to be specified at initialization.
Furthermore, I think the faceName which is an optional parameter, does
override the family. If a wrapped version of wxFont is used, like the Font
class in PythonCard, then the init method could check for the availablity of
the faceNames in the list before resorting to just using the family. The
subclass init could also take care of the default size. Hmm...

> On a related note, even if you use sizers, it seems that in order for a
> layout to be usable you need to be able to vary the font size based on a
> user setting. Different themes, screen resolutions on various
monitor sizes,
> etc. can make using a default size either too big or too small.

What is the default now? wouldn't it be the default that is currently
active in whatever toolkit is being used? That would mean that it would
use whatever theme is being used by GTK, and it would use"big fonts" or
"small fonts" on windows, depending on the user settings. Isn't that
exactly what you would want?

Maybe yes, maybe no. The default on Windows is 8 point if you haven't
changed the scheme, which is actually pretty small, but what is generally
used for dialogs, toolbars, and menus. Anyway, a lot of apps provide their
own settings independent of the system setting, so the user can choose a
default size and the font to use for different text styles. Sometimes, like
in the browser, the size is proportional: Smallest, Smaller, Medium, Larger,
Largest. In the case of IE you can also set the default text encoding.
Having a dialog and preference like this would be a nice addition to the
basic framework.

We probably need to try a number of different types of layout and see how
they look on various machines. We did a bit of this with PythonCard. I was
sort of waiting for wxPython Mac before coming up with a real solution.

On a related note, I am currently working on a UI, using wxDesigner, and
have found that the default button size is larger than I want. The
problem is that if I give the buttons a defined size in pixels, I have
no idea whether it will work on other platforms, with other fonts.

If I find out later that I have made the buttons too small, I'll have to
go it and change them all by hand, which would be a pain. Has anyone
come up with a nifty solution to this?

I think what I want is to set a size, but have the button stretch itself
if the text on it is too large for the size I have set. Is there any way
to do that??

If you use wxDefaultSize (-1, -1) for the size, then I believe it expands so
that the text fits with ample whitespace around the text. If you're using a
sizer, then the font and size would need to be set prior to adding the
control to the sizer or the minimum size is going to be messed up. If you
want less whitespace, then you probably need to do your own text extent
calculation and set the minimum size yourself.

I haven't used the sizing routines much inside a sizer control, so the above
info could be completely wrong. I defer to Robin...

ka

If you use wxDefaultSize (-1, -1) for the size, then I believe it expands

so

that the text fits with ample whitespace around the text. If you're using

a

sizer, then the font and size would need to be set prior to adding the
control to the sizer or the minimum size is going to be messed up. If you
want less whitespace, then you probably need to do your own text extent
calculation and set the minimum size yourself.

It depends on the type of the window. For many of the controls if they are
constructed with (-1,-1) then they will set themselves to a size based on
their initial contents. Whatever the size of the window is when added to
the sizer will be what the sizer uses for the minimum desired size of hte
item until it is told otherwise.

···

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

From: Neil Hodgson

Kevin Altis:

> I think about the only time you see 16 color video is on a server
> with default PCI video and you don't generally run GUI apps on
> those boxes. 256 colors should be a minimum, but 16-bit is
> probably a more sensible minimum these days. Of course, I
> also wish wxWindows didn't bother trying to support Windows
> 3.1 or even Windows 95, but that's just me. I'm having a bad
> cross-platform day.

   Some PDAs are monochrome and there are other embedded devices that a
truly cross-platform kit will want to support. I see this lasting for
another 10 years. There are people that want Scintilla to support
character
cell (as in terminal) displays!

Okay, in order to avoid having to write everything as lowest common
denominator (aka less features, generally looks crappy) we need to have a
"gestalt" (that's what it was called on the Mac long ago) mechanism so the
app has a standard way of finding out what features the platform it is
running on supports. When the framework starts up, it just loads the gestalt
list or dictionary. In addition, to putting the version number info for
Python and wxPython and any other standard libraries we use in one place, we
can put the screen bit depth, os, available RAM, disk space, fonts, etc. It
is possible to grab the info from various places, but it would be better to
have a single class wrapper for it. The list can start simple and expand as
needed.

That way if you want to write a wxPython program that uses win32 features
such as COM or 16-bit color or opengl or numpy or PIL, then when the app
starts up it can check and exit gracefully if the required features aren't
available. This should also help standardize the try/except blocks of code
that people write where specific features are required.

On a related note, there are many options in the wxWindows controls that are
win32 only. That's why I still assume that many apps will have different
layouts for different platforms and the framework should facilitate multiple
layouts. If all the layout info is done in resources, it is a fairly simple
process (if you have a decent layout editor) for a Linux user to copy and
modify the win32 layout to look and work better on Linux without breaking
the program logic. The same goes for internationalization.

What do you think?

ka