Bottom Page

Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Tkinter Gui ScrolledText Insert From Different Class
Hey all, I feel like I'm pretty close, but I cannot seem to figure out why my calls to the function
are not going through and I would greatly appreciate help with this code.

from tkinter import ttk
import tkinter as tk
import tkinter.scrolledtext as tkst

class someGui(tk.Tk):
	def __init__(self,parent):
		self.textBox=textBoxClass(self.parent) #saving the instance 

	def Window(self): 
		self.parent.title("Example Window")
		self.someFrame = ttk.Frame(self.parent)
		self.someFrame.grid(row=0, column=0, sticky='nesw') #changed sticky definition for tk requirements

		textBoxSeparate=textBoxClass(self.parent) # the initial inclusion of the textbox in the frame
		self.someFunction() #no input needed

	def someFunction(self):
		# self.textBox.textDropIn() #there is no parent attribute in textDropIn, so I removed it
		# self.textBox.insert(tk.INSERT, "Some test text.") #split call to two lines and changed to tk.INSERT
		textVar="This is a test."
class textBoxClass(): #removed tkst.ScrolledText in class call because instance was created in textDropIn
	def __init__(self,parent):
		# super().__init__() #kept receiving TypeError: object.__init__() takes no arguments, thus removed args
		self.textDropIn() #removed parent attribute from function call

	def textDropIn(self): #removed parent attribute from definition
		self.someText = tkst.ScrolledText(master=self.root, wrap=tk.WORD, width=50, height=20)
		self.someText.grid(row=0, column=4, rowspan=7, columnspan=4, pady=20, padx=20)

	def TextWindowWrite(self,textToWrite):

def main(): 
	root =tk.Tk()

if __name__=='__main__':
My entire goal here is to update the text window created with ScrolledText so that I can write text based on the operations of other functions in a different class. I am having trouble calling the functions from a different class correctly.
you have a bad recursion issue here:
It hurts to try and follow.

instead of using 'some', suggest you preceded function calls and shared variables with an abbreviation of
the class they belong to.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  [Tkinter] text widgets-insert problem genc74 3 153 Apr-27-2019, 04:00 PM
Last Post: Yoriz
  how to insert image into Text widget Tkinter atlass218 5 353 Apr-17-2019, 05:28 AM
Last Post: atlass218
  [PyQt] pyqt5 comobox insert into mysql Weballround 2 367 Jan-11-2019, 05:56 AM
Last Post: Weballround
  Insert color in tkinter automatically Dwimmerlaik 4 481 Jan-07-2019, 07:10 PM
Last Post: Dwimmerlaik
  GUI insert textbox value into a Class dimvord 0 545 Jul-04-2018, 06:49 PM
Last Post: dimvord
  [Tkinter] insert table columns data in different textboxes dimvord 4 766 Jun-15-2018, 07:40 AM
Last Post: dimvord
  Using a class to create instances of Tkinter Toplevel() windows nortski 2 2,305 Mar-27-2018, 11:44 AM
Last Post: nortski
  tkinter scrolledtext formatting Lux 1 1,466 Aug-14-2017, 12:39 AM
Last Post: Larz60+

Forum Jump:

Users browsing this thread: 1 Guest(s)