Re: [Vala] Changing label when a button is clicked



Simon Chan wrote:
I am writing a simple program that changes the label when a button is
clicked, but I am getting the following error when the button is
clicked:

Gtk-CRITICAL **: gtk_label_set_text: assertion `GTK_IS_LABEL (label)' failed

I am only able to change the label when the label is declared as
"private static Label label"
Help is appreciated, thank you very much!!

Hi,
you must store your Main instance in a variable, otherwise it gets freed
before "Gtk.main()".

BTW, you can connect a single function directly to a signal without
wrapping it into a lambda expression:

  button.clicked.connect (changeLabel);


Best Regards,

Frederik



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]