PgUp и PgDown
This commit is contained in:
@@ -1,21 +1,20 @@
|
|||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
import requests
|
import requests
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
import time
|
||||||
|
|
||||||
api_server = "http://static-maps.yandex.ru/1.x/"
|
api_server = "http://static-maps.yandex.ru/1.x/"
|
||||||
|
|
||||||
lon = "37.530887"
|
lon = "37.530887"
|
||||||
lat = "55.703118"
|
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)
|
response = requests.get(api_server, params=params)
|
||||||
Image.open(BytesIO(
|
Image.open(BytesIO(
|
||||||
response.content)).save("image.png")
|
response.content)).save("image.png")
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from PyQt5.QtWidgets import *
|
from PyQt5.QtWidgets import *
|
||||||
from PyQt5.QtGui import QPixmap
|
from PyQt5.QtGui import QPixmap
|
||||||
import sys
|
import sys
|
||||||
|
from PyQt5 import QtCore
|
||||||
from functions.get_img_map import get_img_map
|
from functions.get_img_map import get_img_map
|
||||||
|
|
||||||
|
|
||||||
@@ -11,7 +12,27 @@ class Window(QMainWindow):
|
|||||||
self.setWindowTitle("Image")
|
self.setWindowTitle("Image")
|
||||||
self.setGeometry(0, 0, 600, 450)
|
self.setGeometry(0, 0, 600, 450)
|
||||||
self.label = QLabel(self)
|
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.pixmap = QPixmap('image.png')
|
||||||
self.label.setPixmap(self.pixmap)
|
self.label.setPixmap(self.pixmap)
|
||||||
self.label.resize(self.pixmap.width(), self.pixmap.height())
|
self.label.resize(self.pixmap.width(), self.pixmap.height())
|
||||||
|
|||||||
Reference in New Issue
Block a user