In this video we’ll modify our Map App to add a Lookup Form and a Slider to Zoom in and Out with Tkinter and Python.

In the last video we created a basic map app.

In this video we’ll add a form and button that will let you lookup a specific address on a map, as well as a slider that will allow you to zoom in and out of the map.

Python Code: map2.py
(Github Code)

from tkinter import *
import tkintermapview
from tkinter import ttk

root = Tk()
root.title('Codemy.com - Tkinter MapView')
root.iconbitmap('c:/gui/codemy.ico')
root.geometry("900x800")


def lookup():
	map_widget.set_address(my_entry.get())
	my_slider.config(value=9)

def slide(e):
	map_widget.set_zoom(my_slider.get())

my_label = LabelFrame(root)
my_label.pack(pady=20)

map_widget = tkintermapview.TkinterMapView(my_label, width=800, height=600, corner_radius=0)
# Set Coordinates
#map_widget.set_position(36.1699, -115.1396) # Vegas Baby!

# Set Address
map_widget.set_address("10 West Elm St., Chicago, IL, United States")

# Set A Zoom Level
map_widget.set_zoom(20)


map_widget.pack()


my_frame = LabelFrame(root)
my_frame.pack(pady=10)

my_entry = Entry(my_frame, font=("Helvetica", 28))
my_entry.grid(row=0, column=0, pady=20, padx=10)

my_button = Button(my_frame, text="Lookup", font=("Helvetica", 18), command=lookup)
my_button.grid(row=0, column=1, padx=10)

my_slider = ttk.Scale(my_frame, from_=4, to=20, orient=HORIZONTAL, command=slide, value=20, length=220)
my_slider.grid(row=0, column=2, padx=10)



root.mainloop()

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of the first dot com boom. After that he developed the award-winning Submission-Spider search engine submission software that's been used by over 3 million individuals, businesses, and governments in over 42 countries. He's written several Amazon #1 best selling books on coding, and runs a popular Youtube coding channel.

View all posts

Add comment

Your email address will not be published. Required fields are marked *

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of...