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 / 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 / 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 / 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 / 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 / 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 / AsciiLuke.py
Created June 3, 2016 15:47
AsciiLuke.py
import ui, io
def get_max_fontsize(rect, font_name):
r = ui.Rect(*rect)
last_w = last_h = 0
for i in range(5, 1000):
w, h = ui.measure_string('W', max_width=0,
@Phuket2
Phuket2 / theme_forum.py
Created June 7, 2016 16:42
theme_forum.py
import ui
import base64, bz2, textwrap
import clipboard, editor
# wrapper.py, Pythonista Forum @JonB
# https://forum.omz-software.com/topic/3176/use-a-pyui-file-in-another-pyui-file
# remember to add the the name of the class to the 'Custom View Class'
# in the .pyui
__the_view = \
@Phuket2
Phuket2 / radio_button.py
Created June 8, 2016 13:40
radio_button.py
import ui
class RadioButton(ui.View):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.frame = (100, 100, 100, 100)
self.touch_enabled = True
self.selected = True
def draw(self):
@Phuket2
Phuket2 / UIShapeBase.py
Created June 12, 2016 08:28
UIShapeBase.py
# Forum @Phuket2
import ui, editor
class UIShapeBase(object):
def __init__(self, frame, *args, **kwargs):
self.frame = ui.Rect(*frame)
self.margin = (0, 0)
self.origin = (0, 0)
self.shape = None
self.alpha = 1
@Phuket2
Phuket2 / controls_idea.py
Created June 13, 2016 15:58
controls_idea.py
import ui
'''
Forum user: @Phuket2
licence: I will pay you to use it, license :)
3 controls that just manipulate ui.Button's attrs
This is more proof of concept rather than finished code.