0

this is my python code GUI generated from PAGE 4.6.

I want to create a function which will change the textbox value in real time example

tbCapturedImage.set("test 1").

take a look at

self.btnCapture.bind('<Button-1>', self.Capture_a)

but it cant seems to change the value of the textbox.

 self.tbCapturedImage = Text(self.TLabelframe1)
        self.tbCapturedImage.place(relx=0.04, rely=0.65, relheight=0.33
                , relwidth=0.93)
        self.tbCapturedImage.configure(background="white")
        self.tbCapturedImage.configure(font="TkTextFont")
        self.tbCapturedImage.configure(selectbackground="#c4c4c4")
        self.tbCapturedImage.configure(width=206)
        self.tbCapturedImage.configure(wrap=WORD)


            self.btnCapture = Button(master)
            self.btnCapture.place(relx=0.01, rely=0.92, height=45, width=982)
            self.btnCapture.configure(activebackground="#d9d9d9")
            self.btnCapture.configure(disabledforeground="#a7a4a7")
            self.btnCapture.configure(font=font11)
            self.btnCapture.configure(text='''Capture Image''')
            self.btnCapture.bind('<Button-1>', self.Capture_a)

            self.Labelframe1 = LabelFrame(master)
            self.Labelframe1.place(relx=0.25, rely=0.48, relheight=0.43
                    , relwidth=0.74)
            self.Labelframe1.configure(relief=GROOVE)
            self.Labelframe1.configure(text='''Color Detection''')
            self.Labelframe1.configure(width=740)        
            self.Labelframe2 = LabelFrame(master)
            self.Labelframe2.place(relx=0.25, rely=0.05, relheight=0.43
                    , relwidth=0.35)
            self.Labelframe2.configure(relief=GROOVE)
            self.Labelframe2.configure(text='''Perspective Transformation''')
            self.Labelframe2.configure(width=350)        
            self.Labelframe3 = LabelFrame(master)
            self.Labelframe3.place(relx=0.61, rely=0.05, relheight=0.43
                    , relwidth=0.38)
            self.Labelframe3.configure(relief=GROOVE)
            self.Labelframe3.configure(text='''Haar-Like Detection''')
            self.Labelframe3.configure(width=380)                
        def Capture():
            tbCapture.Set("test")            
        def Capture_a(self,event):
            self.Capture()   

    if __name__ == '__main__':
        vp_start_gui()
6
  • 1
    If this is your code, it should give an error on line self.Capture(). Something like Capture takes 0 arguments but 1 given. Have you checked your console to see if there are any error messages? Commented Feb 3, 2016 at 8:08
  • Also, even though I can guess, can you please fix the indentation? Commented Feb 3, 2016 at 8:10
  • btw: instead bind you can use Button(..., command=function_name) Commented Feb 3, 2016 at 8:48
  • in method Capture() use self.tbCapture instead of tbCapture and use set instead of Set Commented Feb 3, 2016 at 8:50
  • BTW: I don't see tbCapture in code - maybe you mean tbCapturedImage ? Commented Feb 3, 2016 at 8:53

1 Answer 1

2

You have to use self and set instead of Set

And probably you should use tbCapturedImage instead of tbCapture

 def Capture(self): # self
     self.tbCapturedImage.set("test")  # self, set and tbCapturedImage

BTW: you can use command= in Button instead of bind

 self.btnCapture = Button(master, command=self.Capture)

or

 self.btnCapture.configure(command=self.Capture)

command= doesn't send event so method doesn't need argument event

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.