如何在gtk应用程序中隐藏控制台

5
例如,我有一个类似简单的gtk应用程序:
public class Application : Gtk.Window {
    public Application () {
        this.title = "Zaebis";
        this.window_position = Gtk.WindowPosition.CENTER;
        this.destroy.connect (Gtk.main_quit);
        this.set_default_size (170, 70);
        Gtk.Button button = new Gtk.Button.with_label ("Make everything zaebis");
        this.add (button);
        button.clicked.connect (() => {
            button.label = "Everything is zaebis now";
            });
        }
    public static int main (string[] args) {
        Gtk.init (ref args); (new Application ()).show_all ();
        Gtk.main (); return 0;
        }
    }

我使用valac --pkg gtk+-2.0 main.vala编译它,但在运行时,我也看到了空的控制台。 如何不显示/隐藏此控制台并仅显示我的窗口?


以下是使用Meson的方法:https://dev59.com/5bbna4cB1Zd3GeqPaWn7 - Jens Mühlenhoff
1个回答

6

您是否在Windows系统上运行此程序?

参考https://wiki.gnome.org/Vala/ValaOnWindows

In order to suppress the additional console window for GTK+ applications you have to take the following steps:

  • Download MinGW API for MS-Windows
  • Extract w32api-x.xx-mingw32-dev.tar.gz into the Vala/MinGW installation directory
  • Pass -X -mwindows to the Vala compiler:

    valac -X -mwindows --pkg gtk+-2.0 hellogtk.vala
    

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接