'How store last choose in tkinter combobox for use when reopening app?
Can I choose a combobox tkinter variable from combo list, close and reopen the app with same last value chosen in combobox viewer? The problem is that I want a diferent option when oppening app. For instance, one time I choose 'january', next 'february', and so on. Consequently, comboExample.current(1) is not a good strategy in this case. I think that I can write 'january' to a txt file and use it next time I open app, but it seems a little silly. Is there a more clever way? Following the general idea, how "store things" for next use when reopenig tkinter app? For example: openning the last folder visited before closing app, in a list of Sqlite3 databanks how start accessing always the last one visited before closing app, etc. I cant figure it out at this moment but imagine that the principle must be all the same.
Thanks in advance.
I've got this code from https://www.delftstack.com/pt/tutorial/tkinter-tutorial/tkinter-combobox/
import tkinter as tk
from tkinter import ttk
app = tk.Tk()
app.geometry('200x100')
labelTop = tk.Label(app,
text = "Choose your favourite month")
labelTop.grid(column=0, row=0)
comboExample = ttk.Combobox(app,
values=[
"January",
"February",
"March",
"April"])
pprint(dict(comboExample))
comboExample.grid(column=0, row=1)
comboExample.current(1)
print(comboExample.current(), comboExample.get())
app.mainloop()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
