Hi folks. I have this code but when I click on the bottom 'clear' just the entry fields below are reseted and cleared:
Quote:first_name = tk.Entry(frame)
first_name.place(relwidth=0.65, relheight=0.5, relx=0.01)
last_name = tk.Entry(frame)
last_name.place(relwidth=0.65, relheight=0.5, relx=0.01, rely=0.5)
And I need to clear or restart/reset the function show_entry_fields() as well but I don't know how can I do that.
Also when I do a new search the show_entry_fields need to be updated/renewed. Is it possible?
My full code below:
import os
from tkinter import *
import tkinter as tk
from tkinter import ttk
from PIL import ImageTk, Image
from zeep import Client
HEIGHT = 600
WIDTH = 800
class BridgerSOAP:
m_cliente = ""
m_usuario = ""
m_clave = ""
m_cliente = None
m_searchService = None
m_contexto = None
def __init__(self, cliente, usuario, clave):
self.m_cliente = cliente
self.m_usuario = usuario
self.m_clave = clave
# Get proxy default, port ACCESS
self.m_cliente = Client('https://staging.bridger.lexisnexis.eu/LN.WebServices/11.2/XGServices.svc?wsdl',
service_name="XGServices")
# Proxy for SEARCH port
self.m_searchService = self.m_cliente.create_service(
"{https://bridgerinsight.lexisnexis.com/BridgerInsight.Web.Services.Interfaces.11.2}BasicHttpBinding_ISearch",
"https://staging.bridger.lexisnexis.eu/LN.WebServices/11.2/XGServices.svc/Search")
# Proxy for port LISTMAINTENANCE
self.m_ListMaintService = self.m_cliente.create_service(
"{https://bridgerinsight.lexisnexis.com/BridgerInsight.Web.Services.Interfaces.11.2}BasicHttpBinding_IListMaintenance",
"https://staging.bridger.lexisnexis.eu/LN.WebServices/11.2/XGServices.svc/ListMaintenance")
contexto_tipo = self.m_cliente.get_type('ns1:ClientContext')
self.m_contexto = contexto_tipo(ClientID=cliente, Password=clave, UserID=usuario)
self.searchConfig_tipo = self.m_cliente.get_type("ns1:SearchConfiguration")
self.searchInput_tipo = self.m_cliente.get_type("ns1:SearchInput")
self.inputEntity_tipo = self.m_cliente.get_type("ns1:InputEntity")
self.inputName_tipo = self.m_cliente.get_type("ns1:InputName")
self.inputRecord_tipo = self.m_cliente.get_type("ns1:InputRecord")
def search_individual(self, config, inputNames):
inputRecords = []
for name in inputNames:
inputEntity = self.inputEntity_tipo(EntityType="Individual", Name=name)
inputRecord = self.inputRecord_tipo(Entity=inputEntity)
# You can setup many input record
inputRecords.append(inputRecord)
input = self.searchInput_tipo("?", {"InputRecord": inputRecords})
return self.m_searchService.Search(self.m_contexto, config, input)
def show_entry_fields():
canvas = tk.Canvas(label)
scrollbar = ttk.Scrollbar(label, orient="vertical", command=canvas.yview)
scrollable_frame = ttk.Frame(canvas)
scrollable_frame.bind(
"<Configure>",
lambda e: canvas.configure(
scrollregion=canvas.bbox("all")
)
)
canvas.create_window((0, 0), window=scrollable_frame, anchor='nw')
canvas.configure(yscrollcommand=scrollbar.set)
firstname = first_name.get()
lastname = last_name.get()
middlename = ""
# User and Password for Bridger Access
bridger = BridgerSOAP("USERDATA")
# Predefined Search List configuration
config = bridger.searchConfig_tipo(PredefinedSearchName="Lista de Busqueda", WriteResultsToDatabase=True)
# Do the Search
names = []
names.append(bridger.inputName_tipo(First=firstname, Last=lastname, Middle=middlename))
# print(names)
resultado = bridger.search_individual(config, names)
# RESULTS
if resultado.Records == None:
tk.Label(noresult_label,
text="No result found for this search.").grid(row=0,
column=0,
sticky=tk.W,
pady=4)
else:
for a in resultado.Records.ResultRecord:
text = "=========== ALARM #{0} ===========\n" \
"Accept List: {1} \n" \
"Alert State: {2} \n" \
"Search Name: {3} \n" \
"================================\n".format(a.Record, a.RecordDetails.RecordState.AddedToAcceptList,
a.RecordDetails.RecordState.AlertState,
a.RecordDetails.Name.Full)
numRec = 1
for h in a.Watchlist.Matches.WLMatch:
text += "\n" \
"Record #: {0}\n" \
"Auto False Positive: {1}\n" \
"Best Name: {2}\n" \
"Score: {3}\n" \
"False Positive: {4}\n" \
"File Name: {5}\n" \
"True Match: {6}\n" \
"Reason Listed: {7}\n".format(numRec, h.AutoFalsePositive, h.BestName, h.BestNameScore,
h.FalsePositive,
h.File.Name, h.TrueMatch, h.ReasonListed)
numRec += 1
numRec -= 1
text += "\n" \
"Total # Record(s): {0}".format(numRec)
ttk.Label(scrollable_frame, text=text, font='Calibri 16').pack()
canvas.pack(side="left", fill="both", expand=True)
scrollbar.pack(side="right", fill='y')
def clear_fields():
first_name.delete(first=0, last=30)
last_name.delete(first=0, last=30)
def restart_program():
python = sys.executable
os.execl(python, python, *sys.argv)
root = tk.Tk()
root.title("Bridger Search")
labelframe = LabelFrame(root, text="Name Screening")
labelframe.pack(fill="both", expand="yes")
canvas = tk.Canvas(labelframe, height=HEIGHT, width=WIDTH)
canvas.pack()
frame = tk.Frame(root, bg='#ff0000', bd=3)
frame.place(relx=0.5, rely=0.12, relwidth=0.25, relheight=0.1, anchor='n')
first_name = tk.Entry(frame)
first_name.place(relwidth=0.65, relheight=0.5, relx=0.01)
last_name = tk.Entry(frame)
last_name.place(relwidth=0.65, relheight=0.5, relx=0.01, rely=0.5)
firstname_text = Label(labelframe, text="First Name:")
firstname_text.place(relx=0.290, rely=0.127)
lastname_text = Label(labelframe, text="Last Name:")
lastname_text.place(relx=0.290, rely=0.177)
result_text = Label(labelframe, text="Result:")
result_text.place(relx=0.2, rely=0.20, relwidth=0.1, relheight=0.1, anchor='n')
search_text = Label(labelframe, text="Search Fields:")
search_text.place(relx=0.46, rely=0.07, relwidth=0.2, relheight=0.04, anchor='n')
api_text = Label(labelframe, text="Bridger XG 5 API for Web Services Demo Only. Developed by Jacques Jacob")
api_text.place(relx=0.50, rely=0.965, anchor='n')
button = tk.Button(frame, text="Search", command=lambda: show_entry_fields())
button.place(relx=0.99, rely=0.5, relheight=0.5, relwidth=0.31, anchor='ne')
button_clear = tk.Button(frame, text='Clear', command=lambda: clear_fields())
button_clear.place(relx=0.99, rely=0.00, relheight=0.5, relwidth=0.31, anchor='ne')
button_quit = tk.Button(root, text='Quit', command=root.quit)
button_quit.place(relx=0.83, rely=0.12, relheight=0.04, relwidth=0.1, anchor='ne')
button_reset = tk.Button(root, text='Restart', command=lambda: restart_program())
button_reset.place(relx=0.83, rely=0.17, relheight=0.04, relwidth=0.1, anchor='ne')
lower_frame = tk.Frame(root, bg='#ff0000', bd=10)
lower_frame.place(relx=0.5, rely=0.25, relwidth=0.7, relheight=0.6, anchor='n')
path = "lexisnexis.png"
load = Image.open(path)
load = load.resize((160, 80), Image.ANTIALIAS)
render = ImageTk.PhotoImage(load)
panel = tk.Label(root, image=render)
panel.pack(side="bottom", fill="both", expand="yes")
label = tk.Frame(lower_frame)
label.place(relwidth=1, relheight=1)
noresult_label = tk.Frame(label)
noresult_label.place(relx=0.33)
root.resizable(False, False)
root.mainloop()