Apr-23-2019, 07:25 PM
(This post was last modified: Apr-23-2019, 07:35 PM by francisco_neves2020.)
Hi guys, my main programs are based a lot of from subprocess call, but that is giving me problems (it doesn't matter why). I think i could write any code creating a new Top Level Window, but as you will see below, the main issue is from tkinter import * is not allowed. The new tkinter window code is only required that module. If i remove it, it will show only a window with a small, looks like a off button in the middle. And nothing of the remaining code. How can i make it work?
def next_version():
Utilizador.set('')
bot.set('')
import tkinter as tk
failure_max = 3
passwords = [('alfa', 'nenebot'), ('alfa1', 'nenebot1'), ('alfa2', 'nenebot2'), ('alfa3', 'nenebot3'), ('alfa4', 'nenebot4'), ('alfa5', 'nenebot5')]
def make_entry(parent, caption, width=None, **options):
tk.Label(parent, text=caption).pack(side=tk.TOP)
entry = tk.Entry(parent, **options)
if width:
entry.config(width=width)
entry.pack(side=tk.TOP, padx=10, fill=tk.BOTH)
return entry
def enter(event):
check_password()
def check_password():
""" Collect 1's for every failure and quit program in case of failure_max failures """
if (user.get(), password.get()) in passwords:
check_password.user = user.get()
new_winF()
check_password.failures += 1
if check_password.failures == failure_max:
root.destroy()
raise SystemExit('Acesso Recusado')
else:
root.title('Tente novamente.')
check_password.failures = 0
root = tk.Tk()
root_height = 160
root_width = 300
root.title('Login Obrigatório')
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
x_cordinate = int((screen_width/2) - (root_width/2))
y_cordinate = int((screen_height/2) - (root_height/2))
root.geometry("{}x{}+{}+{}".format(root_width, root_height, x_cordinate, y_cordinate))
user = make_entry(root, "Utilizador:", 16, show='')
password = make_entry(root, "Password:", 16, show="*")
b = tk.Button(root, borderwidth=4, text="Login", width=10, pady=8, command=check_password)
b.pack(side=tk.BOTTOM)
password.bind('<Return>', enter)
user.focus_set()
root.resizable(False,False)
root.mainloop()
def new_winF():
from tkinter import *
root = Tk()
root_height = 202
root_width = 456
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
x_cordinate = int((screen_width/2) - (root_width/2))
y_cordinate = int((screen_height/2) - (root_height/2))
root.geometry("{}x{}+{}+{}".format(root_width, root_height, x_cordinate, y_cordinate))
var = StringVar()
label = Label( root, textvariable=var, relief=RAISED )
var.set(""" NeneBot v1.1 Beta
---------------------------------------------------------------------------------------------
1º reparação de todos os bugs reportados
*********************************************************************************************
2º melhorias na estrutura da App
*********************************************************************************************
3º melhoria na App em termos de facilidade de leitura
*********************************************************************************************
4º adição de calculadora de IP
*********************************************************************************************
5º organizador de ficheiros (um clique e todos os ficheiros em pasta)
*********************************************************************************************
6º adição de outras funcionalidades mediante sugestões reportadas""")
label.pack()
root.resizable(False,False)
root.mainloop()

.