Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # coding: utf-8
- import tkinter
- class App(tkinter.Frame):
- def __init__(self, master=None):
- super().__init__(master)
- self.master = master
- self.pack()
- self.create()
- def create(self):
- a = [[1, 2, 3], ['円', '個', '数']]
- self.s = []
- self.entry = []
- for i, (n, N) in enumerate(zip(*a)):
- tkinter.Label(self, text=f"{n} {N}").grid(column=0, row=i)
- self.s.append(tkinter.StringVar())
- self.entry.append(
- tkinter.Entry(self, textvariable=self.s[-1]).grid(
- column=1, row=i))
- self.button = tkinter.Button(
- self, text='join entry', command=self.join_entry)
- self.button.grid(column=0, columnspan=2, row=3)
- self.label = tkinter.Label(self)
- self.label.grid(column=0, columnspan=2, row=4)
- def join_entry(self):
- self.label['text'] = '|'.join([ss.get() for ss in self.s])
- App(master=tkinter.Tk()).mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement