[Tutor] C# style multi-line textbox in Python

Alan Gauld alan.gauld at btinternet.com
Sun Jun 3 01:15:47 CEST 2007


"Darren Williams" <D3IBZ at hotmail.com> wrote
> I'm completely new when it comes to Python so forgive
> me for asking a potentially very simple question.
> Can C# style multi-line textboxes for user-input
> be scripted in Python?

Yes, but as part of a GUI.

> Are there any other attributes that I can add to
> either input() or raw_input()?

No, it's rather more complex.

Here is an example in Tkinter, the standard GUI
toolkit that comes with python:

from Tkinter import *
tk = Tk()
t = Text(tk)
t.pack()
tk.mainloop()


Or, with a scrollbar:

from Tkinter import *
import ScrolledText
tk = Tk()
ScrolledText.ScrolledText(tk).pack()
tk.mainloop()

Now that doesn't let you read the contents of the
text box but it shows that you can create one.

However before you get to that stage you will be better off
sticking with command line style programs for a while
until you are comfortable with the python language.

There are basic entry dialogs you can use without resorting
to Tkinter  completely but I don't think they include a
multiline input box. Try this link for more info:

http://www.pythonware.com/library/tkinter/introduction/x1164-data-entry.htm

Also the GUI topic of my tutorial covers the minimum needed
for GUI programming in Python.

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list