From 9a0ecd33027aa19456272fdec0985ce7b3d86b27 Mon Sep 17 00:00:00 2001 From: Andrzej Date: Mon, 15 Mar 2021 16:50:33 +0100 Subject: [PATCH] initial commit --- .idea/$CACHE_FILE$ | 17 +++ .idea/.gitignore | 2 + .idea/dictionaries | 6 + .../inspectionProfiles/profiles_settings.xml | 6 + .idea/misc.xml | 4 + .idea/modules.xml | 8 ++ .idea/sapper.iml | 8 ++ .idea/vcs.xml | 6 + bin/main.py | 116 ++++++++++++++++++ files/imgs/image.png | Bin 0 -> 464 bytes 10 files changed, 173 insertions(+) create mode 100644 .idea/$CACHE_FILE$ create mode 100644 .idea/.gitignore create mode 100644 .idea/dictionaries create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/sapper.iml create mode 100644 .idea/vcs.xml create mode 100644 bin/main.py create mode 100644 files/imgs/image.png 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 0000000000000000000000000000000000000000..baa14b56d6c38cd0027111a2c6ca4be2c0707862 GIT binary patch literal 464 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1SBWM%0B~AjKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85o30K$!7fntTONL#n5XV@QPi+Z!8wnH>e(9{LIhbqc$^+14C8H+-czVeruG{+aKgrfJS8e$FuRmBaM-UCN c?*6O4YLl*Ablb(Hz*u1LboFyt=akR{0DsZZb^rhX literal 0 HcmV?d00001