1

my code:

import tkinter as tk
from tkinter import *
truth = ""
us = ""
uss = ""
     
root = Tk()
s = Label(root, text = ".")
s.grid(row = 1, column = 1)
wel = Label(root, text = "whats your email")
wel.grid(row = 1, column = 5)
inp = Entry(root).get()
inp.grid(row = 3, column = 5)
def callback():

   us = inp[:inp.index("@")]
   uss = inp[inp.index("@")+1:]
   truth =us, " is username, and ", uss,"is domain"
   print(truth)
sub = Button(root, text = "submit", command = callback)
sub.grid(row = 5, column = 5)
final = Label(root, textvariable = truth)
final.grid(row = 5, column = 6)

root.mainloop()

Then I get an error message: 'str' object has no attribute 'grid'

How do I use grid system on entry widget affected by .get()?

a121
  • 798
  • 4
  • 9
  • 20
Evan Hall
  • 9
  • 1
  • 2
    `inp = Entry(root).get()` is nonsensical. Calling `.get()` on the Entry immediately after creating it can only return an empty string; when has the user had any chance to actually enter anything? You need to do the `.get()` later, after the user has indicated that they're done typing. Inside `callback()` would be the appropriate place in your case. – jasonharper Jan 31 '21 at 22:33

0 Answers0