23 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
24 |
24 |
25 from types import TupleType |
25 from types import TupleType |
26 |
26 |
27 import wx |
27 import wx |
|
28 import wx.lib.buttons |
28 import wx.lib.agw.customtreectrl as CT |
29 import wx.lib.agw.customtreectrl as CT |
29 |
30 |
30 from PLCControler import * |
31 from PLCControler import * |
31 |
32 from utils.BitmapLibrary import GetBitmap |
32 CWD = os.path.split(os.path.realpath(__file__))[0] |
|
33 |
33 |
34 def GenerateName(infos): |
34 def GenerateName(infos): |
35 if infos[0] in ["input", "output", "value"]: |
35 if infos[0] in ["input", "output", "value"]: |
36 return "%s %d:" % (infos[0], infos[1]) |
36 return "%s %d:" % (infos[0], infos[1]) |
37 elif infos[0] == "range": |
37 elif infos[0] == "range": |
98 if wx.VERSION >= (2, 8, 11): |
98 if wx.VERSION >= (2, 8, 11): |
99 self.SearchResultsTree.SetAGWWindowStyleFlag(search_results_tree_style) |
99 self.SearchResultsTree.SetAGWWindowStyleFlag(search_results_tree_style) |
100 self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnSearchResultsTreeItemActivated, |
100 self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnSearchResultsTreeItemActivated, |
101 id=ID_SEARCHRESULTPANELSEARCHRESULTSTREE) |
101 id=ID_SEARCHRESULTPANELSEARCHRESULTSTREE) |
102 |
102 |
103 self.ResetButton = wx.Button(id=ID_SEARCHRESULTPANELRESETBUTTON, label=_('Reset'), |
103 self.ResetButton = wx.lib.buttons.GenBitmapButton(self, |
104 name='ResetButton', parent=self, pos=wx.Point(0, 0), |
104 bitmap=GetBitmap("reset"), size=wx.Size(28, 28), style=wx.NO_BORDER) |
105 size=wx.DefaultSize, style=0) |
105 self.ResetButton.SetToolTipString(_("Reset search result")) |
106 self.Bind(wx.EVT_BUTTON, self.OnResetButton, |
106 self.Bind(wx.EVT_BUTTON, self.OnResetButton, self.ResetButton) |
107 id=ID_SEARCHRESULTPANELRESETBUTTON) |
|
108 |
107 |
109 self._init_sizers() |
108 self._init_sizers() |
110 |
109 |
111 def __init__(self, parent, window): |
110 def __init__(self, parent, window): |
|
111 self.ParentWindow = window |
|
112 |
112 self._init_ctrls(parent) |
113 self._init_ctrls(parent) |
113 self.ParentWindow = window |
|
114 |
114 |
115 # Define Tree item icon list |
115 # Define Tree item icon list |
116 self.TreeImageList = wx.ImageList(16, 16) |
116 self.TreeImageList = wx.ImageList(16, 16) |
117 self.TreeImageDict = {} |
117 self.TreeImageDict = {} |
118 |
118 |
126 ("RESOURCE", ITEM_RESOURCE), |
126 ("RESOURCE", ITEM_RESOURCE), |
127 ("DATATYPE", ITEM_DATATYPE), |
127 ("DATATYPE", ITEM_DATATYPE), |
128 ("ACTION", "action_block"), |
128 ("ACTION", "action_block"), |
129 ("IL", "IL"), |
129 ("IL", "IL"), |
130 ("ST", "ST")]: |
130 ("ST", "ST")]: |
131 self.TreeImageDict[itemtype]=self.TreeImageList.Add(wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%imgname))) |
131 self.TreeImageDict[itemtype] = self.TreeImageList.Add(GetBitmap(imgname)) |
132 |
132 |
133 for itemtype in ["function", "functionBlock", "program", |
133 for itemtype in ["function", "functionBlock", "program", |
134 "comment", "block", "io_variable", |
134 "comment", "block", "io_variable", |
135 "connector", "contact", "coil", |
135 "connector", "contact", "coil", |
136 "step", "transition", "jump", |
136 "step", "transition", "jump", |
137 "var_local", "var_input", |
137 "var_local", "var_input", |
138 "var_inout", "var_output"]: |
138 "var_inout", "var_output"]: |
139 self.TreeImageDict[itemtype]=self.TreeImageList.Add(wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%itemtype.upper()))) |
139 self.TreeImageDict[itemtype] = self.TreeImageList.Add(GetBitmap(itemtype.upper())) |
140 |
140 |
141 # Assign icon list to TreeCtrl |
141 # Assign icon list to TreeCtrl |
142 self.SearchResultsTree.SetImageList(self.TreeImageList) |
142 self.SearchResultsTree.SetImageList(self.TreeImageList) |
143 |
143 |
144 self.ResetSearchResults() |
144 self.ResetSearchResults() |