Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wiseplat
GitHub Repository: wiseplat/python-code
Path: blob/master/python-igra-morskoy-boy/main_lesson_1.py
5918 views
1
from tkinter import *
2
from tkinter import messagebox
3
import time
4
5
tk = Tk()
6
app_running = True
7
8
size_canvas_x = 600
9
size_canvas_y = 600
10
11
12
def on_closing():
13
global app_running
14
if messagebox.askokcancel("Выход из игры", "Хотите выйти из игры?"):
15
app_running = False
16
tk.destroy()
17
18
19
tk.protocol("WM_DELETE_WINDOW", on_closing)
20
tk.title("Игра Морской Бой")
21
tk.resizable(0, 0)
22
tk.wm_attributes("-topmost", 1)
23
canvas = Canvas(tk, width=size_canvas_x, height=size_canvas_y, bd=0, highlightthickness=0)
24
canvas.create_rectangle(0, 0, size_canvas_x, size_canvas_y, fill="white")
25
canvas.pack()
26
tk.update()
27
28
while app_running:
29
if app_running:
30
tk.update_idletasks()
31
tk.update()
32
time.sleep(0.005)
33
34