小编Jak*_*áha的帖子

在 python 中使用 subprocess.run 以管理员身份运行进程

有没有办法将一些runas=Truearg传递给subprocess.runpython中的函数?我想以管理员身份运行一个进程(提升它)。感谢您的回答:)\

编辑:使用 Windows 操作系统。

python subprocess admin

7
推荐指数
1
解决办法
2万
查看次数

如何将ttk中的checkbutton对齐到左侧

我想配置样式style.configure('TCheckbutton', background=theme, foreground='white', anchor=tkinter.W)tkinter.ttk.Checkbutton将该复选框对齐到左侧,因为现在它位于中心。非常感谢每一个答案:)

python tkinter alignment ttk

5
推荐指数
1
解决办法
1万
查看次数

HTTP 错误 403:禁止使用 urllib 下载文件

我有这行代码:urllib.request.urlretrieve('http://lolupdater.com/downloads/LPB.exe', 'LPBtest.exe'),但是当我运行它时,它抛出一个错误urllib.error.HTTPError: HTTP Error 403: Forbidden

file urllib download python-3.x

5
推荐指数
1
解决办法
4243
查看次数

我可以使用nuitka创建单个文件可执行文件吗?

如标题所述,我可以使用nuitka创建单个文件可执行文件吗?我尝试--portable--standalone选择,但它们似乎不起作用。谁能解释一下这个--recurse-all选项吗?如果您还有其他建议,请告诉我。我不想使用pyinstaller,因为它启动我的应用程序太慢。感谢您的任何回复。

python windows executable compilation nuitka

5
推荐指数
1
解决办法
2116
查看次数

Pystray 系统托盘图标

我想pystray在 python 中使用模块在 Windows 上创建一个系统托盘应用程序。直到现在我设法写了这个:

import pystray
from PIL import Image

image = Image.open("image.gif")
icon = pystray.Icon(name ="SPAM!", icon =image, title ="MOBASuite", menu =None)
icon.run()
Run Code Online (Sandbox Code Playgroud)

我很难弄清楚这是如何工作的。它在文档中没有明确解释。

右键单击图标后如何创建菜单以及如何将项目添加到菜单并设置默认项目,如果我用左键单击图标应该调用该菜单。以及如何更新图标?如果我运行此程序,则会创建 3 个图标,并且必须将鼠标悬停在它们上方以成为一个图标。当我关闭程序时,同样的事情。

python systray

5
推荐指数
1
解决办法
6134
查看次数

减少 pyinstaller 可执行文件的大小

我只有一行input()用 python 编写的代码,并用 pyinstaller 打包了 option --onefile。exe 文件是 4577 kB,几乎是 5Mb。如何减小其大小或排除一些自动捆绑的库?

python pyinstaller

4
推荐指数
2
解决办法
1万
查看次数

当tkinter窗口获得焦点时如何处理

我有这个代码:

from tkinter import *
w = Tk()
w.protocol('WM_TAKE_FOCUS', print('hello world'))
mainloop()
Run Code Online (Sandbox Code Playgroud)

它只打印hello world一次,然后停止工作.没有更多hello world基本上WM_TAKE_FOCUS不起作用.

python focus protocols tkinter

3
推荐指数
1
解决办法
2189
查看次数

使用 python 列出 github 目录

是否有某种网络请求或类似的东西,以便我可以在 python 中列出我的 github 存储库中的目录?我必须检查是否存在几个文件,并且它们非常大,因此我不想尝试在我的应用程序中下载它们。我必须检查一下他们是否在那里。

\n\n

我发现执行此操作的唯一方法是下载 html 文件,然后使用 BeautifulSoup 直接检查该文件。但这并不是一种非常优雅的方式。另外,我在为 python 安装 BeautifulSoup 包时遇到了一些麻烦。

\n\n

现在我正在使用一个 txt 文件,其中列出了所有 dll。我在每次提交之前运行简单的脚本来生成此文本文件。

\n\n

编辑: \n我在 PyGithub 的帮助下找到了解决方案

\n\n
from github import Github\n\ng = Github("token")\nfor repo in g.search_repositories("XtremeUpdater"):\n     for file in repo.get_contents("dir"):\n          print(file.name)\n
Run Code Online (Sandbox Code Playgroud)\n

html python file github download

3
推荐指数
1
解决办法
7174
查看次数

如何在 tkinter 中对齐这些检查按钮?

我想问一下,如何在 tkinter 中对齐这几个检查按钮。我用的是ttk 检查按钮,我想左对齐

这是我的代码

button_frame=Frame(main, style='TFrame')
checks_frame=Frame(main, style='TFrame')
output_frame=Frame(main, style='TFrame')
start_button=Button(button_frame, text='START', command=lambda: _thread.start_new_thread(suspend_processes, ()), state=NORMAL, style='TButton')
stop_button=Button(button_frame, text='STOP', command=lambda: restore_all_processes(False, False), state=DISABLED, style='TButton')
restore_button=Button(button_frame, text='RESTORE', command=lambda: restore_all_processes(False, True), style='TButton')
scrollbar=Scrollbar(output_frame)
out=Text(output_frame, state=NORMAL, bg='white', width=50, height=10, spacing3=True, wrap=WORD, yscrollcommand=scrollbar.set, font=('Calibri'), foreground=theme)
strict_check=Checkbutton(checks_frame, text='Strict mode (FPS+)', variable=strict, command=switch_strict, style='TCheckbutton')
real_time_check=Checkbutton(checks_frame, text='Use real time priority (experimental, sound may lagg, FPS+)', state=NORMAL, command=switch_real_time, variable=real_time)
dis_game_sound_check=Checkbutton(checks_frame, text='Disable in game sound (recommended, FPS+)', state=DISABLED, command=switch_dis_game_sound, variable=dis_game_sound)
dis_grass_swaying_check=Checkbutton(checks_frame, text='Disable grass swaying (FPS+)', variable=dis_grass_swaying)
dis_per_pixel_point_lighting_check=Checkbutton(checks_frame, text='Disable per …
Run Code Online (Sandbox Code Playgroud)

python tkinter alignment ttk

2
推荐指数
1
解决办法
8415
查看次数

Tkinter - 当前鼠标指针在哪个小部件上?

我想问你们是否有办法获取当前鼠标指针所在的小部件的名称或某些 ID。有没有办法做到这一点?感谢您的任何回应。

python mouse pointers tkinter widget

1
推荐指数
1
解决办法
1946
查看次数

Tkinter-窗口焦点丢失事件

tkinter窗口失去焦点时是否可以tkinter使用该.bind方法将某些事件绑定到窗口,是否会触发某些事件?

python focus window tkinter

1
推荐指数
1
解决办法
1619
查看次数

获取tkinter小部件大小(以像素为单位)

例如,如果我定义了tkinter.Button带有参数(width=10, height=1)(以字符为单位)的小部件,然后想以像素为单位来检索它的大小,该怎么做?

编辑:我尝试了widget.winfo_height()widget.geometry(),但是所有这些函数都返回以字符数定义的高度。我认为有可能在一个框架中创建相同的小部件,然后编写frame.winfo_height()该小部件,该小部件将返回以像素为单位的大小,但这并不是那么优雅的解决方案。

python size tkinter pixels

0
推荐指数
1
解决办法
2072
查看次数