• 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')

  • @cvp @ccc @mikael Here is the UI version of the personal protective equipment app. It looks kind of plain. Any suggestions to spruce up how it looks?

    https://github.com/resserone13/PPEasy-ui-only

  • Hey so I actually found a solution on the forum from ages ago. If anyone else is interested you basically have to copy list data source class into a separate module and add in a background colour attribute, works well

  • -.-
    Now I feel pretty dumb haha. I did not expect the β€˜help’ to be that useful, so never selected it.
    That will help out a ton! Thanks for mentioning that @mikael

  • @jackattack Save the graph as picture and then load it in widget.

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

  • This is a working version without significant leak.

    import photos import time import concurrent.futures import objc_util import ui @objc_util.on_main_thread def update(image_view, ui_image): image_view.image = ui_image def loop_photos(): all_photos = photos.get_assets() while True: for p in all_photos: with objc_util.autoreleasepool(): ui_image = p.get_ui_image(size=(300,300)) #image_data = p.get_image_data() update(v['img'], ui_image) time.sleep(.5) time.sleep(5) v = ui.View() v.add_subview(ui.ImageView(name='img')) v.present() with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor: executor.submit(loop_photos)

    Thanks very much for all the suggestions. I'm grateful for the tip about threading and will try to incorporate it into the rest of the project but the thing that does the lifting here is the autoreleasepool context manager; with just this addition and removing the threading it works just fine.

  • @FrankenApps no problem, often not easy to search in forum, better to search via google πŸ˜ƒ

  • Thanks everyone,
    @JonB You cleared my doubt on @ui.in_background, Now I'm using threading instead of ui.in_background

    import ui,threading as thr class view(): def __init__(self): self.flag = True content = ui.TableViewCell() play = ui.Button(frame = (259,0,50,content.height)) pause = ui.Button(frame = play.frame) play.image = ui.Image('iob:ios7_play_256') pause.image = ui.Image('iob:pause_256') pause.hidden = True play.action = self.Play pause.action = self.Pause label = ui.Label(frame =(0,0,0,content.height)) label.touch_enabled = False label.background_color = 'blue' self.play = play self.pause = pause self.label = label self.flag = False content.content_view.add_subview(play) content.content_view.add_subview(pause) content.content_view.add_subview(label) self.content = content def table(self): return self.content def Play(self,sender): t = thr.Thread(target=self.Playy,args=(sender,)) t.daemon = True t.start() def Pause(self,sender): t = thr.Thread(target=self.Pausee,args=(sender,)) t.daemon = True t.start() def Playy(self,sender): sender.hidden = True self.pause.hidden = False import time for a in range(320): self.label.width = a time.sleep(0.1) if self.flag: self.flag = False return def Pausee(self,sender): sender.hidden = True self.play.hidden = False self.flag = True class Llist(): def tableview_number_of_rows(self,t,s): return 40 def tableview_cell_for_row(self,t,s,r): return view().table() a=ui.TableView() a.data_source = Llist() a.allows_selection = False a.present()
  • @yas self is a delegate... It has no bgcolor!

    There is not an easy way to change the section header background color. There are some ways using objc_util, but you may want to crawl first before you walk... .

    The easiest approach is to keep track of headers on your own, and just create a cell instead of a section header.

  • @enceladus thanks, I knew I'd seen that somewhere before!

  • thanks @cvp & @ellie_ff1493.

  • @cvp thank you for the link

  • @JonB Thank you very much. callend_editing() method solves my problem perfectly

  • @struct_engr_ , I think the problem is that for the past 6 months or so, no emails from this forum get actually sent. Neither the password resets or other notifications. @omz, any chance you could take a look?

  • try v['webview1'].load_url('https://google.com')

    or replace webview1 with whatever you named your webview in the designer.

  • Perhaps you want to be presenting a modal view, not a modal scene?
    For instance, present your login view as a popover or sheet, then wait_modal on the view to wait until it is closed.

  • @lachlantula , no problems. I was just intrested in trying it after @abcabc pointed out the secure attr. I have see things go strange before when you play with the size of the system font. But initially I was using the default size. Oh, well

  • One nice thing about the sidebar was that it could be narrower than 200 pt, so a 30 or 40 pix wide sidebar worked well for creating custom auxilary shortcut bars in the editor without sacrificing too much width. But so much more can now be done in objc, I am not complaining.

Internal error.

Oops! Looks like something went wrong!