在PyQt4上显示一个图标

时间:2017-05-17 07:04:52

标签: python-2.7 pyqt4

我是python的初学者,并制作一个简单的脚本来显示带有图标的主窗口,但图标没有显示,也没有错误信息。我使用Linux 16.04,PyQt4,python 2.7并将logo.png和脚本放在桌面上。如何显示图标?请帮忙。这是我使用的.pyw脚本。

   @model IEnumerable<WebArtSampler.Models.SampCutReqMaster>

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.ReqNum)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Fabric)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.SampleRequiredDate)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.AddedDate)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.AddedBy)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.BuyerMaster.BuyerName)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.PatternStyle.StyleName)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.PatterRefMaster.PatterRefNum)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.SampleType.SampleType1)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.SizeDetail)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Qty)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.ReqNum)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Fabric)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.SampleRequiredDate)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.AddedDate)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.AddedBy)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.BuyerMaster.BuyerName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.PatternStyle.StyleName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.PatterRefMaster.PatterRefNum)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.SampleType.SampleType1)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.SizeDetail)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Qty)
        </td>

        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.SampCutreqID }) |
            @Html.ActionLink("Details", "Details", new { id=item.SampCutreqID }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.SampCutreqID })
        </td>
    </tr>
}

</table>

1 个答案:

答案 0 :(得分:0)

尝试输入“logo.png”的完整路径;

class Window(QtGui.QMainWindow):

def __init__(self):
    super(Window, self).__init__()
    self.setGeometry(50, 50, 500, 300)
    self.setWindowTitle("tricoba")
    self.setWindowIcon(QtGui.QIcon("home/user/desktop/logo.png")) #This line
    self.show()

app = QtGui.QApplication(sys.argv)
GUI = Window()
sys.exit(app.exec_())

这适用于Ubuntu 14.10。