1
當我按下某個鍵時,如何在Genie中停止此小部件?停止Gtk.Spinner?
// compila con valac --pkg gtk+-3.0 nombre_archivo.gs uses Gtk init Gtk.init (ref args) var test = new TestVentana() test.show_all() Gtk.main() class TestVentana: Window spinner: Gtk.Spinner init title = "Ejemplo Gtk" default_height = 300 default_width = 300 border_width = 50 window_position = WindowPosition.CENTER destroy.connect(Gtk.main_quit) var spinner = new Gtk.Spinner() spinner.active = true add (spinner) //key_press_event += tecla // OBSOLETO key_press_event.connect(tecla) def tecla(key : Gdk.EventKey):bool //spinner.active = false ??? //spinner.stop() ??? return true
編輯:感謝阿爾·托馬斯誰提供的解決方案(這是範圍問題):
// compila con valac --pkg gtk+-3.0 nombre_archivo.gs uses Gtk init Gtk.init (ref args) var test = new TestVentana() test.show_all() Gtk.main() class TestVentana: Window spinner: Gtk.Spinner init title = "Ejemplo Gtk" default_height = 300 default_width = 300 border_width = 50 window_position = WindowPosition.CENTER destroy.connect(Gtk.main_quit) spinner = new Gtk.Spinner() spinner.active = true add (spinner) // key_press_event += tecla // OBSOLETO key_press_event.connect(tecla) def tecla(key : Gdk.EventKey):bool spinner.active = false return true
謝謝,當我編輯我的問題時,你回答了。 – Webierta