• Try, this script, then

    tap on the button, then on the syringe you will receive a viewfinder (no way to get it in the print screen ) that you move on one of your squares, tap ok, the real rgb will appear, surprise, no one is #00FF00 # coding: utf-8 from objc_util import * import ui def colorPickerViewControllerDidFinish_(_self, _cmd, _controller): #print('colorPickerViewControllerDidFinish') UIColorPickerViewController = ObjCInstance(_controller) def colorPickerViewControllerDidSelectColor_(_self, _cmd, _controller): #print('colorPickerViewControllerDidSelectColor') UIColorPickerViewController = ObjCInstance(_controller) cl = UIColorPickerViewController.selectedColor() rgb = (cl.red(),cl.green(),cl.blue()) coloredButtonItem(UIColorPickerViewController.buttonItem, rgb) methods = [colorPickerViewControllerDidFinish_, colorPickerViewControllerDidSelectColor_] protocols = ['UIColorPickerViewControllerDelegate'] try: MyUIColorPickerViewControllerDelegate = ObjCClass('MyUIColorPickerViewControllerDelegate') except Exception as e: MyUIColorPickerViewControllerDelegate = create_objc_class('MyUIColorPickerViewControllerDelegate', methods=methods, protocols=protocols) def coloredButtonItem(btn,rgb): import ui if rgb: with ui.ImageContext(32,32) as ctx: path = ui.Path.rect(0,0,32,32) ui.set_color(rgb) path.fill() btn.image = ctx.get_image().with_rendering_mode(ui.RENDERING_MODE_ORIGINAL) def UIColorPickerViewController(w, h, alpha_slider=True, title='', rgb=None, popover=None): v = ui.View() v.name = title v.rgb = rgb vc = ObjCInstance(v) colorpicker = ObjCClass('UIColorPickerViewController').new().autorelease() #print(dir(colorpicker)) delegate = MyUIColorPickerViewControllerDelegate.alloc().init() colorpicker.delegate = delegate colorpicker.setSupportsAlpha_(alpha_slider) if rgb: color = ObjCClass('UIColor').colorWithRed_green_blue_alpha_(rgb[0], rgb[1], rgb[2], 1.0) colorpicker.setSelectedColor_(color) clview = colorpicker.view() v.frame = (0,0,w,h) vc.addSubview_(clview) done_button = ui.ButtonItem(title='ok') def tapped(sender): cl = colorpicker.selectedColor() v.rgb = (cl.red(),cl.green(),cl.blue()) v.close() done_button.action = tapped color_button = ui.ButtonItem() coloredButtonItem(color_button,rgb) v.right_button_items = [done_button,color_button] colorpicker.buttonItem = color_button if popover: x,y = popover v.present('popover', popover_location=(x,y)) else: v.present('sheet') v.wait_modal() return v.rgb def rgb_to_hex(rgb): r,g,b = rgb r = int(255*r) g = int(255*g) b = int(255*b) return f'#{r:02x}{g:02x}{b:02x}' class Colors (ui.View): def __init__(self, *args, **kwargs): return super().__init__(self, *args, **kwargs) def draw(self): neon = ui.Path.rect(5, 5, 100, 100) ui.set_color((0, 2, 0)) neon.fill() normal = ui.Path.rect(110, 5, 100, 100) ui.set_color(("#00ff00")) normal.fill() # Protect against import if __name__ == '__main__': example = Colors(bg_color="white") lbl = ui.Label(frame=(5,120,200,32)) lbl.alignment = ui.ALIGN_CENTER example.add_subview(lbl) b1 = ui.ButtonItem() b1.title = '💉' def b1_action(sender): # compute x,y of an ui.ButtonItem vi = ObjCInstance(sender).view() r = vi.convertRect_toView_(vi.bounds(),ObjCInstance(example)) # x,y in screen coordinates, not in view x,y,w,h = r.origin.x,r.origin.y,r.size.width,r.size.height x,y = x+w/2, y+h w,h = 200,50 rgb = UIColorPickerViewController(w,h, alpha_slider=False, popover=(x,y)) if rgb: lbl.text = rgb_to_hex(rgb) b1.action = b1_action example.right_button_items =(b1,) example.present('fullscreen')

  • @JonB @cvp
    Thank you for the suggestions! I ended up going the easy way and requiring to pass in the master view. Kept the TableView hidden on the master (and thus un-touchable) until the combobox is touched.

  • You can test the ios font and their glyphs with a short script:

    from objc_util import * UIFont = ObjCClass('UIFont') vObjCAllFontNames = [] vObjCFontFamilieNames = UIFont.familyNames() for vObjCFontFamilieName in vObjCFontFamilieNames: vObjCFontNamesWithinFamily = UIFont.fontNamesForFamilyName_(vObjCFontFamilieName) vObjCAllFontNames += vObjCFontNamesWithinFamily vFontFamilieNames = [] vAllFontNames = [] for vTemp in vObjCFontFamilieNames: vFontFamilieNames.append(str(vTemp)) for vTemp in vObjCAllFontNames: vAllFontNames.append(str(vTemp)) vAllFontNames.sort() for vFont in vAllFontNames: vConsoleFont = [(vFont, 20), (0, 0, 0)] console.set_font(vConsoleFont[0][0], vConsoleFont[0][1]) console.set_color(vConsoleFont[1][0], vConsoleFont[1][1], vConsoleFont[1][2]) print(vConsoleFont[0][0]) print(u'\u0048\u0065\u006c\u006c\u006f \u0057\u006f\u0072\u006c\u0064\u003a \u10c5\u10c7\u10cd\u10d0\u000a') console.set_font() console.set_color(0.00, 0.00, 0.00)

    Maybe this is a help for you, but i didn't test it.
    FontInstaller

  • @mcriley821, thanks, using editable to effectively disable the one-tap gestures is a good trick, have to keep it in mind.

  • Does import os ; print(os.system("/bin/ls")) do anything?

    https://docs.python.org/3/library/os.html#os.system

    import os ; print(os.system("/bin/bash")) would be a superpower if it actually worked!

    https://docs.python.org/3/library/runpy.html is used by Pyto a lot but that is for launching Python scripts, not system binaries.

  • @mcriley821 Wow, I clearly did not look hard enough initially! That's amazing!

  • Found a better solution @cvp by digging in @JonB objc_hacks.

    import requests as r from bs4 import BeautifulSoup as soup from objc_util import * import notification import ctypes class _block_descriptor (Structure): _fields_ = [('reserved', c_ulong), ('size', c_ulong), ('copy_helper', c_void_p), ('dispose_helper', c_void_p), ('signature', c_char_p)] InvokeFuncType = ctypes.CFUNCTYPE(None, *[c_void_p, ctypes.c_int]) class _block_literal(Structure): _fields_ = [('isa', c_void_p), ('flags', c_int), ('reserved', c_int), ('invoke', InvokeFuncType), ('descriptor', _block_descriptor)] def update_forum(_cmd,_comp): comp=ObjCInstance(_comp) blk=_block_literal.from_address(_comp) blk.invoke(comp,1) with open('most_recent.txt','rb') as f: lst=f.readlines() most_recent,count=lst[0][:-1],lst[1] url='https://forum.omz-software.com/recent' page=r.get(url) page=soup(page.content,'html.parser') newest=page.select('meta')[8] content_name=newest.attrs.get('content') content_name=bytes(content_name,'utf8') post_count=newest.find_all('span')[2].attrs.get('title') post_count=bytes(post_count,'utf8') if content_name != most_recent or post_count != count: with open('most_recent.txt','wb') as f: f.writelines([content_name, b'\n', post_count]) notification.schedule( message=f'Newest on the Forum: {content_name.decode()}', action_url=url, title='Pythonista Forum', identifier='Forum_Updater' ) #else: #notification.schedule( message='Nothing new...', title='Pythonista Forum', identifier='Forum_Updater' ) return scheduler=ObjCClass('NSBackgroundActivityScheduler').alloc().initWithIdentifier_('Scheduler') scheduler.setRepeats_(True) scheduler.setInterval_(10*60) scheduler.setTolerance_(60) scheduler.setQualityOfService_(25) block=ObjCBlock(update_forum,restype=None,argtypes=[c_void_p,c_void_p]) scheduler.scheduleWithBlock_(block)

    Sadly, it only works when in the app. It does free up the console though

  • @mcriley821 ok, sorry, only Python code is available...

  • @mcriley821 Ok, sorry, I Always forget that I work iPad and most of other people work on iPhone

Internal error.

Oops! Looks like something went wrong!