• tk 菜单应用,一个组播ip转mac的实例


     1 # -*- coding:utf-8 -*-
     2 #import tkinter
     3 import tkinter.messagebox  
     4 root=tkinter.Tk()
     5 root.title("mul_ip_mac Tool")
     6 root.geometry("420x200")
     7 
     8 def hello():
     9     print("Hello ")
    10 
    11 def about():
    12     tkinter.messagebox.showinfo("欢迎", "欢迎使用Joyware Switch Tool!
    By 肖勇")
    13 
    14 def ping():
    15     pass
    16 def show_ip_mac():
    17     frame=tkinter.LabelFrame(text=" IPv4组播IP与MAC转换 ")
    18     frame.grid(column=1, row=0, padx=10, pady=30)
    19     label1=tkinter.Label(frame,text="请输入组播IP") 
    20     label1.grid(column=0, row=1)
    21     ip_entry=tkinter.Entry(frame,width=15)
    22     ip_entry.grid(column=1, row=1)
    23     label1=tkinter.Label(frame,text="对应组播MAC") 
    24     label1.grid(column=2, row=1)
    25     mac_entry=tkinter.Entry(frame,width=17)
    26     mac_entry.grid(column=3, row=1)
    27     button1=tkinter.Button(frame,text="转换")
    28     button1.grid(columnspan=4, row=2)
    29     
    30     def rightip(ip):
    31         '''判断输入的ip是否是一个合法的ipv4组播地址'''
    32         if len(ip)==4:
    33             try:
    34                 if int(ip[0]) in range(224,240) and 
    35                 int(ip[1])  in range(0,256) and int(ip[2])
    36                  in range(0,256) and int(ip[3])>=0:
    37                     return 1
    38             except:
    39                 return 0
    40         else:
    41             return 0
    42     
    43     
    44     def ip_mac(event):
    45          
    46         ip=ip_entry.get().split(".")
    47         flg=rightip(ip)
    48         if flg!= 1:
    49             tkinter.messagebox.showinfo('提示','输入的不是一个IPv4组播地址')
    50             return
    51     
    52         if int(ip[1])>128:
    53             ip2=int(ip[1])-128
    54         else:
    55             ip2=int(ip[1])
    56         ip3=int(ip[2])
    57         ip4=int(ip[3])
    58         mac='01-00-5E-%02X-%02X-%02X' %(ip2,ip3,ip4)
    59         mac_entry.delete(0,tkinter.END) #清空文本框
    60         mac_entry.insert(tkinter.END, mac)  # INSERT表示在光标位置插入
    61         mac_entry.update()
    62     button1.bind("<Button-1>",ip_mac)  #<Button-1>表示左键
    63     
    64 
    65 menubar = tkinter.Menu(root)
    66 filemenu = tkinter.Menu(menubar, tearoff=0)
    67 filemenu.add_command(label="ip_mac", command=show_ip_mac)
    68 filemenu.add_separator()
    69 filemenu.add_command(label="ping",command=ping)
    70 filemenu.add_separator()
    71 menubar.add_cascade(label="菜单",menu=filemenu)
    72 helpmenu=tkinter.Menu(menubar, tearoff=0)
    73 helpmenu.add_command(label="关于", command=about)
    74 helpmenu.add_separator()
    75 helpmenu.add_command(label="教程",command=hello)
    76 menubar.add_cascade(label="帮助", menu=helpmenu)
    77 root.config(menu=menubar)
    78 root.mainloop()
  • 相关阅读:
    Unable To Open Database After ASM Upgrade From Release 11.1 To Release 11.2
    11g Understanding Automatic Diagnostic Repository.
    How to perform Rolling UpgradeDowngrade in 11g ASM
    Oracle 11.2.0.2 Patch 说明
    Pattern Matching Metacharacters For asm_diskstring
    Steps To MigrateMove a Database From NonASM to ASM And ViceVersa
    Upgrading ASM instance from Oracle 10.1 to Oracle 10.2. (Single Instance)
    OCSSD.BIN Process is Running in a NonRAC Environment
    Steps To MigrateMove a Database From NonASM to ASM And ViceVersa
    On RAC, expdp Removes the Service Name [ID 1269319.1]
  • 原文地址:https://www.cnblogs.com/shiyongge/p/10820117.html
Copyright © 2020-2023  润新知