Files
new_install/interface/check_oldconf.py
2010-09-27 15:35:57 +08:00

69 lines
1.9 KiB
Python

#!/usr/bin/python
#! coding: utf-8
''' file check_oldconf.py
Decide whether to delete the install.xml file'''
import Tkinter
import sys
import subprocess
import getopt
ins_xml = './install.xml'
lang = 'english'
message = {}
message['english'] = 'The system detects the presence of the last\n \
installation to retain the configuration file, whether to use'
message['chinese'] = '系统检测到存在上次安装保留的配置文件,是否使用它'
def print_usages():
print 'Usage: %s [-l|--language language] [-h|--help]' % sys.argv[0]
print 'language [english|chinese]'
print 'default language is english'
def ok():
root.destroy()
def cancel():
''' remove system left install.xml file'''
cmd='rm -rf ' + ins_xml
subprocess.Popen(cmd,shell=True)
root.destroy()
def init(language):
''' implement Widget'''
global root
root = Tkinter.Tk()
root.geometry("%sx%s+%d+%d" % (root.winfo_screenwidth()/2,\
root.winfo_screenheight()/2,\
root.winfo_screenwidth()/4,
root.winfo_screenheight()/4))
txt = message[language]
lab = Tkinter.Label(root,text=txt)
lab.grid(row=1,column=1)
btn1 = Tkinter.Button(root,text='OK',command=sys.modules[__name__].ok)
btn2 = Tkinter.Button(root,text='Cancle',command=sys.modules[__name__].cancel)
btn1.grid(row=2,column=0,padx=40,pady=100,ipadx=20)
btn2.grid(row=2,column=2,padx=20,pady=100,ipadx=15)
root.rowconfigure(1,weight=2)
root.columnconfigure(1,weight=1)
root.rowconfigure(2,weight=1)
root.mainloop()
try:
opts,args = getopt.getopt(sys.argv[1:],"l:",["language="])
except getopt.GetoptError:
print_usages()
sys.exit(1)
for opt,arg in opts:
if opt in ('-l','--language'):
lang = arg
if lang in ('english','chinese'):
init(lang)
else:
print_usages()
sys.exit(1)