简体   繁体   English

使用python脚本打开Idle

[英]Opening Idle with a python script

I'm a windows user, and currently I have a simple script to launch all the programs I need while writing code. 我是Windows用户,目前有一个简单的脚本可以启动编写代码时所需的所有程序。

Its called setup.py. 它叫做setup.py。 This is just two programs that it opens... 这只是打开的两个程序...

import sys, string, os
os.chdir(r"C:\Program Files (x86)\Google\Chrome\Application")
os.startfile(r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe")
os.chdir(r"C:\Python27\Lib\idlelib")
os.startfile(r"C:\Python27\Lib\idlelib\idle.py")

When I run this program a shell window pops up, both Chrome and Idle launch, however the shell window stays open 当我运行该程序时,会弹出一个外壳窗口,同时启动Chrome和Idle,但是外壳窗口保持打开状态

When I exit the shell window ( To make room in my task bar ) Idle closes and chrome stays open. 当我退出外壳窗口时( 要在任务栏中腾出空间 ),空闲关闭,Chrome保持打开状态。 I would like both to stay open. 我想都保持开放。

How can I do this? 我怎样才能做到这一点?

EDIT This probably has to do with the extension type .exe vs .py .. still not sure how to go about this though 编辑这可能与扩展名.exe.py ..仍然不确定如何解决这个问题

Not sure if the windows tag is relevant,. 不确定windows标记是否相关。 ask me to remove it and I will 请我删除它,我会

You're right, it's the extension type. 没错,这是扩展名类型。 startfile operates like double-clicking a file in Windows explorer, so if you navigate to a Python file (.py) and double-click it, it launches the file and the console. startfile操作就像在Windows资源管理器中双击一个文件一样,因此,如果导航到Python文件(.py)并双击它,它将启动文件和控制台。 If you want just the file, change it to: 如果只需要该文件,请将其更改为:

os.startfile(r"C:\Python27\Lib\idlelib\idle.pyw")

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

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