1

In wxPython, how can I tell what is the state of the drop-down list of a ComboBox, that is, is it open or closed?

I'm trying to implement a ComboBox that allows the user to delete a value from the list by opening the drop-down list, selecting an item, and pressing delete (Edit: when I say selecting here I mean just highlighting an item, without clicking it yet, so the drop-down list remains open).
I can bind the delete key, and I know how to delete an item, the only problem is the delete key has a different function if the drop-down list is closed (its usual function in the text field), which I want to preserve.

4

1 回答 1

2

使用 EVT_COMBOBOX。当用户从列表中选择某些内容时触发。我会将选择存储在实例变量中(如 self.currentSelection)。您可能还想存储以前的选择。然后,当用户按下“删除”时,您可以删除新选择或显示提示询问他们是否真的要删除该项目。

更新:正如评论中提到的,我认为 ComboCtrl 是一个不错的选择。您可以在以下位置找到其用法示例:

于 2012-11-27T17:03:46.487 回答