Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from fpdf import FPDF
- import os
- import subprocess
- #INICIAR JANELA
- janela = Tk()
- def on_enter(event):
- butao_calc['background']='#006400'
- butao_calc['foreground']='#00FF00'
- def on_leave(event):
- butao_calc['background']='#00FF00'
- butao_calc['foreground']='#006400'
- #DEFENIR TAMANHO DA JANELA
- WIDTH =janela.winfo_screenwidth()//2
- HEIGHT= janela.winfo_screenheight()-100
- winx = janela.winfo_screenwidth()//2- (WIDTH//2)
- winy = janela.winfo_screenheight()//2 -(HEIGHT//2)-50
- janela.geometry(f'{WIDTH}x{HEIGHT}+{winx}+{winy}')
- janela.resizable(False,False)
- #VARIÁVEIS
- cor_letra = '#fff'
- tamanho=30
- botao = 15
- px,py=15,15
- comb =24
- salario , sub_alimentacao, valor_hora,num_hextra,opcao_hextra,num_filhos= StringVar(), StringVar(),StringVar(),StringVar(),StringVar(),StringVar()
- check1, check2 = IntVar(),IntVar(),
- #DEFINIR TITULO DA JANELA
- janela.title('RECIBO VENCIMENTO')
- #DEFINIR LOGO
- #DEFINIR FONTE
- fonte=('Arial',16,'bold')
- fonte2=('Arial',12,'bold')
- janela['bd']=10
- janela['bg']='#fff'
- #BOTÃO CALCULAR
- butao_calc =Button(janela, text='Calcular', fg='#00FF00',bg ='#006400' ,width=botao,activeforeground='#00FF00',activebackground='#006400',bd=2)
- butao_calc.place(x=WIDTH//2-60,y=HEIGHT - 200)
- #BOTÃO LIMPAR
- butao_limpar = Button(janela, text='Limpar', width=botao, bg='yellow',bd=2)
- butao_limpar.place(x=60,y=HEIGHT - 200)
- #BOTÃO SAIR
- butao_sair = Button(janela, text='Sair', width=botao,bg='red',bd=2)
- butao_sair.place(x=WIDTH-180,y=HEIGHT - 200)
- butao_calc.bind('<Enter>', on_enter)
- butao_calc.bind('<Leave>', on_leave)
- #PDF
- #https://pyfpdf.readthedocs.io/en/latest/reference/cell/index.html
- pdf = FPDF('L', 'pt', 'A4')
- pdf.set_author("Joao")
- pdf.add_page()
- def text(x1=0, y1=0, x2=0, y2=0, text='', font="arial", size=10,
- bold=False, italic=False, underline=False, align=""):
- if text:
- font = font.strip().lower()
- if font == 'arial black':
- font = 'arial'
- style = ""
- if bold: style += "B"
- if italic: style += "I"
- if underline: style += "U"
- align = {'I':'L','D':'R','C':'C','':'',None:None}[align]
- pdf.set_font(font,style,size)
- pdf.set_xy(x1,y1)
- pdf.cell(w=x2-x1,h=y2-y1,txt=text,border=0,ln=0,align=align)
- def line(x1=0, y1=0, x2=0, y2=0, size=0):
- pdf.set_line_width(size)
- pdf.line(x1, y1, x2, y2)
- def rect(x1=0, y1=0, x2=0, y2=0, size=0):
- pdf.set_line_width(size)
- pdf.rect(x1, y1, x2, y2)
- y = 20
- MAX = 820
- rect(3,20,190,30)
- rect(3,70,190,30)
- rect(3,120,190,30)
- rect(200,20,450,30)
- rect(200,70,450,30)
- rect(200,120,450,30)
- text(10 ,40,180,30,"Nome do Funcionario")
- text(10 ,140,180,30,"Data")
- text(10 ,240,180,30,"Montante")
- rect(370,520,400,30)
- line(600,640,800,640)
- text(550 ,960,180,30,"Assinatura")
- #for i in range(100):
- # x =5 + i * 14
- # print(x)
- # text(x ,5,10,10,str(i))
- pdf.output('save.pdf', 'F')
- #LOOP DA JANELA
- janela.mainloop()
- #subprocess.Popen(['save.pdf'], shell=False)
Advertisement
Add Comment
Please, Sign In to add comment