-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame
31 lines (26 loc) · 825 Bytes
/
game
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import tkinter as tk
class Node:
def __init__(self, text, x, y):
self.text = text
self.x = x
self.y = y
class TextAdventureCreator:
def __init__(self, master):
self.master = master
self.nodes = []
self.canvas = tk.Canvas(master, width=800, height=600)
self.canvas.pack()
self.canvas.bind("<Button-1>", self.create_node)
def create_node(self, event):
x, y = event.x, event.y
text = "Sample Text"
node = Node(text, x, y)
self.nodes.append(node)
self.canvas.create_oval(x-50, y-50, x+50, y+50, fill="white")
self.canvas.create_text(x, y, text=text, font=("Arial", 10))
def main():
root = tk.Tk()
app = TextAdventureCreator(root)
root.mainloop()
if __name__ == "__main__":
main()