Good evening all,
Hope you are doing fine. I have an issue and I hope you could shed some light.
ERROR:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Program Files\Python37\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "", line 69, in <lambda> self.mini_refresh.config(command=lambda: LaunchSiteFunction._launch_mini(self))
File "", line 42, in _launch_mini
self.mac_mini_search_bar.send_keys(lambda:TmobileGUI._mac_mini_name_entry(self))
File "C:\Users\\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\remote\webelement.py", line 478, in send_keys
{'text': "".join(keys_to_typing(value)),
File "C:\Users\\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\common\utils.py", line 150, in keys_to_typing
for i in range(len(val)):
TypeError: object of type 'function' has no len()
Problem:
The problem occurred after changing Tkinter GUI code and Selenium code into a class. (I'm new to python, but I am trying to become familiar with classes).
Before:
- I would type something in "mini_entry"
- Hit refresh and Selenium would launch a website
- Take the input from "mini_entry" (for example: W85FGSD9385)
- Input that into the websites search bar
- The website would return any info on W85FGSD9385
After:
- I can type something into "mini_entry"
- Hit refresh but Selenium now launches the website
- Doesn't do anything.
Thanks in advance!
class LaunchSiteFunction:
def _launch_mini(self):
self.mini_site = webdriver.Chrome()
self.mini_site.get('https://jamf-tools.apps.px-npe01.cf.t-mobile.com/mini_health/')
self.mini_site.implicitly_wait(10)
self.mac_mini_search_bar = self.mini_site.find_element_by_id('myInput')
self.mac_mini_search_bar.clear()
self.mac_mini_search_bar.send_keys(lambda: GUI._mac_mini_name_entry(self)))
self.mac_mini_search_bar.send_keys(Keys.RETURN)
class GUI:
def run_program(self):
root.title("Network GUI")
self._mac_mini_name_label()
self._mac_mini_name_entry()
self._mac_mini_refresh_button()
self._mac_mini_output_label()
# Lines mac mini section:
def _mac_mini_name_label(self):
self.mini_label = tk.Label(program_frame, text='Mac Mini', bg='#ffffff', fg='#ea0a8e', font=('Calibre', 10))
self.mini_label.place(relwidth=0.11, relheight=.1)
def _mac_mini_name_entry(self):
self.mini_entry = tk.Entry(program_frame, bg='#000000', fg='#ffffff', font=('Calibre', 10))
self.mini_entry.place(relx=0.12, relheight=.1, relwidth=0.18)
def _mac_mini_refresh_button(self):
self.mini_refresh = tk.Button(program_frame, text='Refresh', bg='#000000', fg='#ea0a8e', font=('Calibre', 10))
self.mini_refresh.place(relx=0.31, relheight=.1, relwidth=0.1)
self.mini_refresh.config(command=lambda: LaunchSiteFunction._launch_mini(self))
def _mac_mini_output_label(self):
self.mini_output = tk.Label(program_frame, bg='#ffffff', bd='10')
self.mini_output.place(relx=0.42, relheight=.1, relwidth=0.15)
if "__main__" == __name__:
run = GUI()
run.run_program()
root.mainloop()