It definitely doesn’t work with big images, but I have same problem even with 200x300 images.
Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Posts made by iOSBrett
-
RE: Trouble using imported images from Photos
-
RE: Trouble using imported images from Photos
Thanks for that, exception is ‘could not load texture’
Had to remove ui.image.named as I couldn’t convert it to a texture for SpriteNode
Exception doesn’t really help us much, this is a weird one.
‘’’
try:
self.background = SpriteNode('IMG_0202.PNG')
except Exception as e:
print(str(e))
‘’’ -
RE: Trouble using imported images from Photos
Tried that too, same issue, thanks anyways.
-
RE: Trouble using imported images from Photos
i added a try catch block, wasn’t sure how to catch the error though. But strangely even trying to list the current dir is not working. I’m not much of a python programmer, am a Swift coder, but I realise now that the strange errors are actually due to it throwing an exception in the init method. My errors happen in other methods due to the rest of the init method not being run.
I did:
‘’’
class MyScene (Scene):
def setup(self):self.background_color = '#000000' #print(os.listdir('.')) try: self.image = ui.Image('IMG_0204.PNG') except: print(os.listdir('.'))
‘’’
I am now thinking it may be something to do with directory length. This project is anpbout 5 sub folders deep.
-
Trouble using imported images from Photos
Hi,
I am currently teaching some young kids to code using Pythonista, our current project is Pac Man. As the kids are young I am having to take some shortcuts. For instance instead of building the background with tiles, I just want to load it from an image.
So I have saved some images from the internet and am attempting to load them into my Scene as a SpriteNode. I can import them into Pythonista without any issue, however when I try to use them in the code I get strange errors. Sometime it is ‘could not load image’, but other times it gives errors on future lines, such as if you forget a semi colon.
My image is in the same folder as the code, and I have tried lots of different images. One time one image worked, so I deleted it and tried again (need to ensure it works for kids) and it failed.
I am on iOS11 with the latest version of Pythonista. Has anybody ne experienced this issue or have an ideas?
‘’’
from scene import *
import sound
import random
import math
from joystick import Joystick
from player import Player
from tile import Tile
from direction import DirectionA = Action
class MyScene (Scene):
def setup(self):self.background_color = '#000000' self.background = SpriteNode('IMG_0204.PNG') self.background.position = self.size.width / 2, self.size.height / 2 self.add_child(self.background)
‘’’
-
RE: Fractal drawing using canvas doesn’t show drawing
@JonB thanks, I didn’t realise it wasn’t really supported, good to know.
My day job is Swift/iOS, so doing the python thing as something fun, trying to keep away from the iOS specific stuff unless I really have to.
-
Fractal drawing using canvas doesn’t show drawing
Hi,
I am playing around with some Fractal drawing using the canvas module. My scripts use recursion and I am finding that if I go to many levels deep (10ish) and “wide” then the output flashes up briefly and disappears. By “wide” l am referring to the fact that my recursion doubles each time I go down a level as it calls itself twice. The result is that the stack probably resembles the Fractal Tree I am trying to draw.
Adding begin_updates and end_updates just causes a crash.
Any advice on how I might get around this?
import random
import canvas
from math import pidef drawBranch( angle, length):
if length < 10: return canvas.draw_line( 0, 0, 0, length) canvas.translate( 0, length) canvas.save_gstate() canvas.rotate( angle * pi / 180) drawBranch( angle, length -10) canvas.restore_gstate() canvas.save_gstate() canvas.rotate( - angle * pi / 180) drawBranch( angle, length -10) canvas.restore_gstate()
width = 800
height = 800
canvas.set_size( width, height)
canvas.translate( width / 2, 0)
drawBranch( 17, 120)