python 界面编程 并执行sh命令

#!/usr/bin/python
# -*- coding: UTF-8 -*-
from Tkinter import *           # 导入 Tkinter 库
import thread
import time
import os
class MessageShow:
	def __init__(self):	
		
		#传入参数 消息内容 和这条消息显示的时间
		
		#消息显示的时间
		#self.WaitTime=time
		self.root = Tk()                     # 创建窗口对象的背景色
		self.root.wm_title("机器人控制主窗口")#title
		#居中显示
		self.root.resizable(False,False)
		self.root.update() # update window ,must do
		curWidth = self.root.winfo_reqwidth() # get current width
		curHeight = self.root.winfo_height() # get current height
		scnWidth,scnHeight = self.root.maxsize() # get screen width and height
		# now generate configuration information
		tmpcnf = '%dx%d+%d+%d'%(200,100,
		(scnWidth-curWidth)/2,(scnHeight-curHeight)/2)
		self.root.geometry(tmpcnf)
		
		#l1=Label(self.root,text=message,background="yellow")
		#font=("宋体", 12, "normal")
		#l1=Label(self.root,text=message,foreground="red")
		#l1.pack(side=TOP,expand=YES)
		b1=Button(self.root,text="启动机器人虚拟驱动",command=self.b1Command)	
		#b1['width']=10
		#b1['height']=1
		b1.pack(side=TOP,expand=YES)
		b2=Button(self.root,text="启动机器人虚拟路径导航界面",command=self.b2Command)
		b2.pack()	
		b3=Button(self.root,text="启动机器人movebase",command=self.b3Command)
		b3.pack()

		
		#thread.start_new_thread(self.autoDestory,())
		    
		self.root.mainloop()                 # 进入消息循环
	def b1Command(self):
		os.system("gnome-terminal -x bash -c \"roslaunch agv fakeMinimalAGV.launch\"")
	def b2Command(self):
		os.system("gnome-terminal -x bash -c \"roslaunch agv mplannerfake.launch\"")
	def b3Command(self):
		os.system("gnome-terminal -x bash -c \"roslaunch agv move_base.launch\"")
	def autoDestory(self):
		time.sleep(self.WaitTime)
		self.root.destroy()
if __name__=='__main__':
	MessageShow()

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值