Hi, all.
As the title suggests, I started to write ui module on desktop which bridges between ui.py on Pythonista and kivy on desktop.
To give you an idea, here's a sample python script that's working on both Pythonista and desktop.
(I will omit .pyui since it's too long and unimportant here)
import ui
def button_tapped(sender):
'@type sender: ui.Button'
# Get the button's title for the following logic:
t = sender.title
global shows_result
# Get the labels:
label_sentence = sender.superview['label_sentence']
input_sentence = sender.superview['input_sentence']
label_answer = sender.superview['label_answer']
if t == 'Check':
label_answer.text = input_sentence.text
v = ui.load_view()
label_sentence = v['label_sentence']
input_sentence = v['input_sentence']
label_answer = v['label_answer']
label_sentence.text = 'test'
v.present('sheet')
I can't run this script on desktop because there is no ui module.
So, I wrote ui.py that internally calls kivy.
it's working with Button(along with its action function), Label, TextField classes so far.
Q) My code is based on ui.py from Pythonista. Can I upload my code to a public repository such as github?
I'm aware of the fact that there are similar topics on this forum.
https://forum.omz-software.com/topic/1869/ui-on-desktop
https://forum.omz-software.com/topic/3964/unipage-as-a-bridge-between-kivy-and-pythonista
However, I couldn't find the way to meet my goal: run scripts with .pyui on desktop without ANY modification
UniPAGe has a great advantage that it can run on five major platforms with almost identical visuals, but with no disrespect, it has a disadvantage that one has to write the script with it from the start. Also, I think it deprives Pythonista of its great UI editing ability since a variety of attributes including the position and size have to be hard-coded inside the script.
-> UniPAGe now has a visual interface designer. Check it out here
One might think what I'm trying to achieve is a little bit odd because ui module is not universal--it could be only used in Pythonista.
I am a software engineer and python is not my main language.
If I use python, that would be mainly on Pythonista.
Occasionally, I would like to run it on desktop too.
My work will minimize inconvenience to such a job.
I can say I am almost new to python.
So, things I understood and mentioned above could be wrong.
I would appreciate if you correct me.