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 / app.py
Created August 24, 2018 07:59
Launch Application - For Alfred Workflow
'''
Launch Application (Emulate standard Alfred operation)
+ Requires Alfred Powerpack and Version 3+
A script meant to be used in Alfred Script Filter(Input) within
a workflow that is connected to a 'Open File' (Action)
looks for entries with ext '.app' in the directories in the _dir_list.
Creates a list of dicts as per the Alfred Documentation and returns
@Phuket2
Phuket2 / table_test.py
Created August 5, 2018 04:38
Recreate table cursor in toga
import toga
from toga.style.pack import *
def table_callback(widget, **kwargs):
x = kwargs.get('row')._source
print(dir(x))
class MyApp(toga.App):
def startup(self):
self.main_window = toga.MainWindow(title=self.name)
@Phuket2
Phuket2 / DisplayPythonSource.py
Created November 27, 2017 12:38
DisplayPythonSource.py
# coding: utf-8
import ui
import io
import editor
import console
import dialogs
from pygments import highlight
from pygments.formatters import HtmlFormatter
from pygments.styles import get_all_styles
@Phuket2
Phuket2 / MobilePlatormSurvey.json
Last active November 24, 2017 10:35
MobilePlatormSurvey.json
[
{
"frame": "{{0.0,44.0},{320.0,320.0}}",
"class": "View",
"nodes": [
{
"frame": "{{21.0,20.0},{279.0,45.0}}",
"class": "Label",
"attributes": {
"flex": "",
@Phuket2
Phuket2 / crappy_search.py
Created October 3, 2017 08:51
crappy_search.py
'''
this is crap. i mashed to files together without editing.
but it could be something. i have just been to lazy to bring it
together. i use it the wrench menu myself.
it acually works for me as a quickie when i am looking for a script.
'''
import ui, editor, console, editor
import io, re
@Phuket2
Phuket2 / forum_response.py
Created September 30, 2017 13:37
forum_response.py
import ui
# only use this func to create a button for convienience
def quick_button(p, title="", **kwargs):
# p is the parent view
_inset = 60
btn = ui.Button(name='btn', **kwargs)
btn.frame = ui.Rect(0, 0, p.width, p.width).inset(_inset, _inset)
btn.corner_radius = btn.width / 2
btn.center = p.bounds.center()
@Phuket2
Phuket2 / test_table.py
Created August 26, 2017 09:41
test_table.py
import ui
from random import choice
_color_list = ['purple', 'orange', 'deeppink', 'lightblue', 'cornflowerblue'
'red', 'yellow', 'green', 'pink', 'navy', 'teal', 'olive',
'lime', 'maroon', 'aqua', 'silver', 'fuchsia',
]
@Phuket2
Phuket2 / form_dialog_wapper.py
Created August 6, 2017 07:52
form_dialog_wapper.py
import ui
import dialogs
import datetime as dt
class FormDialogWrapper(object):
'''
A Wrapper/Helper class around the dialogs.form_dialog
Does it need one?? Maybe not. But by attempting to do one, I learn more
about the form_dialog.
To me these wrappers/helps also seem such a good idea in the begining. Then I get
@Phuket2
Phuket2 / notation.py
Created July 23, 2017 10:18
notation.py
'''
****** WRENCH ITEM ******
create notes for the current source file in the Pythonisita Editor
This file should be added to the wrench menu, and will be run on the active editor tab
The idea is simple. just sometimes you want to make notes as you working on a file. This
script just automates creating a sub dir to save a notes file as well as file by the
same name, but different ext. The ext can be changed below.
A dir will be created in the directory of the source file if one does not exit,
@Phuket2
Phuket2 / simple_view2.py
Created September 27, 2016 13:26
simple_view2.py
# Pythonista Forum - @Phuket2
import ui, editor
from collections import deque, namedtuple
# maybe silly, but each view created in here, we add a dynamic attr
# called vid (view id) to each view. i use it in add_labels_to_sv, a
# debug function, not sure how much more useful it can be.
# ammendment, also use in subviews_as_tuples, in this case, its handy
_v_id = 1