Created
July 29, 2015 11:45
-
-
Save alessaba/15c47541fef94a8bcf70 to your computer and use it in GitHub Desktop.
PythonistaMod.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
from objc_util import * | |
import ui | |
@on_main_thread | |
def main(): | |
app=ObjCClass('UIApplication').sharedApplication() #Si accede all app in se | |
root_vc=app.keyWindow().rootViewController() #si accede alla view di base | |
mainView=root_vc.detailViewController().view() #Si acccede alla view principale | |
#size=mainView.bounds().size #si puó usare tutto cio che è di ui | |
#Setup primo bottone | |
button1=ui.Button() | |
button1.frame=(200,25,32,32) | |
button1.image=ui.Image.named('iob:code_32') | |
button1.tint_color=(.43, .55, .78) | |
button1.action=comment | |
#Setup secondo bottone | |
button2=ui.Button() | |
button2.frame=(250,25,32,32) #(x,y,width,height) | |
button2.image=ui.Image.named('iob:ios7_cloud_outline_32') | |
button2.tint_color=(.43, .55, .78) | |
button2.action=iclouddrive | |
#Si aggiungono i bottoni (ma potrebbe essere qualunque tipo di elemento) alla view dell'app | |
mainView.addSubview_(button1) | |
mainView.addSubview_(button2) | |
def comment(sender): | |
import editor | |
try: | |
HASH='#' | |
i=editor.get_line_selection() | |
t=editor.get_text() | |
editor.replace_text(i[0],i[1]-1,HASH+re.sub(r'\n',r'\n'+HASH,t[i[0]:i[1]-1])) | |
editor.set_selection(i[0],i[1]-len(t)+len(editor.get_text())) | |
except Exception: | |
pass | |
def iclouddrive(sender): | |
import dialogs | |
#dialogs.import_file() | |
print 'iCloud Drive!' | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment