Skip to content

Instantly share code, notes, and snippets.

View Phuket2's full-sized avatar

Ian Joicey Phuket2

  • Pattaya, Thailand
View GitHub Profile
@Phuket2
Phuket2 / TextRender.py
Created June 1, 2016 10:10
TextRender.py
import ui
import copy, math, functools
'''
@Phuket2
Class - UIText
For writing text in rects.
the instance attrs are preserved if used as a context manager
ie, 'with'
'''
@Phuket2
Phuket2 / TextRender.py
Created May 30, 2016 13:08
TextRender.py
import ui
import copy
class UIText(object):
dict_list = []
def __init__(self, r = ui.Rect(), *args, **kwargs):
r = ui.Rect(*r)
# defaults
@Phuket2
Phuket2 / DashBoard.py
Created May 21, 2016 09:08
DashBoard.py
import ui
import datetime as dt
from time import time, strftime
_sfn = 'Arial Rounded MT Bold'
def current_time_str():
return strftime('%H:%M:%S')
def _make_label(name, text, font, color):
@Phuket2
Phuket2 / TimerTesting.py
Created May 14, 2016 18:09
TimerTesting.py
from threading import Timer
import threading
import datetime as dt
from datetime import timedelta
import ui
class MyTimer(object):
def __init__(self, *args, **kwargs):
self.thread = None
@Phuket2
Phuket2 / CircleView.py
Created April 15, 2016 16:58
CircleView.py
# coding: utf-8
import ui
import functools
import time
import string
# decorator memoize copied from ....
# https://wiki.python.org/moin/PythonDecoratorLibrary#Memoize
# note that this decorator ignores **kwargs
@Phuket2
Phuket2 / Cir.py
Created April 14, 2016 17:41
Cir.py
# coding: utf-8
import ui
# Pythonista Forum - @Phuket2
# for @ccc , should be pep8 ok and pyflakes :)
# No break through here. just expanded on the Pythonista help
# code for ui.ImageContext
# draw text in a circle, and return a ui.image
@Phuket2
Phuket2 / CalView2.py
Created March 23, 2016 12:38
CalView2.py
# coding: utf-8
# coding: utf-8
import calendar
import datetime as dt
import ui
class CalendarView(ui.View): #here
def __init__(self,fldname,dateval,action=None, *args, **kwargs): #here
@Phuket2
Phuket2 / Indcator.py
Created March 12, 2016 18:34
Indcator.py
# coding: utf-8
import ui
import time
from math import pi, sin, cos, radians
# a dict for kwargs shortcuts
_indicator_attr_short_cuts = \
{
'cw' : 'cell_width',
@Phuket2
Phuket2 / PageIndicatorPosted.py
Created March 10, 2016 11:29
PageIndicatorPosted.py
# coding: utf-8
import ui
'''
Date: 10 March 2016
Pythonista 2.01 beta
PageIndicator Class
===================
An attempt to mimick the page indicator found in some iOS interfaces
supports circles/rects, defaults to circles.
@Phuket2
Phuket2 / code_view.py
Created March 1, 2016 11:29
code_view.py
# coding: utf-8
import ui
from pygments import highlight
from pygments.formatters import HtmlFormatter
from pygments.styles import get_style_by_name
from pygments.lexers import get_lexer_by_name
from pygments.styles import get_all_styles
class CodeDisplay(ui.View):