简体   繁体   English

GTK #Window Icon无效

[英]GTK# Window Icon Not working

Does anyone know why this fails to run. 有谁知道为什么这不能运行。 I have this code and a file named logo.png in the same directory. 我在同一目录中有这个代码和名为logo.png的文件。 Then I run this code and it fails, saying it cant find the file 然后我运行这个代码,它失败了,说它无法找到该文件

using System;
using Gtk;

public class Trackbox {

    static int Main() {
        Application.Init();

        //Create the Window
        Window myWin = new Window("TrackBox");
        myWin.SetIconFromFile("logo.png");
        myWin.Resize(200, 100);


        //Create a label and put some text in it.     
        Label myLabel = new Label();
        myLabel.Text = "Welcome to TrackBox";

        //Add the label to the form     
        myWin.Add(myLabel);

        //Show Everything     
        myWin.ShowAll();

        Application.Run();

        return 0;
    }
}

It returns an error saying it can't find logo.png ... Why is this? 它返回一个错误,说它找不到logo.png ......这是为什么? Thanks for the help. 谢谢您的帮助。

The solution was to place the icon next to the executable. 解决方案是将图标放在可执行文件旁边。 I though the icon had to be in the root solution folder but it actually looks in the root executable folder. 我虽然图标必须在根解决方案文件夹中,但它实际上在根可执行文件夹中查找。

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

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