On Fri, Aug 02, 2002 at 05:05:55AM -0400, Nate Custer wrote:
> Hey all,
>
> I am writing a 5250 terminal emulator in python, and would like to use
> gtk2 for the gui. However I am not sure I can find the right widget to
> use for the main terminal window. Here are the requirments:
>
> 1) must be able to capture all key presses to be parsed by emulator.
> 2) must be able to support different color text in the same widget.
> 3) must support different color background colors for the text in the
> widget.
> 4) must be able to display a block cursor.
>
The GtkText can do all of these things, with a small amount of
extra effort. Set the widget to be "non-editable", then catch
"key-press-event", and do all of your own processing. A block
cursor can be constructed by inserting a trailing space after
your regular insertion, with foreground and background colors
reversed. The key-press-event contains enough information in the
"event" argument to allow you to catch function keys and
cursor-movement commands, as well as control, meta, and so
forth.
To prevent "tab" and other special characters from being
passed on and doing inconvenient things like switching the
focus out of the widget, you can do "emit_stop_by_name" on
the event for those particular "problem" keys.
I have a "console" window for the application I am working
on, which works this way -- I use it for interacting with the
Python interpreter while the GUI event loop is running. I can
send you example code from this, if you want to go this route.
-- Andrew Reid
[EMAIL PROTECTED]
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/