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.
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())
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.
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.
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!