-1

I'm making a coding language in python and I want to be able to write code into a ScrolledText widget, click a save button in a menubar and then get os to write a file containing whats in the ScrolledText Widget

I've already tried multiple variations of the .get() function (including .get('1.0', END) but they all come back with the error AttributeError: 'NoneType' object has no attribute 'get'

from tkinter import *
import os

root = Tk()

shell = ScrolledText(root, width=167, height=42).grid(column=0, row=1)

def save():
   file = open("code.txt", "x")
   file.write(shell.get("1.0", END))
   file.close()

I want the result to be like: file.write(shell.get(FIXED .GET CODE))

manveti
  • 1,691
  • 2
  • 13
  • 16

1 Answers1

0

Note that shell isn't assigned the ScrolledText object, but rather the result of the call to that object's grid method. So, as the error output suggests, shell is None. If you assign the object to shell and then call shell.grid things should work out the way you want.

manveti
  • 1,691
  • 2
  • 13
  • 16