https://blog.csdn.net/qq_52480014/article/details/114264635
import tkinter as tk # Python 3 import
# import Tkinter as tk # Python 2 import
root = tk.Tk()
def my_function():
    current_id = my_entry.get()
    url_member = "https://api.example.com/member?member_id="+str(current_id)
    print(url_member)
    #do stuff with url_member
my_label = tk.Label(root, text = "Member ID# ")
my_label.grid(row = 0, column = 0)
my_entry = tk.Entry(root)
my_entry.grid(row = 0, column = 1)
my_button = tk.Button(root, text = "Submit", command = my_function)
my_button.grid(row = 1, column = 1)
root.mainloop()
#coding:utf-8
from tkinter import *
class App:
  def __init__(self,root):
    #定义帧
    frame = Frame(root)
    frame.pack()
    self.frame = frame
    w = Label(frame,text = "calculator")
    w.pack()
    self.newinput()
    #调用回调函数
    button1 = Button(frame,text=‘1‘,fg="red",command = lambda : self.buttoncb(1))
    button1.pack()
    button2 = Button(frame,text=‘2‘,fg="red",command = lambda : self.buttoncb(2))
    button2.pack()
    button = Button(frame,text=‘Quit‘,fg="red",command = root.quit)
    button.pack()
  def newinput(self):
    v = StringVar()
    e = Entry(self.frame,textvariable = v)
    self.v = v
    e.pack()
  #定义回调函数
  def buttoncb(self,i):
    #print "button"
    val = self.v.get()
    self.v.set(val+str(i))
root=Tk()
a = App(root)
root.mainloop()
原文:https://www.cnblogs.com/amize/p/15154538.html