I wrote a script that is controlled via an ui and outputs what it does through the console.
My problem is that it doesn't output the data in realtime.
My code works like the following example.
The time.sleep(5) is just some time consuming task.
I would like to have an output like this
a
b
waiting 5 seconds
c
d
Instead the output is
a
waiting 5 seconds
b
c
d
# coding: utf-8
import ui, time, tempfile
ui_file = '[{"selected" : false,"frame" : "{{0, 0}, {240, 240}}","class" : "View","nodes" : [{"selected" : true,"frame" : "{{75, 49}, {80, 32}}","class" : "Button","nodes" : [],"attributes" : {"action" : "button","frame" : "{{80, 104}, {80, 32}}","title" : "Button","class" : "Button","uuid" : "269E121F-FCD6-478B-B6CD-2F2C2D3E2ED8","font_size" : 15,"name" : "button1"}}],"attributes" : {"enabled" : true,"background_color" : "RGBA(1.000000,1.000000,1.000000,1.000000)","tint_color" : "RGBA(0.000000,0.478000,1.000000,1.000000)","border_color" : "RGBA(0.000000,0.000000,0.000000,1.000000)","flex" : ""}}]'
def button(sender):
print 'b'
time.sleep(5)
print 'c'
open('Test_abcd.pyui', 'w').write(ui_file)
print 'a'
v = ui.load_view('Test_abcd')
v.present('sheet')
v.wait_modal()
print 'd'