Try to create the listbox
as an instance variable with self
:
from Tkinter import *
class GuiCreate:
def __init__(self,parent):
#Textbox
window = Frame(width=620, height=50)
window.place(x=25,y=320)
vscroll = Scrollbar(window)
hscroll = Scrollbar(window, orient='horizontal')
# create instance variable with "self"
self.listbox = Text(window, height=10)
self.listbox.pack(side=LEFT, fill=X, padx=5, pady=5, expand=1)
vscroll.config(command=self.listbox.yview, relief=SUNKEN)
hscroll.config(command=self.listbox.xview, relief=SUNKEN)
self.listbox.config(yscrollcommand=vscroll.set, relief=SUNKEN)
self.listbox.config(xscrollcommand=hscroll.set)
f7 = Frame(width=30, height=20)
f7.place(x=20,y=260)
srcButton = Button(f7, text="START", command=self.startProcess)
srcButton.pack(side='left')
def startProcess(self):
textinsert = 'abcdefg'
self.listbox.insert('end', textinsert)
root = Tk()
root.title("Clipfinder")
root.geometry('650x550+200+100')
gui = GuiCreate(root)
root.configure(background = 'gray')
root.mainloop()
You can learn more about classes and object-orient programming in python here, a few paragraphs down it
touches upon using self
.