[pygtk] how combine/display: text/button data
pyme at darkwinner.com
pyme at darkwinner.com
Mon Nov 26 03:23:29 WST 2007
Hi folks!
I'm putting together my first program in pyGTK, and am getting tripped up
by something seemingly simple. Here's my question:
============
How do you combine data entered from "keyboard data" with "button clicked
data", and display the combined data in the typed entry box?
==========
The following program illustrates a simplified abstraction of what I'm
trying to do:
--------
source code at:
http://www.darkwinner.com/linux/testProgram.html
--------
There is a text box with 2 buttons in it. You enter data by typing or
clicking a button.
#============
You want to enter 'fred1' (but let's say your keyboard has no number keys
on it)
So you type 'fred' and click 'print1'.
The textbox should then read 'fred1'
#===============
The program doesn't work like that now. My two problems:
-------------
Problem 1:
allEnteredList starts with [1,2,3] and the fullMessage ('123') starts off
displayed in the text box.
But when allEnteredList becomes [1,2,3,1] (because button 1 was pushed):
fullMessage becomes 1231 (as it should)
but the text box isn't updated to display a message of 1231
How should I alter the source code to fix update the message when
button1 is pushed??
-------------
Problem 2:
I can't figure out how to connect MessageView with "printIt" (or if that's
even the best way to combine data b/w buttons and typing) "activated"
should work if you hit enter (but it doesn't), I'm looking for something
that says, "Run the printIt function every time a key is entered."
How do I do that?
-------------
If this was pygame, I could solve problem 1 by redrawing a blank textbox
and re-blitting the updated full message. And I could solve problem 2 by
polling keyboard typing and say if 'a' typed, send 'a' to printIt.
But I'm unsure how to do this with pyGTK. (I'm guessing I need to insert
it into the mainloop?) I've marked the problem area with commented #>>>.
It would be a big help if someone could explain how to modify the code to
get it to work.
Thanks in advance
The Darkwinner
http://www.darkwinner.com/linux/testProgram.html
More information about the pygtk
mailing list