gpt4 book ai didi

python - 如何隐藏我的应用程序的控制台窗口?

转载 作者:可可西里 更新时间:2023-11-01 10:53:46 28 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
How can I hide the console window in a PyQt app running on Windows?

我制作了一个简单的应用程序,它可以打开 QWebView,但除了应用程序窗口之外,Windows 控制台窗口也会打开。

这可能是什么原因?

import sys
import socket
from PyQt4 import QtCore, QtGui
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import QWebView

class AppWindow(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)

self.setGeometry(300, 300, 200, 25)
self.setWindowTitle('TrayIP')
self.create_sys_tray()

self.hostname = socket.gethostname()
self.ip = socket.gethostbyname(self.hostname)

self.label = QLabel("IP: " + self.ip, self)
self.label.setFont(QtGui.QFont('Helvetica', 14))

self.timer = QTimer()
self.connect( self.timer, QtCore.SIGNAL('timeout()'), self.timerupdate)
self.timer.start(10000)

def timerupdate(self):
self.web = QWebView()
self.web.load( QUrl('http://xxx') )

def create_sys_tray(self):
self.sysTray = QtGui.QSystemTrayIcon(self)
self.sysTray.setIcon( QtGui.QIcon('ico.ico') )
self.sysTray.setVisible(True)
self.connect(self.sysTray, QtCore.SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), self.on_sys_tray_activated)

self.sysTrayMenu = QtGui.QMenu(self)
act = self.sysTrayMenu.addAction("FOO")

def on_sys_tray_activated(self, reason):
if self.isVisible ():
self.setVisible(False)
else:
self.setVisible(True)

app = QtGui.QApplication(sys.argv)
window = AppWindow()
window.show()
sys.exit(app.exec_())

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com