TKinter和Python:如何指定进程名称?

时间:2018-07-25 14:22:33

标签: python tkinter process naming

当我运行用Python 3创建的TKinter程序时,在Linux系统监视器中,我仅看到“ Python3”作为其进程名。我该如何更改?我想看到一个表示我的程序的名称。

作为解决方案,我只发现了https://blog.abhi.host/blog/2010/10/18/changing-process-name-of-python-script/,但我还没有尝试过。我想TKinter提供了一种更简单的方法!

更新 链接的解决方案(“在Linux中更改python脚本的进程名称”)确实有效! 示例代码:

from ctypes import cdll, byref, create_string_buffer

procname = b'myprogramname\x00'  # Null terminated string

def setProcName(self):
    libc = cdll.LoadLibrary('libc.so.6')  # Loading a 3rd party library C
    buff = create_string_buffer(len(procname)+1)  # Note: One larger than the name (man prctl says that)
    buff.value = procname  # Null terminated string as it should be

    libc.prctl(15, byref(buff), 0, 0, 0)
    # Refer to "#define" of "/usr/include/linux/prctl.h" for the mysterious value 16 & arg[3..5] are zero as the man page says.

0 个答案:

没有答案