Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- from tkinter import messagebox
- import time
- def on_close_window():
- global run_app
- if messagebox.askokcancel("Морской бой", "Завершить работу программы?"):
- run_app = False
- game.destroy()
- def draw_game_map():
- for i in range(cells_w + 1):
- canvas.create_line(cell_size_w * i, 0, cell_size_w * i, size_w)
- for i in range(cells_h + 1):
- canvas.create_line(0, cell_size_h * i, size_h, cell_size_h * i)
- size_w = 700
- size_h = 700
- cells_w = cells_h = 10
- cell_size_w = size_w // cells_w
- cell_size_h = size_h // cells_h
- _version = "0.1"
- run_app = True
- game = tk.Tk()
- game.protocol("WM_DELETE_WINDOW", on_close_window)
- game.resizable(0, 0) # Запрет изменения размеров окна
- game.wm_attributes("-topmost", 1) # окно приложение всегда на первом плане.
- game.title(f"Игра морской бой. Версия {_version}")
- canvas = tk.Canvas(game, width=size_w, height=size_h, bd=0, highlightthickness=0)
- canvas.create_rectangle(0, 0, size_w, size_h, fill="white")
- canvas.pack()
- draw_game_map()
- while run_app:
- if run_app:
- game.update_idletasks()
- game.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement