connectors/PYRO/__init__.py
branch#2476
changeset 2001 bcbd41efd846
parent 1919 ccea0fa6ea91
child 2005 0d32b17f15b9
equal deleted inserted replaced
1991:34a9287b6c7d 2001:bcbd41efd846
    34 import Pyro
    34 import Pyro
    35 import Pyro.core
    35 import Pyro.core
    36 import Pyro.util
    36 import Pyro.util
    37 from Pyro.errors import PyroError
    37 from Pyro.errors import PyroError
    38 
    38 
       
    39 import wx
       
    40 from controls.UriLocationEditor import IConnectorPanel
       
    41 from zope.interface import implementer
    39 
    42 
    40 service_type = '_PYRO._tcp.local.'
    43 service_type = '_PYRO._tcp.local.'
    41 # this module attribute contains a list of DNS-SD (Zeroconf) service types
    44 # this module attribute contains a list of DNS-SD (Zeroconf) service types
    42 # supported by this connector confnode.
    45 # supported by this connector confnode.
    43 #
    46 #
    44 # for connectors that do not support DNS-SD, this attribute can be omitted
    47 # for connectors that do not support DNS-SD, this attribute can be omitted
    45 # or set to an empty list.
    48 # or set to an empty list.
       
    49 
       
    50 URITypes = ["LOCAL", "PYRO", "PYROS"]
    46 
    51 
    47 
    52 
    48 def PYRO_connector_factory(uri, confnodesroot):
    53 def PYRO_connector_factory(uri, confnodesroot):
    49     """
    54     """
    50     This returns the connector to Pyro style PLCobject
    55     This returns the connector to Pyro style PLCobject
   202                 member = PyroCatcher(my_local_func, None)
   207                 member = PyroCatcher(my_local_func, None)
   203                 self.__dict__[attrName] = member
   208                 self.__dict__[attrName] = member
   204             return member
   209             return member
   205 
   210 
   206     return PyroProxyProxy()
   211     return PyroProxyProxy()
       
   212 
       
   213 
       
   214 def PYRO_connector_dialog(confnodesroot):
       
   215     [ID_IPTEXT, ID_PORTTEXT] = [wx.NewId() for _init_ctrls in range(2)]
       
   216 
       
   217 
       
   218     @implementer(IConnectorPanel)
       
   219     class PYROConnectorPanel(wx.Panel):
       
   220         def __init__(self, typeConnector, parrent, *args, **kwargs):
       
   221             self.type = typeConnector
       
   222             self.parrent = parrent
       
   223             wx.Panel.__init__(self, parrent, *args, **kwargs)
       
   224             self._init_ctrls()
       
   225             self._init_sizers()
       
   226             self.uri = None
       
   227 
       
   228         def _init_ctrls(self):
       
   229             self.IpText = wx.TextCtrl(parent=self, id=ID_IPTEXT, size = wx.Size(200, -1))
       
   230             self.PortText = wx.TextCtrl(parent=self, id=ID_PORTTEXT, size = wx.Size(200, -1))
       
   231 
       
   232         def _init_sizers(self):
       
   233             self.mainSizer = wx.BoxSizer(wx.VERTICAL)
       
   234             self.uriSizer = wx.BoxSizer(wx.HORIZONTAL)
       
   235             self.portSizer = wx.BoxSizer(wx.HORIZONTAL)
       
   236 
       
   237             self.uriSizer.Add(wx.StaticText(self, wx.ID_ANY, "URI host:", size = wx.Size(70, -1)), proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
       
   238             self.uriSizer.AddSpacer((0,0))
       
   239             self.uriSizer.Add(self.IpText, proportion=1, flag=wx.ALIGN_RIGHT)
       
   240             self.mainSizer.Add(self.uriSizer, border=2, flag=wx.ALL)
       
   241 
       
   242             self.portSizer.Add(wx.StaticText(self, wx.ID_ANY, "URI port:", size = wx.Size(70, -1)), proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
       
   243             self.portSizer.AddSpacer((0,0))
       
   244             self.portSizer.Add(self.PortText, proportion=1, flag=wx.ALIGN_RIGHT)
       
   245             self.mainSizer.Add(self.portSizer, border=2, flag=wx.ALL)
       
   246 
       
   247             self.SetSizer(self.mainSizer)
       
   248 
       
   249         def SetURI(self, uri):
       
   250             self.uri = uri
       
   251             uri_list = uri.strip().split(":")
       
   252             length = len(uri_list)
       
   253             if length == 3:
       
   254                 self.IpText.SetValue(uri_list[1].strip("/"))
       
   255                 self.PortText.SetValue(uri_list[2])
       
   256             elif length == 2:
       
   257                 self.IpText.SetValue(uri_list[1].strip("/"))
       
   258 
       
   259 
       
   260         def GetURI(self):
       
   261             self.uri = self.type+"://"+self.IpText.GetValue()+":"+self.PortText.GetValue()
       
   262             return self.uri
       
   263 
       
   264     return PYROConnectorPanel("PYRO", confnodesroot)