PgUp и PgDown

This commit is contained in:
2023-01-30 18:57:31 +07:00
parent 8e144b01e5
commit 1630f048f8
3 changed files with 29 additions and 9 deletions
+4 -5
View File
@@ -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"
def get_img_map(delta):
params = {
"ll": ",".join([lon, lat]),
"spn": ",".join([delta, delta]),
"spn": ",".join([str(delta), str(delta)]),
"l": "map"
}
def get_img_map():
response = requests.get(api_server, params=params)
Image.open(BytesIO(
response.content)).save("image.png")
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

+22 -1
View File
@@ -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())