Created
March 9, 2019 19:05
-
-
Save jaizon2000/e09bca3a31c9934a6b9a18924bffa354 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from graphics import * | |
def main(): | |
# make window | |
win = GraphWin("Fancy UI", 300, 400) | |
# Entry | |
Text(Point(100,100), "Name").draw(win) | |
entry = Entry(Point(200,100), 10) | |
entry.draw(win) | |
# Button | |
btn = Rectangle(Point(100,175), Point(200, 230)) | |
btn.draw(win) | |
Text(Point(150, 200), "Greet").draw(win) | |
# Greeting | |
greeting = Text(Point(150,275), None) | |
greeting.draw(win) | |
while win.isOpen(): # While open | |
try: | |
pt = win.getMouse() # get point of mouse | |
except: | |
return | |
if (btn.p1.x < pt.x and pt.x < btn.p2.x and # if (x,y) of pt is less the (x,y) of the button points... | |
btn.p1.y < pt.y and pt.y < btn.p2.y): | |
greeting.setText("hello, " + entry.getText()) # Greet them, with the name entered in entry | |
else: | |
win.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment