Python Forum
Unwanted random generation of scripted Shapes in GASP
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unwanted random generation of scripted Shapes in GASP
#1
Hello,

I'm currently learning Python 2.7 with the help of this tutorial: http://openbookproject.net/thinkcs/pytho.../ch04.html If you look at the bottom of that page, in exercise 10, I am to produce the pictured six houses with a script. I've written a script, but when I load it, not all of the windows and doors are visible. The really odd thing is that the windows and doors that ARE visible are different every time I load the script.

Note that I'm using Windows 8, which means I'm not using the latest version of GASP, as described here: http://dev.laptop.org/pub/gasp/downloads/

Below are an image of the script and the problem. Thanks in advance.

Edit: I suspect the problem has to do with the blue boxes covering the other shapes, as everything is visible when I set the blue boxes to filled=False.

[Image: 2a4wz7t.jpg]
Reply
#2
Please post the code using the Python button (6th button from the right), not a 'picture' of the code.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#3
from gasp import *

def draw_house(x, y):


    Box((x, y), 100, 100, True, color.BLUE)     #house
    Box((x + 35, y), 30, 50, True, color.GREEN)       #door
    Box((x + 20, y + 60), 20, 20, True, color.YELLOW)       #left window
    Box((x + 60, y + 60), 20, 20, True, color.YELLOW)       #right window
    Polygon(((x, y + 100),(x + 50, y + 140),(x + 100, y + 100)),True, color.RED)

begin_graphics(title="Houses at Night", background=color.BLACK)
draw_house(20, 20)
draw_house(270, 20)
draw_house(520, 20)
draw_house(145, 170)
draw_house(395, 170)
draw_house(270, 320)
update_when('key_pressed')  #keep canvas open until key pressed
end_graphics()              #close canvas
Reply
#4
To be honest i think you shall skip this part of the book,
because i really do not like when when author of books make wrapper around stuff like(Pygame,Tkinter...).
The you wonder about stuff like,is it the GASP tool(Pygame wrapper) that make this error?
Do they keep GASP updated,no it's from 2010 ect.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  data input while debugging causes unwanted code completion fred1232 2 2,688 Sep-14-2025, 03:32 PM
Last Post: deanhystad
  How to remove unwanted images and tables from a Word file using Python? rownong 2 2,306 Feb-04-2025, 08:30 AM
Last Post: Pedroski55
  Parquet file generation woliveiras 1 1,302 Dec-07-2024, 02:52 AM
Last Post: deanhystad
Photo image generation with text style Belialhun 0 1,268 Oct-08-2024, 01:53 PM
Last Post: Belialhun
  How can I design shapes on a curve in python? mervea 2 2,347 Sep-14-2023, 01:04 PM
Last Post: Pedroski55
  Node Flow Generation in Python Linenloid 0 1,512 Feb-21-2023, 07:09 PM
Last Post: Linenloid
  Allure Report Generation rotemz 0 1,857 Jan-24-2023, 08:30 PM
Last Post: rotemz
  x and y must have same first dimension, but have shapes (1,) and (50,) asja2010 5 7,004 Jan-12-2023, 07:24 PM
Last Post: deanhystad
Question Unwanted execution of unittest ThomasFab 9 6,393 Nov-15-2022, 05:33 PM
Last Post: snippsat
  Shapes in Video finndude 0 1,580 Oct-07-2022, 03:30 PM
Last Post: finndude

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020