0

Hi,
I have created a checkbutton within a dialog box. But, I am not able to capture the value of the checkbutton. The value always seems to be 0 whether checked or not.

class MyDialog:
    
    def __init__(self,parent):
        self.Frame1= Tix.Frame(parent)
        self.Frame1.pack(side=Tix.LEFT, fill=Tix.BOTH)
        
        self.enabled = Tix.IntVar()
        
        self.checkbutton = Tix.Checkbutton(self.Frame1,text = "Enable Email Option", variable=self.enabled,command=self.OnCheckBoxClick)
        self.checkbutton.pack(side=Tix.TOP)
        
            
    def OnCheckBoxClick(self):
        iTemp = self.enabled.get()
        print "iTemp %s"%iTemp

Can you tell me whats wrong with the code?

Thanks!

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by psvpython
0

The following works for me. Check the rest of your code that is not posted for differences.

from Tkinter import *
class MyDialog:
 
    def __init__(self,parent):
        self.Frame1= Frame(parent)
        self.Frame1.pack()
 
        self.enabled = IntVar()
 
        self.checkbutton = Checkbutton(self.Frame1,text = "Enable Email Option", variable=self.enabled,command=self.OnCheckBoxClick)
        self.checkbutton.pack()
 
 
    def OnCheckBoxClick(self):
        iTemp = self.enabled.get()
        print "iTemp %s"%iTemp

root=Tk()
M=MyDialog(root)
root.mainloop()
0
import Tix

class MyDialog:
 
    def __init__(self,parent):
        self.Frame1= Tix.Frame(parent)
        self.Frame1.pack()
 
        self.enabled = Tix.IntVar()
 
        self.checkbutton = Tix.Checkbutton(self.Frame1,text = "Enable Email Option", variable=self.enabled,command=self.OnCheckBoxClick)
        self.checkbutton.pack()
 
 
    def OnCheckBoxClick(self):
        iTemp = self.enabled.get()
        print "iTemp %s"%iTemp

root=Tix.Tk()
M=MyDialog(root)
root.mainloop()

This code works perfectly on IDLE. But, the exact same code isn't working on WingIDE for me :(

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.