• BapeHiks

    @JeremyMH a foundation vote that proposed @enceladus but without the editor UI

    import ui
    class StopWatch(ui.View):
        def __init__(self, *args, **kwargs):
            super().__init__(*args, **kwargs)
            self.value = 0
            self.state = 'stop'
            self.update_interval = .1
    
        def draw(self):
            t0 = (self.value // (600 * 60), self.value // 600, self.value // 10)
            t1 = (t0[0], t0[1] % 60, t0[2] % 60)
            ui.draw_string(
                "{:02}:{:02}:{:02}".format(*t1),
                font=('Helvetica', 20),
                rect=(150, 0, 0, 0),
                color='black',
                alignment=ui.ALIGN_CENTER)
    
        def update(self):
            if self.state == 'run':
                self.value += 1
            self.set_needs_display()
    
    
    def button_action(sender):
        v1 = sender.superview['Watch']
        sender.hidden = True
        if sender.title == 'Reset':
            v1.value = 0
            v1.state = 'stop'
            sender.superview['Start'].hidden = False
        elif sender.title == 'Start':
            v1.value = 0
            v1.state = 'run'
            sender.superview['Stop'].hidden = False
        elif sender.title == 'Stop':
            v1.state = 'stop'
            sender.superview['Reset'].hidden = False
            
    v = ui.View(width=397, height=271)
    
    v.add_subview(StopWatch(name = 'Watch', frame = (0, 30, 345.00, 76.00)))
    v.present('sheet')
    
    for btn in ['Reset', 'Stop', 'Start']:
        v.add_subview(ui.Button(frame=(v.center.x-40, v.center.y-40, 80, 80), name=btn, border_width=1, corner_radius=40, action=button_action))
        v[btn].title = btn
        if btn != 'Start':
            v[btn].hidden = True```

    posted in Pythonista read more
  • BapeHiks

    @brx Python is really a great language to learn, and even more so with an application like pythonista, I myself just got into it less than a year ago and did absolutely everything with pythonista, I didn't even sit at the computer, I can advise you not to get distracted by node from your notes.js and scriptable, all they can do can be pythonista and much more thanks to python, I used to study javascript a long time ago and after that python seemed more complicated, but very quickly I made sure that it solved some problems much easier, you should start with the ui documentation if you already have experience writing scripts and small programs, also documentation from apple UIKit to understand how ui works in pythonista. about the xcode template, you don't have to worry about it until you have a good understanding of it by omz as promised. beeware is a great future-oriented framework, and most importantly it is compatible with pythonista, but for now it is still raw for ios, but in the future it will be a great addition for pythonista and cross development.

    posted in Pythonista read more
  • BapeHiks

    for correct work toga ui methods should be wrapped with objc_util.on_main_thread().
    Unfortunately, it was a long time ago and I didn't need it, it might be useful for you.

    posted in Pythonista read more
  • BapeHiks

    I once tried to use BeeWare with pythonista, toga_ios was fully pythonista compatible since it uses rubicon, I even wanted to make a pythonista_toga module to be able to use the standard ui module with toga_core, you can see toga_ios for use, the only important thing to do is to create UIViewController instead of creating a new UIWindow, and it is desirable to do the check "if running ios pythonista instead of UIWindow use ui.View" to be able to close the window

    posted in Pythonista read more
  • BapeHiks

    @itsseanl

    everything works for me too. try as a crutch

    with open(testdst, 'x') as testdst, open(filePath,'r') as filePath:
       testdst.write(filePath.read())
    

    if it does not work, then most likely you do not have write access in this directory

    posted in Pythonista read more
  • BapeHiks

    @stephen
    I used the examples above, generally in the

    taking the very first post with code managed to
    changed

    def adaptivePresentationStyleForPresentationController_(_self, _cmd, controller):
        return -1 #UIModalPresentationNone # == -1
    
    vc.modalPresentationStyle = 7 #UIModalPresentationPopover # == 7
    

    img

    posted in Pythonista read more
  • BapeHiks

    I don't have an iPad, but maybe you could use an option

    import console
    console.set_font('Menlo', 12)
    del console
    

    posted in Pythonista read more
  • BapeHiks

    sourcevc = sourceview.objc_instance._findNearestViewController()
    
    AttributeError: No method found for selector ":findNearestViewController"
    

    if I understand correctly sourcevc should be a view.

    posted in Pythonista read more
  • BapeHiks

    I haven't managed to make something work, ViewHierarchy is like I understand a pointer in <popover in ios 13, and how to make it all on 12.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!