i have some small project in my work, and i cant figure out, how its must be done. so, i build some small wxPython panel and button, and i wanna disable that one button when i found from db multiple files.
Heres my code:
class Settings(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=wx.EmptyString, pos=wx.DefaultPosition,
size=wx.Size(700, 405), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)
self.SetSizeHints(wx.DefaultSize, wx.DefaultSize)
frame_sizer = wx.BoxSizer(wx.VERTICAL)
self.main_panel = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL)
self.main_sizer = wx.BoxSizer(wx.VERTICAL)
frame_sizer.Add(self.main_panel, 1, wx.EXPAND)
self.SetSizer(frame_sizer)
self.save_button = wx.Button(self.main_panel, wx.ID_ANY, u"Save", wx.DefaultPosition, wx.DefaultSize, 0)
#bottom_buttons_sizer.Add(self.save_button, 0, wx.ALL, 5)
self.Layout()
self.Centre(wx.BOTH)
self.Bind(wx.EVT_BUTTON, self.onDisable)
self.Bind(wx.EVT_BUTTON, self.anotherFunc)
def SerializationDB(self):
con = sl.connect('Test.db')
cursor = con.cursor()
cursor.execute('CREATE TABLE if not exists TESTS(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name, reference_script)').fetchone()
with con:
sql = 'INSERT INTO TESTS (name, reference_script) values(?, ?)'
data = [('Test 1', 'TestText')]
p = cursor.executemany(sql, data)
return p
def checkNames(self, e):
con = sl.connect('Test.db')
cursor = con.cursor()
k = cursor.execute('SELECT name, COUNT(*) from TESTS WHERE id between 1 and 30 group by name HAVING COUNT(*)').fetchone()[1]
return k
def onDisable(self, e):
if self.checkNames(e) > 1:
self.save_button.Disable() #<- doesnt work.
def anotherFunc(self, e):
self.save_button.Enable()
I dont know how those binds works, for any advice appreciated.
How i can unbind(?) or do something with that button, when another functions was running?