Skip to content

Instantly share code, notes, and snippets.

Avatar

Ian Joicey Phuket2

  • Pattaya, Thailand
View GitHub Profile
@Phuket2
Phuket2 / app.py
Created Aug 24, 2018
Launch Application - For Alfred Workflow
View app.py
'''
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 Aug 5, 2018
Recreate table cursor in toga
View table_test.py
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 Nov 27, 2017
DisplayPythonSource.py
View 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 Nov 24, 2017
MobilePlatormSurvey.json
View 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": "",
View 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
View 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()
View 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',
]
View 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
View 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,
View 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