|
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
|
@@ -512,16 +513,19 @@ def __init__(self, canvas, window, *, pack_toolbar=True):
|
512 | 513 | if tooltip_text is not None:
|
513 | 514 | ToolTip.createToolTip(button, tooltip_text)
|
514 | 515 |
|
| 516 | + self._label_font = tkinter.font.Font(size=10) |
| 517 | + |
515 | 518 | # This filler item ensures the toolbar is always at least two text
|
516 | 519 | # lines high. Otherwise the canvas gets redrawn as the mouse hovers
|
517 | 520 | # over images because those use two-line messages which resize the
|
518 | 521 | # toolbar.
|
519 |
| - label = tk.Label(master=self, |
| 522 | + label = tk.Label(master=self, font=self._label_font, |
520 | 523 | text='\N{NO-BREAK SPACE}\n\N{NO-BREAK SPACE}')
|
521 | 524 | label.pack(side=tk.RIGHT)
|
522 | 525 |
|
523 | 526 | self.message = tk.StringVar(master=self)
|
524 |
| - self._message_label = tk.Label(master=self, textvariable=self.message) |
| 527 | + self._message_label = tk.Label(master=self, font=self._label_font, |
| 528 | + textvariable=self.message) |
525 | 529 | self._message_label.pack(side=tk.RIGHT)
|
526 | 530 |
|
527 | 531 | NavigationToolbar2.__init__(self, canvas)
|
@@ -589,8 +593,10 @@ def _Button(self, text, image_file, toggle, command):
|
589 | 593 | if size > 24 else image_file) as im:
|
590 | 594 | image = ImageTk.PhotoImage(im.resize((size, size)),
|
591 | 595 | master=self)
|
592 |
| - b.config(image=image, height='24p', width='24p') |
| 596 | + b.configure(image=image, height='24p', width='24p') |
593 | 597 | b._ntimage = image # Prevent garbage collection.
|
| 598 | + else: |
| 599 | + b.configure(font=self._label_font) |
594 | 600 | b.pack(side=tk.LEFT)
|
595 | 601 | return b
|
596 | 602 |
|
@@ -733,8 +739,10 @@ def __init__(self, toolmanager, window):
|
733 | 739 | tk.Frame.__init__(self, master=window,
|
734 | 740 | width=int(width), height=int(height),
|
735 | 741 | borderwidth=2)
|
| 742 | + self._label_font = tkinter.font.Font(size=10) |
736 | 743 | self._message = tk.StringVar(master=self)
|
737 |
| - self._message_label = tk.Label(master=self, textvariable=self._message) |
| 744 | + self._message_label = tk.Label(master=self, font=self._label_font, |
| 745 | + textvariable=self._message) |
738 | 746 | self._message_label.pack(side=tk.RIGHT)
|
739 | 747 | self._toolitems = {}
|
740 | 748 | self.pack(side=tk.TOP, fill=tk.X)
|
|
0 commit comments