|
5 | 5 | import os.path |
6 | 6 | import sys |
7 | 7 | import tkinter as tk |
8 | | -from tkinter.simpledialog import SimpleDialog |
9 | 8 | import tkinter.filedialog |
| 9 | +import tkinter.font |
10 | 10 | import tkinter.messagebox |
| 11 | +from tkinter.simpledialog import SimpleDialog |
11 | 12 |
|
12 | 13 | import numpy as np |
13 | 14 | from PIL import Image, ImageTk |
@@ -525,16 +526,19 @@ def __init__(self, canvas, window, *, pack_toolbar=True): |
525 | 526 | if tooltip_text is not None: |
526 | 527 | ToolTip.createToolTip(button, tooltip_text) |
527 | 528 |
|
| 529 | + self._label_font = tkinter.font.Font(size=10) |
| 530 | + |
528 | 531 | # This filler item ensures the toolbar is always at least two text |
529 | 532 | # lines high. Otherwise the canvas gets redrawn as the mouse hovers |
530 | 533 | # over images because those use two-line messages which resize the |
531 | 534 | # toolbar. |
532 | | - label = tk.Label(master=self, |
| 535 | + label = tk.Label(master=self, font=self._label_font, |
533 | 536 | text='\N{NO-BREAK SPACE}\n\N{NO-BREAK SPACE}') |
534 | 537 | label.pack(side=tk.RIGHT) |
535 | 538 |
|
536 | 539 | self.message = tk.StringVar(master=self) |
537 | | - self._message_label = tk.Label(master=self, textvariable=self.message) |
| 540 | + self._message_label = tk.Label(master=self, font=self._label_font, |
| 541 | + textvariable=self.message) |
538 | 542 | self._message_label.pack(side=tk.RIGHT) |
539 | 543 |
|
540 | 544 | NavigationToolbar2.__init__(self, canvas) |
@@ -602,8 +606,10 @@ def _Button(self, text, image_file, toggle, command): |
602 | 606 | if size > 24 else image_file) as im: |
603 | 607 | image = ImageTk.PhotoImage(im.resize((size, size)), |
604 | 608 | master=self) |
605 | | - b.config(image=image, height='18p', width='18p') |
| 609 | + b.configure(image=image, height='18p', width='18p') |
606 | 610 | b._ntimage = image # Prevent garbage collection. |
| 611 | + else: |
| 612 | + b.configure(font=self._label_font) |
607 | 613 | b.pack(side=tk.LEFT) |
608 | 614 | return b |
609 | 615 |
|
@@ -745,8 +751,10 @@ def __init__(self, toolmanager, window): |
745 | 751 | tk.Frame.__init__(self, master=window, |
746 | 752 | width=int(width), height=int(height), |
747 | 753 | borderwidth=2) |
| 754 | + self._label_font = tkinter.font.Font(size=10) |
748 | 755 | self._message = tk.StringVar(master=self) |
749 | | - self._message_label = tk.Label(master=self, textvariable=self._message) |
| 756 | + self._message_label = tk.Label(master=self, font=self._label_font, |
| 757 | + textvariable=self._message) |
750 | 758 | self._message_label.pack(side=tk.RIGHT) |
751 | 759 | self._toolitems = {} |
752 | 760 | self.pack(side=tk.TOP, fill=tk.X) |
|
0 commit comments