From 62f063ad09a467ad419370dd4cc9d026331c430f Mon Sep 17 00:00:00 2001 From: Louie Lu Date: Fri, 7 Jul 2017 15:51:58 +0800 Subject: [PATCH] bpo-30870: IDLE: Change sample font when select by key-up/down --- Lib/idlelib/configdialog.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Lib/idlelib/configdialog.py b/Lib/idlelib/configdialog.py index 840922751836..982380c0d474 100644 --- a/Lib/idlelib/configdialog.py +++ b/Lib/idlelib/configdialog.py @@ -14,7 +14,7 @@ from tkinter import (Toplevel, Frame, LabelFrame, Listbox, Label, Button, StringVar, BooleanVar, IntVar, TRUE, FALSE, TOP, BOTTOM, RIGHT, LEFT, SOLID, GROOVE, NORMAL, DISABLED, NONE, BOTH, X, Y, W, E, EW, NS, NSEW, NW, - HORIZONTAL, VERTICAL, ANCHOR, END) + HORIZONTAL, VERTICAL, ANCHOR, ACTIVE, END) from tkinter.ttk import Scrollbar import tkinter.colorchooser as tkColorChooser import tkinter.font as tkFont @@ -157,8 +157,9 @@ class ConfigDialog(Toplevel): frame_font_name, justify=LEFT, text='Font Face :') self.list_fonts = Listbox( frame_font_name, height=5, takefocus=FALSE, exportselection=FALSE) - self.list_fonts.bind( - '', self.on_list_fonts_button_release) + self.list_fonts.bind('', self.on_list_fonts_button_release) + self.list_fonts.bind('', self.on_list_fonts_key_release) + self.list_fonts.bind('', self.on_list_fonts_key_release) scroll_font = Scrollbar(frame_font_name) scroll_font.config(command=self.list_fonts.yview) self.list_fonts.config(yscrollcommand=scroll_font.set) @@ -1033,6 +1034,11 @@ class ConfigDialog(Toplevel): self.font_name.set(font.lower()) self.set_font_sample() + def on_list_fonts_key_release(self, event): + font = self.list_fonts.get(ACTIVE) + self.font_name.set(font.lower()) + self.set_font_sample() + def set_font_sample(self, event=None): "Update the screen samples with the font settings from the dialog." font_name = self.font_name.get() -- 2.47.3