• Peter S

    @cvp When I put the variable i in b.my_attribute = .... as str(i), it returns the number of the button pressed. That number correspondents with the right article in the list of articles which I can show in a separate window. A very good solution, thanks.

    posted in Pythonista read more
  • Peter S

    @cvp You hit the nail on the head, thanks.

    My idea was to put the buttons in the window myself and fill in the title by program code.
    Your idea is to put the buttons in by code and that makes them a lot better to control.

    Thanks again!

    posted in Pythonista read more
  • Peter S

    I’m building a program that shows the heads of twenty articles in twenty buttons. After pressing a button a window containing the corresponding text of the article is to be shown.

    For each button a function is needed. Do I need to make twenty functions or is it possible to use one? I like the idea of the latter, but I have no clue how to find out which button was pressed. The function call accepts no parameters.

    How do I know which button?

    posted in Pythonista read more
  • Peter S

    @cvp Of course not, the whole code worked, it only needed a bit of pumping up the image. Thanks again!

    posted in Pythonista read more
  • Peter S

    Fantastic view from wall to wall. Thank you very much!
    And you're right, the site is pretty slow. Nevertheless, good answers are always in time...

    posted in Pythonista read more
  • Peter S

    Here the same result with your code for the imageview. When I bypass GifInView and load a png in my pyui with r['imageview1'].image = ui.Image.named('./gif/image.png'), the picture fills the whole frame.

    Succes, looking forward to a solution!

    posted in Pythonista read more
  • Peter S

    Part of the py:

    class GifInView(ui.View):
        def __init__(self,view,gif_file):
            self.ImageView = ui.ImageView()
            self.add_subview(self.ImageView)
            self.pil = Image.open(gif_file)
            wi,hi = self.pil.size
            wiv = view.width
            hiv = wiv * hi / wi
            self.frame = (0,0,wiv,hiv)
            view.add_subview(self)
            # In a GIF file, each frame has its own duration
            # assume here all frames have the same duration 
            self.update_interval = self.pil.info['duration']/1000
            self.frame_id = 0
        def pil2ui(self,imgIn):
            with io.BytesIO() as bIO:
                imgIn.save(bIO, 'PNG')
                imgOut = ui.Image.from_data(bIO.getvalue())
            del bIO
            return imgOut
        def update(self):
            # Display individual frames from the loaded animated GIF file
            self.pil.seek(self.frame_id)
            self.ImageView.image = self.pil2ui(self.pil)
            self.ImageView.content_mode = ui.CONTENT_SCALE_TO_FILL
            self.frame_id = self.frame_id + 1
            if self.frame_id >= self.pil.n_frames:
                self.frame_id = 0
    
    
    # knop regenradar
    def knopje(sender):
        uri = 'https://api.buienradar.nl/image/1.0/radarmapnl/gif/?hist=0&forc=36&width=550&l=1&step=1'
        with open('./gif/radar.gif', 'wb') as f:
            f.write(requests.get(uri).content)
        r = ui.load_view('Radar')
        if ui.get_screen_size()[1] >= 768:
            r.present('sheet')
        else:
            r.present()
        GifInView(r['imageview1'],'./gif/radar.gif')
    

    The link to the gif:
    link text

    The result is an animated gif displayed, but too small for the imageview (about 1/4th).

    posted in Pythonista read more
  • Peter S

    @cvp I pasted class GitToView into my program, made an imageview, downloaded an animated gif and displayed it. It works, the animation runs fine. But...

    The gif is about 450 x 450 px, the imageview as well, the displayed version is about one/third of the original. When I move the x,y of the imageview, the gif moves with it.

    I don't understand what happens in the class, so I can't solve the problem. Can you point out what I'm doing wrong? Thanks.

    posted in Pythonista read more
  • Peter S

    @cvp Thank you for both tips. The second one would make it possible to see the raindrops fall. I’ll think about that 😀

    posted in Pythonista read more
  • Peter S

    @cvp The result: [https://scheelpj.home.xs4all.nl/Weer.jpg](link url)

    Thanks again!

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!