[Tutor] small graphics question

Alan Gauld alan.gauld at yahoo.co.uk
Tue Feb 9 20:09:37 EST 2021


On 09/02/2021 22:36, nathan tech wrote:

> I am pondering a simple question:
> 
> How do I write x to the power of y, in python/

Its not simple, its extremely difficult!

The reason is it depends on many factors including
choice of font and OS. Being wxPython the OS issues
are hopefully dealt with there. But the font
issues remain.

> Not 5^2 for 5 squared, but 5 superscript 2? or 5 superscript x where x 
> is any number?
> 
> Similarly, how do I produce fractions??

This is all about producing smaller characters and
then raising or lowering them above the baseline.

The easiest way may be to create an HTML text window
and use HTML and CSS to create the effects you want.
HTML can certainly do super and sub scripts

> I asked here in the end because I figure for wx python it is just 
> tracking down that character sequence and then writing it on screen 

Not that simple and the wxPython crowd probably have
more people who do this kind of thing regularly.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list