Ok so, I'm really new at python (and programming itself) so sorry for my ignorance, but I really needed to ask this. So im doing a wxPython project where I added several tabs for a notebook (each tab of the notebook = a class) and there is one tab where I added a checkbox (in a tab, lets call it for example Tab1), and what I want is that when someone checks it, a button that exists in other tab (class called for example Tab2) gets disabled.
Well I know that this isn't hard to accomplish if they were in the same class using the EVT_CHECKBOX, GetValue() of the checkbox and Disable() on the button, but the problem is that they aren't in the same class and I just can't figure it out.
Hope someone can help me because it is really bothering me, and sorry for my ignorance once again.
Here is what I kinda have:
Well I know that this isn't hard to accomplish if they were in the same class using the EVT_CHECKBOX, GetValue() of the checkbox and Disable() on the button, but the problem is that they aren't in the same class and I just can't figure it out.
Hope someone can help me because it is really bothering me, and sorry for my ignorance once again.
Here is what I kinda have:
Code:
class Tab2(wx.Panel):
def __init__(self, parent):
.....
self.jaddbutton = wx.Button(self,-1, label ="Button",size = (160,24))
self.jaddbutton.Bind(wx.EVT_BUTTON, self.jaddbuttonclick, self.jaddbutton)
def jaddbuttonclick(self, event):
....
class Tab1(wx.Panel):
def __init__(self, parent):
self.jdcheck = wx.CheckBox(self, -1, 'Disable')
self.jdcheck.Bind(wx.EVT_CHECKBOX, self.checkoptions, self.jdcheck)
def checkoptions(self,event):
checkboxval = self.jdcheck.GetValue()
if checkboxval == False:
self.jaddbutton.Disable() # This is what I want to do but it is on the other class
else:
self.jaddbutton.Enable() # Same as above
class TextFrame(wx.Frame):
def __init__(self):
p = wx.Panel(self)
self.nb = wx.Notebook(p, size = (750, 332))
#Tabs
tab1 = Tab1(self.nb)
tab2 = Tab2(self.nb)
self.nb.AddPage(tab1, "ssomething")
self.nb.AddPage(tab2, "somethingr")
Comment