FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Mention keyboard modifiers in toolbar tooltip texts. by anntzer · Pull Request #17687 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .m  (1) .py  (2) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
8 changes: 6 additions & 2 deletions lib/matplotlib/backend_bases.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff 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 deletion lib/matplotlib/backends/backend_macosx.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff 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 deletions src/_macosx.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff 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

Back | FazBrowse Home | New Git URL