mathtext in wx widgets

View: New views
12 Messages — Rating Filter:   Alert me  

mathtext in wx widgets

by Paul Kienzle-8 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

It would be great to be able to display math markup in other parts of my
application, such as labels, tables, lists and menus.  Has anyone ever
tried doing this for wx or gtk?

Thanks in advance,

        - Paul

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Re: mathtext in wx widgets

by Michael Droettboom-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Cool idea.  I don't know if anyone has tried this.  I assume you'd want
to get something that you could pass to wx.ImageFromBuffer() (and the
equivalent in Gtk).  It would just be a matter of or'ing together all of
the greyscale ft2font buffers (which aren't currently exposed to Python)
and converting them to an RGB buffer and Alpha buffer.  Not that
difficult, but it would require some additional C routines in ft2font.cpp.

(And long term, as cool as matplotlib is, it would be nice to refactor
this out as a separate library for apps that don't do any plotting...)

Cheers,
Mike

Paul Kienzle wrote:

> Hi,
>
> It would be great to be able to display math markup in other parts of my
> application, such as labels, tables, lists and menus.  Has anyone ever
> tried doing this for wx or gtk?
>
> Thanks in advance,
>
> - Paul
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >>  http://get.splunk.com/
> _______________________________________________
> Matplotlib-devel mailing list
> Matplotlib-devel@...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Re: mathtext in wx widgets

by John Hunter-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 8/30/07, Michael Droettboom <mdroe@...> wrote:

> (And long term, as cool as matplotlib is, it would be nice to refactor
> this out as a separate library for apps that don't do any plotting...)

I agree, the mathtext stuff is becoming really good, and will be
really good when we have a good set of fonts to work with.  I can see
it being useful in lots of contexts, and more users in other contexts
will make it more useful for us down the road.

JDH

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Re: mathtext in wx widgets

by Christopher Barker :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Paul Kienzle wrote:
> It would be great to be able to display math markup in other parts of my
> application, such as labels, tables, lists and menus.  Has anyone ever
> tried doing this for wx or gtk?

It's worth a post to the wxPython-users list -- it gets talked about now
and again.

It shouldn't be too hard to use the ustex stuff from MPL -- doesn't that
use TeX, etc to make a png or something? If so, it could be stuck on a
wx.widget easily.

Michael Droettboom wrote:
> (And long term, as cool as matplotlib is, it would be nice to refactor
> this out as a separate library for apps that don't do any plotting...)

Yes, that would be great -- a kind of mini-TeX that's embeddable.
Another plus to that is you'd expand the user base, and with that
hopefully the developer base, so it could get fuller featured faster.

How tied in with MPL is the code? Could it just be it's own module?

-Chris



--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker@...

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Re: mathtext in wx widgets

by Paul Kienzle-8 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Aug 30, 2007 at 01:56:36PM -0500, John Hunter wrote:
> On 8/30/07, Michael Droettboom <mdroe@...> wrote:
>
> > (And long term, as cool as matplotlib is, it would be nice to refactor
> > this out as a separate library for apps that don't do any plotting...)
>
> I agree, the mathtext stuff is becoming really good, and will be
> really good when we have a good set of fonts to work with.  I can see
> it being useful in lots of contexts, and more users in other contexts
> will make it more useful for us down the road.

The challenge is to separate the backends from matplotlib.

If mathtext takes over all of the font handling then matplotlib won't need
to include freetype.  If matplotlib handles bitmap rotation, then mathtext
won't need to include agg.  Then mathtext need only take the format string
and return a bounding box, a bitmap, or the PDF/PS/SVG instructions
necessary to render the text.

I don't know if PDF/PS/SVG can rotate the coordinate system prior to
rendering.  If not, then rotation will need to be moved into mathtext
as well.

        - Paul

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Parent Message unknown Re: mathtext in wx widgets

by Michael Droettboom-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It would probably be considerable work to ply mathtext out of matplotlib, particularly if you consider bringing along the Ps/Pdf/Svg/Cairo backends.  Just bringing the raster backend (which is really in ft2font.cpp) would be considerably less work.

But I was mainly just sharing a "wouldn't it be cool if...".  Separating mathtext would be a project unto itself.

Cheers,
Mike

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Re: mathtext in wx widgets

by Michael Droettboom-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

There is now preliminary support for getting a mathtext bitmap to
transfer to a GUI widget in SVN, along with a toy wxPython example in
examples/mathtext_wx.py.  I've only tested this on
Linux/wxGTK2/wxPython-2.8.  I'd appreciate help with testing (and
screenshots) on any other platforms you may care about.

Gtk+ and Qt should also be theoretically possible.  Tk will be more
difficult, because a) it doesn't support an alpha channel (which would
mainly be a quality problem), and b) you have to use the _tkagg C++
bridge to get the image data into a widget.

Be aware that the API for this may change due to my planned
mathtext/backend communication refactoring.  If you do plan on relying
on this functionality, I recommend wrapping it in a function (like
mathtext_to_wxbitmap in the example) so any future changes will be
localized.

Cheers,
Mike

Michael Droettboom wrote:

> Cool idea.  I don't know if anyone has tried this.  I assume you'd want
> to get something that you could pass to wx.ImageFromBuffer() (and the
> equivalent in Gtk).  It would just be a matter of or'ing together all of
> the greyscale ft2font buffers (which aren't currently exposed to Python)
> and converting them to an RGB buffer and Alpha buffer.  Not that
> difficult, but it would require some additional C routines in ft2font.cpp.
>
> (And long term, as cool as matplotlib is, it would be nice to refactor
> this out as a separate library for apps that don't do any plotting...)
>
> Cheers,
> Mike
>
> Paul Kienzle wrote:
>> Hi,
>>
>> It would be great to be able to display math markup in other parts of my
>> application, such as labels, tables, lists and menus.  Has anyone ever
>> tried doing this for wx or gtk?
>>
>> Thanks in advance,
>>
>> - Paul
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by: Splunk Inc.
>> Still grepping through log files to find problems?  Stop.
>> Now Search log events and configuration files using AJAX and a browser.
>> Download your FREE copy of Splunk now >>  http://get.splunk.com/
>> _______________________________________________
>> Matplotlib-devel mailing list
>> Matplotlib-devel@...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >>  http://get.splunk.com/
> _______________________________________________
> Matplotlib-devel mailing list
> Matplotlib-devel@...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Re: mathtext in wx widgets

by Michael Droettboom-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I should also mention my mathtext_wx.py example reveals a [possible] bug
in wxPython-2.8 and/or the underlying Gtk.  When you put a bitmap on a
menu item, the *height* of the menu item is determined by the *width* of
the bitmap.

And placing bitmaps in menu items reportedly doesn't work at all on
wxCocoa. -- so maybe it's best to stay away from that altogether.

Cheers,
Mike

Michael Droettboom wrote:

> There is now preliminary support for getting a mathtext bitmap to
> transfer to a GUI widget in SVN, along with a toy wxPython example in
> examples/mathtext_wx.py.  I've only tested this on
> Linux/wxGTK2/wxPython-2.8.  I'd appreciate help with testing (and
> screenshots) on any other platforms you may care about.
>
> Gtk+ and Qt should also be theoretically possible.  Tk will be more
> difficult, because a) it doesn't support an alpha channel (which would
> mainly be a quality problem), and b) you have to use the _tkagg C++
> bridge to get the image data into a widget.
>
> Be aware that the API for this may change due to my planned
> mathtext/backend communication refactoring.  If you do plan on relying
> on this functionality, I recommend wrapping it in a function (like
> mathtext_to_wxbitmap in the example) so any future changes will be
> localized.
>
> Cheers,
> Mike
>
> Michael Droettboom wrote:
>> Cool idea.  I don't know if anyone has tried this.  I assume you'd
>> want to get something that you could pass to wx.ImageFromBuffer() (and
>> the equivalent in Gtk).  It would just be a matter of or'ing together
>> all of the greyscale ft2font buffers (which aren't currently exposed
>> to Python) and converting them to an RGB buffer and Alpha buffer.  Not
>> that difficult, but it would require some additional C routines in
>> ft2font.cpp.
>>
>> (And long term, as cool as matplotlib is, it would be nice to refactor
>> this out as a separate library for apps that don't do any plotting...)
>>
>> Cheers,
>> Mike
>>
>> Paul Kienzle wrote:
>>> Hi,
>>>
>>> It would be great to be able to display math markup in other parts of my
>>> application, such as labels, tables, lists and menus.  Has anyone ever
>>> tried doing this for wx or gtk?
>>>
>>> Thanks in advance,
>>>
>>>     - Paul
>>>
>>> -------------------------------------------------------------------------
>>>
>>> This SF.net email is sponsored by: Splunk Inc.
>>> Still grepping through log files to find problems?  Stop.
>>> Now Search log events and configuration files using AJAX and a browser.
>>> Download your FREE copy of Splunk now >>  http://get.splunk.com/
>>> _______________________________________________
>>> Matplotlib-devel mailing list
>>> Matplotlib-devel@...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>>
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by: Splunk Inc.
>> Still grepping through log files to find problems?  Stop.
>> Now Search log events and configuration files using AJAX and a browser.
>> Download your FREE copy of Splunk now >>  http://get.splunk.com/
>> _______________________________________________
>> Matplotlib-devel mailing list
>> Matplotlib-devel@...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>
>


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Re: mathtext in wx widgets

by Paul Kienzle-8 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Aug 31, 2007 at 03:28:49PM -0400, Michael Droettboom wrote:
> There is now preliminary support for getting a mathtext bitmap to
> transfer to a GUI widget in SVN, along with a toy wxPython example in
> examples/mathtext_wx.py.  I've only tested this on
> Linux/wxGTK2/wxPython-2.8.  I'd appreciate help with testing (and
> screenshots) on any other platforms you may care about.

