Last active
August 4, 2021 14:45
-
-
Save rodrigo-x/fa64b03650ccb54673f76419c26f5421 to your computer and use it in GitHub Desktop.
login + tk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import tkinter as tk | |
from tkinter import ttk | |
from ttkthemes import ThemedTk | |
from functools import partial | |
# Função que valida o Login | |
def validar_login(username, password): | |
print('Usuário : ', username.get()) | |
print('Senha : ', password.get()) | |
return | |
# Colocando o Tema TTK yaru | |
root = ThemedTk(theme='yaru') | |
# Imagem que vai no centro do login | |
imagem = tk.PhotoImage(file=r'home\rodrigo\login.png') | |
label = tk.Label(root, image=imagem) | |
label.imagem = imagem | |
# Posição | |
label.place(x=120, y=10) | |
# Input de usuário e pegando a String digitada | |
username = tk.StringVar() | |
input_user = tk.Entry(root, textvariable=username, cursor='hand2', | |
width=29, foreground='#252547', background='#F0F0F0', | |
font='TkDefaultFont 14') | |
input_user.place(x=40, y=155) | |
input_user.configure(justify='left', bd=1, | |
relief='ridge', selectforeground='white', | |
selectbackground='orange') | |
# PlaceHolder A | |
placeholdera = '[email protected]' | |
input_user.delete(0, tk.END) | |
input_user.insert(0, ' '+placeholdera) | |
password = tk.StringVar() | |
input_password = tk.Entry(root, textvariable=password, | |
width=29, foreground='#252547', background='#F0F0F0', | |
font='TkDefaultFont 14') | |
input_password.place(x=40, y=200) | |
input_password.configure(justify='left', bd=1, | |
relief='ridge', selectforeground='white', | |
selectbackground='orange') | |
# Placeholder B | |
placeholderb = '*****************' | |
input_password.delete(0, tk.END) | |
input_password.insert(0, ' '+placeholderb) | |
validar_login = partial(validar_login, username, password) | |
# Botão de Submit que invoca a função que valida o Login | |
submit = ttk.Button(root, text='LOGIN', width=50, | |
cursor='hand2', command=validar_login) | |
submit.place(x=40, y=240) | |
# Factory Padrão.. | |
root.title('Tkinter - Mostrando um Login') | |
root.geometry('400x300') | |
root.resizable(False, False) | |
root.iconbitmap(r'home\rodrigo\lock2.ico') | |
root.eval('tk::PlaceWindow . center') | |
root.mainloop() |
Author
rodrigo-x
commented
Mar 11, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment