Tikinter Combobox Set default option
After Combobox is created, you can use the current() method to establish the default options.
Example#1
Set tuple index 0 for elements Python is the default option.
from tkinter import *
from tkinter.ttk import *
root = Tk()
root.title("apidemos.com")
root.geometry("300x120")
var = StringVar()
cb = Combobox(root,textvariable=var) # Create Combobox
cb["value"] = ("Python","Java","C#","C","C++") # Set default option
cb.current(0)
cb.pack(pady=10)
root.mainloop()
Output:
In the process of establishing Combobox in front of textvariable=var, this var is created in line 8, with it you can use var.set ("xx") way to establish the default options, of course, for this example, it is more convenient to use the current ( ) method.
Example#2
Use var.set() to establish default options.
from tkinter import *
from tkinter.ttk import *
root = Tk()
root.title("apidemos.com")
root.geometry("300x120")
var = StringVar()
cb = Combobox(root,textvariable=var) # Create Combobox
cb["value"] = ("Python","Java","C#","C","C++") # Set default option
var.set("Python") # cb.current(0)
cb.pack(pady=10)
root.mainloop()
Output: