我如何实现一个列表,在其中我可以放置一些电话号码

2024-04-25 22:03:45 发布

您现在位置:Python中文网/ 问答频道 /正文

#! / 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 ()

我想点击“信息”旁边的“添加”,然后必须有一个新窗口,我可以在其中键入电话号码。在点击ok或者类似的按钮之后,我想在中间有一个窗口,在那里我可以看到我输入的数字


Tags: andtheselfadddefhelpbuttonwindow