# -*- coding:utf-8 -*-
import win32api
import time
import os
from Tkinter import *
area = ('All','Aomen')
type = ('3d14','3de','4de','Bzp','D14','Eqs','Fd510k','GzMj','Hl5z','HnMj','LsMj','Mj','njmj','Pdk','qrdzz','Srnn','xiCho4rchp','xsbn','ybddz','ybmg','ycmj','ydr')
port = ('','','','','','','','','','','','','','','','','','','','','')
a = len(type)
b = len(port)
print a
print b
def startGserver(area,type,port):
os.chdir('d:\\server\\gserver\\' + area + '\\' + type + '\\1-20\\G' + port)
win32api.ShellExecute(0, 'open', 'gserver.exe', '', '', 0)
time.sleep(2)
#startAll函数
def startAll():
startGserver(area[0],type[0],port[0])
startGserver(area[0],type[1],port[1])
startGserver(area[1],type[3],port[2])
startGserver(area[1],type[2],port[3])
startGserver(area[2],type[4],port[4])
startGserver(area[2],type[5],port[5])
#startSingle单个GServer函数
def startSingle(one,two,three):
startGserver(area[one],type[two],port[three])
# 停止所有GServer函数
def stopGServer():
command = 'taskkill /F /IM GServer.exe'
os.system(command)
aa = ((0,0,0),(0,1,1),(1,3,2),(1,2,3),(2,4,4),(2,5,5))
root = Tk()
root.geometry('500x300')
Button(root,text="启动所有游戏",command=lambda : startAll()).pack()
Button(root,text="关闭所有游戏",command=lambda : stopGServer()).pack()
#num = len(port)
#i = 0
# while i < num:
# Button(root,text=port[i],command=lambda : startSingle(aa[i][0],aa[i][1],aa[i][2])).pack()
# i += 1
# print i
Button(root, text=port[0],command=lambda : startSingle(aa[0][0],aa[0][1],aa[0][2])).pack()
Button(root, text=port[1],command=lambda : startSingle(aa[1][0],aa[1][1],aa[1][2])).pack()
Button(root, text=port[2],command=lambda : startSingle(aa[2][0],aa[2][1],aa[2][2])).pack()
Button(root, text=port[3],command=lambda : startSingle(aa[3][0],aa[3][1],aa[3][2])).pack()
Button(root, text=port[4],command=lambda : startSingle(aa[4][0],aa[4][1],aa[4][2])).pack()
root.mainloop()