author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Wed, 23 May 2018 20:22:45 +0200 | |
changeset 2017 | c76d4be6f438 |
parent 2008 | 1f31a2f61993 |
child 2179 | 84c4e56b38d6 |
permissions | -rw-r--r-- |
2007
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
1 |
#!/usr/bin/env python |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
3 |
|
2008
1f31a2f61993
#2476 Changes to the comment.
dporopat <denis.poropat@smarteh.si>
parents:
2007
diff
changeset
|
4 |
# Copyright (C) 2018: Smarteh |
2007
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
5 |
# |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
6 |
# See COPYING file for copyrights details. |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
7 |
|
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
8 |
|
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
9 |
from __future__ import absolute_import |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
10 |
from __future__ import print_function |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
11 |
|
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
12 |
import wx |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
13 |
from controls.UriLocationEditor import IConnectorPanel |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
14 |
from zope.interface import implementer |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
15 |
|
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
16 |
URITypes = ["LOCAL", "PYRO", "PYROS"] |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
17 |
|
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
18 |
|
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
19 |
def PYRO_connector_dialog(confnodesroot): |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
20 |
[ID_IPTEXT, ID_PORTTEXT] = [wx.NewId() for _init_ctrls in range(2)] |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
21 |
|
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
22 |
|
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
23 |
@implementer(IConnectorPanel) |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
24 |
class PYROConnectorPanel(wx.Panel): |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
25 |
def __init__(self, typeConnector, parrent, *args, **kwargs): |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
26 |
self.type = typeConnector |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
27 |
self.parrent = parrent |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
28 |
wx.Panel.__init__(self, parrent, *args, **kwargs) |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
29 |
self._init_ctrls() |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
30 |
self._init_sizers() |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
31 |
self.uri = None |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
32 |
|
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
33 |
def _init_ctrls(self): |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
34 |
self.IpText = wx.TextCtrl(parent=self, id=ID_IPTEXT, size = wx.Size(200, -1)) |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
35 |
self.PortText = wx.TextCtrl(parent=self, id=ID_PORTTEXT, size = wx.Size(200, -1)) |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
36 |
|
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
37 |
def _init_sizers(self): |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
38 |
self.mainSizer = wx.BoxSizer(wx.VERTICAL) |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
39 |
self.uriSizer = wx.BoxSizer(wx.HORIZONTAL) |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
40 |
self.portSizer = wx.BoxSizer(wx.HORIZONTAL) |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
41 |
|
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
42 |
self.uriSizer.Add(wx.StaticText(self, wx.ID_ANY, "URI host:", size = wx.Size(70, -1)), proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
43 |
self.uriSizer.AddSpacer((0,0)) |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
44 |
self.uriSizer.Add(self.IpText, proportion=1, flag=wx.ALIGN_RIGHT) |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
45 |
self.mainSizer.Add(self.uriSizer, border=2, flag=wx.ALL) |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
46 |
|
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
47 |
self.portSizer.Add(wx.StaticText(self, wx.ID_ANY, "URI port:", size = wx.Size(70, -1)), proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
48 |
self.portSizer.AddSpacer((0,0)) |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
49 |
self.portSizer.Add(self.PortText, proportion=1, flag=wx.ALIGN_RIGHT) |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
50 |
self.mainSizer.Add(self.portSizer, border=2, flag=wx.ALL) |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
51 |
|
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
52 |
self.SetSizer(self.mainSizer) |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
53 |
|
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
54 |
def SetURI(self, uri): |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
55 |
self.uri = uri |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
56 |
uri_list = uri.strip().split(":") |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
57 |
length = len(uri_list) |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
58 |
if length == 3: |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
59 |
self.IpText.SetValue(uri_list[1].strip("/")) |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
60 |
self.PortText.SetValue(uri_list[2]) |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
61 |
elif length == 2: |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
62 |
self.IpText.SetValue(uri_list[1].strip("/")) |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
63 |
|
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
64 |
|
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
65 |
def GetURI(self): |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
66 |
self.uri = self.type+"://"+self.IpText.GetValue()+":"+self.PortText.GetValue() |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
67 |
return self.uri |
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
68 |
|
ef2d479f564f
#2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff
changeset
|
69 |
return PYROConnectorPanel("PYRO", confnodesroot) |