First create a new project (which creates a new project folder)
Then get the Zelle graphics library and put it in your project folderThen create a window that looks basically like the one below:
After your program gets this window up, you need to loop forever (while True:)
wait for the user to click the mouse,
To make your life a little easier, you can use the function below to help you determine if one of the fake buttons is pushed (and do nothing if the mouse is clicked outside of those fake buttons).
def is_clicked(rect:graphics.Rectangle, point:graphics.Point):
xloc = point.getX()
yloc = point.getY()
button_width = abs(rect.getP1().getX() - rect.getP2().getX())
button_height = abs(rect.getP1().getY() - rect.getP2().getY())
center = rect.getCenter()
if xloc >= center.getX()- button_width/2 and xloc <= center.getX() + button_width/2 and \
yloc >= center.getY() - button_height/2 and yloc <= center.getY() + button_height/2:
return True
else:
return False
Just paste the function in your code above your def main(): line.
For the example below, assume that click_loc is initialized as follows:
click_loc = window.getMouse()
and clear_rect is the graphics.Rectangle object that I used to draw it up above. Then can use this in_clicked something like the following:
if is_clicked(clear_rect, click_loc):
Submit your project via blackboard.