import ui
filename = 'name.txt'
def read_username(filename=filename):
username = None
with open(filename) as in_file:
for line in in_file.readlines():
username = line.strip() or username
# change the draw() method below to draw your plot
# using the ui.Path drawing commands documented at
import ui
class PlotView(ui.View):
def __init__(self, parent = None):
self.frame = (0, 0, 255, 255)
#!/usr/bin/env python
recent_entries() will print out info on all posts to the Pythonista forum in the past 24 hours.
watch_feed() will print out info on the last post to the Pythonista forum.
Sleeps for 15 minutes then check to see if there is a newer post.
If so, prints out info on it and opens its URL in the webbrowser. Repeat.
import Image, ImageDraw, scene
def diagonalLineImage(inLength = 200, inColors = ('blue', 'ivory')):
imageLength = inLength + 100 # the image can be larger than what you draw
theImage ='RGBA', (imageLength, imageLength), inColors[1])
draw = ImageDraw.Draw(theImage)
draw.line((0, 0, inLength, inLength), fill = inColors[0])
del draw
return theImage
Moved to GitHub repo:
# -*- coding: utf-8 -*-
import scene
keyboard_layouts = (
q w e r t y u i o p del
a s d f g h j k l return
z x c v b n m , . shift
.?123 space .?123
import location, webbrowser #, time
def getLocation():
# time.sleep(1)
currLoc = location.get_location()
location.stop_updates() # stop GPS hardware ASAP to save battery
return currLoc
def getStreetAddress(loc = getLocation()):
import json, requests, sys #, pprint
Use (works on Pythonista) to get your Twitter access_token.
> You will need to create a new application on
> Enter below the Twitter access_token you get from running
# an improved version at
import math, time
def elapsedTime(start_time):
dt = time.time() - start_time
minutes = dt / 60
seconds = dt % 60
centiseconds = math.modf(dt)[0] * 100
return '%02d:%02d.%02d' % (minutes, seconds, centiseconds)
import bs4, collections, console, requests, scene
tkColorDict = collections.OrderedDict() # key = tkinter color name
def loadTkColorDict(): # will automaticly be called by getColor() if needed
tkColorURL = ''
print('Loading tkinter colors from: ' + tkColorURL)
tkColorSoup = bs4.BeautifulSoup(requests.get(tkColorURL).text).tbody
print('Soup is ready. Creating color table...')
for tableRow in tkColorSoup.find_all('tr'):