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 / run_uipy.py
Created July 30, 2016 13:05
run_uipy.py
import ui, editor
'''
VERY IMPORTANT
For the .pyui file to be loaded as you would expect, in the
ui Designer you have to go to the top level (no obejects sekected),
you will see a field called 'Custom View Class', you need to enter
the key that is used for WrapInstance attr that is passed in the
bindings param to ui.load_view. With the example below you would
use MyClass.
@Phuket2
Phuket2 / themes_icon_view.py
Created July 29, 2016 19:08
themes_icon_view.py
'''
Pythonista Forum - @Phuket2
'''
import ui, editor, bz2, base64
#_pyui_file_name = 'booking.pyui'
__pyui_str__ ='''
QlpoOTFBWSZTWaO7pcYAGNlf4NVVUGd/9T/n3Y6/79/+IAAAQMAAYAv/A+B25OipHWmzGq
VFrRVbpiUohIELwkkp6I0jTxJ6QaABoDR6jeoE00AAABJQTBNNNNRU/UAmAAAAAAAABw0e
@Phuket2
Phuket2 / std_table_view.py
Created July 1, 2016 16:42
std_table_view.py
import ui
_colors = ['teal', 'deeppink', 'orange', 'blue', 'red']
class CustomTableViewCell(ui.View):
'''
some magic from @JonB see...
https://forum.omz-software.com/topic/3297/ui-tableviewcell-returning-a-custom-class-instead/4
'''
def as_cell(self):
@Phuket2
Phuket2 / scap.py
Created July 1, 2016 12:00
scap.py
#turtle.py
# Basic Turtle graphics module for Pythonista
#
# When run as a script, the classic Koch snowflake is drawn as a demo.
# The module can also be used interactively or from other scripts:
# >>> from turtle import *
# >>> right(30)
# >>> forward(100)
# ...
@Phuket2
Phuket2 / crappy_search.py
Created June 22, 2016 11:37
crappy_search.py
'''
this is crap. i mashed to files together without editing.
but i could be something. i have just been to lazy to bring it
together. i use it the wrench menu myself.
it acually works for meas a quickie when i am looking for a script.
'''
import ui, editor, console, editor
@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.
@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 / 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 / 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 / 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,