From fada354c740cac0062829a922d9096766f48044a Mon Sep 17 00:00:00 2001 From: justuser31 Date: Sat, 22 Apr 2023 15:31:49 +0300 Subject: [PATCH] Add icon and add cordinates --- map.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/map.py b/map.py index 21cc53c..b9baa67 100644 --- a/map.py +++ b/map.py @@ -10,10 +10,17 @@ root = tk.Tk() canvas = tk.Canvas(root) canvas.pack() -# Устанавливаем размеры окна root.geometry("1024x800") +root.tk.call('wm', 'iconphoto', root._w, tk.PhotoImage(file='map.png')) +ttext = tk.Canvas(root, width=80, height=20, bg="black") +ttext.place(x=950, y=0) +text = ttext.create_text(40, 10, text="X: 1, Y: 1", fill="white") while True: + x = root.winfo_pointerx() - root.winfo_rootx() + y = 800 - (root.winfo_pointery() - root.winfo_rooty()) + ttext.itemconfig(text, text=f"X: {x}, Y: {y}") + # Открываем URL как файл image_file = io.BytesIO(urllib.request.urlopen(url).read()) @@ -30,20 +37,19 @@ while True: canvas.place(x=0, y=0) try: - # Удаляем предыдущий Canvas canvas_old.destroy() except: pass canvas_old = canvas + tk.Misc.lift(ttext) # Обновляем окно root.update() - - # Ждем 0.1 секунду перед следующим обновлением time.sleep(0.1) root.mainloop() +