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.
can u help me Out?
-
@some-user I write it easily understood but the code of @ccc is more professional and also supports the iPhone. I'll include his additional field this afternoon.
-
@some-user try this, taken in account dimensions in @ccc code
import ui # init dictionnary with items names and unit proces items = {} items['tomate'] = 2 items['salami'] = 1.5 items['käse'] = 1.5 items['butter'] = 1.5 items['frischkäse'] = 1.5 # create main View mv = ui.View() mv.frame = (0,0,360,360) mv.name = 'test' # init some parametrized dimensions, you could change to see effect d = 10 # horizontal and vertical distance between contiguous fields h = 32 # height of fields y = d # initial y for item in sorted(items.keys()): # loop on items, sorted by names p = items[item] # get item price from dictionnary # create Label for item name l = ui.Label() l.frame = (d,y,215,h) # its area in main view x,y,dx,dy l.text = item # init it with item name mv.add_subview(l) # set the label as field of main view # create TextField for entry of number of items n = ui.TextField(name=item) # set its name as the item name n.keyboard_type = ui.KEYBOARD_NUMBER_PAD # use numeric keyboard n.frame = (d*2+215,y,50,h) # its area in main view mv.add_subview(n) # create Label for unit price lp = ui.Label() lp.frame = (d*3+265,y,50,h) # its area lp.alignment = ui.ALIGN_RIGHT # align the text at right lp.text = '{0:.2f}'.format(p) + ' €' # format the unit price as '1.23 €' mv.add_subview(lp) # compute vertical position y for next row y = y + h + d # create Label for expenses title l = ui.Label() l.frame = (d,y,215,h) # its area in main view x,y,dx,dy l.text = 'Ausgaben' mv.add_subview(l) # set the label as field of main view # create TextField for entry of xpenses ex = ui.TextField(name='expenses') ex.keyboard_type = ui.KEYBOARD_DECIMAL_PAD # works on iPhones, not iPads ex.frame = (d*2+215,y,50,h) # its area in main view mv.add_subview(ex) # create Label for € l = ui.Label() l.frame = (d*3+265,y,50,h) # its area in main view x,y,dx,dy l.text = '€' mv.add_subview(l) # set the label as field of main view y = y + h + d # define the code to execute when ok is tapped def b_action(sender): t = 0 # init total for item in items.keys(): # loop on items try: # protect if number not filled or not numeric n = float(mv[item].text) # get entered number in textfield named item t = t + float(items[item]) * n # cumulate price x n except: pass try: t = t - float(mv['expenses'].text) except: pass # fill result field with total formatted as '123.45 €' sender.superview['total'].text = '{0:.2f}'.format(t) + ' €' # create button for ok b = ui.Button() b.frame = (d*3+265,y,50,h) # its area b.border_width = 1 # display a border to button b.corner_radius = 5 # with rounded corners b.title = 'ok' b.action = b_action # which code to execute of tapped mv.add_subview(b) # create Label to display computed total ltot = ui.Label(name='total') # give a name to access it in b_action code ltot.frame = (d,y,100,h) ltot.border_width = 1 ltot.corner_radius = 5 ltot.alignment = ui.ALIGN_RIGHT mv.add_subview(ltot) y = y + h + d # compute y at bottom of last total field mv.height = y # setof displayed main view mv.present('sheet') # present the main view and wait
-
@cvp Thank you, but there is still a problem. If "Ausgaben" is a number with a comma (for example, 3.33), it will not be considered. I tried to get it myself but it just does not work for me. If you can do that, you must explain that to me.
-
@some-user You, like me, will need to wait a little bit because my iPad is busy with my granddaughter who is playing Fortnite on it and I'll never dare to interrupt her 😂
-
@some-user Just an idea: I can't test without iPad (see above 😥), but did you try 3,33 and 3.33 because, in function of your keyboard language, one is taken as a string, thus refused, the other one as a number, thus accepted
-
@cvp Omg, I'm so stupid. Thank you for your help. I would never have done it without you. Maybe I will contact you again if I do not get something in the script. Thank you.
-
@some-user In this forum, there is no stupid because you use Pythonista 😂 Be sure, we all do some errors...
-
@cvp okay one more question. How do I add this to my homescreen now? If I want to do that, I'll be redirected to Safari. Then it says I should add this to my homescreen. But that looks like that
https://twitter.com/Someuse79137145/status/1102583731959808000?s=09 -
@some-user I suppose you use the standard version of app, not the beta. I don't have any more this version thus I can't test the shortcut creation of this version but what you get is really not normal. It seems like the Safari page is an url, not a data...
what happens when you click on your icon? -
@cvp it opens the app and runs the Script
-
@some-user ok, that's normal but not the icon it-self
-
@JonB
Spotted your pointer to the GitHub humberry UI Tutorial, excitedly skipped over to GitHub
As I really do want to “get” using pyui’s....
Aargh! New Brick Walls!It may sound simple but how do I get a GitHub resident PYUI file to my iPad.
You cannot imagine what I have tried so far, including forking the Tutorial!Yours incompetently
Adrius42 -
There are a few ways to get a github repo onto your iPad.
-
install https://github.com/ywangd/stash, which if you read the readme comes with its own simple install script
Then you have a git command, which can clone a repo. You need to run stash using py2.7 for this to work. -
on a recent device, you can install the Working Copy app, which let's you clone repos, and has integration with pythonista.
-
every GitHub repo has a zip download address, you can use wget in stash, or requests or urllib to download, then unzip it.
-
pythonista tools has various tools, of various pedigree:
https://github.com/Pythonista-Tools/Pythonista-Tools/blob/master/GitHub Tools.md
Some may not work at all in current pythonista versions...
-
-
@adrius42 there is a more manual workaround to copying pyui files from GitHub into Pythonista:
- Go to the .pyui file’s webpage on GitHub
- Click the Raw button near the upper right of that page.
- Select all the text and tap Copy
- Go back to Pythonista and create a new script
- Paste the text into that script
- Rename the script to change its file extension from .py to .pyui
-
@some-user If you want to be able to "go to next input field" by a key, see here
Example: next number of items