• AceNinjaFire

    @ccc

    Ah thank you lol, I got as far as image_data = BytesIO(requests.get().content)

    I never thought about using the Context Manager and putting the “.getvalue()” on the image_data. Lol I appreciate the help!

    posted in Pythonista read more
  • AceNinjaFire

    @stephen @ccc

    Shiiiiit sorry lol I had not realized that anyone had replied. I knew I could do that from the beginning, I was just trying to go from jpeg/image object straight to ui.Image/Ui.ImageView.

    I ended up just making a list from each requests.get().content and using that.
    I was just trying to swim up river to see if I could do it I guess lol.

    posted in Pythonista read more
  • AceNinjaFire

    Nvm I think I figured it out, it has to be a bytes-like object. I just have to figure out how to get image.tobytes() to byte-like and not bytes

    posted in Pythonista read more
  • AceNinjaFire

    Been trying to get an idea of mine working. I made a script to download galleries, and I’m trying to set the image view after the image has been downloaded.
    But for some reason what I did below doesn’t do anything. Could someone tell me what I’m doing wrong?

    import ui,requests,Image
    from io import BytesIO
    Image_url =“some image url”
    
    image_data = BytesIO(requests.get(image_url).content)
    
    image = Image.open(image_data)
    
    w,h = ui.get_screen_size()
    testview = ui.View()
    testview.frame = (0,0,w,h)
    
    Img_view = ui.ImageView()
    
    Img_view.frame() = testview.frame()
    
    testview.add_subview(img_view)
    
    testview.present()
    
    Img_view.image= ui.Image.from_data(image.tobytes())
    
    
    
    

    posted in Pythonista read more
  • AceNinjaFire

    @JonB

    thanks that did it!

    posted in Pythonista read more
  • AceNinjaFire

    @JonB

    I’ve gotten that far, but I was trying to shorten what I type even more. As I’ve read in some posts that you can format the init.py file in a way that will completely dump all of the functions of the files into init file. So I wouldn’t have to reference module1 at all and just type from mypackage import some_function.

    posted in Pythonista read more
  • AceNinjaFire

    Hey everyone, I just found out about how to make packages in python and thought it was an absolutely good idea especially with how it can get repetitive typing the same code over and over again.

    My setup

    base folder
    main.py

    /mypackage
    init.py
    module1.py

    But as I’ve tried to do so in Pythonista it just keeps giving me errors.
    I’ve tried it this way

    #__init__.py
    
    from module1 import some_function
    
    

    And this way

    #__init__.py
    from .module1 import some_function
    

    Excluding and including the period.
    As I’ve seen it in many guides of making packages. But I keep getting this message when I try calling it from my main.py .

    ModuleNotFoundError: No module named 'main.module1'; 'main' is not a package

    I’m sure I’ve completely overlooked the answer somewhere. I’ve been on stackoverflow and seen quite a few posts about explicit relative imports but I can’t make heads or tails of what to do to make a package.

    I’d appreciate any help I can get!

    posted in Pythonista read more
  • AceNinjaFire

    @JonB

    Dang thanks man, and that’s definitely something I’ll look into. I’ve been looking for a reason to delve into js again after my initial dive into it. What types of projects have you done bridging the two together?

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!