You are on page 1of 3

# 1. cria uma imagem e salve como file.gif no mesmo diretorio onde criar os prog ramas # 2.

salve este arquivo com main.py ou inicio.py #!/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): 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, master, relief='raised', borderwidth= 5) self.main = master # don't show main window self.main.withdraw() self.overrideredirect(1) # use Tkinter's PhotoImage for .gif files self.image = tk.PhotoImage(file=image) self.after_idle(self.centerOnScreen) 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() ymax = self.winfo_screenheight() x0 = self.x0 = xmax/2 - self.width/2 y0 = self.y0 = ymax/2 - self.height/2 self.geometry("%dx%d+%d+%d" % (self.width, self.height, x0, y0)) self.createSplash() 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, 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") # Geometria: Largura x Altura JanelaMenu(root) root.mainloop() #def ChamarSplash(): if __name__ == "__main__": import os # main window root = tk.Tk() image_file = "file.gif" assert os.path.exists(image_file) s = SplashScreen(root, timeout=3000, image=image_file) root.mainloop()

# 3. Salve este arquivo como menu.py # !/usr/bin/env python # coding:utf-8 from Tkinter import * import tkMessageBox from vendas import * from clientes import * from produtos import * class JanelaMenu: def __init__(self, master): master.title("Principal") master.resizable(width=False, height=False) caixa = Frame(master) caixa.pack(fill="both", expand=True) self.sair = master self.texto = Label(caixa, text=" Formulrio Principal ", height=2, width=20,relief="raised", font="Times 15 bold", fg="red", bg="cyan").grid(row=0 , column=0, sticky=E) # Botoes de Controle self.botao0 = Button(caixa, text=" Vendas ", height=2, width=20 , state="normal", relief="groove", font="Times 14 bold",fg="blue", command=self. ChamarVendas) self.botao1 = Button(caixa, text=" Clientes ", height=2, 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.botao1.grid(row=3, self.botao2.grid(row=4, self.botao3.grid(row=5, column=0) column=0) column=0) 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") #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") #Largura x Altura JanelaCliente(cliente) cliente.mainloop() def ChamarProduto(self): produto = Tk() produto.geometry("700x300") #Largura x Altura JanelaProduto(produto) produto.mainloop() if __name__ == "main": main()

You might also like