I am working on making a ciphering program in Tkinter and need to seperate the words inputted into an Entry into seperate characters.
For example, if the user inputted the word "monkey", it would be put into an array like this seperatedWord = ["m","o","n","k","e","y"]
How would I go about doing this?
as commented by acw1668.
separatedWord = list(input_word)
you can typecast a string as list
try this code:
from tkinter import *
class MyEntry(Entry):
def __init__(self, root, textvariable):
Entry.__init__(self, master=root, textvariable=textvariable)
#binding your trace handler to your textvariable
textvariable.trace_add("write", self._traceHandler)
#or just use this handler
def _traceHandler(self, x, y, z):
# code block
print(self.getSeparatedWord())
#you can call this
def getSeparatedWord(self):
value = self.get()
return list(value)
root = Tk()
my_textvar = StringVar()
my_entry = MyEntry(root, my_textvar)
my_entry.pack()
root.mainloop()