def on_message(message): global dota_players # Everyone's commands words = message.content.lower() if (words.startswith('!')): print words word = words.split() if word[0] == '!lenny': client.send_message(message.channel, '( ͡° ͜ʖ ͡°)') elif word[0] == '!dickbutt': client.send_message(message.channel, '░░░░░░░░░░░░░░░░░░░░░\n░░░░░░░░░░░░▄▀▀▀▀▄░░░\n░░░░░░░░░░▄▀░░▄░▄░█░░\n░▄▄░░░░░▄▀░░░░▄▄▄▄█░░\n█░░▀▄░▄▀░░░░░░░░░░█░░\n░▀▄░░▀▄░░░░█░░░░░░█░░\n░░░▀▄░░▀░░░█░░░░░░█░░\n░░░▄▀░░░░░░█░░░░▄▀░░░\n░░░▀▄▀▄▄▀░░█▀░▄▀░░░░░\n░░░░░░░░█▀▀█▀▀░░░░░░░\n░░░░░░░░▀▀░▀▀░░░░░░░░') elif word[0] == '!dota': if word[1] == 'stats': player = '' if len(word) > 3: for i in range(2, len(word)): player += word[i] if i != len(word)-1: player += ' ' else: player = word[2] response = Dota.dotastats(player, dota_players) elif word[1] == 'counter': hero = '' if len(word) > 3: for i in range(2, len(word)): hero += word[i] if i != len(word)-1: hero += '-' else: hero = word[2] hero = hero.lower() response = Dota.dotaCounter(hero) client.send_message(message.channel, response) elif word[0] == '!add': if word[1] == 'dotaplayer': if len(word) == 4: dota_players = Dota.addDotaPlayer(word[2], word[3], dota_players) else: client.send_message(message.channel, "ERROR: Incorrect usage.\n\t!add dotaplayer $playername $dotabuff_player_ID") elif word[0] == '!help': counter = 0 players = '' for player in dota_players: if counter % 2 == 0: players += player + '\n\t' counter += 1 client.send_message(message.channel, """Current commands:\n\t- !lenny\n\t- !dickbutt\n\t- !dota stats $player\n\t- !dota counter $hero\n\t- !add dotaplayer $username $dotabuff_player_ID\n\t- !wiki $wikiSearchWord(s) \t- !urban $word(s)\n\t- !report @user Dota players included:""" + '\n\t' + players) elif word[0] == '!wiki': searchWord = '' if len(word) > 2: for i in range(1, len(word)): searchWord += word[i] if i != len(word)-1: searchWord += '_' else: searchWord = word[1] client.send_message(message.channel, Fun.wikiSearch(searchWord)) elif word[0] == '!urban': define = '' if len(word) > 2: for i in range(1, len(word)): define += word[i] if i != len(word)-1: define += ' ' else: define = word[1] client.send_message(message.channel, Fun.urbanSearch(define).encode('utf-8')) elif word[0] == '!report': reported = '' if len(word) > 2: for i in range(1, len(word)): reported += word[i] else: reported = word[1] reportedAlt = reported[2:len(reported)-1] f = open(message.server.name + ' reports.txt', 'r') user_array = {} for line in f: line = line.decode('utf-8') line = line.split(',') user_array[line[1]] = [line[0],line[2].rstrip('\n')] f.close() #print 'Reported: ' + user_array[reportedAlt][0] if reportedAlt in user_array: user_array[reportedAlt][1] = int(user_array[reportedAlt][1]) + 1 f = open(message.server.name + ' reports.txt', 'wb') for key, value in user_array.items(): f.write(value[0].encode('utf-8') + ',' + key.encode('utf-8') + ',' + str(value[1]) + '\n') client.send_message(message.channel, 'Reported ' + user_array[reportedAlt][0].encode('utf-8') + '. Current Reports: ' + str(user_array[reportedAlt][1])) f.close() else: client.send_message(message.channel, reported + ' does not exist as a user in this server.') #baseURL = https://api.steampowered.com/IDOTA2Match_570/ # Calum's commands #if message.author.name == '1nsayn': # Steam ID: 76561198066749272 # Tibor's commands #if message.author.name == 'robit': # Steam ID: 76561197996963851 # Michael's commands #if message.author.name == 'Lekcian': # Steam ID: 76561197991432811 if message.author.name == 'MoySauce': if message.content == '!logout': client.send_message(message.channel, 'Bot has logged out') client.logout()
def on_message(message): global dota_players global game_list global rock_queue global firstPlayer global secondPlayer # Everyone's commands words = message.content.lower() if (words.startswith('!')): print words word = words.split() if word[0] == '!lenny': client.send_message(message.channel, '( ͡° ͜ʖ ͡°)') if word[0] == '!rekt': x = Fun.roll(1) if x == 1: client.send_message(message.channel, '☐ Not REKT ☑ REKT') if x == 0: client.send_message(message.channel, '☑ Not REKT ☐ REKT') if word[0] == '!checkem': client.send_message(message.channel, Fun.checkEm()) elif word[0] == '!rps': if rock_queue == 0: firstPlayer = message.author.name client.send_message(message.channel, "%s is playing Rock Paper Scissors, need 1 more player." % firstPlayer) rock_queue = 1 elif rock_queue == 1: secondPlayer = message.author.name client.send_message(message.channel, "%s has joined the game." % secondPlayer) client.send_message(message.channel, "Rock. Paper. Scissors!") client.send_message(message.channel, Fun.rps(firstPlayer, secondPlayer)) rock_queue = 0 elif word[0] == '!dickbutt': client.send_message(message.channel, '░░░░░░░░░░░░░░░░░░░░░\n░░░░░░░░░░░░▄▀▀▀▀▄░░░\n░░░░░░░░░░▄▀░░▄░▄░█░░\n░▄▄░░░░░▄▀░░░░▄▄▄▄█░░\n█░░▀▄░▄▀░░░░░░░░░░█░░\n░▀▄░░▀▄░░░░█░░░░░░█░░\n░░░▀▄░░▀░░░█░░░░░░█░░\n░░░▄▀░░░░░░█░░░░▄▀░░░\n░░░▀▄▀▄▄▀░░█▀░▄▀░░░░░\n░░░░░░░░█▀▀█▀▀░░░░░░░\n░░░░░░░░▀▀░▀▀░░░░░░░░') elif word[0] == '!roll': if len(word) == 2: # word = [int(i)for i in word] client.send_message(message.channel, Fun.roll((word[1]))) else: client.send_message(message.channel, Fun.roll()) elif word[0] == '!dota': if word[1] == 'stats': player = '' if len(word) > 3: for i in range(2, len(word)): player += word[i] if i != len(word)-1: player += ' ' else: player = word[2] response = Dota.dotastats(player, dota_players) elif word[1] == 'counter': hero = '' if len(word) > 3: for i in range(2, len(word)): hero += word[i] if i != len(word)-1: hero += '-' else: hero = word[2] hero = hero.lower() response = Dota.dotaCounter(hero) client.send_message(message.channel, response) elif word[0] == '!add': if word[1] == 'dotaplayer': if len(word) == 4: dota_players = Dota.addDotaPlayer(word[2], word[3], dota_players) else: client.send_message(message.channel, "ERROR: Incorrect usage.\n\t!add dotaplayer $playername $dotabuff_player_ID") elif word[0] == '!rollthedice': client.send_message(message.channel, Fun.rollTheDice(game_list)) elif word[0] == '!games': client.send_message(message.channel, game_list) elif word[0] == '!help': counter = 0 players = '' for player in dota_players: if counter % 2 == 0: players += player + '\n\t' counter += 1 client.send_message(message.channel, """Current commands:\n\t- !lenny\n\t- !dickbutt\n\t- !dota stats $player\n\t- !dota counter $hero\n\t- !add dotaplayer $username $dotabuff_player_ID\n\t- !wiki $wikiSearchWord(s) \t- !urban $word(s)\n\t- !report @user Dota players included:""" + '\n\t' + players) elif word[0] == '!wiki': searchWord = '' if len(word) > 2: for i in range(1, len(word)): searchWord += word[i] if i != len(word)-1: searchWord += '_' else: searchWord = word[1] client.send_message(message.channel, Fun.wikiSearch(searchWord)) elif word[0] == '!urban': define = '' if len(word) > 2: for i in range(1, len(word)): define += word[i] if i != len(word)-1: define += ' ' else: define = word[1] client.send_message(message.channel, Fun.urbanSearch(define).encode('utf-8')) elif word[0] == '!report': reported = '' if len(word) > 2: for i in range(1, len(word)): reported += word[i] else: reported = word[1] reportedAlt = reported[2:len(reported)-1] f = open(message.server.name + ' reports.txt', 'r') user_array = {} for line in f: line = line.decode('utf-8') line = line.split(',') user_array[line[1]] = [line[0],line[2].rstrip('\n')] f.close() #print 'Reported: ' + user_array[reportedAlt][0] if reportedAlt in user_array: user_array[reportedAlt][1] = int(user_array[reportedAlt][1]) + 1 f = open(message.server.name + ' reports.txt', 'wb') for key, value in user_array.items(): f.write(value[0].encode('utf-8') + ',' + key.encode('utf-8') + ',' + str(value[1]) + '\n') client.send_message(message.channel, 'Reported ' + user_array[reportedAlt][0].encode('utf-8') + '. Current Reports: ' + str(user_array[reportedAlt][1])) f.close() else: client.send_message(message.channel, reported + ' does not exist as a user in this server.') #baseURL = https://api.steampowered.com/IDOTA2Match_570/ # Calum's commands #if message.author.name == '1nsayn': # Steam ID: 76561198066749272 # Tibor's commands #if message.author.name == 'robit': # Steam ID: 76561197996963851 # Michael's commands #if message.author.name == 'Lekcian': # Steam ID: 76561197991432811 if message.author.name == 'Mokio' or message.author.name == 'MoySauce': if message.content == '!logout': client.send_message(message.channel, 'Bot has logged out') client.logout() elif word[0] == '!add': if word[1] == 'game': define = '' if len(word) > 3: for i in range(3, len(word)): define += word[i] if i != len(word)-1: define += ' ' if len(word) == 3: game_list = Fun.addGame(word[2], game_list) client.send_message(message.channel, "%s was added to the list" % word[2]) else: client.send_message(message.channel, "ERROR: you f****d up.")
def __init__(self, root, isTKroot=True): className = self.__class__.__name__ Fun.G_UIElementArray[className] = {} Fun.G_ElementBindingDataArray[className] = {} global ElementBGArray global ElementBGArray_Resize global ElementBGArray_IM Fun.AddElement(className, 'UIClass', self) self.root = root if isTKroot == True: root.title("Form1") root.geometry("574x150") Form_1 = tkinter.Canvas(root, width=10, height=4) Form_1.place(x=0, y=0, width=574, height=150) Form_1.configure(bg="#efefef") Fun.AddElement(className, 'root', root) Fun.AddElement(className, 'Form_1', Form_1) Group_1_Variable = Fun.AddElementVariable(className, 'Group_1') Group_1_Variable.set(1) #Create the elements of root Label_2 = tkinter.Label(root, text="姓名", width=10, height=4) Label_2.place(x=18, y=13, width=82, height=20) Fun.AddElement(className, 'Label_2', Label_2) Entry_3_Variable = Fun.AddElementVariable(className, 'Entry_3') Entry_3 = tkinter.Entry(root, textvariable=Entry_3_Variable) Entry_3.place(x=120, y=14, width=120, height=20) Entry_3.configure(relief="sunken") Fun.AddElement(className, 'Entry_3', Entry_3) Label_4 = tkinter.Label(root, text="性别", width=10, height=4) Label_4.place(x=18, y=44, width=82, height=20) Fun.AddElement(className, 'Label_4', Label_4) RadioButton_5 = tkinter.Radiobutton(root, variable=Group_1_Variable, value=1, text="男", anchor=tkinter.W) RadioButton_5.place(x=116, y=45, width=68, height=19) Fun.AddElement(className, 'RadioButton_5', RadioButton_5) RadioButton_6 = tkinter.Radiobutton(root, variable=Group_1_Variable, value=2, text="女", anchor=tkinter.W) RadioButton_6.place(x=191, y=44, width=100, height=20) Fun.AddElement(className, 'RadioButton_6', RadioButton_6) Label_7 = tkinter.Label(root, text="年龄", width=10, height=4) Label_7.place(x=18, y=78, width=82, height=20) Fun.AddElement(className, 'Label_7', Label_7) Entry_8_Variable = Fun.AddElementVariable(className, 'Entry_8') Entry_8 = tkinter.Entry(root, textvariable=Entry_8_Variable) Entry_8.place(x=121, y=75, width=120, height=20) Entry_8.configure(relief="sunken") Fun.AddElement(className, 'Entry_8', Entry_8) Label_9 = tkinter.Label(root, text="地址", width=10, height=4) Label_9.place(x=18, y=110, width=82, height=20) Fun.AddElement(className, 'Label_9', Label_9) ComboBox_10_Variable = Fun.AddElementVariable(className, 'ComboBox_10') ComboBox_10 = tkinter.ttk.Combobox(root, textvariable=ComboBox_10_Variable, state="readonly") ComboBox_10.place(x=120, y=110, width=124, height=20) ComboBox_10.configure(state="readonly") ComboBox_10["values"] = ['北京', '天津', '上海'] ComboBox_10.current(0) Fun.AddElement(className, 'ComboBox_10', ComboBox_10) Button_11 = tkinter.Button(root, text="增加", width=10, height=4) Button_11.place(x=448, y=103, width=100, height=28) Button_11.configure(command=lambda: Page1_cmd.Button_11_onCommand( className, "Button_11")) Fun.AddElement(className, 'Button_11', Button_11) #Inital all element's Data Fun.InitElementData(className)
def __init__(self,root,isTKroot = True): className = self.__class__.__name__ Fun.G_UIElementArray[className]={} Fun.G_ElementBindingDataArray[className]={} global ElementBGArray global ElementBGArray_Resize global ElementBGArray_IM Fun.AddElement(className,'UIClass',self) self.root = root if isTKroot == True: root.title("Form1") root.geometry("432x283") Form_1= tkinter.Canvas(root,width = 10,height = 4) Form_1.place(x = 0,y = 0,width = 432,height = 283) Form_1.configure(bg = "#efefef") Fun.AddElement(className,'root',root) Fun.AddElement(className,'Form_1',Form_1) #Create the elements of root Label_2= tkinter.Label(root,text="快递公司",width = 10,height = 4) Label_2.place(x = 11,y = 15,width = 75,height = 20) Fun.AddElement(className,'Label_2',Label_2) ComboBox_3_Variable = Fun.AddElementVariable(className,'ComboBox_3') ComboBox_3= tkinter.ttk.Combobox(root,textvariable=ComboBox_3_Variable, state="readonly") ComboBox_3.place(x = 107,y = 15,width = 173,height = 20) ComboBox_3.configure(state = "readonly") Fun.AddElement(className,'ComboBox_3',ComboBox_3) Label_4= tkinter.Label(root,text="快递单号",width = 10,height = 4) Label_4.place(x = 11,y = 55,width = 75,height = 20) Fun.AddElement(className,'Label_4',Label_4) Entry_5_Variable = Fun.AddElementVariable(className,'Entry_5') Entry_5= tkinter.Entry(root,textvariable=Entry_5_Variable) Entry_5.place(x = 107,y = 56,width = 172,height = 20) Entry_5.configure(relief = "sunken") Fun.AddElement(className,'Entry_5',Entry_5) Button_6= tkinter.Button(root,text="查询",width = 10,height = 4) Button_6.place(x = 297,y = 53,width = 100,height = 28) Button_6.configure(command=lambda:Express_Query_cmd.Button_6_onCommand(className,"Button_6")) Fun.AddElement(className,'Button_6',Button_6) ListBox_7= tkinter.Listbox(root) ListBox_7.place(x = 24,y = 101,width = 372,height = 160) Fun.AddElement(className,'ListBox_7',ListBox_7) import Express Express_9=Express.Express() #Express_9.xy(186,74) Express_9.set_CompanyID('4') Express_9.set_ExpressNumber('0000001') Express_9.set_ComboBox(ComboBox_3) Fun.AddElement(className,'Express_9',Express_9) CheckButton_10_Variable = Fun.AddElementVariable(className,'CheckButton_10') CheckButton_10_Variable.set(False) CheckButton_10= tkinter.Checkbutton(root,variable=CheckButton_10_Variable,text="多线程查询",anchor=tkinter.W) CheckButton_10.place(x = 302,y = 20,width = 100,height = 20) Fun.AddElement(className,'CheckButton_10',CheckButton_10) #Inital all element's Data Fun.InitElementData(className)
def __init__(self, root): global ElementBGArray global ElementBGArray_Resize global ElementBGArray_IM Fun.G_UIElementArray['UIClass'] = self self.root = root root.title("Form1") root.geometry("454x410") Form_1 = tkinter.Canvas(root, width=10, height=4) Form_1.place(x=0, y=0, width=454, height=410) Form_1.configure(bg="#efefef") Fun.G_UIElementArray['root'] = root Fun.G_UIElementArray['Form_1'] = Form_1 Fun.G_UIElementVariableArray['Group_1'] = tkinter.IntVar() Fun.G_UIElementVariableArray['Group_1'].set(1) #Create the elements of root Label_2 = tkinter.Label(root, text="", width=10, height=4) Label_2.place(x=48, y=33, width=77, height=48) ElementBGArray[2] = Image.open("ico1.png") ElementBGArray_Resize[2] = ElementBGArray[2].resize((77, 48), Image.ANTIALIAS) ElementBGArray_IM[2] = ImageTk.PhotoImage(ElementBGArray_Resize[2]) Label_2.configure(image=ElementBGArray_IM[2]) Label_2_Ft = tkinter.font.Font(family='System', size=24, weight='bold', slant='roman', underline=0, overstrike=0) Label_2.configure(font=Label_2_Ft) Fun.G_UIElementArray['Label_2'] = Label_2 Label_3 = tkinter.Label(root, text="注册信息", width=10, height=4) Label_3.place(x=134, y=34, width=256, height=45) Label_3_Ft = tkinter.font.Font(family='System', size=29, weight='bold', slant='roman', underline=0, overstrike=0) Label_3.configure(font=Label_3_Ft) Fun.G_UIElementArray['Label_3'] = Label_3 Label_4 = tkinter.Label(root, text="姓名", width=10, height=4) Label_4.place(x=53, y=111, width=100, height=20) Fun.G_UIElementArray['Label_4'] = Label_4 Fun.G_UIElementVariableArray['Entry_5'] = tkinter.StringVar() Entry_5 = tkinter.Entry( root, textvariable=Fun.G_UIElementVariableArray['Entry_5']) Entry_5.place(x=175, y=110, width=120, height=20) Entry_5.configure(relief="sunken") Fun.G_UIElementArray['Entry_5'] = Entry_5 Label_6 = tkinter.Label(root, text="性别", width=10, height=4) Label_6.place(x=54, y=146, width=100, height=20) Fun.G_UIElementArray['Label_6'] = Label_6 RadioButton_7 = tkinter.Radiobutton( root, variable=Fun.G_UIElementVariableArray['Group_1'], value=1, text="男", anchor=tkinter.W) RadioButton_7.place(x=173, y=147, width=48, height=20) Fun.G_UIElementArray['RadioButton_7'] = RadioButton_7 RadioButton_8 = tkinter.Radiobutton( root, variable=Fun.G_UIElementVariableArray['Group_1'], value=2, text="女", anchor=tkinter.W) RadioButton_8.place(x=243, y=149, width=48, height=20) Fun.G_UIElementArray['RadioButton_8'] = RadioButton_8 Label_9 = tkinter.Label(root, text="邮箱", width=10, height=4) Label_9.place(x=54, y=181, width=100, height=20) Fun.G_UIElementArray['Label_9'] = Label_9 Fun.G_UIElementVariableArray['Entry_10'] = tkinter.StringVar() Entry_10 = tkinter.Entry( root, textvariable=Fun.G_UIElementVariableArray['Entry_10']) Entry_10.place(x=175, y=185, width=195, height=20) Entry_10.configure(relief="sunken") Fun.G_UIElementArray['Entry_10'] = Entry_10 Label_11 = tkinter.Label(root, text="个人简介", width=10, height=4) Label_11.place(x=55, y=220, width=100, height=20) Fun.G_UIElementArray['Label_11'] = Label_11 Text_12 = tkinter.Text(root) Text_12.place(x=175, y=220, width=240, height=120) Text_12.configure(relief="sunken") Fun.G_UIElementArray['Text_12'] = Text_12 Button_13 = tkinter.Button(root, text="确定", width=10, height=4) Button_13.place(x=176, y=354, width=100, height=28) Button_13.configure(command=RegDlg_cmd.Button_13_onCommand) Fun.G_UIElementArray['Button_13'] = Button_13 Button_14 = tkinter.Button(root, text="取消", width=10, height=4) Button_14.place(x=310, y=354, width=100, height=28) Button_14.configure(command=RegDlg_cmd.Button_14_onCommand) Fun.G_UIElementArray['Button_14'] = Button_14 #Inital all element's Data Fun.InitElementData()
def __init__(self, root, isTKroot=True): className = self.__class__.__name__ Fun.G_UIElementArray[className] = {} Fun.G_UIElementUserDataArray[className] = {} Fun.Register(className, 'UIClass', self) self.root = root style = TicketQuery_sty.SetupStyle() if isTKroot == True: root.title("Form1") Fun.CenterDlg(None, root, 721, 400) Form_1 = tkinter.Canvas(root, width=10, height=4) Form_1.place(x=0, y=0, width=721, height=400) Form_1.configure(bg="#efefef") Form_1.configure(highlightthickness=0) Fun.Register(className, 'root', root) Fun.Register(className, 'Form_1', Form_1) #Create the elements of root Label_2 = tkinter.Label(root, text="出发", width=10, height=4) Label_2.place(x=13, y=25, width=44, height=37) Label_2.configure(relief="flat") Label_2_Ft = tkinter.font.Font(family='System', size=12, weight='bold', slant='roman', underline=0, overstrike=0) Label_2.configure(font=Label_2_Ft) Fun.Register(className, 'Label_2', Label_2) Entry_3_Variable = Fun.AddTKVariable(className, 'Entry_3', '') Entry_3 = tkinter.Entry(root, textvariable=Entry_3_Variable) Entry_3.place(x=65, y=26, width=120, height=37) Entry_3.configure(relief="sunken") Fun.Register(className, 'Entry_3', Entry_3) Label_4 = tkinter.Label(root, text="到达", width=10, height=4) Label_4.place(x=193, y=32, width=46, height=28) Label_4.configure(relief="flat") Label_4_Ft = tkinter.font.Font(family='System', size=12, weight='bold', slant='roman', underline=0, overstrike=0) Label_4.configure(font=Label_4_Ft) Fun.Register(className, 'Label_4', Label_4) Entry_5_Variable = Fun.AddTKVariable(className, 'Entry_5', '') Entry_5 = tkinter.Entry(root, textvariable=Entry_5_Variable) Entry_5.place(x=242, y=26, width=120, height=37) Entry_5.configure(relief="sunken") Fun.Register(className, 'Entry_5', Entry_5) Label_6 = tkinter.Label(root, text="日期", width=10, height=4) Label_6.place(x=364, y=28, width=56, height=35) Label_6.configure(relief="flat") Label_6_Ft = tkinter.font.Font(family='System', size=12, weight='bold', slant='roman', underline=0, overstrike=0) Label_6.configure(font=Label_6_Ft) Fun.Register(className, 'Label_6', Label_6) Entry_8_Variable = Fun.AddTKVariable(className, 'Entry_8', '') Entry_8 = tkinter.Entry(root, textvariable=Entry_8_Variable) Entry_8.place(x=422, y=26, width=140, height=37) Entry_8.configure(relief="sunken") Fun.Register(className, 'Entry_8', Entry_8) Button_9 = tkinter.Button(root, text="查询", width=10, height=4) Button_9.place(x=568, y=23, width=119, height=43) Button_9.configure(command=lambda: TicketQuery_cmd.Button_9_onCommand( className, "Button_9")) Button_9_Ft = tkinter.font.Font(family='System', size=12, weight='bold', slant='roman', underline=0, overstrike=0) Button_9.configure(font=Button_9_Ft) Fun.Register(className, 'Button_9', Button_9) ListBox_10 = tkinter.Listbox(root) ListBox_10.place(x=13, y=74, width=690, height=309) Fun.Register(className, 'ListBox_10', ListBox_10) #Inital all element's Data Fun.InitElementData(className) #Call Form_1's OnLoad Function TicketQuery_cmd.Form_1_onLoad(className)
def __init__(self, root, isTKroot=True): className = self.__class__.__name__ Fun.G_UIElementArray[className] = {} Fun.G_ElementBindingDataArray[className] = {} global ElementBGArray global ElementBGArray_Resize global ElementBGArray_IM Fun.AddElement(className, 'UIClass', self) self.root = root if isTKroot == True: root.title("Form1") root.geometry("454x410") Form_1 = tkinter.Canvas(root, width=10, height=4) Form_1.place(x=0, y=0, width=454, height=410) Form_1.configure(bg="#efefef") Fun.AddElement(className, 'root', root) Fun.AddElement(className, 'Form_1', Form_1) Group_1_Variable = Fun.AddElementVariable(className, 'Group_1') Group_1_Variable.set(1) #Create the elements of root Label_2 = tkinter.Label(root, text="", width=10, height=4) Label_2.place(x=50, y=0, width=100, height=100) ElementBGArray[2] = Image.open("ico.png") ElementBGArray_Resize[2] = ElementBGArray[2].resize((100, 100), Image.ANTIALIAS) ElementBGArray_IM[2] = ImageTk.PhotoImage(ElementBGArray_Resize[2]) Label_2.configure(image=ElementBGArray_IM[2]) Label_2_Ft = tkinter.font.Font(family='System', size=24, weight='bold', slant='roman', underline=0, overstrike=0) Label_2.configure(font=Label_2_Ft) Fun.AddElement(className, 'Label_2', Label_2) Label_3 = tkinter.Label(root, text="注册信息", width=10, height=4) Label_3.place(x=150, y=34, width=206, height=45) Label_3_Ft = tkinter.font.Font(family='System', size=29, weight='bold', slant='roman', underline=0, overstrike=0) Label_3.configure(font=Label_3_Ft) Fun.AddElement(className, 'Label_3', Label_3) Label_4 = tkinter.Label(root, text="姓名", width=10, height=4) Label_4.place(x=53, y=111, width=100, height=20) Fun.AddElement(className, 'Label_4', Label_4) Entry_5_Variable = Fun.AddElementVariable(className, 'Entry_5') Entry_5 = tkinter.Entry(root, textvariable=Entry_5_Variable) Entry_5.place(x=175, y=110, width=120, height=20) Entry_5.configure(relief="sunken") Fun.AddElement(className, 'Entry_5', Entry_5) Label_6 = tkinter.Label(root, text="性别", width=10, height=4) Label_6.place(x=54, y=146, width=100, height=20) Fun.AddElement(className, 'Label_6', Label_6) RadioButton_7 = tkinter.Radiobutton(root, variable=Group_1_Variable, value=1, text="男", anchor=tkinter.W) RadioButton_7.place(x=173, y=147, width=48, height=20) Fun.AddElement(className, 'RadioButton_7', RadioButton_7) RadioButton_8 = tkinter.Radiobutton(root, variable=Group_1_Variable, value=2, text="女", anchor=tkinter.W) RadioButton_8.place(x=243, y=149, width=48, height=20) Fun.AddElement(className, 'RadioButton_8', RadioButton_8) Label_9 = tkinter.Label(root, text="邮箱", width=10, height=4) Label_9.place(x=54, y=181, width=100, height=20) Fun.AddElement(className, 'Label_9', Label_9) Entry_10_Variable = Fun.AddElementVariable(className, 'Entry_10') Entry_10 = tkinter.Entry(root, textvariable=Entry_10_Variable) Entry_10.place(x=175, y=185, width=195, height=20) Entry_10.configure(relief="sunken") Fun.AddElement(className, 'Entry_10', Entry_10) Label_11 = tkinter.Label(root, text="个人简介", width=10, height=4) Label_11.place(x=55, y=220, width=100, height=20) Fun.AddElement(className, 'Label_11', Label_11) Text_12 = tkinter.Text(root) Text_12.place(x=175, y=220, width=240, height=120) Text_12.configure(relief="sunken") Fun.AddElement(className, 'Text_12', Text_12) Button_13 = tkinter.Button(root, text="确定", width=10, height=4) Button_13.place(x=176, y=354, width=100, height=28) Button_13.configure(command=lambda: RegDlg_cmd.Button_13_onCommand( className, "Button_13")) Fun.AddElement(className, 'Button_13', Button_13) Button_14 = tkinter.Button(root, text="取消", width=10, height=4) Button_14.place(x=310, y=354, width=100, height=28) Button_14.configure(command=lambda: RegDlg_cmd.Button_14_onCommand( className, "Button_14")) Fun.AddElement(className, 'Button_14', Button_14) #Inital all element's Data Fun.InitElementData(className)
def Button_5_onCommand(): MySocket = Fun.getUIEle('MySocket_9') IPAddr = Fun.getUIData('Entry_2','IPAddr') PORT = Fun.getUIData('Entry_4','Port') MySocket.createServer(IPAddr,PORT)
def Button_10_onCommand(className, widgetName): Webbrowser_5 = Fun.GetUIEle(className, 'Webbrowser_5') Webbrowser_5.gohome()
def Button_9_onCommand(className, widgetName): Webbrowser_5 = Fun.GetUIEle(className, 'Webbrowser_5') Webbrowser_5.refresh()
def __init__(self, root, isTKroot=True): className = self.__class__.__name__ Fun.G_UIElementArray[className] = {} Fun.G_ElementBindingDataArray[className] = {} global ElementBGArray global ElementBGArray_Resize global ElementBGArray_IM Fun.AddElement(className, 'UIClass', self) self.root = root if isTKroot == True: root.title("Form1") root.geometry("543x244") Form_1 = tkinter.Canvas(root, width=10, height=4) Form_1.place(x=0, y=0, width=543, height=244) Form_1.configure(bg="#efefef") Fun.AddElement(className, 'root', root) Fun.AddElement(className, 'Form_1', Form_1) #Create the elements of root Entry_2_Variable = Fun.AddElementVariable(className, 'Entry_2') Entry_2 = tkinter.Entry(root, textvariable=Entry_2_Variable) Entry_2.place(x=93, y=20, width=120, height=20) Entry_2.configure(bg="#ffffff") Entry_2.configure(relief="sunken") Fun.AddUIData(className, 'Entry_2', 'IPAddr', 'string', '127.0.0.1', 1) Fun.AddElement(className, 'Entry_2', Entry_2) Label_3 = tkinter.Label(root, text="端口", width=10, height=4) Label_3.place(x=216, y=19, width=74, height=20) Fun.AddElement(className, 'Label_3', Label_3) Entry_4_Variable = Fun.AddElementVariable(className, 'Entry_4') Entry_4 = tkinter.Entry(root, textvariable=Entry_4_Variable) Entry_4.place(x=294, y=19, width=120, height=20) Entry_4.configure(relief="sunken") Fun.AddUIData(className, 'Entry_4', 'Port', 'int', 8888, 1) Fun.AddElement(className, 'Entry_4', Entry_4) Button_5 = tkinter.Button(root, text="启动", width=10, height=4) Button_5.place(x=433, y=16, width=100, height=28) Button_5.configure(command=lambda: Server_cmd.Button_5_onCommand( className, "Button_5")) Fun.AddElement(className, 'Button_5', Button_5) ListBox_6 = tkinter.Listbox(root) ListBox_6.place(x=21, y=57, width=394, height=160) Fun.AddElement(className, 'ListBox_6', ListBox_6) Label_7 = tkinter.Label(root, text="IP地址", width=10, height=4) Label_7.place(x=4, y=21, width=74, height=20) Fun.AddElement(className, 'Label_7', Label_7) import MySocket MySocket_9 = MySocket.MySocket() #MySocket_9.xy(4,21) MySocket_9.set_HOST('127.0.0.1') MySocket_9.set_PORT('8888') MySocket_9.set_LISTBOX(ListBox_6) Fun.AddElement(className, 'MySocket_9', MySocket_9) #Inital all element's Data Fun.InitElementData(className)