def test_autocompleteentry(self): entry = AutocompleteEntry(self.window, completevalues=["Apple", "Pear", "Banana"]) entry.pack() self.window.update() entry.insert(0, "A") self.window.update() for item in ["A", "Up", "Down", "Left", "Right", "Return"]: entry.handle_keyrelease(TestEvent(item)) entry.autocomplete(0) entry.set_completion_list(["Apply"])
def test_autocompleteentry(self): entry = AutocompleteEntry(self.window, completevalues=["Apple", "Pear", "Banana"]) entry.pack() self.window.update() self.assertIn('completevalues', entry.keys()) self.assertEqual(entry['completevalues'], sorted(["Apple", "Pear", "Banana"])) entry.insert(0, "A") self.window.update() for item in ["A", "Up", "Down", "Left", "Right", "Return"]: entry.handle_keyrelease(TestEvent(item)) entry.autocomplete(0) entry.set_completion_list(["Apply"]) self.assertEqual(entry['completevalues'], ["Apply"]) entry['completevalues'] = ["Test"] self.assertEqual(entry['completevalues'], ["Test"])
# -*- coding: utf-8 -*- # Copyright (c) Juliette Monsel 2018 # For license see LICENSE from ttkwidgets.autocomplete import AutocompleteEntry import tkinter as tk window = tk.Tk() tk.Label(window, text="Entry with autocompletion for the Tk instance's methods:").pack( side='left') entry = AutocompleteEntry(window, width=20, completevalues=dir(window)) entry.pack(side='right') window.mainloop()