【发布时间】:2015-02-27 14:31:35
【问题描述】:
我编写了一个程序,在 Ubuntu 上通过 Python 以 GUI 格式打开视频,我不希望命令终端屏幕总是在通过 Geany 编译器执行程序后打开。
你能不能请我离开这个终端屏幕
import Tkinter,ttk
import tkMessageBox
from Tkinter import *
import io,sys,os,subprocess
from tkFileDialog import askopenfilename
def askforvideo():
global process
name= askopenfilename(title=[("videopen")],filetypes=[("Video Files","*.h264")])
if name != "":
subprocess.call(['vlc',name,'--play-and-exit'])
return
root = Tk()
root.title("Flight Recording Application")
mainframe = ttk.Frame(root, padding="200 200 200 200")
mainframe.grid()
ttk.Button(mainframe, text="Video Open", command=askforvideo).grid(column=10, row=3)
ttk.Button(mainframe, text="Exit", command=root.quit).grid(column=95, row=3)
root.mainloop()
【问题讨论】:
-
你试过 root.withdraw() 吗?
-
@Duncan 我应该在程序的哪里输入这一行?
-
@Duncan,这将隐藏他的 GUI 窗口,但我认为他想隐藏执行 Python 脚本时出现的空白命令提示符窗口。
-
@Kevin aaah 好的,我怀疑会有一个可以设置的编译标志,类似于 py2exe 的“windows”与“console”选项。
-
好的,这不是编译问题,而是 Geany 执行命令的方式。它调用终端然后执行命令,你可以把它换成 bash 就可以了,只要知道这个改变已经完成了。
标签: python ubuntu terminal geany