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.
Frame for tetris
-
@Karina try this
Board(position=(sw/2,sh/2), parent=self)
-
@cvp 👍 and what 2 first args do in
ui.Path.rect()
?
Thanks for help🤗 -
@Karina I think that as used here in ShapeNode path, x and y are not used, only width and height. If you draw an ui.path in general, x and y set path position, but not here.
-
@cvp Thank you now the frame where it needs to be.
Then I need to draw vertical lines in the frame, but it doesn’t work. And if change z_position - nothing.import arrows from scene import * colors = ['purple', 'red', 'blue', 'orange', 'yellow', 'green', 'lightblue'] sw = get_screen_size()[0] sh = get_screen_size()[1] class Board(ShapeNode): def __init__(self, parent=None, *args, **kwargs): self.rect_w = sw/2 self.rect_h = sh-100 path = ui.Path.rect(0, 0, self.rect_w, self.rect_h) path.line_width = 10 super().__init__(path, z_position=-1, fill_color='white', stroke_color='purple', parent=parent, *args, **kwargs) def draw_lines(self): fill(0, 0, 0) stroke_weight(2) rect(sw-200, sh/2, 100, 100) for l in range(int(self.rect_w/30)): line_path = ui.Path.rect(sw/3 - self.rect_w/2 + 30*l, sh/2 + self.rect_h/2, self.rect_w, self.rect_h) class Game(Scene): def setup(self): self.background_color = 'white' self.board = Board(position=(sw/3, sh/2), parent=self) self.add_buttons() def draw(self): self.board.draw_lines() def add_buttons(self): ars = arrows.Main() self.present_modal_scene(ars) if __name__ == '__main__': run(Game())
But beyond the purple frame I can draw😐
-
@Karina sincerely, not sure this is what you want. If not, sorry and forget quickly this post
class Board(ShapeNode): def __init__(self, parent=None, *args, **kwargs): self.rect_w = sw/2 self.rect_h = sh-100 path = ui.Path.rect(0, 0, self.rect_w, self.rect_h) path.line_width = 2 d = int(self.rect_w/30) for l in range(int(self.rect_w/d)): x = l*d path.move_to(x,0) path.line_to(x,self.rect_h) . . .
Comment temporarily your draw_lines process, to watch the result
-
@cvp It’s nearly what I need, I just want it in grey color. But when I put it into the draw_lines and not Board’s init, it doesn’t work. And I don’t want to overload init
-
@Karina it does not work because you pass the path to super.init and thus when you draw the lines, the path is already built
This is not really an overload
-
-
@Karina said:
colors = ['purple', 'red', 'blue', 'orange', 'yellow', 'green', 'lightblue']
sw = get_screen_size()[0]
sh = get_screen_size()[1]colors = ‘purple red blue orange yellow green lightblue'.split()
sw, sh = get_screen_size() -
This post is deleted! -
@ccc with sw sh okay, but what this
colors = ‘purple red blue orange yellow green lightblue'.split()
gives? -
-
@Karina, just to be clear, there is nothing wrong with
colors = ['purple', 'red', 'blue', 'orange', 'yellow', 'green', 'lightblue']
– for all-string arrays of this size, thestr.split()
version may just be more convenient to type. -
-
-
object has no attr _suspend_updates
https://docs.python.org/3/library/functions.html are cool things to study as you learn Python. One of those is
dir(object)
which lists all the variables and methods of object. The message above means thatdir(object)
does not contain_suspend_updates
but some code is assuming that it does. Practice a lot withdir(object)
because it will help you to anticipate bugs. -
-
-
- Give us some code that generates this error --and/or--
- Give us the full multiline error message (stack trace) so we can understand the context of the error.
We do not even know the datatype of
object
. -
@Karina said:
_suspend_updates