I'm quite new in programming, even in speaking in English.. so I'm just trying to explain my problem here:
I'm building a GUI using Glade 3, which need show all output of 'print' in a TextView or some Widgets else of Glade 3,
My python code is something like this:
#ab.py
def a():
print 'AAAAA'
def b():
print 'BBBBB'
and
#button_c.py
def button_c():
if:
print '11111'
elif:
print '22222'
else:
print '33333'
a()
b()
if __name__ == '__main__':
button_c()
I'm trying use some code like this to show all of the output of 'print' in the object textview1 in a real time, just like the Python Interpreter did:
def on_button_c_clicked(self, widget):
button_c()
self.builder.get_object("textview1").get_buffer().set_text(??????)
I've googled a lot and seeing something about sys.stdout, thread, subprocess and textbuffer, but I still can't figure it out, the only idea i have in the moment is change all 'print' parte of the code as:
def a():
# print 'AAAAA'
output_gui = 'AAAAA'
print output_gui
self.builder.get_object("textview1").get_buffer().set_text(output_gui)
I haven't tried this yet because there must be another smarter way, no?