from tkinter import *
from tkinter import ttk
root=Tk()
class appmilha():
def __init__(self):
self.root = root
self.janela()
self.frames_da_janela()
self.widgets_frame1()
self.Menus()
root.mainloop()
def janela(self):
self.root.title("Milha")
self.root.configure(background='#1e3743')
self.root.geometry("600x200")
self.root.resizable(0,0)
def frames_da_janela(self):
self.frame_1 = Frame(self.root, bd=4,
bg='#dfe3ee',
highlightbackground='#759fe6',
highlightthickness=2)
self.frame_1.place(relx=0.02, rely=0.02,
relwidth=0.96, relheight=0.96)
def widgets_frame1(self):
self.abas = ttk.Notebook(self.frame_1)
self.milhaterreste = Frame(self.abas)
self.milhanautica = Frame(self.abas)
self.milhaterreste.configure(background="#dfe3ee")
self.milhanautica.configure(background="#dfe3ee")
self.abas.add(self.milhaterreste,
text="Converter Milha Terrestre para Milha Naútica")
self.abas.add(self.milhanautica, text="Converter Milha Naútica para Milha Terrestre")
self.abas.place(relx=0, rely=0, relwidth=0.98, relheight=0.98)
# Converter Milha Terrestre para Milha Naútica
self.rmilhaterrestre = DoubleVar()
self.lb_rmilhaterrestre = Label(self.milhaterreste,
text="Milha Terrestre"
,bg='#dfe3ee', fg='#107db2',font=("arial","12","bold"))
self.lb_rmilhaterrestre.place(relx=0.2, rely=0.05)
self.rmilhaterrestre_entry = Entry(self.milhaterreste,
textvariable=self.rmilhaterrestre,justify='center',
font=("arial","12","bold"),fg="brown")
self.rmilhaterrestre_entry.place(relx=0.6, rely=0.05, relwidth=0.15)
self.bt_calcular1 = Button(self.milhaterreste, text="Calcular",
bd=2,bg='#107db2', fg='white',
font=('verdana', 14, 'bold'),
command=self.butaoclick1)
self.bt_calcular1.place(relx=0.25, rely=0.3, relwidth=0.2, relheight=0.2)
self.bt_limpar1 = Button(self.milhaterreste, text="Limpar",
bd=2, bg='#107db2', fg='white',
font=('verdana', 14, 'bold'),
command=self.limpar1)
self.bt_limpar1.place(relx=0.6, rely=0.3, relwidth=0.2, relheight=0.2)
self.resultadonautica = StringVar()
self.resultado1 = Label(self.milhaterreste,
textvariable=self.resultadonautica,font=("arial","12","bold"))
self.resultado1.place(relx=0.55, rely=0.7, relwidth=0.3)
self.lb_resultado1 = Label(self.milhaterreste, text="Resultado da Milhas Naúticas:",
bg='#dfe3ee', fg='#107db2',font=("arial","10","bold"))
self.lb_resultado1.place(relx=0.25, rely=0.7)
#Converter Milha Naútica para Milha Terrestre
self.rmilhanaútica = DoubleVar()
self.lb_milhanaútica = Label(self.milhanautica,
text="Milhas Naúticas"
, bg='#dfe3ee', fg='#107db2', font=("arial", "12", "bold"))
self.lb_milhanaútica .place(relx=0.2, rely=0.05)
self.milhanaútica_entry = Entry(self.milhanautica,
textvariable=self.rmilhanaútica, justify='center',
font=("arial", "12", "bold"), fg="brown")
self.milhanaútica_entry.place(relx=0.6, rely=0.05, relwidth=0.15)
self.bt_calcular2 = Button(self.milhanautica, text="Calcular",
bd=2, bg='#107db2', fg='white',
font=('verdana', 14, 'bold'),
command=self.butaoclick2)
self.bt_calcular2.place(relx=0.25, rely=0.3, relwidth=0.2, relheight=0.2)
self.bt_limpar2 = Button(self.milhanautica, text="Limpar",
bd=2, bg='#107db2', fg='white',
font=('verdana', 14, 'bold'),
command=self.limpar2)
self.bt_limpar2.place(relx=0.6, rely=0.3, relwidth=0.2, relheight=0.2)
self.resultadoterrestre = StringVar()
self.resultado2 = Label(self.milhanautica,
textvariable=self.resultadoterrestre,
font=("arial", "12", "bold"))
self.resultado2.place(relx=0.55, rely=0.7, relwidth=0.3)
self.lb_resultado2 = Label(self.milhanautica, text="Resultado da Milhas Terrestre:",
bg='#dfe3ee', fg='#107db2', font=("arial", "10", "bold"))
self.lb_resultado2.place(relx=0.25, rely=0.7)
def limpar1(self):
self.rmilhaterrestre_entry.delete(0, END)
def limpar2(self):
self.milhanaútica_entry.delete(0, END)
def butaoclick1(self):
t = self.rmilhaterrestre.get()
calcular = t*1.1507794
rarredondar = round(calcular,5)
return self.resultadonautica.set(rarredondar)
def butaoclick2(self):
n = self.rmilhanaútica.get()
calcular2 = n/1.1507794
valorterrestre = round(calcular2,5)
return self.resultadoterrestre.set(valorterrestre)
def Quit(self):
self.root.destroy()
def Menus(self):
menubar = Menu(self.root)
self.root.config(menu=menubar)
filemenu = Menu(menubar)
menubar.add_cascade(label="Opções", menu=filemenu)
filemenu.add_command(label="Sair", command=self.Quit)
appmilha()
Comentários
Enviar um comentário