简体   繁体   English

如何在 Mac 上启动 IDLE 时运行自定义脚本?

[英]How to run a custom script on the launch of IDLE on Mac?

When I click IDLE icon, IDLE shell opens!当我单击 IDLE 图标时,IDLE shell 打开! It looks like this看起来像这样

Python IDLE shell just after startup Python IDLE shell 刚启动后

So, there is a script that runs whenever I launch IDLE, and this scripts has commands that print因此,每当我启动 IDLE 时都会运行一个脚本,并且该脚本具有打印命令

"Python 3.8.5 (v3.8.5:580fbb018f, Jul 20 2020, 12:11:27) “Python 3.8.5(v3.8.5:580fbb018f,2020 年 7 月 20 日,12:11:27)
[Clang 6.0 (clang-600.0.57)] on darwin [Clang 6.0 (clang-600.0.57)] 关于达尔文
Type "help", "copyright", "credits" or "license()" for more information.输入“help”、“copyright”、“credits”或“license()”以获取更多信息。 ". ”。

1- Is it possible to locate this file on my computer(Mac) and edit it? 1-是否可以在我的计算机(Mac)上找到此文件并对其进行编辑? if yes, how?如果是,如何?
2- Is it possible to add another separate script to run at startup? 2-是否可以添加另一个单独的脚本以在启动时运行? if yes, how?如果是,如何?
3- I initially wanted some easy way to clean the shell, the easiest way was to define a function like this 3-我最初想要一些简单的方法来清洁 shell,最简单的方法是像这样定义 function
def cls(): print('\n' * 44) def cls(): 打印('\n' * 44)
I don't want to write it whenever the shell was restarted.每当 shell 重新启动时,我都不想写它。 any other solution for this problem will be helpful此问题的任何其他解决方案都会有所帮助

Thanks谢谢

  1. Currently , the startup script is idlelib/pyshell.py .目前,启动脚本是idlelib/pyshell.py You can edit it in IDLE (make a backup first), by loading it with File >= Load module and entering idlelib.pyshell in the dialog.您可以在 IDLE 中编辑它(首先进行备份),方法是使用File >= Load module加载它并在对话框中输入idlelib.pyshell

  2. See Command Line Usage in the IDLE doc, available in IDLE as Help >= IDLE Help .请参阅 IDLE 文档中的命令行用法,在 IDLE 中作为Help >= IDLE Help提供。 In particular, "-s run $IDLESTARTUP or $PYTHONSTARTUP first, in shell window", where XYZSTARTUP is an environmental variable.特别是“-s 先运行 $IDLESTARTUP 或 $PYTHONSTARTUP,在 shell 窗口中”,其中XYZSTARTUP是环境变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM