Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix Wx inconsistencies#10518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletionsexamples/user_interfaces/embedding_in_wx2_sgskip.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@
"""

from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.backends.backend_wx import NavigationToolbar2Wx as NavigationToolbar
from matplotlib.figure import Figure

import numpy as np
Expand DownExpand Up@@ -38,7 +38,7 @@ def __init__(self):
self.add_toolbar() # comment this out for no toolbar

def add_toolbar(self):
self.toolbar =NavigationToolbar2Wx(self.canvas)
self.toolbar =NavigationToolbar(self.canvas)
self.toolbar.Realize()
# By adding toolbar in sizer, we are able to put it at the bottom
# of the frame - so appearance is closer to GTK version.
Expand Down
7 changes: 4 additions & 3 deletionsexamples/user_interfaces/embedding_in_wx3_sgskip.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,7 +29,8 @@
import matplotlib
import matplotlib.cm as cm
import matplotlib.cbook as cbook
from matplotlib.backends.backend_wxagg import Toolbar, FigureCanvasWxAgg
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg as NavigationToolbar
from matplotlib.figure import Figure
import numpy as np

Expand All@@ -47,8 +48,8 @@ def __init__(self, parent):
wx.Panel.__init__(self, parent, -1)

self.fig = Figure((5, 4), 75)
self.canvas =FigureCanvasWxAgg(self, -1, self.fig)
self.toolbar =Toolbar(self.canvas) # matplotlib toolbar
self.canvas =FigureCanvas(self, -1, self.fig)
self.toolbar =NavigationToolbar(self.canvas) # matplotlib toolbar
self.toolbar.Realize()
# self.toolbar.set_active([0,1])

Expand Down
6 changes: 3 additions & 3 deletionsexamples/user_interfaces/embedding_in_wx4_sgskip.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@
"""

from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg
from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg as NavigationToolbar
from matplotlib.backends.backend_wx import _load_bitmap
from matplotlib.figure import Figure

Expand All@@ -16,14 +16,14 @@
import wx


class MyNavigationToolbar(NavigationToolbar2WxAgg):
class MyNavigationToolbar(NavigationToolbar):
"""
Extend the default wx toolbar with your own event handlers
"""
ON_CUSTOM = wx.NewId()

def __init__(self, canvas, cankill):
NavigationToolbar2WxAgg.__init__(self, canvas)
NavigationToolbar.__init__(self, canvas)

# for simplicity I'm going to reuse a bitmap from wx, you'll
# probably want to add your own.
Expand Down
8 changes: 4 additions & 4 deletionsexamples/user_interfaces/embedding_in_wx5_sgskip.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,16 +14,16 @@
import wx.aui as aui

import matplotlib as mpl
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg asCanvas
from matplotlib.backends.backend_wxagg importNavigationToolbar2Wx asToolbar
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg asFigureCanvas
from matplotlib.backends.backend_wxagg importNavigationToolbar2WxAgg asNavigationToolbar


class Plot(wx.Panel):
def __init__(self, parent, id=-1, dpi=None, **kwargs):
wx.Panel.__init__(self, parent, id=id, **kwargs)
self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2, 2))
self.canvas =Canvas(self, -1, self.figure)
self.toolbar =Toolbar(self.canvas)
self.canvas =FigureCanvas(self, -1, self.figure)
self.toolbar =NavigationToolbar(self.canvas)
self.toolbar.Realize()

sizer = wx.BoxSizer(wx.VERTICAL)
Expand Down
4 changes: 2 additions & 2 deletionsexamples/user_interfaces/fourier_demo_wx_sgskip.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@
import numpy as np

import wx
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.figure import Figure


