I am trying to create a simple GUI where a user enters some text and I bold certain words. I am using graphics library however my a getting a 'str' object has no attribute 'draw'. Also the window closes nearly instant.
from graphics import *
win = GraphWin("Hangman", 600, 600)
win.setBackground("yellow")
textEntry = Entry(Point(233,200),50)
textEntry.draw(win)
# click the mouse to signal done entering text
win.getMouse()
text = textEntry.getText()
testText = Text(Point(150,15), text)
testText.draw(win)
finalOut = ""
outtxt = text
outtxtSplit = outtxt.split()
for word in outtxtSplit:
if word == "bold":
finalOut = finalOut + word.setStyle("bold")
else:
finalOut = finalOut + word
outtxt.draw(win)
exitText = Text(Point(200,50), outtxt)
exitText.draw(win)
win.getMouse()
win.close()
outtxt.draw(win)You are calling draw on astrobject, the error message tells you that. What behaviour were you expecting?