• cook

    @ccc @phuket2 you had a lot going on here with this and I didn't see. Sorry! Ian's original post got me thinking about layout a lot, and I started on something as well. I really like how you can do a lot of auto layout in html with css or javascript and it's really useful. I think the same is possible for 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.

    posted in Pythonista read more
  • cook

    @phuket2 I like the idea of this!

    Here's a thought:
    For vertical alignment you have another term you can use:

    Top
    Middle
    Bottom

    posted in Pythonista read more
  • cook

    @Webmaster4o
    The date from the post above:
    2015-08-05T15:37:01.049Z

    posted in Announcements read more
  • cook

    Sorry I don't quite follow...
    Do you want to know good ways to back up your files or good ways to give your files to others?

    posted in Pythonista read more
  • cook

    Great!
    I'd also like something similar with Japanese Living Bible....need to get it somehow first. I think I may write to the publishing company.

    posted in Pythonista read more
  • cook

    The copy sounds very useful to me. I don't use the console too much, but these days I'm starting to more. Being able to copy things easily would be great.

    Will try the search bar thing again. Was on my iPad but will try like you said.

    posted in Pythonista read more
  • cook

    An unfortunate bit about the search bar in the title bar- in panel presentation the width is limited.... Maybe there's some workaround but...

    posted in Pythonista read more
  • cook

    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
    

    posted in Pythonista read more
  • cook

    @ccc yeah I havent really ventured out into making a project that incorporates more than one file yet. But of course when I do (and from now on) I think this sort of thing will be very nice. It's much better than cluttering up the console!!

    posted in Pythonista read more
  • cook

    Didn't know about the logger module until I was reading this discussion initiated by @phuket2. Thanks @ccc for mentioning about the logging module.

    I've made logging_setup.py just 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 fmt keyword)

    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

    Quick setup:

    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 log in 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).

    Code:

    logging_setup.py

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!