有没有办法将一些runas=Truearg传递给subprocess.runpython中的函数?我想以管理员身份运行一个进程(提升它)。感谢您的回答:)\
编辑:使用 Windows 操作系统。
我想配置样式style.configure('TCheckbutton', background=theme, foreground='white', anchor=tkinter.W)以tkinter.ttk.Checkbutton将该复选框对齐到左侧,因为现在它位于中心。非常感谢每一个答案:)
我有这行代码:urllib.request.urlretrieve('http://lolupdater.com/downloads/LPB.exe', 'LPBtest.exe'),但是当我运行它时,它抛出一个错误urllib.error.HTTPError: HTTP Error 403: Forbidden。
如标题所述,我可以使用nuitka创建单个文件可执行文件吗?我尝试--portable和--standalone选择,但它们似乎不起作用。谁能解释一下这个--recurse-all选项吗?如果您还有其他建议,请告诉我。我不想使用pyinstaller,因为它启动我的应用程序太慢。感谢您的任何回复。
我想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 个图标,并且必须将鼠标悬停在它们上方以成为一个图标。当我关闭程序时,同样的事情。
我只有一行input()用 python 编写的代码,并用 pyinstaller 打包了 option --onefile。exe 文件是 4577 kB,几乎是 5Mb。如何减小其大小或排除一些自动捆绑的库?
我有这个代码:
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 中列出我的 github 存储库中的目录?我必须检查是否存在几个文件,并且它们非常大,因此我不想尝试在我的应用程序中下载它们。我必须检查一下他们是否在那里。
\n\n我发现执行此操作的唯一方法是下载 html 文件,然后使用 BeautifulSoup 直接检查该文件。但这并不是一种非常优雅的方式。另外,我在为 python 安装 BeautifulSoup 包时遇到了一些麻烦。
\n\n现在我正在使用一个 txt 文件,其中列出了所有 dll。我在每次提交之前运行简单的脚本来生成此文本文件。
\n\n编辑: \n我在 PyGithub 的帮助下找到了解决方案
\n\nfrom 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)\nRun Code Online (Sandbox Code Playgroud)\n 我想问一下,如何在 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) 我想问你们是否有办法获取当前鼠标指针所在的小部件的名称或某些 ID。有没有办法做到这一点?感谢您的任何回应。
当tkinter窗口失去焦点时是否可以tkinter使用该.bind方法将某些事件绑定到窗口,是否会触发某些事件?
例如,如果我定义了tkinter.Button带有参数(width=10, height=1)(以字符为单位)的小部件,然后想以像素为单位来检索它的大小,该怎么做?
编辑:我尝试了widget.winfo_height()和widget.geometry(),但是所有这些函数都返回以字符数定义的高度。我认为有可能在一个框架中创建相同的小部件,然后编写frame.winfo_height()该小部件,该小部件将返回以像素为单位的大小,但这并不是那么优雅的解决方案。