Tkinter: which ttk widget for database table primary key?
MRAB
python at mrabarnett.plus.com
Wed Mar 18 17:21:10 EDT 2020
On 2020-03-18 20:39, Rich Shepard wrote:
> Subject might be confusing so I'll expand it here.
>
> My application uses a database backend in which each table has a unique and
> database-generated sequential numeric key. I want to display that key in the
> GUI for that class but it's not entered by the user or altered. It seems to
> me that the ttk.Entry and ttk.Spinbox widgets are inappropriate. As a
> newcomer to Tkinter I ask for advice on which widget to use.
>
You can make the Entry widget read-only:
entry_widget['state'] = 'readonly'
The user will still be able to copy from it.
Alternatively, you can disable it:
entry_widget['state'] = 'disabled'
The user won't be able to copy from it.
When updating the GUI, you'll need to make it writeable if you have it
currently read-only or disabled:
entry_widget['state'] = 'normal'
:
# Change the contents here.
:
entry_widget['state'] = 'readonly'
More information about the Python-list
mailing list