diff --git a/functions/get_img_map.py b/functions/get_img_map.py index 3c44d56..3f50e41 100644 --- a/functions/get_img_map.py +++ b/functions/get_img_map.py @@ -1,21 +1,20 @@ from io import BytesIO import requests from PIL import Image +import time api_server = "http://static-maps.yandex.ru/1.x/" lon = "37.530887" lat = "55.703118" -delta = "0.002" - -params = { - "ll": ",".join([lon, lat]), - "spn": ",".join([delta, delta]), - "l": "map" -} -def get_img_map(): +def get_img_map(delta): + params = { + "ll": ",".join([lon, lat]), + "spn": ",".join([str(delta), str(delta)]), + "l": "map" + } response = requests.get(api_server, params=params) Image.open(BytesIO( response.content)).save("image.png") diff --git a/image.png b/image.png new file mode 100644 index 0000000..c2724ad Binary files /dev/null and b/image.png differ diff --git a/main.py b/main.py index 81b37fc..98bcce8 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,7 @@ from PyQt5.QtWidgets import * from PyQt5.QtGui import QPixmap import sys +from PyQt5 import QtCore from functions.get_img_map import get_img_map @@ -11,7 +12,27 @@ class Window(QMainWindow): self.setWindowTitle("Image") self.setGeometry(0, 0, 600, 450) self.label = QLabel(self) - get_img_map() + self.delta = 0.02 + get_img_map(self.delta) + self.pixmap = QPixmap('image.png') + self.label.setPixmap(self.pixmap) + self.label.resize(self.pixmap.width(), self.pixmap.height()) + self.show() + + def keyPressEvent(self, event): + try: + if event.key() == QtCore.Qt.Key_Up: + self.delta += 0.01 + self.update() + if event.key() == QtCore.Qt.Key_Down: + self.delta -= 0.01 + self.update() + event.accept() + except Exception as e: + print(e) + + def update(self): + get_img_map(self.delta) self.pixmap = QPixmap('image.png') self.label.setPixmap(self.pixmap) self.label.resize(self.pixmap.width(), self.pixmap.height())