Forum Archive

Pythonista 3 Rect attributes

amdescombes

Hi,

I've started using Pythonista and really love it but since moving to Pythonista 3 some of the scripts I was using stopped working :
I get a message saying Rect objects have no attribute left(), right(), top() or bottom(), is there anyway around this?
Thanks for any help.

Cheers
Andre

chriswilson

Are the attributes of the scene.Rect class not x, y, width and height (without parentheses as they are attributes, not methods)?

Phuket2

@chriswilson , I am sure you are right. I was going to reply to this one, but I thought maybe he was using a module that I don't use. I don't use scene, but ui.Rect() is the same. Only properties and no left, top methods or properties etc. x, y notation.
print(dir(ui.Rect()) or print dir(scene.Rect()) is the same.

chriswilson

@Phuket2
Yeah I wondered if it might be a different module. Im only really familiar with scene.Rect()!

ccc
import scene, ui
print(scene.Rect() == ui.Rect())  # True
print(scene.Rect == ui.Rect)      # True
print(scene.Rect is ui.Rect)      # True
amdescombes

Where these methods removed? Is there any reason this was done?

chriswilson

@amdescombes
I'm not sure actually. I didn't know those attributes had been available.

amdescombes

I was going through the docs and I see that a Rect object has the following attributes :

  • min_x # I guess I could use it instead of left()
  • max_x # I guess I could use it instead of right()
  • min_y # I guess I could use it instead of bottom()
  • max_y # I guess I could use it instead of top()
Phuket2

@amdescombes , they are basically just short cuts. Very handy ones. Like max_y will be the rects.y + height. If you are doing things in a ui.ScrollView for example, the short cuts importance becomes very apparent. The .Rect also has an origin property, that could also factor into things.

amdescombes

Hi @chriswilson, I was trying to run some of the examples on github but I couldn't because I kept getting errors saying those attributes did not exist, that's what prompted my question, LOL

ccc

@amdescombes You might want to "open an issue" on the GitHUb repos that do not work and then watch how the owners fix their problems.