简体   繁体   English

不存在所需条目时的Gtk.ComboBox.new_with_model_and_entry行为

[英]Gtk.ComboBox.new_with_model_and_entry behaviour when desired entry is not present

The box behaves OK when I select an item that is present. 当我选择一个存在的项目时,该框的行为正常。 Sometimes the desired value is not in the store. 有时,所需的值不在存储中。 I want to type in the value and signify by something like Enter that I am done; 我想输入值并用Enter之类的东西来表示; this should emit a signal so that -for example I can add the new value to the store (after confirmation:). 这应该发出一个信号,以便-例如,我可以将新值添加到存储中(在确认后:)。 Is there such a signal and when does it get triggered? 是否有这样的信号,何时触发?

  1. get the entry first from Gtk.ComboBox by: 首先从Gtk.ComboBox获取条目:

     entry = combobox.get_child () 
  2. connect the "entry" with "activate" signals 用“激活”信号连接“输入”

     void on_activate (self, entry_widget) 
  3. assumiing you have the model beforehand, append whatever value you want into the model within the signal 事先假设您拥有模型,将所需的任何值附加到信号中的模型中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM