Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for HTTP proxies #128

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

KingsMMA
Copy link

@KingsMMA KingsMMA commented Mar 5, 2024

No description provided.

Copy link

@batduder batduder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code proposed here did not work for me. My solution was to disable verification with session.verify = False. That works on VPN, off VPN and doesn't care about proxy servers. However, I am not sure that is a desirable method. But in general this code should be using a single session since the performance increase is shocking because the session remains open. The map widget becomes BLAZING fast. So you should also use a session instead and then the requests.get calls should be replaced with session.get. My solution also did not require a change to the widget API. Here is some sample code:

In the class constructor add:
# Create a request session for map tile fetching and hold onto it
self.session = requests.Session()
self.session.trust_env=False
self.session.verify = False

In the destroy event add:
def destroy(self):
self.session.close()

When getting tiles modify:
image = Image.open(self.session.get(url, stream=True, headers={"User-Agent": "TkinterMapView"}).raw)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants