V
V
vadimeasy2021-10-21 10:28:49
Python
vadimeasy, 2021-10-21 10:28:49

How to pass value from string to Tkinter?

Hello, there is a selenium program, now it works through the console. I want to make an interface for it. It is necessary to transfer the value from the input field in the interface and receive prints after the program script fires into the interface window, how can I do it better.

interface

import tkinter as tk

window = tk.Tk()
label = tk.Label(text="ГУИД")
entry = tk.Entry()


label.pack()
entry.pack()
window.mainloop()


script
import sys
from PyQt5.QtWidgets import (QWidget, QPushButton, QLineEdit,
    QInputDialog, QApplication)
from selenium import webdriver
import time
from art import tprint
from selenium.webdriver.chrome import options
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options


url = "https://cerberus.vetrf.ru/cerberus/actualObject/pub/actualInfo/"
options = Options()
options.headless = True




            
try:
    guid = str (input('Введите GUID:'))
    options = Options()
    options.headless = True
    # driver = webdriver.Chrome()
    driver = webdriver.Chrome(chrome_options=options)
    
    driver.get(url=url)
    driver.find_element_by_tag_name('input').send_keys(guid)
    driver.find_element_by_tag_name('button').click()
    print('Запрос выполняется...')
    time.sleep(0.5)
    
    # print ('stage1')

    if driver.find_elements_by_xpath('//span[@class="label label-success"][1]'):
        if True:
            tes1 = tprint('Success')
            
    elif driver.find_elements_by_xpath('//span[@class="label label-warning"][1]'):
        if True:
            tes = tprint('Non success')

    elif driver. find_elements_by_tag_name("tbody"):
        if True:
            tes = tprint('ERROR')
                    





            


except Exception as ex:
    print(ex)
finally:
    driver.close()
    driver.quit()


please help me figure out how to entry = tk.Entry()
pass the value to guid = str (input('Введите GUID:'))
and run the script. to then get prints from the block
if driver.find_elements_by_xpath('//span[@class="label label-success"][1]'):
        if True:
            tes1 = tprint('Success')
            
    elif driver.find_elements_by_xpath('//span[@class="label label-warning"][1]'):
        if True:
            tes = tprint('Non success')

    elif driver. find_elements_by_tag_name("tbody"):
        if True:
            tes = tprint('ERROR')

Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question