Advertisement
here2share

# LambdaEntryBoxing.py

Oct 6th, 2023 (edited)
883
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 KB | None | 0 0
  1. # LambdaEntryBoxing.py
  2.  
  3. '''
  4. Because chatbots such as ChatGPT* has often suggested what does not work,
  5. here is a way to do a quick test of all it can recommend.
  6. '''
  7.  
  8. import tkinter as tk
  9. from tkinter import ttk
  10. import ast
  11.  
  12. root = tk.Tk()
  13. root.geometry("450x600+10+10")
  14. root.title("Lambda Entry Boxing")
  15.  
  16. current_value_x = {}
  17.  
  18. x = 0
  19. solutions = '''
  20. entry_x.configure(textvariable=current_value_x[i])
  21. root.setvar(name='current_value_x[i]', value=x)
  22. current_value_x[i].set(x)
  23. entry_x.__setitem__('textvariable', tk.StringVar(value=x))
  24. entry_x.insert(0, x),
  25. entry_x.__setitem__('textvariable', current_value_x[i])
  26. setattr(current_value_x[i], 'variable', x)
  27. entry_x.delete(0, tk.END) or entry_x.insert(0, x)
  28. entry_x.configure(text=str(x))
  29. entry_x.__setitem__('state', 'readonly')
  30. '''.strip().splitlines()
  31.  
  32. for i, solution in enumerate(solutions):
  33.     i += 1
  34.     current_value_x[i] = tk.StringVar()
  35.     row = ttk.Frame(root)
  36.     row.pack(fill='x', padx=10, pady=2)
  37.  
  38.     label = ttk.Label(row, text=f'Row {i}:   {solution}', width=60, anchor='w')
  39.     label.pack(side='left', padx=5)
  40.  
  41.     entry_x = ttk.Entry(row, textvariable=current_value_x[i], justify='left', width=12)
  42.     entry_x.pack(side='right', fill='both', expand=True)
  43.  
  44.     x = str(i * 100)
  45.     exec(solution) ### only use with caution
  46.  
  47. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement