#! / Usr / bin / python
# - * - coding: UTF-8 - * -
from tkinter import *
from tkinter import messagebox
def button_action ():
print ("I ran from the menu.")
def action_get_info_dialog ():
m_text = "\
************************ \ n \
office \ n \
\ n \
************************ "
messagebox.showinfo (message = m_text, title = "Info")
def button (self):
self.button = tk.Button (master = self.window, \
text = "Add")
self.button.pack ()
self.window.mainloop ()
window = Tk ()
window.title ( "telephone numbers")
add def (self):
self.window.mainloop ()
# Create menu bar
menu list = Menu (window)
# Create File and Help menu
file_menu = Menu (menuleiste, tearoff = 0)
help_menu = Menu (menuleiste, tearoff = 0)
add_menu = Menu (menuleiste, tearoff = 0)
# Click on File or Help to get more entries.
# These are added to "file_menu" and "help_menu"
datei_menu.add_command (label = "Save")
file_menu.add_separator () # Adds a separator
file_menu.add_command (label = "Exit", command = window.quit)
help_menu.add_command (label = "Info!", command = action_get_info_dialog)
add_menu.add_command (label = "Add", command = Add)
# Now we add the menus (File and Help) to the menu bar as
# "Drop-down menu" added
menuleiste.add_cascade (label = "file", menu = file_menu)
menuleiste.add_cascade (label = "Help", menu = help_menu)
menuleiste.add_cascade (label = "Add" menu = add_menu)
# Pass the menu bar with the menu entries to the window and you're done.
window.config (menu = menubar)
window.mainloop ()
我想在“信息”旁边单击“添加”,然后必须有一个新窗口可以在其中键入电话号码。在单击“确定”或类似的内容后,我希望在中间的窗口中可以看到我所输入的数字输入。