<div><div>code like the following .After it <span style="color: rgb(0, 0, 0); font-family: arial; font-size: 14px; line-height: 23.7999992370605px;"> </span><span style="color: rgb(0, 0, 0); font-family: arial; font-size: 14px; line-height: 23.7999992370605px;">running for about half a minute ,then close the window, then the "</span>Python has stopped working<span style="color: rgb(0, 0, 0); font-family: arial; font-size: 14px; line-height: 23.7999992370605px;">" dialog pops up(</span>you had better try more than once. <span style="line-height: 23.7999992370605px;">)</span></div><div><span style="color: rgb(0, 0, 0); font-family: arial; font-size: 14px; line-height: 23.7999992370605px;"> I wonder why this happen ?any solution to this ?</span></div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: 14px;"><br></div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: 14px;"><br></div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: 14px;"><br></div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: 14px;"><pre style="margin-top: 0px; margin-bottom: 0px; padding: 0px; font-size: medium; line-height: normal; background-color: rgb(255, 255, 255);"><span class="kn" style="color: green; font-weight: 700;">from</span> <span class="nn" style="color: rgb(0, 0, 255); font-weight: 700;">PyQt4.QtCore</span> <span class="k" style="color: green; font-weight: 700;">import</span> <span class="o" style="color: rgb(102, 102, 102);">*</span><span class="kn" style="color: green; font-weight: 700;">from</span> <span class="nn" style="color: rgb(0, 0, 255); font-weight: 700;">PyQt4.QtGui</span> <span class="k" style="color: green; font-weight: 700;">import</span> <span class="o" style="color: rgb(102, 102, 102);">*</span><span class="k" style="color: green; font-weight: 700;">class</span> <span class="nc" style="color: rgb(0, 0, 255); font-weight: 700;">MainWindow</span><span class="p">(</span><span class="n">QMainWindow</span><span class="p">):</span>

    <span class="k" style="color: green; font-weight: 700;">def</span> <span class="nf" style="color: rgb(0, 0, 255);">__init__</span><span class="p">(</span><span class="bp" style="color: green;">self</span><span class="p">):</span>
        <span class="nb" style="color: green;">super</span><span class="p">()</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="n">__init__</span><span class="p">()</span>

        <span class="bp" style="color: green;">self</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="n">setWindowIcon</span><span class="p">(</span><span class="n">QIcon</span><span class="p">(</span><span class="s" style="color: rgb(186, 33, 33);">"./wa.png"</span><span class="p">))</span>
        <span class="bp" style="color: green;">self</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="n">createTrayIcon</span><span class="p">()</span>

    <span class="k" style="color: green; font-weight: 700;">def</span> <span class="nf" style="color: rgb(0, 0, 255);">createTrayIcon</span><span class="p">(</span><span class="bp" style="color: green;">self</span><span class="p">):</span>

        <span class="bp" style="color: green;">self</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="n">trayIcon</span> <span class="o" style="color: rgb(102, 102, 102);">=</span> <span class="n">QSystemTrayIcon</span><span class="p">()</span>
        <span class="bp" style="color: green;">self</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="n">trayIcon</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="n">setIcon</span><span class="p">(</span><span class="bp" style="color: green;">self</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="n">windowIcon</span><span class="p">())</span>
        <span class="bp" style="color: green;">self</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="n">trayIcon</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="n">show</span><span class="p">()</span><span class="k" style="color: green; font-weight: 700;">if</span> <span class="n">__name__</span> <span class="o" style="color: rgb(102, 102, 102);">==</span> <span class="s" style="color: rgb(186, 33, 33);">"__main__"</span><span class="p">:</span>
    <span class="kn" style="color: green; font-weight: 700;">import</span> <span class="nn" style="color: rgb(0, 0, 255); font-weight: 700;">sys</span>
    <span class="n">app</span> <span class="o" style="color: rgb(102, 102, 102);">=</span> <span class="n">QApplication</span><span class="p">(</span><span class="n">sys</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="n">argv</span><span class="p">)</span>

    <span class="n">ui</span> <span class="o" style="color: rgb(102, 102, 102);">=</span> <span class="n">MainWindow</span><span class="p">()</span>
    <span class="n">ui</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="n">show</span><span class="p">()</span>
    <span class="n">sys</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="n">exit</span><span class="p">(</span><span class="n">app</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="n">exec_</span><span class="p">())</span></pre></div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: 14px;"><br></div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: 14px;"><br></div></div><!-- jy5ContentSuffix --><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>