Expand DownExpand Up@@ -123,7 +123,7 @@ def __init__(self, *args, **kwargs):
def createCanvas(self, parent):
self.lines = []
self.figure = Figure()
self.canvas =FigureCanvasWxAgg(parent, -1, self.figure)
self.canvas =FigureCanvas(parent, -1, self.figure)
self.canvas.callbacks.connect('button_press_event', self.mouseDown)
self.canvas.callbacks.connect('motion_notify_event', self.mouseMotion)
self.canvas.callbacks.connect('button_release_event', self.mouseUp)
Expand Down
15 changes: 6 additions & 9 deletionslib/matplotlib/backends/backend_wx.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1473,6 +1473,7 @@ def updateButtonText(self, lst):
}


@cbook.deprecated("2.2")
class SubplotToolWX(wx.Frame):
def __init__(self, targetfig):
wx.Frame.__init__(self, None, -1, "Configure subplots")
Expand DownExpand Up@@ -1698,6 +1699,11 @@ def set_history_buttons(self):
self.EnableTool(self.wx_ids['Forward'], can_forward)


@cbook.deprecated("2.2", alternative="NavigationToolbar2Wx")
class Toolbar(NavigationToolbar2Wx):
pass


class StatusBarWx(wx.StatusBar):
"""
A status bar is added to _FigureFrame to allow measurements and the
Expand DownExpand Up@@ -1955,15 +1961,6 @@ def OnPrintPage(self, page):
return True
# >

########################################################################
#
# Now just provide the standard names that backend.__init__ is expecting
#
########################################################################


Toolbar = NavigationToolbar2Wx


@_Backend.export
class _BackendWx(_Backend):
Expand Down
13 changes: 6 additions & 7 deletionslib/matplotlib/backends/backend_wxagg.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,11 +6,12 @@
import wx

import matplotlib
from.. import cbook
frommatplotlib import cbook
from . import wx_compat as wxc
from .backend_agg import FigureCanvasAgg
from .backend_wx import (
_BackendWx, _FigureCanvasWxBase, FigureFrameWx, NavigationToolbar2Wx)
_BackendWx, _FigureCanvasWxBase, FigureFrameWx,
NavigationToolbar2Wx as NavigationToolbar2WxAgg)


class FigureFrameWxAgg(FigureFrameWx):
Expand DownExpand Up@@ -71,15 +72,13 @@ def blit(self, bbox=None):
filetypes = FigureCanvasAgg.filetypes


@cbook.deprecated("2.2")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please leave until 3.0 (one minor-release deprecation period at least, usually two).

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I don't see that any other NavigationToolbar2 is deprecated, especially not the wx non-Agg one.
With the derived class removed and the modifiedimport NavigationToolbar2Wx as NavigationToolbar2WxAgg things are consistent again (no deprecation).

Not having the Toolbar alias in backend_wxagg can break things, though.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Having a deprecation for the Toolbar alias would require to replace the assignmentToolbar = NavigationToolbar2Wx with a derived and deprecated class. I would now be in favor of having this in wx and wxagg. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

derived deprecated class sounds good to me.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks. Done, incl. alternatives in deprecation messages.

class NavigationToolbar2WxAgg(NavigationToolbar2Wx):
def get_canvas(self, frame, fig):
return FigureCanvasWxAgg(frame, -1, fig)
@cbook.deprecated("2.2", alternative="NavigationToolbar2WxAgg")
class Toolbar(NavigationToolbar2WxAgg):
pass


# agg/wxPython image conversion functions (wxPython >= 2.8)


def _convert_agg_to_wx_image(agg, bbox):
"""
Convert the region of the agg buffer bounded by bbox to a wx.Image. If
Expand Down
3 changes: 2 additions & 1 deletionlib/matplotlib/backends/backend_wxcairo.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,8 @@

from .backend_cairo import cairo, FigureCanvasCairo, RendererCairo
from .backend_wx import (
_BackendWx, _FigureCanvasWxBase, FigureFrameWx, NavigationToolbar2Wx)
_BackendWx, _FigureCanvasWxBase, FigureFrameWx,
NavigationToolbar2Wx as NavigationToolbar2WxCairo)
import wx.lib.wxcairo as wxcairo


Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp