Criei um GUI no PAGE para facilitar aprendizado e estou tentando receber valor do FORM quando finalizado. Alguém tem uma solução?
Script base ‘start.py’ onde é iniciado o programa
import sys
import Login
try:
import Tkinter as tk
except ImportError:
import tkinter as tk
try:
import ttk
py3 = False
except ImportError:
import tkinter.ttk as ttk
py3 = True
def init(top, gui, *args, **kwargs):
global w, top_level, root
w = gui
top_level = top
root = top
def destroy_window():
# Function which closes the window.
global top_level
top_level.destroy()
top_level = None
if __name__ == '__main__':
Login.vp_start_gui()
Aqui o script do FORM ‘Login.py’
import sys
import start
try:
import Tkinter as tk
except ImportError:
import tkinter as tk
try:
import ttk
py3 = False
except ImportError:
import tkinter.ttk as ttk
py3 = True
def vp_start_gui():
global val, w, root
root = tk.Tk()
top = Form_Login (root)
start.init(root, top)
root.mainloop()
w = None
def create_Form_Login(rt, *args, **kwargs):
global w, w_win, root
#rt = root
root = rt
w = tk.Toplevel (root)
top = Form_Login (w)
start.init(w, top, *args, **kwargs)
return (w, top)
def destroy_Form_Login():
global w
w.destroy()
w = None
def buttonLogin(tb_Login):
if bool(tb_Login.get().strip()):
#
#Se entrar, Finaliza e retorna valores
#
root.destroy()
else:
print ('------------------------------')
print ('Existem campos não preenchidos')
print ('------------------------------')
class Form_Login:
def __init__(self, top=None):
_bgcolor = '#d9d9d9' # X11 color: 'gray85'
_fgcolor = '#000000' # X11 color: 'black'
_compcolor = '#d9d9d9' # X11 color: 'gray85'
_ana1color = '#d9d9d9' # X11 color: 'gray85'
_ana2color = '#ececec' # Closest X11 color: 'gray92'
top.geometry("300x100")
top.minsize(120, 1)
top.maxsize(1924, 1061)
top.resizable(0, 0)
top.title("..:: Login ::.. ")
top.configure(background="#99b4d1")
top.configure(highlightbackground="#d9d9d9")
top.configure(highlightcolor="black")
top.eval('tk::PlaceWindow . center')
top.attributes('-toolwindow', True)
self.tb_Login = tk.Entry(top)
self.tb_Login.place(relx=0.167, rely=0.08, height=20, relwidth=0.813)
self.tb_Login.configure(background="white")
self.tb_Login.configure(disabledforeground="#a3a3a3")
self.tb_Login.configure(font="-family {Helvetica} -size 9")
self.tb_Login.configure(foreground="#000000")
self.tb_Login.configure(highlightbackground="#d9d9d9")
self.tb_Login.configure(highlightcolor="black")
self.tb_Login.configure(insertbackground="black")
self.tb_Login.configure(selectbackground="blue")
self.tb_Login.configure(selectforeground="white")
self.tb_Login.focus_set()
self.tb_Pass = tk.Entry(top)
self.tb_Pass.place(relx=0.167, rely=0.33, height=20, relwidth=0.813)
self.tb_Pass.configure(background="white")
self.tb_Pass.configure(disabledforeground="#a3a3a3")
self.tb_Pass.configure(font="-family {Helvetica} -size 9")
self.tb_Pass.configure(foreground="#000000")
self.tb_Pass.configure(highlightbackground="#d9d9d9")
self.tb_Pass.configure(highlightcolor="black")
self.tb_Pass.configure(insertbackground="black")
self.tb_Pass.configure(selectbackground="blue")
self.tb_Pass.configure(selectforeground="white")
self.btn_Login = tk.Button(top, command= lambda: buttonLogin(self.tb_Login, self.tb_Pass))
self.btn_Login.place(relx=0.69, rely=0.6, height=34, width=87)
self.btn_Login.configure(activebackground="#ececec")
self.btn_Login.configure(activeforeground="#000000")
self.btn_Login.configure(background="#d9d9d9")
self.btn_Login.configure(disabledforeground="#a3a3a3")
self.btn_Login.configure(foreground="#000000")
self.btn_Login.configure(highlightbackground="#d9d9d9")
self.btn_Login.configure(highlightcolor="black")
self.btn_Login.configure(pady="0")
self.btn_Login.configure(text='''Login''')
Removi algumas coisas do Form só pra diminuir o o Script com o necessário, tenho o metodo “buttonLogin” que valida se os campos estão vazios e teria que retornar os valores.
me divirto com c# e resolvi testar o Py, e é uma loucura!