[Tutor] Reading from a GUI

Budgester budgester@budgester.com
Wed, 24 Jan 2001 22:59:09 -0000

>D-Man Wrote :
>What is meant by "escape code" can differ by useage.  For example, in
>Eiffel you would use "%N" as the excape code for a newline.  \012 is
>the octal value of the character.  0xA is the hexadeciaml value and 10
>is the decimal value.  In C/C++/Java/Perl and Python \n is used as the
>escape for a newline, but with the proper conversion you can use any
>of these.

They are the escape code I was looking for.

>To "read from" a GUI you need to check the docs of the gui you are
>using.  In GTK, for example, there is a funciton get_text in the
>Gtk.Text widget (or some similar name).  The function returns a string

I'm currently using Tkinter, but from reading this list it seems like the
most popular Toolkit is GTK, what is the general preference for python,
i.e. best documentation, ease of use, samples etc < I'm not trying to start
a holy war here, just peoples experiences ;-) >

>import string
>my_str = text_widget.get_text()
>modified_str = string.replace( my_str, "\n" , "<br>" )
>print my_str
>pirnt modified_str

pretty much exactly the code I was after.


Loads thanks

I'll let you know how it goes.