okay the point of the program is to have the user select two points which would be the points that make up the base of the house, then they select a point inside the house that will serve as the center of a door, however if they click outside of the house my program should ask them to click a point a different point, that's where i'm having problems.

from graphics22 import *

def main():
    win = GraphWin('House Builder', 800,600)
    message = Text(Point(400,10),'Please click two points to make the body of the house')
    message.draw(win)
    p1 = win.getMouse()
    p1.draw(win)
    p2 = win.getMouse()
    p2.draw(win)

    base = Rectangle(p1,p2)
    base.setFill("green")
    base.draw(win)

    distance = (p2.x - p1.x)
    d = (distance/10)

    message.setText('Please click inside the house to open a door')

    p3 = win.getMouse()
    p3.draw(win)
    p4 = Point(p3.x-d,p1.y)
    p5 = Point(p3.x+d,p3.y)

    door = Rectangle(p4,p5)
    door.setFill("orange")

    for i in range(1):
        if p4.x <= p1.x or p5.x >= p2.x:
            break;
        else:
            door.draw(win)
    message.setText('Please click two points inside the house to open a window')
    p6 = win.getMouse()
    p6.draw(win)
    p7 = win.getMouse()
    p7.draw(win)
    window = Rectangle(p6,p7)
    window.setFill("lightblue")
    for i in range(1):
        if p6.getX() < p1.getX() or p7.getX() > p2.getX():
            message.setText('Please click two points INSIDE the house to open a window')
            
        else:
            window.draw(win)
    
    win.getMouse()
    win.close()
    
main()

i feel the major problem lies in the fact that i'm using a for loop but i'm clueless as to what else to do

base = Rectangle(p1,p2)

Can you draw a rectangle with only 2 points? The simple way to do this is to have the house rectangle on the horizontal (set both x values to the same integer), then you just have to set the x from the door click to the x of the base of the house, and check that the y value is between the two y values of the house.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.