That's wonderful!  I'm attaching a screen shot for wx 2.8 on OS/X.

The rendering is kind of ugly, but I haven't looked into it.

        - Paul


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

mathtext_wx.png (49K) Download Attachment

Re: mathtext in wx widgets

by Paul Kienzle-8 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Aug 31, 2007 at 03:32:09PM -0400, Michael Droettboom wrote:
> And placing bitmaps in menu items reportedly doesn't work at all on
> wxCocoa. -- so maybe it's best to stay away from that altogether.

The wxPython demo.py for menus has a smiley face bit map that displays
just fine.  Let me know if you want a screen shot.

        - Paul

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Re: mathtext in wx widgets

by Michael Droettboom-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Just FYI -- this is what it looks like in Linux/wxGTK.

Paul Kienzle wrote:

> On Fri, Aug 31, 2007 at 03:28:49PM -0400, Michael Droettboom wrote:
>> There is now preliminary support for getting a mathtext bitmap to
>> transfer to a GUI widget in SVN, along with a toy wxPython example in
>> examples/mathtext_wx.py.  I've only tested this on
>> Linux/wxGTK2/wxPython-2.8.  I'd appreciate help with testing (and
>> screenshots) on any other platforms you may care about.
>
> That's wonderful!  I'm attaching a screen shot for wx 2.8 on OS/X.
>
> The rendering is kind of ugly, but I haven't looked into it.
>
> - Paul
>
>
> ------------------------------------------------------------------------
>


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Screenshot.png (31K) Download Attachment

Re: mathtext in wx widgets

by John Hunter-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 8/31/07, Paul Kienzle <pkienzle@...> wrote:

> That's wonderful!  I'm attaching a screen shot for wx 2.8 on OS/X.
>
> The rendering is kind of ugly, but I haven't looked into it.

My giess is that for some reason wx is not respecting the alpha
channel -- that will give you the rough, chunky text you are seeing.
I saw similar looking text when working with dvipng output before I
got the alpha channel right.

JDH

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel