Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # LambdaEntryBoxing.py
- '''
- Because chatbots such as ChatGPT* has often suggested what does not work,
- here is a way to do a quick test of all it can recommend.
- '''
- import tkinter as tk
- from tkinter import ttk
- import ast
- root = tk.Tk()
- root.geometry("450x600+10+10")
- root.title("Lambda Entry Boxing")
- current_value_x = {}
- x = 0
- solutions = '''
- entry_x.configure(textvariable=current_value_x[i])
- root.setvar(name='current_value_x[i]', value=x)
- current_value_x[i].set(x)
- entry_x.__setitem__('textvariable', tk.StringVar(value=x))
- entry_x.insert(0, x),
- entry_x.__setitem__('textvariable', current_value_x[i])
- setattr(current_value_x[i], 'variable', x)
- entry_x.delete(0, tk.END) or entry_x.insert(0, x)
- entry_x.configure(text=str(x))
- entry_x.__setitem__('state', 'readonly')
- '''.strip().splitlines()
- for i, solution in enumerate(solutions):
- i += 1
- current_value_x[i] = tk.StringVar()
- row = ttk.Frame(root)
- row.pack(fill='x', padx=10, pady=2)
- label = ttk.Label(row, text=f'Row {i}: {solution}', width=60, anchor='w')
- label.pack(side='left', padx=5)
- entry_x = ttk.Entry(row, textvariable=current_value_x[i], justify='left', width=12)
- entry_x.pack(side='right', fill='both', expand=True)
- x = str(i * 100)
- exec(solution) ### only use with caution
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement