import tkinter as tk
from tkinter import ttk
from typing import List, Optional

class Select(ttk.Combobox):
    """下拉选择框组件"""
    
    def __init__(
        self,
        master,
        options: List[str],
        default: Optional[str] = None,
        **kwargs
    ):
        super().__init__(master, **kwargs)
        
        # 设置选项列表
        self['values'] = options
        self['state'] = 'readonly'  # 设置为只读模式
        
        # 创建变量并绑定
        self.var = tk.StringVar()
        self.configure(textvariable=self.var)
        
        # 设置默认值
        if default and default in options:
            self.var.set(default)
        elif options:
            self.var.set(options[0])