Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello โ I'm @olemoritz on Twitter.
ui.View Update
-
Hey Guys,
I have a new Problem...
When i run "big" MYSQL Codes (one Function) i would do an Update an some Labels... when my first codes done in the Function...
but the Text and Background of the "new" Label takes effect when the MYSQL Codes are Complete finished....Is it possible to solve this ??
thanks and greets -
@DavinE, to me, the easiest approach would be to use scripter,
pip install pythonista-scripter
, then you can write your function like this, and the UI will be updated always when youyield
:from scripter import * @script def my_func(label): open_database() for loop: do_some_operations() label.text = "Some update" yield close_database()
-
@mikael, This looks great!
but i don't know why this function in @script works and then it don't work....i used it in this way:
from scripter import script @script def test(self, sender): if......: open_database() close_database() self.barcodeNumberCheckDisplayLabel.text = getText('datanormUpdateNONE', self.DEVICE) self.barcodeNumberCheckDisplayLabel.bg_color = getColor('selectionNONE') yield else: self.barcodeNumberCheckDisplayLabel.text = getText('datanormUpdateDONE', self.DEVICE) self.barcodeNumberCheckDisplayLabel.bg_color = getColor('selectionYES') yield if......: open_database() close_database() self.ebraNumberCheckDisplayLabel.text = getText('datanormUpdateNONE', self.DEVICE) self.ebraNumberCheckDisplayLabel.bg_color = getColor('selectionNONE') yield else: self.ebraNumberCheckDisplayLabel.text = getText('datanormUpdateDONE', self.DEVICE) self.ebraNumberCheckDisplayLabel.bg_color = getColor('selectionYES') yield if......: open_database() close_database() self.cuttingCheckDisplayLabel.text = getText('datanormUpdateNONE', self.DEVICE) self.cuttingCheckDisplayLabel.bg_color = getColor('selectionNONE') yield else: self.cuttingCheckDisplayLabel.text = getText('datanormUpdateDONE', self.DEVICE) self.cuttingCheckDisplayLabel.bg_color = getColor('selectionYES') yield
is anything wrong on this ?
EDIT: When i press the button sometimes it goes and sometimes it don't goes and nothing will happened...
EDIT1: I know when the Problem is....
I Open Pythonista... Run my App call the Function then i close my App and open it again... then it don't worked
I need to reopen Pythonista then it works every Time.... but Why ? -
@mikael , Iโve got a simular problem ! My animations with calls to scripter only works one time ๐ข. I need to restart Pythonista !
I take this opportunity to thank you for your fantastic modules. iPadOS 14.3 beta on iPad mini 4 -
@DavinE, Enez, looks like the PyPI version had a bit of a globals issue, should be fixed now.
-
@mikael , unfortunately, the problem persists ! Do I need to reinstall something ?
-
@Enez-Houad, did you
pip update pythonista-scripter
? And maybe restart Pythonista to force re-import? -
@mikael, Yes, Iโve updated Scripter (even uninstall and reinstall) and restarted Pythonista. And nowโฆ it works the first time, doesnโt the second and crash the third !
-
@Enez-Houad, anything you could share so I can reproduce/fix?
-
@mikael, here is a simple example:
import ui from scripter import script from anchors import dock, size_to_fit, attach mainview = ui.View(name='scripter_view', bg_color='black') Label_1 = size_to_fit(ui.Label(name='Label_1', bg_color='red', text='nothing will happend')) dock(Label_1).top_center(mainview) Label_2 = size_to_fit(ui.Label(name='Label_2', bg_color='red', text='nothing will happend')) attach(Label_2).below(Label_1) Label_3 = size_to_fit(ui.Label(name='Label_3', bg_color='red', text='nothing will happend')) attach(Label_3).below(Label_2) @script def test(): Label_1.text = 'okay' Label_1.bg_color = 'green' yield 2 Label_2.text = 'okay' Label_2.bg_color = 'green' yield 2 Label_3.text = 'okay' Label_3.bg_color = 'green' yield if __name__ == '__main__': mainview.present('fullscreen') test()
the fist time it works perfect...
then close the view and reopen the view... nothing will happened..
you need to reopen Pythonista.hope this will help you out
-
@DavinE, could not find a better way to make this reliable than requiring an explicit call to
start_scripter
, see example below (requires update).import ui from scripter import script, start_scripter mainview = ui.View(name='scripter_view', bg_color='black') start_scripter(mainview) ...
-
@mikael, Perfect ๐๐๐๐
Thank you very much, I would find it hard to do without Scripter! -
@mikael said:
@DavinE, could not find a better way to make this reliable than requiring an explicit call to
start_scripter
, see example below (requires update).import ui from scripter import script, start_scripter mainview = ui.View(name='scripter_view', bg_color='black') start_scripter(mainview) ...
@mikael, It works Perfect!
Thanks for your help and work into it!