|
From: Kevin A. <al...@se...> - 2001-08-27 04:34:50
|
One other thing that you may be tempted to try, but which won't work is dot
dot set notation. For example:
self.components.field1.text.size = 12 # can't change the font size
This won't work. You can do a get just fine:
print self.components.field1.text.size
I don't think there is a workaround for the set + set problem, but one of
the Python wizards may have a solution. If you need to set a font property
for a widget, just get a reference to the font, change the attribute you are
interested in, then change the font for the widget.
Also, because the Font class doesn't actually keep a reference to a real
wxPython wxFont, you can just create a Font class that you want to use for a
group of widgets, then iterate through the widgets to make them all use the
same font characteristics. More on this kind of stuff as the fonts mature.
ka
> -----Original Message-----
> From: pyt...@li...
> [mailto:pyt...@li...]On Behalf Of Kevin
> Altis
> Sent: Sunday, August 26, 2001 6:11 PM
> To: pythoncard-Users
> Subject: [Pythoncard-users] fonts - day three
>
>
> dialog.py, test_dialogs.py, and widget.py have been updated in cvs to use
> the new Font class. This is highly experimental, but doesn't
> appear to break
> any existing samples.
>
> I chose to combine and hide some of the wxPython font settings. A Font is
> described by its optional attributes:
> family: 'serif', 'sansSerif', 'monospace', 'default'
> faceName: an actual font name from the system (Arial, Courier New...)
> size: a number representing point size (8, 9, 10, etc.)
> style: 'regular', 'bold', 'italic', 'boldItalic'
> underline is currently turned off
>
> If None is passed in to initialize the Font class then you currently get a
> Font with an empty faceName, a default family, 8 point, and
> 'regular' style.
> If a faceName is present, it overrides the family attribute. If
> you specify
> a faceName then you risk that font not being available on a different
> system. You should only use 'faceName' right now for cross-platform
> compatibility.
>
> You can provide a 'font' attribute in the .rsrc.py files for a widget such
> as:
>
> 'font':{'family':'monospace', 'size':12}
> 'font':{'faceName':'Garamond', 'size':10, 'style':'boldItalic'}
>
> or you can set the font while the program is running.
>
> f = PythonCardPrototype.widget.Font({'family':'monospace', 'size':12})
> self.field1.font = f
>
> I need to work on some mechanism, so that a list of alternative
> fonts can be
> searched for in order such as ["Garamond, Times New Roman,
> Times"] in order
> to make a match. I also need to provide a set of named fonts. Finally, I
> need to change the Font class initialization, so that the defaults aren't
> hard-coded, by using GetFont() on the background panel (Panel class) prior
> to initializing any of the widgets.
>
> ka
>
>
> _______________________________________________
> Pythoncard-users mailing list
> Pyt...@li...
> http://lists.sourceforge.net/lists/listinfo/pythoncard-users
>
|