# File: entrynoscroll.py # References: # http://infohost.nmt.edu/tcc/help/pubs/tkinter//entry.html # http://www.tcl.tk/man/tcl8.5/TkCmd/ttk_entry.htm from tkinter import * from tkinter import ttk from demopanels import MsgPanel, SeeDismissPanel class EntryNoScrollDemo(ttk.Frame): def __init__(self, isapp=True, name='entrynoscrolldemo'): ttk.Frame.__init__(self, name=name) self.pack(expand=Y, fill=BOTH) self.master.title('Entry without scroll Demo') self.isapp = isapp self._create_widgets() def _create_widgets(self): if self.isapp: MsgPanel(self, ["Three different entries are displayed below. You can add characters by pointing, ", "clicking and typing. The normal Motif editing characters are supported, along ", "with many Emacs bindings.\n\n", "For example, Backspace and Control-h delete the character to the left of the ", "insertion cursor and Delete and Control-d delete the chararacter to the right ", "of the insertion cursor\n\n", "For entries that are too large to fit in the window all at once, you can scan ", "through the entries by dragging with the left mouse button pressed."]) SeeDismissPanel(self) self._create_demo_panel() def _create_demo_panel(self): demoPanel = ttk.Frame(self) demoPanel.pack(side=TOP, fill=BOTH, expand=Y) longTxt = ["This entry contains a long value, ", "much to long to fit into the window ", "at one time; so long in fact, that ", "you'll have to scan and scroll to ", "get to the end."] # entry fields e1 = ttk.Entry(demoPanel) e2 = ttk.Entry(demoPanel) e3 = ttk.Entry(demoPanel) # add some text to the fields e1.insert(END, 'Initial value') e2.insert(END, ''.join(longTxt)) # pack and show e1.pack(side=TOP, pady=5, padx=10, fill=X) e2.pack(side=TOP, pady=5, padx=10, fill=X) e3.pack(side=TOP, pady=5, padx=10, fill=X) if __name__ == '__main__': EntryNoScrollDemo().mainloop()
Page List
▼
Sunday, July 29, 2012
Tkinter Entry without scroll Demo
This code is based on Tcl entry1.tcl demo. It displays three basic, single line entry fields.