Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在后台删除py.exe_Python_Python 3.x_Tkinter - Fatal编程技术网

Python 在后台删除py.exe

Python 在后台删除py.exe,python,python-3.x,tkinter,Python,Python 3.x,Tkinter,我正在从事tkinter项目。双击python文件时,py.exe文件在后台可见,看起来不太好。那么,有没有办法使py.exe不可见或调整其大小。请帮助我了解您的想法。多谢各位 示例代码: import tkinter.messagebox from tkinter import ttk class Demo1: data = [] def __init__(self, master): self.master = mast

我正在从事tkinter项目。双击python文件时,py.exe文件在后台可见,看起来不太好。那么,有没有办法使py.exe不可见或调整其大小。请帮助我了解您的想法。多谢各位

示例代码:

import tkinter.messagebox
from tkinter import ttk

class Demo1:
    data = []
    def __init__(self, master):
        
        
        self.master = master
        self.label=tkinter.Label(text="Add IP/Hostname")
        self.label.pack()
        self.t=tkinter.Text(self.master,height=20,width=50)
        self.t.pack()
        self.button = tkinter.Button(self.master,height=3,width=10, text="OK"
                                     )
        self.button.pack()

    
def main():
    root = tkinter.Tk()
    app = Demo1(root)
    root.mainloop()


if __name__ == '__main__':
    main()
这样行吗

import ctypes
ctypes.windll.user64.ShowWindow(ctypes.windll.kernel64.GetConsoleWindow(), 6 )

否则请发布示例代码。

.py
扩展名更改为
.pyw
。这将抑制控制台窗口


注意:
.pyw
扩展应该与
pythonw.exe
关联以打开。通常这是由Python安装程序完成的。如果没有,请在第一次单击
.pyw
文件时选择
pythonw.exe
。这将产生正确的关联。

您是否使用了pyinstaller?因为做了一个exe@CoolCloud,我指的是运行每个.py文件时可见的自动py.exe。谢谢这很奇怪,通常不会有py.exe。你在哪里运行你的应用程序、终端或使用IDE@CoolCloud,我通常在空闲状态下运行它(python),它在那里工作得很好,但我只想通过双击.py文件本身来运行它。。只有这样才能使py.exe可见。@CoolCloud,好的,谢谢。@lurad101,谢谢你的建议。它不工作,所以我添加了一些示例代码。