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

FigureCanvasWx/Agg fixed size#10153

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

Closed
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
81 changes: 53 additions & 28 deletionslib/matplotlib/backends/backend_wx.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,7 @@
unicode_literals)

from six.moves import xrange
import six

import sys
import os
Expand DownExpand Up@@ -948,8 +949,19 @@ def _onSize(self, evt):
"""

DEBUG_MSG("_onSize()", 2, self)
sz = self.GetParent().GetSizer()
if sz: si = sz.GetItem(self)
if not sz or not si or (not si.Proportion and not si.Flag & wx.EXPAND):
# not managed by a sizer at all or with a constant size
size = self.GetMinSize()
else:
# variable size, managed by a wx.Sizer
size = self.GetClientSize()
if getattr(self, "_width", None) and size==(self._width,self._height):
# no change in size
return
self._width, self._height = size
# Create a new, correctly sized bitmap
self._width, self._height = self.GetClientSize()
self.bitmap = wxc.EmptyBitmap(self._width, self._height)

self._isDrawn = False
Expand DownExpand Up@@ -1483,9 +1495,13 @@ def __init__(self, targetfig):
tool = SubplotTool(targetfig, toolfig)


class NavigationToolbar2Wx(NavigationToolbar2, wx.ToolBar):
class NavigationController2Wx(NavigationToolbar2):
"""
The parts from NavigationToolbar2Wx that are not specific to wx.ToolBar;
so this functionality can be used without adding a toolbar.
"""

def __init__(self, canvas):
wx.ToolBar.__init__(self, canvas.GetParent(), -1)
NavigationToolbar2.__init__(self, canvas)
self.canvas = canvas
self._idle = True
Expand All@@ -1501,33 +1517,8 @@ def get_canvas(self, frame, fig):
return FigureCanvasWx(frame, -1, fig)

def _init_toolbar(self):
DEBUG_MSG("_init_toolbar", 1, self)

self._parent = self.canvas.GetParent()

self.wx_ids = {}
for text, tooltip_text, image_file, callback in self.toolitems:
if text is None:
self.AddSeparator()
continue
self.wx_ids[text] = wx.NewId()
wxc._AddTool(self, self.wx_ids, text,
_load_bitmap(image_file + '.png'),
tooltip_text)

self.Bind(wx.EVT_TOOL, getattr(self, callback),
id=self.wx_ids[text])

self.Realize()

def zoom(self, *args):
self.ToggleTool(self.wx_ids['Pan'], False)
NavigationToolbar2.zoom(self, *args)

def pan(self, *args):
self.ToggleTool(self.wx_ids['Zoom'], False)
NavigationToolbar2.pan(self, *args)

def configure_subplots(self, evt):
frame = wx.Frame(None, -1, "Configure subplots")

Expand DownExpand Up@@ -1688,6 +1679,40 @@ def set_message(self, s):
if self.statbar is not None:
self.statbar.set_function(s)


class NavigationToolbar2Wx(NavigationController2Wx, wx.ToolBar):
def __init__(self, canvas):
wx.ToolBar.__init__(self, canvas.GetParent(), -1)
NavigationController2Wx.__init__(self, canvas)

def _init_toolbar(self):
DEBUG_MSG("_init_toolbar", 1, self)

self._parent = self.canvas.GetParent()

self.wx_ids = {}
for text, tooltip_text, image_file, callback in self.toolitems:
if text is None:
self.AddSeparator()
continue
self.wx_ids[text] = wx.NewId()
wxc._AddTool(self, self.wx_ids, text,
_load_bitmap(image_file + '.png'),
tooltip_text)

self.Bind(wx.EVT_TOOL, getattr(self, callback),
id=self.wx_ids[text])

self.Realize()

def zoom(self, *args):
self.ToggleTool(self.wx_ids['Pan'], False)
NavigationToolbar2.zoom(self, *args)

def pan(self, *args):
self.ToggleTool(self.wx_ids['Zoom'], False)
NavigationToolbar2.pan(self, *args)

def set_history_buttons(self):
can_backward = self._nav_stack._pos > 0
can_forward = self._nav_stack._pos < len(self._nav_stack._elements) - 1
Expand Down
9 changes: 7 additions & 2 deletionslib/matplotlib/backends/backend_wxagg.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,8 +9,8 @@
from . import wx_compat as wxc
from . import backend_wx
from .backend_agg import FigureCanvasAgg
from .backend_wx import (
_BackendWx, FigureCanvasWx, FigureFrameWx, NavigationToolbar2Wx, DEBUG_MSG)
from .backend_wx import (_BackendWx, FigureCanvasWx, FigureFrameWx,
NavigationToolbar2Wx, NavigationController2Wx, DEBUG_MSG)


class FigureFrameWxAgg(FigureFrameWx):
Expand DownExpand Up@@ -90,6 +90,11 @@ def print_figure(self, filename, *args, **kwargs):
self.draw()


class NavigationController2WxAgg(NavigationController2Wx):
def get_canvas(self, frame, fig):
return FigureCanvasWxAgg(frame, -1, fig)


class NavigationToolbar2WxAgg(NavigationToolbar2Wx):
def get_canvas(self, frame, fig):
return FigureCanvasWxAgg(frame, -1, fig)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp