omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. Webmaster4o

    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.


    • Profile
    • Following 4
    • Followers 13
    • Topics 93
    • Posts 994
    • Best 192
    • Controversial 0
    • Groups 0

    Luke Deen Taylor

    @Webmaster4o

    I'm fourteen and living in New Paltz, NY. Python is a hobby outside of school.

    319
    Reputation
    6605
    Profile views
    994
    Posts
    13
    Followers
    4
    Following
    Joined Last Online
    Website luke.deentaylor.com Location New Paltz, NY. Age 21

    Webmaster4o Unfollow Follow

    Best posts made by Webmaster4o

    • Wish list for next release

      First of all, great job with 2.0, it's a great update, and everything I expected.

      I don't know if you're planning to work on an editorial update next or pythonista, or maybe something else, but I thought I'd start a thread where people can post their thoughts about what should go into the next update.

      I think for the next update, it would be helpful to just provide more modules for use. This would be a good contrast to 2.0, which updates the editor in a lot of ways. The top 5 modules I'd like to see the most are:

      1. Scipy
      2. OpenCV
      3. The photos module but for videos
      4. scikit-image
      5. sickit-learn

      I think this alone would be a significant update to pythonista, adding a lot of functionality.

      I'm curious to hear what other people want to see most from the next update.

      posted in Pythonista
      Webmaster4o
      Webmaster4o
    • [Feature Request] Pythonista built-in file picker

      I think Pythonista is really missing something very beneficial in a built-in scriptable file navigator. The one that's inside the "move" dialog is really nice, but only supports folders, and plus, it's not user-accessible.

      I think Pythonista should have a filenav module that allows for easy creation of nice file navigators. They're pretty hard to write, IMHO, and so could benefit from being built-in. How I envision this is as follows:

      A filenav module that provides file browsers and navigators.
      1. Higher-level functions for picking files with callbacks. A function that would allow for picking files and folders. Something like:
      def pick_file(start_dir, folders_only=False, select_multiple=False, should_pick="both")
      

      where should_pick is a string that describes what should be selectable, "files", "folders", or "both" and folders_only is whether the file picker should only display folders, and hide files from view.
      2. A subclassable class like filenav.FilePicker. This would serve important functions:
      - Allow users to implement custom methods for file browsing. Users could define methods for listing directories, etc. A (far from complete) example:

      class myPicker(filenav.FilePicker):
      	def listdir(dir):
      		'''Should return a list of files and directories below a directory as a dictionary'''
      		list = os.listdir(dir)
      		dirs = [f for f in list if os.path.isdir(os.path.abspath(f))]
      		files = set(list)-set(dirs)
      		return {'dirs':dirs,'files':files}
      		
      	def fileSelected(path):
      		'''Called with the path of a file whenever a file is selected'''
      		pass
      		
      	def dirSelected(path):
      		'''Called with the path of a directory whenever a directory is selected'''
      		pass
      	
      
      if __name__=='__main__':
      	a=myPicker('test_dir/a/b/c')
      	#Picked will be a list of both files and directories that the user picked out of test_dir/a/b/c
      	picked = a.pick_file(multiple=True,should_pick='both')
      

      This doesn't immediately seem useful, but has tons of practical applications. For example, it would be easy, using a class like this, to create methods that would make a file browser for zip files. Using zipfile, custom methods could be created that allowed browsing through zip files without extracting first. This would allow a pythonista app to let users to pick certain files to extract from a zip.

      These two functionalities combined could help create a scriptable file browser that's easy for beginners, yet hugely powerful for more advanced users.

      I'd very much like to see a built-in file browser with these features in a future release.

      P.S. I actually have struggled to create a zip file browser in Pythonista in the past. I've gotten this far on GitHub, and Here's a sideways YouTube video

      posted in Pythonista
      Webmaster4o
      Webmaster4o
    • Progress Tracker on App Badge

      This is a quick utility I put together with about an hour. Thanks to @filippocld for the app badge discovery. It's a basic system by which the progress of one or more tasks can be displayed as a badge on the app icon. Overall progress of tasks can be displayed either as percent complete or as estimated time remaining.

      After each task is complete, a notification is sent. It uses objc_util, so requires 2.0. The gist is here. If anyone complains, I'll move it to a repo.

      posted in Pythonista
      Webmaster4o
      Webmaster4o
    • Framer-style UI editor

      I've been playing with Framer as a UI designer recently, and it's really awesome. For those not familiar, the concept is that in addition to the two editing modes in the Pythonista UI editor (the right bar with properties and the drag'n'drop interface on the left), Framer also has a third pane which is a code editor. As you move elements around or change properties, it's reflected in realtime in code (CoffeeScript in this case).

      This is an awesome tool, it works very well and makes prototyping and animation design really easy. Something similar for Pythonista would be neat. Just a thought. Maybe I'll try to build it :O

      posted in Pythonista
      Webmaster4o
      Webmaster4o
    • [Suggestion] file move improvement

      Just a minor suggestion, I think that the file move dialog should start with the file's current directory expanded, because it is common for people to want to move a file to a subdirectory of the folder it's currently in. Right now, it just starts with Documents expanded.

      posted in Pythonista
      Webmaster4o
      Webmaster4o
    • More keyboard shortcuts

      I recently saw a tweet about how many keyboard shortcuts Pixure offers.

      I frequently work in Pythonista with an external keyboard. I'd love to have some new keyboard shortcuts. I'm thinking specifically it'd be nice to have:

      • Keyboard shortcuts for documentation
        • Show / hide documentation
        • Focus in the search bar
        • Use up/down arrows to browser through the suggestions that pop up
      • Keyboard shortcuts for the file navigator
        • Show the file navigator
        • Use up down left right keys to go up/down and into/out of folders
        • Enter to select a file
      • Miscellaneous optimizations
        • When pressing ⌘+J to view the console window, automatically focus in the prompt

      That's my list of requested keyboard shortcuts. I don't know how many, if any, of these it'd be possible to implement in objc_util.

      posted in Pythonista
      Webmaster4o
      Webmaster4o
    • [Share Code] theme_utils.py

      theme-utils

      This is a module called theme_utils that makes it easy to work with themes, as well as making it easy to style UI components with these themes.

      The module

      The module consists of two main parts, but they're in the same namespace.

      1. Utilities for getting attributes of the current user theme. These include ready-made functions for accessing the most useful and common attribute of the theme, as well as lower-level functions like load_theme that can help with more specific use cases (like getting the colors of the code syntax). These include:
        • load_theme- return a Python dict representing the current theme
        • get_theme_name - return the name of the current theme
        • get_tint - return the tint color of the current theme
        • get_color_scheme - return a color scheme to go with the current theme. This consists of four colors, the editor background color, the library background color, the top bar's color, and the color of the backgrounder tabs. These are sorted by "intensity," which is dark to light for "dark themes" and light to dark for "light themes"
        • theme_is_light and theme_is_dark- is the theme a light theme, or a dark theme. Judged by averaging intensities of the 4 main colors, from get_color_schemes
      2. Utilities for styling uis to match the current theme.
        • style_ui(view), and view (and its children) will be styled to match the current theme. A few special things are happening in the background here.
          • Certain elements, like ui.View, ui.Label,ui.Slider, and ui.NavigationView have their backgrounds set to the "dominant color" (the first in the get_color_scheme). These are elements that either are "background elements," elements which serve primarily as a background for other elements, or are elements whose background isn't a part of the element. The background of a ui.Slider should appear opaque, but the background of a ui.Button or a ui.TextField should appear as part of the element, and therefore in a color that stands out. Because these colors are pulled directly from the themes, in high-contrast themes, this contrast will be more, but in a theme with very little contrast, this contrast will be less.
          • You can choose to have elements which have already been styled not have their styles overridden by setting respect_changes to True

      Examples

      Solarized Light:

      Tomorrow Night:

      Running the script as-is will output some useful information about the current theme:

      Custom themes

      All of these functions work flawlessly with custom themes, built with @omz's Pythonista Theme Editor.

      Pacific Dark:

      The code

      The code is here. I haven't include the pyui file I used for testing, but that's easy enough to make yourself.

      This will likely be merged into Pythonista-Tweaks as part of the theme functionality, but that will be after there is much more control over these things.

      posted in Pythonista
      Webmaster4o
      Webmaster4o
    • RE: Python 3.x Progress Update

      My one comment is that there needs to be a way to copy files between the apps, not just move. The first thing I tried to do was copy my site-packages to Pythonista 3, but then I found that they had all been removed from the Pythonista 2 app

      posted in Pythonista
      Webmaster4o
      Webmaster4o
    • Pythonista ReplayKit

      Not by me, wanted to share though.

      Load framework:
      https://gist.github.com/bmw1821/de3ab9cb8bb4b7719571
      Add a button:
      https://gist.github.com/bmw1821/3be78eef290c72f962f6

      posted in Pythonista
      Webmaster4o
      Webmaster4o
    • Open page source in Pythonista

      There was a recent post about opening page source in Textastic. I don't own Textastic personally, so I wrote a script to open page source in Pythonista:

      import appex
      import urllib2
      from objc_util import *
      #Helper functions
      def openUrl(url):
      	'''Allows webbrowser.open()-esque functionality from the app extension'''
      	app=UIApplication.sharedApplication()
      	app._openURL_(nsurl(url))
      def getDocPath():
      	'''Gets the path to ~/Documents'''
      	split=__file__.split('/')
      	path=split[:split.index('Documents')+1]
      	return '/'.join(path)+'/'
      #Get the url	
      url=appex.get_url()
      #Read page contents
      f=urllib2.urlopen(url)
      source=f.read()
      f.close()
      #Detect the type of page we're viewing
      test=source.lower().strip()
      if '<html>' in test or test.startswith('<!doctype html>'): #Page is HTML
      	extension='.html'
      else: #fallback to .txt
      	extension='.txt'	
      #Where to save the source
      filename='source'+extension
      filepath=getPath()+filename
      #Save the source
      with open(filepath,'w') as f:
      	f.write(source)
      #Close appex window
      appex.finish()
      #Open in pythonista
      openUrl('pythonista://'+filename)
      

      It's under 50 lines so I can justify not putting it in a Gist for the time being :)

      posted in Pythonista
      Webmaster4o
      Webmaster4o

    Latest posts made by Webmaster4o

    • RE: [solved] duplicate a directory or multiple files.

      Use shutil.copytree

      posted in Pythonista
      Webmaster4o
      Webmaster4o
    • RE: Split a string

      x.split() will give you each word as an element in a list. So, to get the second word of your sentence, you use x.split()[1].

      You could do something like:

      words = x.split()
      if words[0].lower() == "jump":
          second_word = x.split()[1]
      
      posted in Pythonista
      Webmaster4o
      Webmaster4o
    • RE: Was 3D Touch removed in Pythonista 3?

      There may be an API incompatibility with iOS 10, I'm sure @omz will fix it soon enough

      posted in Pythonista
      Webmaster4o
      Webmaster4o
    • RE: Turtle module speed of turtle

      The Pythonista turtle module is rewritten completely from the desktop module, so I don't know if there's complete feature parity, but in the desktop module I think you can use turtle.speed(0). Give it a try and let me know.

      posted in Pythonista
      Webmaster4o
      Webmaster4o
    • Python 3.6 and objc_util syntax

      When we were discussing a cleaner objc_util syntax a few months ago, the suggestion of using kwargs was rejected because there as no way to guarantee the order. However, look at this from the Python 3.6 release notes!

      **kwargs in a function signature is now guaranteed to be an insertion-order-preserving mapping.

      This is from PEP 468

      Unless I'm mistaken, this would enable that syntax.

      posted in Pythonista
      Webmaster4o
      Webmaster4o
    • RE: Pythonista Lambda microservice packager

      @mikael I'm actually currently working on the same thing for https://zeit.co/now

      posted in Pythonista
      Webmaster4o
      Webmaster4o
    • RE: Forum Suggestion - New area to post tips, shares labs etc....

      @Phuket2 A github repo just for your experiments would be a good way to organize them, I think

      posted in Pythonista
      Webmaster4o
      Webmaster4o
    • RE: [Lab] determine black or white color to draw text onto a CSS color

      One tip for making text more readable is something the Material Design guidelines recommend: While white text should be rgba(255, 255, 255, 1), but black text should be rgba(0, 0, 0, 0.87). The slight opacity in the black makes it much more readable on colored backgrounds.

      posted in Pythonista
      Webmaster4o
      Webmaster4o
    • RE: Discord.py

      @SpiesWithin This example is correct. client is defined with client = discord.Client()

      posted in Pythonista
      Webmaster4o
      Webmaster4o
    • RE: livejson - Webmaster4o - Tuples

      @ccc It does, but it can't possibly convert them back into tuples.

      In [2]: a = livejson.File("/Users/luke/Desktop/a.json")
      
      In [3]: a["b"] = (0, 1, 2, 3)
      
      In [4]: a["b"]
      Out[5]: [0, 1, 2, 3]
      
      posted in Pythonista
      Webmaster4o
      Webmaster4o