Get and display location to the preference UI

This commit is contained in:
2023-12-26 15:29:27 +01:00
parent 1a8a986674
commit ccaf08e238
5 changed files with 96 additions and 36 deletions

View File

@@ -1,3 +1,17 @@
def get_location_by_network() -> list:
#todo
return []
import urllib.request, json
from threading import Thread
class Location(Thread):
def __init__(self):
Thread.__init__(self)
self.GEO_URL = "https://get.geojs.io/v1/ip/geo.json"
def run(self) -> dict:
request = urllib.request.urlopen(self.GEO_URL)
data = json.load(request)
self.result = {
"latitude": data["latitude"],
"longitude": data["longitude"]
}

View File

@@ -20,7 +20,7 @@ class Time_Bar_Chart:
self.bar_pos_x = []
def create_bar_chart(self, image_width: int, image_height: int, times: list):
def create_bar_chart(self, save_location: str, image_width: int, image_height: int, times: list):
""" Create a time bar chart
Args:
@@ -36,7 +36,7 @@ class Time_Bar_Chart:
self.image_code.insert(0, '<svg xmlns="http://www.w3.org/2000/svg" width="%s" height="%s">' % (image_width, image_height))
self.image_code.append('</svg>')
file = open("time_bar.svg", "w")
file = open(save_location + "/time_bar.svg", "w")
for i in self.image_code:
file.write(i + '\n')