commit 9a0ecd33027aa19456272fdec0985ce7b3d86b27 Author: Andrzej Date: Mon Mar 15 16:50:33 2021 +0100 initial commit diff --git a/.idea/$CACHE_FILE$ b/.idea/$CACHE_FILE$ new file mode 100644 index 0000000..d9e91eb --- /dev/null +++ b/.idea/$CACHE_FILE$ @@ -0,0 +1,17 @@ + + + + + + + + + + + Buildout + + + + + + \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..5c98b42 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml \ No newline at end of file diff --git a/.idea/dictionaries b/.idea/dictionaries new file mode 100644 index 0000000..9b3d8b4 --- /dev/null +++ b/.idea/dictionaries @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..5ea737b --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..53f9910 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/sapper.iml b/.idea/sapper.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/sapper.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/bin/main.py b/bin/main.py new file mode 100644 index 0000000..5e6dbff --- /dev/null +++ b/bin/main.py @@ -0,0 +1,116 @@ +from doctest import master +from tkinter import * + +from PIL import Image, ImageTk + +WINDOW_X = 1100 +WINDOW_Y = 540 +FRAME_WIDTH = 533 +FRAME_HEIGHT = 533 +IMAGE_SIZE = 50 +X_START = Y_START = 3 +STEP = IMAGE_SIZE + X_START + +current_x = 3 +current_y = 3 + + +def Rectangle(): + global current_x + global current_y + canvas.create_rectangle(current_x, current_y, current_x + STEP - 2, current_y + STEP - 2, width=3, outline='red') + + # t_x = current_x - STEP + # t_y = current_y - STEP + # canvas.create_rectangle(t_x, t_y, STEP, STEP, width=3, outline='white') + + window.bind("", Moving) + + +def Field(): + x = X_START + y = Y_START + for i in range(10): + for j in range(10): + canvas.create_image(x, y, anchor=NW, image=img) + x += IMAGE_SIZE + X_START + y += IMAGE_SIZE + Y_START + x = X_START + + +def Moving(event): + global current_x + global current_y + if event.keysym == "Right": + if current_x + STEP < FRAME_WIDTH: + current_x += STEP + canvas.delete('all') + Field() + Rectangle() + elif event.keysym == "Left": + if current_x - STEP >= X_START: + current_x -= STEP + canvas.delete('all') + Field() + Rectangle() + elif event.keysym == "Up": + if current_y - STEP >= Y_START: + current_y -= STEP + canvas.delete('all') + Field() + Rectangle() + elif event.keysym == "Down": + if current_y + STEP < FRAME_HEIGHT: + current_y += STEP + canvas.delete('all') + Field() + Rectangle() + + +def main(): + # This creates the main window of an application + window_size = f'{WINDOW_X}x{WINDOW_Y}' + global window + window = Tk() + window.title("Sapper") + window.geometry(window_size) + + frame = Frame(master, width=FRAME_WIDTH, height=FRAME_HEIGHT, bd=1) + frame.pack(anchor=NW) + + global canvas + canvas = Canvas(frame, width=FRAME_WIDTH, height=FRAME_HEIGHT, bg='white') + canvas.pack() + + global img + img = PhotoImage(file="../files/imgs/image.png") + + # x = X_START + # y = Y_START + # for i in range(10): + # for j in range(10): + # canvas.create_image(x, y, anchor=NW, image=img) + # x += IMAGE_SIZE + X_START + # y += IMAGE_SIZE + Y_START + # x = X_START + + # canvas.create_rectangle(X_START, Y_START, X_START + IMAGE_SIZE, Y_START + IMAGE_SIZE, width=3, outline='red') + + # app = Sapper. + + # global current_x + # global current_y + # current_x = 3 + # current_y = 3 + + Field() + Rectangle() + window.bind("", Moving) + window.mainloop() + + # moving(window) + # window.mainloop() + + +if __name__ == '__main__': + main() diff --git a/files/imgs/image.png b/files/imgs/image.png new file mode 100644 index 0000000..baa14b5 Binary files /dev/null and b/files/imgs/image.png differ