0
need example for get values from textbox tkinter
def summary(): a=text.get('1.0',END) print(a) but=Button(command=summary) but.pack() This not work((
1 Odpowiedź
+ 1
# your code is incomplete and your meaning vague however
# here is a simple example of grabbing text from an entry box
# and placing the text on a label by pressing a button.
# I've included a basic layout I use because you might find it helpful,
# If not just extract the essence and apply it to your layout.
# There are multiple ways to deal with an operation you appear to be describing # and this
# is just one example , hope it helps. If you need more information the best
# resources I have found, and use often are
# http://www.tkdocs.com/index.html
# and the pdf file
# http://infohost.nmt.edu/tcc/help/pubs/tkinter/tkinter.pdf
# good luck
import tkinter as tk
from tkinter import ttk
class MainFrame(ttk.Frame):
def __init__(self,master=None):
super().__init__(master)
self.grid()
self.create_widgets()
def create_widgets(self):
self.textbox1 = tk.Entry()
self.textbox1.grid(column=0,row=0)
self.button1 = ttk.Button(text='put entry box text on label',
command=self.write)
self.button1.grid(column=0,row=1)
self.label1 = tk.Label(text="default text")
self.label1.grid(column=1,row=1)
def write(self):
self.label1["text"]=self.textbox1.get()
if __name__ == "__main__":
root = tk.Tk()
app = MainFrame(master=root)
app.mainloop()