Tk backend different from others

I was working on my embedding chapter of my book when I noticed a subtle difference in the tkagg backend from other interactive backends. First, all other interactive Canvas classes inherit their respective backend’s widget:

ben@...965...:~/Programs/matplotlib$ git grep "FigureCanvasBase" | grep "class "
lib/matplotlib/backend_bases.py:class FigureCanvasBase(object):
lib/matplotlib/backends/backend_agg.py:class FigureCanvasAgg(FigureCanvasBase):
lib/matplotlib/backends/backend_cairo.py:class FigureCanvasCairo (FigureCanvasBase):
lib/matplotlib/backends/backend_gdk.py:class FigureCanvasGDK (FigureCanvasBase):
lib/matplotlib/backends/backend_gtk.py:class FigureCanvasGTK (gtk.DrawingArea, FigureCanvasBase):
lib/matplotlib/backends/backend_gtk3.py:class FigureCanvasGTK3 (Gtk.DrawingArea, FigureCanvasBase):
lib/matplotlib/backends/backend_macosx.py:class FigureCanvasMac(_macosx.FigureCanvas, FigureCanvasBase):
lib/matplotlib/backends/backend_pdf.py:class FigureCanvasPdf(FigureCanvasBase):
lib/matplotlib/backends/backend_pgf.py:class FigureCanvasPgf(FigureCanvasBase):
lib/matplotlib/backends/backend_ps.py:class FigureCanvasPS(FigureCanvasBase):
lib/matplotlib/backends/backend_qt5.py:class FigureCanvasQT(QtWidgets.QWidget, FigureCanvasBase):
lib/matplotlib/backends/backend_svg.py:class FigureCanvasSVG(FigureCanvasBase):
lib/matplotlib/backends/backend_template.py:class FigureCanvasTemplate(FigureCanvasBase):
lib/matplotlib/backends/backend_wx.py:class FigureCanvasWx(FigureCanvasBase, wx.Panel):

(I am going to assume that _macosx.FigureCanvas has all needed things built-in, and I’ll ignore the switched order for FigureCanvasWx). I have no clue if this is potentially an issue or not, it just seemed a bit inconsistent.

Second, while I haven’t tried out all the backends yet, I noticed that the Figure window for tkagg has an annoying border that the other backends don’t have. It is fairly wide, 4 pixels. I would like to get rid of that. Does anybody object to that? I can make a PR for that and any other border widths I find.

Cheers!

Ben Root

I was working on my embedding chapter of my book when I noticed a subtle
difference in the tkagg backend from other interactive backends. First,
all other interactive Canvas classes inherit their respective backend's
widget:

ben@...965...:~/Programs/matplotlib$ git grep "FigureCanvasBase" | grep
"class "
lib/matplotlib/backend_bases.py:class FigureCanvasBase(object):
lib/matplotlib/backends/backend_agg.py:class
FigureCanvasAgg(FigureCanvasBase):
lib/matplotlib/backends/backend_cairo.py:class FigureCanvasCairo
(FigureCanvasBase):
lib/matplotlib/backends/backend_gdk.py:class FigureCanvasGDK
(FigureCanvasBase):
lib/matplotlib/backends/backend_gtk.py:class FigureCanvasGTK
(gtk.DrawingArea, FigureCanvasBase):
lib/matplotlib/backends/backend_gtk3.py:class FigureCanvasGTK3
(Gtk.DrawingArea, FigureCanvasBase):
lib/matplotlib/backends/backend_macosx.py:class
FigureCanvasMac(_macosx.FigureCanvas, FigureCanvasBase):
lib/matplotlib/backends/backend_pdf.py:class
FigureCanvasPdf(FigureCanvasBase):
lib/matplotlib/backends/backend_pgf.py:class
FigureCanvasPgf(FigureCanvasBase):
lib/matplotlib/backends/backend_ps.py:class
FigureCanvasPS(FigureCanvasBase):
lib/matplotlib/backends/backend_qt5.py:class
FigureCanvasQT(QtWidgets.QWidget, FigureCanvasBase):
lib/matplotlib/backends/backend_svg.py:class
FigureCanvasSVG(FigureCanvasBase):
lib/matplotlib/backends/backend_template.py:class
FigureCanvasTemplate(FigureCanvasBase):
lib/matplotlib/backends/backend_wx.py:class
FigureCanvasWx(FigureCanvasBase, wx.Panel):

(I am going to assume that _macosx.FigureCanvas has all needed things
built-in, and I'll ignore the switched order for FigureCanvasWx). I have
no clue if this is potentially an issue or not, it just seemed a bit
inconsistent.

There are a lot of differences; I don't know whether it would even be possible to make TkAgg more similar to the others. One of the differences is that most of the others have a native part (e.g., backend_qt5) and the part that pulls in agg (e.g., backend_qt5agg). TkAgg does it all in one. I don't think the difference is problematic.

Second, while I haven't tried out all the backends yet, I noticed that
the Figure window for tkagg has an annoying border that the other
backends don't have. It is fairly wide, 4 pixels. I would like to get
rid of that. Does anybody object to that? I can make a PR for that and
any other border widths I find.

Offhand, sounds reasonable.

Eric

···

On 2014/11/15, 6:14 AM, Benjamin Root wrote:

Cheers!
Ben Root

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk

_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options

Hello Ben,

···

On 15/11/14 17:14, Benjamin Root wrote:

Second, while I haven't tried out all the backends yet, I noticed that
the Figure window for tkagg has an annoying border that the other
backends don't have. It is fairly wide, 4 pixels. I would like to get
rid of that. Does anybody object to that? I can make a PR for that and
any other border widths I find.

I'm trying to switch from the MacOSX backend to the the WXAgg backend
because the font handling in the first is quite a bit broken. However
the black border is very annoying. Did you manage to get rid of it?

Cheers,
Daniele

That’s the weird thing… I couldn’t! I tried a few different things and I couldn’t make it go away. I’ll probably give it another shot during scipy2015.

Ben Root

···

On Jun 15, 2015 4:50 AM, “Daniele Nicolodi” <daniele@…1172…> wrote:

Hello Ben,

On 15/11/14 17:14, Benjamin Root wrote:

Second, while I haven’t tried out all the backends yet, I noticed that

the Figure window for tkagg has an annoying border that the other

backends don’t have. It is fairly wide, 4 pixels. I would like to get

rid of that. Does anybody object to that? I can make a PR for that and

any other border widths I find.

I’m trying to switch from the MacOSX backend to the the WXAgg backend

because the font handling in the first is quite a bit broken. However

the black border is very annoying. Did you manage to get rid of it?

Cheers,

Daniele



Matplotlib-devel mailing list

Matplotlib-devel@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Perhaps MEP27 will make that job easier, we shall see…

···

From: Benjamin Root <ben.root@…553…>
To: Daniele Nicolodi <daniele@…1172…>
Cc: matplotlib development list matplotlib-devel@lists.sourceforge.net
Sent: Monday, 15 June 2015, 13:23
Subject: Re: [matplotlib-devel] Tk backend different from others

That’s the weird thing… I couldn’t! I tried a few different things and I couldn’t make it go away. I’ll probably give it another shot during scipy2015.

Ben Root

On Jun 15, 2015 4:50 AM, “Daniele Nicolodi” <daniele@…1172…> wrote:

Hello Ben,

On 15/11/14 17:14, Benjamin Root wrote:

Second, while I haven’t tried out all the backends yet, I noticed that

the Figure window for tkagg has an annoying border that the other

backends don’t have. It is fairly wide, 4 pixels. I would like to get

rid of that. Does anybody object to that? I can make a PR for that and

any other border widths I find.

I’m trying to switch from the MacOSX backend to the the WXAgg backend

because the font handling in the first is quite a bit broken. However

the black border is very annoying. Did you manage to get rid of it?

Cheers,

Daniele



Matplotlib-devel mailing list

Matplotlib-devel@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-devel



Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

I'm guessing, but did you try changing the (Tk) ``highlightthickness``?
E.g., something like:

widget.config(borderwidth=0, highlightthickness=0)

It's a moderately classic Tkinter gotcha. You remove all the borders and
there's still one (hightlightthickness) still there, but it only shows up
when you interact with the Frame.

Hope that helps,
-Joe

···

On Mon, Jun 15, 2015 at 6:23 AM, Benjamin Root <ben.root@...553...> wrote:

That's the weird thing... I couldn't! I tried a few different things and I
couldn't make it go away. I'll probably give it another shot during
scipy2015.

No, I did not try that one. I’ll give it a shot. I don’t do any Tkinter programming, so I wasn’t familiar with that one.

···

On Mon, Jun 15, 2015 at 9:23 AM, Joe Kington <joferkington@…149…> wrote:

On Mon, Jun 15, 2015 at 6:23 AM, Benjamin Root <ben.root@…553…> wrote:

That’s the weird thing… I couldn’t! I tried a few different things and I couldn’t make it go away. I’ll probably give it another shot during scipy2015.

I’m guessing, but did you try changing the (Tk) highlightthickness? E.g., something like:

widget.config(borderwidth=0, highlightthickness=0)

It’s a moderately classic Tkinter gotcha. You remove all the borders and there’s still one (hightlightthickness) still there, but it only shows up when you interact with the Frame.

Hope that helps,

-Joe

I think that worked! I made a PR: https://github.com/matplotlib/matplotlib/pull/4530

···

On Mon, Jun 15, 2015 at 9:50 AM, Benjamin Root <ben.root@…868…3…> wrote:

No, I did not try that one. I’ll give it a shot. I don’t do any Tkinter programming, so I wasn’t familiar with that one.

On Mon, Jun 15, 2015 at 9:23 AM, Joe Kington <joferkington@…149…> wrote:

On Mon, Jun 15, 2015 at 6:23 AM, Benjamin Root <ben.root@…854…> wrote:

That’s the weird thing… I couldn’t! I tried a few different things and I couldn’t make it go away. I’ll probably give it another shot during scipy2015.

I’m guessing, but did you try changing the (Tk) highlightthickness? E.g., something like:

widget.config(borderwidth=0, highlightthickness=0)

It’s a moderately classic Tkinter gotcha. You remove all the borders and there’s still one (hightlightthickness) still there, but it only shows up when you interact with the Frame.

Hope that helps,

-Joe