python example with tkinter

Solutions on MaxInterview for python example with tkinter by the best coders in the world

showing results for - "python example with tkinter"
Simona
16 Sep 2017
1from tkinter import *
2from tkinter import ttk
3
4def calculate(*args):
5    try:
6        value = float(feet.get())
7        meters.set(int(0.3048 * value * 10000.0 + 0.5)/10000.0)
8    except ValueError:
9        pass
10
11root = Tk()
12root.title("Feet to Meters")
13
14mainframe = ttk.Frame(root, padding="3 3 12 12")
15mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
16root.columnconfigure(0, weight=1)
17root.rowconfigure(0, weight=1)
18
19feet = StringVar()
20feet_entry = ttk.Entry(mainframe, width=7, textvariable=feet)
21feet_entry.grid(column=2, row=1, sticky=(W, E))
22
23meters = StringVar()
24ttk.Label(mainframe, textvariable=meters).grid(column=2, row=2, sticky=(W, E))
25
26ttk.Button(mainframe, text="Calculate", command=calculate).grid(column=3, row=3, sticky=W)
27
28ttk.Label(mainframe, text="feet").grid(column=3, row=1, sticky=W)
29ttk.Label(mainframe, text="is equivalent to").grid(column=1, row=2, sticky=E)
30ttk.Label(mainframe, text="meters").grid(column=3, row=2, sticky=W)
31
32for child in mainframe.winfo_children(): 
33    child.grid_configure(padx=5, pady=5)
34
35feet_entry.focus()
36root.bind("<Return>", calculate)
37
38root.mainloop()
39
queries leading to this page
tkinter examplesusing tkinter in pythonwhat can you do with tkinterhow to use tkinter as function pythontkinter for pythontkinter example appeasy things you can create from tkinter pythonuse tkinteropython tkinterhow to put python code in tkinterpython tkinter programhow to use tkintertkinter python sample tkinter code exampleshow to run tkinter program in pythontkinter web pythonwhat is tkinter in python used fortkinter in python usetkinter example programsusing tkintertkinter in pythontkinter basictkinter examplewhat can i make with tkinterhow to use tkinter python3how to write in tkinterhow to use tkinter in pythonwhat can you make with tkinterpython tkinter htmluse tkinter in pythonuses of tkinter in pythonpython tkinter code examplestkinter stands for in pythontkinter code in pythonpython example with tkintertkinter python programpython tkinter code examplewhy do we use tkinter in pythonpython tkinter examplestkinter python tutorialpython tkinter application examplepython tkinter tutorialhow to work with tkinter in pythonwhat is the use of tkinter in pythontkinter python exampletkinker python codetkinter basicshow to write code with tkinter pythonpython and tkinter programmingtkinter examples python3howo to use tkinter in pythonhow to use tkinter in a functiontkinter simple exampletkinter with htmluse of tkinter in pythonpython using tkinter tkinter example python 3tkinter tutorial python 3tkinter e2 80 94 python exampleshould i use tkinterexample of a tkinter applicationtkinter sample codetkinter program examplehow to use tkinter in python 3about python tkinterhow to use tkinter librarysample python tkinter codepython tkinter codehow to make a tkinter on pythontkinter tutorialwhy use tkinter in pythonpython tkinter explainedtkinter in pythocreate tkinter pythonhow to use tkinter in jythontkinter in python tutorialpython tkinter how to usepython example with tkinter