Sztuczna_inteligencja_gr_13/bin/Classess/Field.py

71 lines
2.3 KiB
Python
Raw Normal View History

2021-04-02 03:39:46 +02:00
from doctest import master
from tkinter import *
# from bin.main import PlayerReturn as player
# from bin.main import DrawingLargeImage
WINDOW_X = 533 + 1200
WINDOW_Y = 950
FRAME_WIDTH = 533
FRAME_HEIGHT = 533
# Size of small image
IMAGE_SIZE = 50
step = IMAGE_SIZE + 3
class Field(object):
def __init__(self):
self.win = Tk()
self.width = 533
self.height = 533
self.image_size = 50
self.rows = 10
self.columns = 10
self.x_start = 3
self.y_start = 3
self.state_of_cell_array = [[0 for i in range(3)] for j in range(200)]
self.small_image_array = [[0 for i in range(self.rows)] for j in range(self.columns)]
self.large_image_array = [[0 for i in range(self.rows)] for j in range(self.columns)]
self.main_frame = Frame(master, width=FRAME_WIDTH, height=FRAME_HEIGHT, bd=0)
self.main_frame.pack(anchor=NW)
self.small_field_canvas = Canvas(self.main_frame, width=FRAME_WIDTH, height=FRAME_HEIGHT, highlightthickness=0,
bg='light gray')
self.small_field_canvas.pack()
self.large_image_canvas = Canvas(self.win, width=WINDOW_X - 533 - 20, height=900, highlightthickness=0,
bg='gray')
self.large_image_canvas.place(x=FRAME_WIDTH + 5, y=3)
2021-04-02 04:08:50 +02:00
# Clear Canvases
def Moving(self):
self.small_field_canvas.delete('all')
self.large_image_canvas.delete('all')
2021-04-02 03:39:46 +02:00
2021-04-02 04:08:50 +02:00
def PuttingSmallImages(self):
x = self.x_start
y = self.y_start
row = 0
column = 0
# Putting small images
for i in range(self.columns):
for j in range(self.rows):
small_image_name = self.small_image_array[column][row]
self.small_field_canvas.image = small_image_name
self.small_field_canvas.create_image(x, y, anchor=NW, image=small_image_name)
x += self.image_size + self.x_start
row += 1
y += self.image_size + self.y_start
x = self.x_start
column += 1
row = 0
def PuttingLargeImage(self, large_img_name):
self.large_image_canvas.image = large_img_name
self.large_image_canvas.create_image(0, 0, anchor=NW, image=large_img_name)