mirror of https://github.com/chriskiehl/Gooey.git
Browse Source
Removed thread listener by overwriting stdout's write method. added functions to RuntimeDisplay for updated the textbox
pull/1/head
Removed thread listener by overwriting stdout's write method. added functions to RuntimeDisplay for updated the textbox
pull/1/head
3 changed files with 49 additions and 51 deletions
Unified View
Diff Options
-
42src/app/dialogs/runtime_display_panel.py
-
BINsrc/app/images/image_store.pyc
-
58src/experiments/command.py
@ -1,38 +1,40 @@ |
|||||
|
|
||||
''' |
''' |
||||
Created on Jan 7, 2014 |
Created on Jan 7, 2014 |
||||
|
|
||||
@author: Chris |
@author: Chris |
||||
''' |
''' |
||||
|
|
||||
import types |
|
||||
|
|
||||
class Fooer(object): |
|
||||
def __init__(self): |
|
||||
self.a=1 |
|
||||
self.b=2 |
|
||||
self.c=3 |
|
||||
|
|
||||
def error(self, msg): |
|
||||
print msg |
|
||||
|
|
||||
|
import sys |
||||
|
import time |
||||
|
|
||||
class Barer(object): |
|
||||
def __init__(self): |
|
||||
self._fooer = Fooer() |
|
||||
|
|
||||
def __getattr__(self, a): |
|
||||
return getattr(self._fooer, a) |
|
||||
|
_time = time.time |
||||
|
|
||||
class Bazzer(object): |
|
||||
|
class MessagePump(object): |
||||
def __init__(self): |
def __init__(self): |
||||
self._f = Fooer() |
|
||||
|
# self.queue = queue |
||||
|
self.stdout = sys.stdout |
||||
|
self.asdf = [] |
||||
|
|
||||
|
|
||||
def error2(self, msg): |
|
||||
print 'HEY! I\'ve been patched!' |
|
||||
|
|
||||
b = Barer() |
|
||||
|
|
||||
b.error = types.MethodType(error2, b) |
|
||||
|
|
||||
b.error('asdf') |
|
||||
|
# Overrides stdout's write method |
||||
|
def write(self, text): |
||||
|
self.asdf.append((text, _time())) |
||||
|
# if text != '': |
||||
|
# self.queue.put(text) |
||||
|
|
||||
|
|
||||
|
# self.queue = Queue.Queue() |
||||
|
_stdout = sys.stdout |
||||
|
sys.stdout = MessagePump() |
||||
|
# listener = Listener(self.queue, self.cmd_textbox) |
||||
|
# listener.start() |
||||
|
|
||||
|
print 'hello!' |
||||
|
time.sleep(1) |
||||
|
print 'Jello!' |
||||
|
|
||||
|
output = sys.stdout.asdf |
||||
|
sys.stdout = _stdout |
||||
|
for i in output: |
||||
|
print i |
||||
|
print _time() |
Write
Preview
Loading…
Cancel
Save