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

Backport PR #17687 on branch v3.3.x (Mention keyboard modifiers in toolbar tooltip texts.)#17701

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
8 changes: 6 additions & 2 deletionslib/matplotlib/backend_bases.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2818,8 +2818,12 @@ class NavigationToolbar2:
('Back', 'Back to previous view', 'back', 'back'),
('Forward', 'Forward to next view', 'forward', 'forward'),
(None, None, None, None),
('Pan', 'Pan axes with left mouse, zoom with right', 'move', 'pan'),
('Zoom', 'Zoom to rectangle', 'zoom_to_rect', 'zoom'),
('Pan',
'Left button pans, Right button zooms\n'
'x/y fixes axis, CTRL fixes aspect',
'move', 'pan'),
('Zoom', 'Zoom to rectangle\nx/y fixes axis, CTRL fixes aspect',
'zoom_to_rect', 'zoom'),
('Subplots', 'Configure subplots', 'subplots', 'configure_subplots'),
(None, None, None, None),
('Save', 'Save the figure', 'filesave', 'save_figure'),
Expand Down
7 changes: 6 additions & 1 deletionlib/matplotlib/backends/backend_macosx.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -113,8 +113,13 @@ class NavigationToolbar2Mac(_macosx.NavigationToolbar2, NavigationToolbar2):

def __init__(self, canvas):
self.canvas = canvas # Needed by the _macosx __init__.
data_path = cbook._get_data_path('images')
_, tooltips, image_names, _ = zip(*NavigationToolbar2.toolitems)
_macosx.NavigationToolbar2.__init__(
self, str(cbook._get_data_path('images')))
self,
tuple(str(data_path / image_name) + ".pdf"
for image_name in image_names if image_name is not None),
tuple(tooltip for tooltip in tooltips if tooltip is not None))
NavigationToolbar2.__init__(self, canvas)

def draw_rubberband(self, event, x0, y0, x1, y1):
Expand Down
43 changes: 15 additions & 28 deletionssrc/_macosx.m
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1108,8 +1108,6 @@ -(void)save_figure:(id)sender

self->height = height;

const char* basedir;

obj = PyObject_GetAttrString((PyObject*)self, "canvas");
if (obj==NULL)
{
Expand All@@ -1130,8 +1128,6 @@ -(void)save_figure:(id)sender
return -1;
}

if(!PyArg_ParseTuple(args, "s", &basedir)) return -1;

NSRect bounds = [view bounds];
NSWindow* window = [view window];

Expand All@@ -1141,35 +1137,24 @@ -(void)save_figure:(id)sender
bounds.size.height += height;
[window setContentSize: bounds.size];

NSString* dir = [NSString stringWithCString: basedir
encoding: NSASCIIStringEncoding];
const char* images[7];
const char* tooltips[7];
if (!PyArg_ParseTuple(args, "(sssssss)(sssssss)",
&images[0], &images[1], &images[2], &images[3],
&images[4], &images[5], &images[6],
&tooltips[0], &tooltips[1], &tooltips[2], &tooltips[3],
&tooltips[4], &tooltips[5], &tooltips[6])) {
return -1;
}

NSButton* buttons[7];

NSString* images[7] = {@"home.pdf",
@"back.pdf",
@"forward.pdf",
@"move.pdf",
@"zoom_to_rect.pdf",
@"subplots.pdf",
@"filesave.pdf"};

NSString* tooltips[7] = {@"Reset original view",
@"Back to previous view",
@"Forward to next view",
@"Pan axes with left mouse, zoom with right",
@"Zoom to rectangle",
@"Configure subplots",
@"Save the figure"};

SEL actions[7] = {@selector(home:),
@selector(back:),
@selector(forward:),
@selector(pan:),
@selector(zoom:),
@selector(configure_subplots:),
@selector(save_figure:)};

NSButtonType buttontypes[7] = {NSMomentaryLightButton,
NSMomentaryLightButton,
NSMomentaryLightButton,
Expand All@@ -1194,9 +1179,11 @@ -(void)save_figure:(id)sender
rect.origin.x = gap;
rect.origin.y = 0.5*(height - rect.size.height);

for (i = 0; i < 7; i++)
{
NSString* filename = [dir stringByAppendingPathComponent: images[i]];
for (i = 0; i < 7; i++) {
NSString* filename = [NSString stringWithCString: images[i]
encoding: NSUTF8StringEncoding];
NSString* tooltip = [NSString stringWithCString: tooltips[i]
encoding: NSUTF8StringEncoding];
NSImage* image = [[NSImage alloc] initWithContentsOfFile: filename];
buttons[i] = [[NSButton alloc] initWithFrame: rect];
[image setSize: size];
Expand All@@ -1205,7 +1192,7 @@ -(void)save_figure:(id)sender
[buttons[i] setImage: image];
[buttons[i] scaleUnitSquareToSize: scale];
[buttons[i] setImagePosition: NSImageOnly];
[buttons[i] setToolTip:tooltips[i]];
[buttons[i] setToolTip:tooltip];
[[window contentView] addSubview: buttons[i]];
[buttons[i] release];
[image release];
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp