Tkinter Python Tela de Splash e Menu
Tkinter Python Tela de Splash e Menu
#!/usr/bin/env python
#coding:utf-8
# a Tkinter splash screen (uses a GIF image file, does not need PIL)
import Tkinter as tk
from menu import *
class SplashScreen(tk.Toplevel):
SplashScreen(tk.Toplevel):
def __init__(self, master, image=None, timeout=1000):
"""
create a splash screen from a specified image file
keep splash screen up for timeout milliseconds
"""
tk.Toplevel.__init__(self,
tk.Toplevel.__init__(self, master, relief='raised', borderwidth=
5)
self.main = master
self.update()
self.after(timeout, self.destroySplash)
def centerOnScreen(self):
self.update_idletasks()
self.width, self.height = self.image.width(), self.image.height(
)
xmax = self.winfo_screenwidth()
self.winfo_screenwidth()
ymax = self.winfo_screenheight()
self.winfo_screenheight()
def createSplash(self):
# show the splash image
self.canvas = tk.Canvas(self, height=self.height, width=self.wid
th)
self.canvas.create_image(0,0,
self.canvas.create_image(0,0, anchor='nw', image=self.image)
self.canvas.pack()
def destroySplash(self):
# bring back main window and destroy splash screen
self.main.update()
#self.main.deiconify()
self.withdraw()
self.destroy()
self.Inicio()
def Inicio(self):
root = Tk()
root.geometry("245x380")
root.geometry("245x380") # Geometria: Largura x Altura
JanelaMenu(root)
root.mainloop()
#def ChamarSplash():
if __name__ == "__main__":
import os
# main
root = window
tk.Tk()
image_file = "file.gif"
assert os.path.exists(image_file)
os.path.exists(image_file)
s = SplashScreen(root, timeout=3000, image=image_file)
root.mainloop()
# !/usr/bin/env python
# coding:utf-8
class JanelaMenu:
master.title("Principal")
master.resizable(width=False,
master.resizable(width=False, height=False)
caixa = Frame(master)
caixa.pack(fill="both",
caixa.pack(fill="both", expand=True)
self.sair = master
# Botoes de Controle
self.botao0 = Button(caixa,
Button(caixa, text=" Vendas ", height=2,
height=2, width=20
width=20
, state="normal", relief="groove", font="Times 14 bold",fg="blue", command=self.
ChamarVendas)
self.botao1 = Button(caixa,
Button(caixa, text=" Clientes ", height=2,
height=2, width=
width=
20, state="normal", relief="groove", font="Times 14 bold",fg="blue", command=sel
f.ChamarClientes)
self.botao2 = Button(caixa, text=" Produtos ", height=2, width
=20, state="normal", relief="groove", font="Times 14 bold",fg="blue", command=se
lf.ChamarProduto)
self.botao3 = Button(caixa, text=" Sair ", height=2, width=2
0, state="normal", relief="groove", font="Times 14 bold",fg="blue", command=self
.f_sair)
self.botao0.grid(row=2,
self.botao0.grid(row=2, column=0)
self.botao1.grid(row=3,
self.botao1.grid(row=3, column=0)
self.botao2.grid(row=4,
self.botao2.grid(row=4, column=0)
self.botao3.grid(row=5,
self.botao3.grid(row=5, column=0)
def f_sair(self):
resultado = tkMessageBox.askquestion(" Finalizar !!!", " Você real
mente deseja sair do programa?")
if resultado == 'yes':
self.sair.destroy()
#root.destroy()
else:
return
def ChamarVendas(self):
#vendas = Tkinter.Tk()
vendas = Tk()
vendas.geometry("500x300")
vendas.geometry("500x3 00") #Largura x Altura
JanelaVendas(vendas) # Janela produto é a classe dentro de vendas.
py
vendas.mainloop()
def ChamarClientes(self):
#cliente = Tkinter.Tk()
cliente = Tk()
cliente.geometry("500x350")
cliente.geometry("500x350") #Largura x Altura
JanelaCliente(cliente)
cliente.mainloop()
def ChamarProduto(self):
produto = Tk()
produto.geometry("700x300")
produto.geometry("700x300") #Largura x Altura
JanelaProduto(produto)
produto.mainloop()
if __name__ == "main":
main()