# HG changeset patch # User btaylor@grond.willowglen.ab.ca # Date 1246901226 21600 # Node ID 19db1076e93c1067a7b764066690598f940e4c1d # Parent e9698d0ee5f3edeffff0dd9e969c5907017639f6 close ZeroConf object when exiting the Service Discovery window. (otherwise pythonw.exe does not exit when closing Beremiz on Windows) diff -r e9698d0ee5f3 -r 19db1076e93c discovery.py --- a/discovery.py Tue Jun 09 10:10:34 2009 +0200 +++ b/discovery.py Mon Jul 06 11:27:06 2009 -0600 @@ -23,7 +23,7 @@ #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import wx -from Zeroconf import * +from Zeroconf import * import socket import wx.lib.mixins.listctrl as listmix @@ -77,11 +77,11 @@ btsizer.AddGrowableCol(3) b = wx.Button(self, wx.ID_CANCEL, "Cancel") - #self.Bind(wx.EVT_BUTTON, self.OnClose, b) + self.Bind(wx.EVT_BUTTON, self.OnCancel, b) btsizer.Add(b) b = wx.Button(self, wx.ID_OK, "OK") - #self.Bind(wx.EVT_BUTTON, self.OnConnect, b) + self.Bind(wx.EVT_BUTTON, self.OnOk, b) b.SetDefault() btsizer.Add(b) @@ -94,6 +94,8 @@ self.zConfInstance = Zeroconf() self.RefreshList() + self.Bind(wx.EVT_CLOSE, self.OnClose) + def RefreshList(self): type = "_PYRO._tcp.local." self.browser = ServiceBrowser(self.zConfInstance, type, self) @@ -103,6 +105,18 @@ self.browser.cancel() self.RefreshList() + def OnClose(self, event): + self.zConfInstance.close() + event.Skip() + + def OnCancel(self, event): + self.zConfInstance.close() + event.Skip() + + def OnOk(self, event): + self.zConfInstance.close() + event.Skip() + # Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py def GetListCtrl(self): return self.list @@ -143,11 +157,11 @@ def GetResult(self): return self.my_result - def removeService(self, zeroconf, type, name): + def removeService(self, zeroconf, type, name): pass - + def addService(self, zeroconf, type, name): - info = self.zConfInstance.getServiceInfo(type, name) + info = self.zConfInstance.getServiceInfo(type, name) typename = type.split(".")[0][1:] num_items = self.list.GetItemCount() self.list.InsertStringItem(num_items, name.split(".")[0])