UI. So far I have:
- distribute horizontally (equal distribution) with padding is possible
- distribute vertically (equal distribution) with padding is possible
- adjust width/height/x/y by percent (rather than by points or pixels)
Working on a grid distribution.
None of this is too hard or rocket science. Just a bunch of numbers. I'm sure anyone could do it...
It's really different than what @phuket2 has above though...!!
I don't know why I didn't think to do this before... I seem to use a kind of distribution for doing buttons at times, but having it in a module would be much easier. Will share once I've got kinks worked out...
With what I have already I could do @phuket2 's battleship grid without the headache! But I want to improve the functions to make it even more straightforward.
Thank you @jonb. I am not sure if I will use this too much. But it's nice to just read through the UI code. Especially this part about hijacking UI.buttonitem:
I will try to use that for something else. That's really cool!!
searchField=ui.TextField() searchField.placeholder='Search' searchField.frame=(0,0,180,32) searchField.clear_button_mode='always' editor.apply_ui_theme(searchField) searchBarButton=ui.ButtonItem() ObjCInstance(searchBarButton).customView=searchField
logging_setup.pyjust for ease of use. I'm just sharing it if anyone wants to.
This has a few defaults:
- prints to a file (.txt b/c Pythonista doesn't open .log by default)
- Note: if used in different scripts, the 'name' arg is important for logging to different files.
- mode is set to overwrite (you can set it with keyword arg)
- format looks like this: "DEBUG: this is a message." (can change with
A few benefits:
- can have the log file in a tab in the editor
- can use the 'Find' in editor to search the log
- no console take-over when running your script
import logging import logging_setup log = logging_setup.logging_setup('my_log') #use a unique name log.debug('a message for the log') log.error('oh no.') log.warning('oh no.') log.critical('call 911... or omz') log.info('well now it seems you have some mighty fine logging going on.') logging.shutdown() #necessary at the end of the script running
I did test this with using it in a few different files at the same time. I didn't think it was going to work because of name spaces (ex: if you use
login two files and have imported one file into the other) - but it seems to work fine. One very important thing: if you do not use
logging.shutdown()it will not work properly (seems that logs are carried over from before).