• @Luximonsti I save the image to my photos on my iPhone 11. Then I go into photos and click on the image. Once I’ve clicked on the image I click on the share icon. Then I click save to files. On that screen I rename the file and save it Pythonista somewhere. After that I go in to fight on Easter and move it into my project folder. Hopefully that helps

  • Lol, ok I can see this topic generated as much interest as watching grass grow :).
    But at least to give something visual, i did the below. Just using a static form here with no chance to give feedeback because the form is just sitting as a json file in a github repo. Baby steps :)
    I still like the idea/concept though. Maybe I am alone on this one! Again, this not what I described above. I just thought If i could do a static example, may give it more context. BTW, the recipe in the example is real and fantastic. It was from YouTube, I should have put the link in, but again this is just an example. No interaction is possible with this simple example. But I think you could see how there could be.

    import ui import requests import json _form_raw_url = '''https://raw.githubusercontent.com/Phuket2/ui_forms/master/MicrowaveEggRecipe.json''' resp = requests.get(_form_raw_url, timeout=5) if resp.status_code != 200: resp.raise_for_status() def close_action(sender): sender.superview.close() v = ui.load_view_str(json.dumps(resp.json())) if v["_dismiss"]: v["_dismiss"].action = close_action v.present('sheet')
  • @Webmaster4o , lol does not surprise me. But let's face it a lot of little treasures in Pythonista.
    I wish they could all be documented, but I understand why they are not. It would take a big chunk out of the development time. I can't remember how long I have had Pythonista now, but I am astounded how much it has evolved in that short time.

  • @ccc , sorry for not being clear. It goes into the pyui file. Screenshot, below. Sorry, I left it full screen so it's clear to others also.

    Edit: oops, that is creating a dynamic attr in pic. But it's the same place / same idea.

    The eval is called on the CustomAtrributes, in the ui.py function _view_from_dict

    Sorry a few edits: I rushed this. But the self.sayhello(1,2) evals() to calling a method of that name in our class. You can leave off the self and call a function, but I think from memory you have to return True, otherwise warnings are printed.
    This seems very close to what the action method does , when it's defined inside the pyui file.

  • @dgelessus , super cool. The problem was the set_needs_display().works as expected now, have to say, it's pretty nice. I know what you mean about the zero base. Things started going wrong so I started adjusting things. But just happy it's working. Will go and look at your other ideas. I also have another mistake with scaling the rects for the ovals also. It's just top,left based. But now the basics are working I can get excited again 😱👍

    Edit : I also meant to say thank you.

  • @JonB , revised version of the test code. is a lot of extra just for testing. But so clean now for the timer part. Also a lot more accurate timings . Thanks again

    import ui import datetime, time class Test (ui.View): def __init__(self, duration = 1.0): self.frame = (0,0,300,300) self.background_color = 'white' btn = ui.Button(title = 'start') btn.width = 100 btn.border_width = .5 # hmmmmmmm, center does not work ( as you would expect it too ) # eg. btn.center = self.center btn.center = (self.center[0], self.center[1] - (44/2)) btn.action = self.JonB_way self.fire_obj = btn self.add_subview(btn) self.auto_close_duration = float(duration) self.start = None def JonB_way(self, sender): self.fire_obj.enabled = False self.start = datetime.datetime.now() ui.delay(self.fire_delay, self.auto_close_duration) def fire_delay(self): self.name = str(datetime.datetime.now() - self.start) self.fire_obj.enabled = True
  • See my other reply: make sure your loaded pyui return PanelMorphic as the CustomClass. init gets called on the class of whatever new returns.

  • A few minor changes to get HeaderClass working without a parent

    # coding: utf-8 import ui _demo_headers = ['one', 'two', 'three', 'four', 'five'] _header_heigth = 32 class MyCustomClass(ui.View): def __init__(self, frame): self.frame = frame self.background_color = 'white' self.flex = 'WH' self.img = ui.ImageView() self.img.image = ui.Image.named('iob:alert_circled_256') self.add_subview(self.img) self.header = HeaderClass() self.add_subview(self.header) def layout(self): # do resizing in the main class first self.img.frame = (0, _header_heigth, self.width, self.height - _header_heigth) # then call a layout method on my inc. views self.header.user_layout(self.width, _header_heigth) class HeaderClass(ui.View): def __init__(self): self.background_color = 'white' for col, header in enumerate(_demo_headers): lb = ui.Label(name = str(col)) lb.text = header lb.alignment = ui.ALIGN_CENTER lb.border_width = .5 self.add_subview(lb) # if you want layout called on this custom # class as i understand it. self.flex = 'WH' def layout(self): # if the class has no parent class calling # the shots... if not self.superview: self.user_layout(self.width, _header_heigth) def user_layout(self, w, h): self.width = w self.height = h num_headers = len(self.subviews) cell_width = self.width / num_headers for i, sv in enumerate(self.subviews): sv.frame = (i * cell_width , 0, cell_width, h) if __name__ == '__main__': #f = (0,0,540, 576) #mcc = MyCustomClass(f) #mcc.present('') h = HeaderClass().present()
Internal error.

Oops! Looks like something went wrong!