Ho cercato come farlo accadere ma non riesco a trovarlo da nessuna parte. Ho anche indovinato come abilitare/disabilitare l'elemento Quicklist, quindi come aggiungere la funzione invocata dopo aver fatto clic sull'elemento, ma questo è tutto. Qualche idea?
Voglio creare un elenco rapido per la mia app che consisterà in caselle di controllo o pulsanti di opzione. Ho trovato informazioni su come aggiungere elementi senza azione associata all'elenco rapido (tutorial) ma è tutto ciò che ho trovato, non ci sono informazioni su come aggiungere altri tipi di elementi (caselle di controllo, pulsanti di opzione, divisori orizzontali o elemento con azione associata) che sono menzionati lì.
Sto cercando di ottenere qualcosa del genere.
Risposta accettata:
Non sono sicuro che sia corretto, ma sto usando qualcosa del genere:
- casella di controllo:
def check_item_activated_callback (menuitem, a, b): if menuitem.property_get_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE) == Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED: menuitem.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, Dbusmenu.MENUITEM_TOGGLE_STATE_UNCHECKED) else: menuitem.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED) check1 = Dbusmenu.Menuitem.new () check1.property_set (Dbusmenu.MENUITEM_PROP_LABEL, "Checkbox") check1.property_set (Dbusmenu.MENUITEM_PROP_TOGGLE_TYPE, Dbusmenu.MENUITEM_TOGGLE_CHECK) check1.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED) check1.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, True) check1.connect (Dbusmenu.MENUITEM_SIGNAL_ITEM_ACTIVATED, check_item_activated_callback, None) qucklist.child_append (check1)
- pulsanti di opzione:
def radio_item_activated_callback (radioitem1, a, radioitem2): radioitem1.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED) radioitem2.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, Dbusmenu.MENUITEM_TOGGLE_STATE_UNCHECKED) radio1 = Dbusmenu.Menuitem.new () radio1.property_set (Dbusmenu.MENUITEM_PROP_LABEL, "Radio Button 1") radio1.property_set (Dbusmenu.MENUITEM_PROP_TOGGLE_TYPE, Dbusmenu.MENUITEM_TOGGLE_RADIO) radio1.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, Dbusmenu.MENUITEM_TOGGLE_STATE_UNCHECKED) radio1.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, True) quicklist.child_append (radio1) radio2 = Dbusmenu.Menuitem.new() radio2.property_set (Dbusmenu.MENUITEM_PROP_LABEL, "Radio Button 2") radio2.property_set (Dbusmenu.MENUITEM_PROP_TOGGLE_TYPE, Dbusmenu.MENUITEM_TOGGLE_RADIO) radio2.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED) radio2.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, True) quicklist.child_append (radio2) radio1.connect (Dbusmenu.MENUITEM_SIGNAL_ITEM_ACTIVATED, radio_item_activated_callback, radio2) radio2.connect (Dbusmenu.MENUITEM_SIGNAL_ITEM_ACTIVATED, radio_item_activated_callback, radio1)
- separatore (noto anche come "divisori orizzontali"):
separator = Dbusmenu.Menuitem.new (); separator.property_set (Dbusmenu.MENUITEM_PROP_TYPE, Dbusmenu.CLIENT_TYPES_SEPARATOR) separator.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, True) quicklist.child_append (separator)
- voci di menu abilitate/disabilitate:
item1 = Dbusmenu.Menuitem.new () item1.property_set (Dbusmenu.MENUITEM_PROP_LABEL, "Item Enabled") item1.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, True) item1.property_set_bool (Dbusmenu.MENUITEM_PROP_ENABLED, True) quicklist.child_append (item1) item2 = Dbusmenu.Menuitem.new () item2.property_set (Dbusmenu.MENUITEM_PROP_LABEL, "Item Disabled") item2.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, True) item2.property_set_bool (Dbusmenu.MENUITEM_PROP_ENABLED, False) quicklist.child_append (item2)