akadjoker

Untitled

May 3rd, 2022
800
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.38 KB | None | 0 0
  1. from tkinter import *
  2. from fpdf import FPDF
  3. #INICIAR JANELA
  4. janela = Tk()
  5.  
  6.  
  7. def on_enter(event):
  8.     butao_calc['background']='#006400'
  9.     butao_calc['foreground']='#00FF00'
  10.  
  11. def on_leave(event):
  12.     butao_calc['background']='#00FF00'
  13.     butao_calc['foreground']='#006400'
  14.     #DEFENIR TAMANHO DA JANELA
  15. WIDTH =janela.winfo_screenwidth()//2
  16. HEIGHT= janela.winfo_screenheight()-100
  17. winx = janela.winfo_screenwidth()//2- (WIDTH//2)
  18. winy = janela.winfo_screenheight()//2 -(HEIGHT//2)-50
  19. janela.geometry(f'{WIDTH}x{HEIGHT}+{winx}+{winy}')
  20. janela.resizable(False,False)
  21.  
  22. #VARIÁVEIS
  23. cor_letra = '#fff'
  24. tamanho=30
  25. botao = 15
  26. px,py=15,15
  27. comb =24
  28. salario , sub_alimentacao, valor_hora,num_hextra,opcao_hextra,num_filhos= StringVar(), StringVar(),StringVar(),StringVar(),StringVar(),StringVar()
  29. check1, check2 = IntVar(),IntVar(),
  30.  
  31. #DEFINIR TITULO DA JANELA
  32. janela.title('RECIBO VENCIMENTO')
  33.  
  34. #DEFINIR LOGO
  35.  
  36.  
  37. #DEFINIR FONTE
  38. fonte=('Arial',16,'bold')
  39. fonte2=('Arial',12,'bold')
  40. janela['bd']=10
  41. janela['bg']='#fff'
  42.  
  43. #BOTÃO CALCULAR
  44. butao_calc =Button(janela, text='Calcular', fg='#00FF00',bg ='#006400' ,width=botao,activeforeground='#00FF00',activebackground='#006400',bd=2)
  45. butao_calc.place(x=WIDTH//2-60,y=HEIGHT - 200)
  46.  
  47. #BOTÃO LIMPAR
  48. butao_limpar = Button(janela, text='Limpar', width=botao, bg='yellow',bd=2)
  49. butao_limpar.place(x=60,y=HEIGHT - 200)
  50.  
  51. #BOTÃO SAIR
  52. butao_sair = Button(janela, text='Sair', width=botao,bg='red',bd=2)
  53. butao_sair.place(x=WIDTH-180,y=HEIGHT - 200)
  54.  
  55. butao_calc.bind('<Enter>', on_enter)
  56. butao_calc.bind('<Leave>', on_leave)
  57.  
  58. #PDF
  59. #https://pyfpdf.readthedocs.io/en/latest/reference/cell/index.html
  60. pdf = FPDF('L', 'pt', 'A4')
  61. pdf.set_author("Joao")
  62. pdf.add_page()
  63.  
  64. pdf.set_title('Recibo')
  65. pdf.set_font('Arial', 'B', 12)
  66. pdf.set_font('Arial', '', 8)
  67. pdf.cell(80)
  68. pdf.write(5,"Nome\n")
  69. pdf.write(5,"\n")
  70.  
  71.  
  72. pdf.set_fill_color(255,255,0)
  73. pdf.rect(100,500,90,20,'F')
  74. pdf.set_fill_color(0,155,0)
  75. pdf.rect(400,500,90,20,'F')
  76. pdf.set_fill_color(255,0,0)
  77. pdf.rect(700,500,90,20,'F')
  78.  
  79. pdf.set_x(100)
  80. pdf.set_y(505)
  81. pdf.cell(90)
  82. pdf.write(len("Limpar"),"Limpar\n")
  83. #pdf.cell(100,505,"Limpar")
  84.  
  85. pdf.set_x(100)
  86. pdf.set_y(505)
  87. pdf.cell(400)
  88. pdf.write(len("Calcular"),"Calcular\n")
  89.  
  90.  
  91. pdf.set_x(100)
  92. pdf.set_y(505)
  93. pdf.cell(700)
  94. pdf.write(len("Sair"),"Sair\n")
  95.  
  96. pdf.output('save.pdf', 'F')
  97.  
  98.  
  99. #LOOP DA JANELA
  100. janela.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment