def __init__(self, strCaption="", imageIndex=-1, enabled=True):
"""
Default class constructor.
:param `strCaption`: the tab caption;
:param `imageIndex`: the tab image index based on the assigned (set)
:class:`ImageList` (if any);
:param `enabled`: sets the tab as enabled or disabled.
"""
self._pos = wx.Point()
self._size = wx.Size()
self._strCaption = strCaption
self._ImageIndex = imageIndex
self._captionRect = wx.Rect()
self._bEnabled = enabled
python类Point()的实例源码
def _init_ctrls(self, prnt):
wx.Panel.__init__(self, id=ID_SEARCHRESULTPANEL,
name='SearchResultPanel', parent=prnt, pos=wx.Point(0, 0),
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
self.HeaderLabel = wx.StaticText(id=ID_SEARCHRESULTPANELHEADERLABEL,
name='HeaderLabel', parent=self,
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
search_results_tree_style = CT.TR_HAS_BUTTONS | CT.TR_NO_LINES | CT.TR_HAS_VARIABLE_ROW_HEIGHT
self.SearchResultsTree = CT.CustomTreeCtrl(id=ID_SEARCHRESULTPANELSEARCHRESULTSTREE,
name="SearchResultsTree", parent=self,
pos=wx.Point(0, 0), style=search_results_tree_style)
if wx.VERSION >= (2, 8, 11):
self.SearchResultsTree.SetAGWWindowStyleFlag(search_results_tree_style)
self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnSearchResultsTreeItemActivated,
id=ID_SEARCHRESULTPANELSEARCHRESULTSTREE)
self.ResetButton = wx.lib.buttons.GenBitmapButton(
self, bitmap=GetBitmap("reset"),
size=wx.Size(28, 28), style=wx.NO_BORDER)
self.ResetButton.SetToolTipString(_("Reset search result"))
self.Bind(wx.EVT_BUTTON, self.OnResetButton, self.ResetButton)
self._init_sizers()
def UpdateScrollPos(self, event):
if (event.Dragging() and self.SelectedElement is not None) or self.rubberBand.IsShown():
position = event.GetPosition()
move_window = wx.Point()
window_size = self.Editor.GetClientSize()
xstart, ystart = self.GetViewStart()
if position.x < SCROLL_ZONE and xstart > 0:
move_window.x = -1
elif position.x > window_size[0] - SCROLL_ZONE:
move_window.x = 1
if position.y < SCROLL_ZONE and ystart > 0:
move_window.y = -1
elif position.y > window_size[1] - SCROLL_ZONE:
move_window.y = 1
if move_window.x != 0 or move_window.y != 0:
self.RefreshVisibleElements(xp=xstart + move_window.x, yp=ystart + move_window.y)
self.Scroll(xstart + move_window.x, ystart + move_window.y)
self.RefreshScrollBars(move_window.x, move_window.y)
def _create_NetworkEditor(self, prnt):
self.NetworkEditor = wx.Panel(
id=-1, parent=prnt, pos=wx.Point(0, 0),
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
NetworkEditorTemplate._init_ctrls(self, self.NetworkEditor)
main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=1, vgap=0)
main_sizer.AddGrowableCol(0)
main_sizer.AddGrowableRow(0)
main_sizer.AddWindow(self.NetworkNodes, 0, border=5, flag=wx.GROW | wx.ALL)
self.NetworkEditor.SetSizer(main_sizer)
return self.NetworkEditor
def __init__(self, parent, name, initial=False, id=None):
Graphic_Element.__init__(self, parent)
DebugDataConsumer.__init__(self)
self.SetName(name)
self.Initial = initial
self.Id = id
self.Highlights = []
self.Size = wx.Size(SFC_STEP_DEFAULT_SIZE[0], SFC_STEP_DEFAULT_SIZE[1])
# Create an input and output connector
if not self.Initial:
self.Input = Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH)
else:
self.Input = None
self.Output = None
self.Action = None
self.PreviousValue = None
self.PreviousSpreading = False
def RefreshConnectors(self):
scaling = self.Parent.GetScaling()
horizontal_pos = self.Size[0] / 2
vertical_pos = self.Size[1] / 2
if scaling is not None:
horizontal_pos = round(float(self.Pos.x + horizontal_pos) / float(scaling[0])) * scaling[0] - self.Pos.x
vertical_pos = round(float(self.Pos.y + vertical_pos) / float(scaling[1])) * scaling[1] - self.Pos.y
# Update input position if it exists
if self.Input:
self.Input.SetPosition(wx.Point(horizontal_pos, 0))
# Update output position
if self.Output:
self.Output.SetPosition(wx.Point(horizontal_pos, self.Size[1]))
# Update action position if it exists
if self.Action:
self.Action.SetPosition(wx.Point(self.Size[0], vertical_pos))
self.RefreshConnected()
# Refresh the position of wires connected to step
def RefreshConnectors(self):
scaling = self.Parent.GetScaling()
horizontal_pos = self.Size[0] / 2
vertical_pos = self.Size[1] / 2
if scaling is not None:
horizontal_pos = round(float(self.Pos.x + horizontal_pos) / float(scaling[0])) * scaling[0] - self.Pos.x
vertical_pos = round(float(self.Pos.y + vertical_pos) / float(scaling[1])) * scaling[1] - self.Pos.y
# Update input position
self.Input.SetPosition(wx.Point(horizontal_pos, 0))
# Update output position
self.Output.SetPosition(wx.Point(horizontal_pos, self.Size[1]))
if self.Type == "connection":
self.Condition.SetPosition(wx.Point(0, vertical_pos))
self.RefreshConnected()
# Refresh the position of the wires connected to transition
def SetType(self, type, condition=None):
if self.Type != type:
if self.Type == "connection":
self.Condition.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
self.Type = type
if type == "connection":
self.Condition = Connector(self, "", "BOOL", wx.Point(0, self.Size[1] / 2), WEST)
else:
if condition is None:
condition = ""
self.Condition = condition
self.RefreshConditionSize()
elif self.Type != "connection":
if condition is None:
condition = ""
self.Condition = condition
self.RefreshConditionSize()
self.RefreshBoundingBox()
# Returns the transition type
def AddBranch(self):
if self.Type in [SELECTION_DIVERGENCE, SIMULTANEOUS_DIVERGENCE]:
maxx = 0
for output in self.Outputs:
pos = output.GetRelPosition()
maxx = max(maxx, pos.x)
connector = Connector(self, "", None, wx.Point(maxx + SFC_DEFAULT_SEQUENCE_INTERVAL, self.Size[1]), SOUTH, onlyone=True)
self.Outputs.append(connector)
self.MoveConnector(connector, 0)
elif self.Type in [SELECTION_CONVERGENCE, SIMULTANEOUS_CONVERGENCE]:
maxx = 0
for input in self.Inputs:
pos = input.GetRelPosition()
maxx = max(maxx, pos.x)
connector = Connector(self, "", None, wx.Point(maxx + SFC_DEFAULT_SEQUENCE_INTERVAL, 0), NORTH, onlyone=True)
self.Inputs.append(connector)
self.MoveConnector(connector, SFC_DEFAULT_SEQUENCE_INTERVAL)
# Remove a branch from the divergence
def SetSize(self, width, height):
height = self.GetMinSize()[1]
for i, input in enumerate(self.Inputs):
position = input.GetRelPosition()
if self.RealConnectors:
input.SetPosition(wx.Point(int(round(self.RealConnectors["Inputs"][i] * width)), 0))
else:
input.SetPosition(wx.Point(int(round(float(position.x)*float(width)/float(self.Size[0]))), 0))
input.MoveConnected()
for i, output in enumerate(self.Outputs):
position = output.GetRelPosition()
if self.RealConnectors:
output.SetPosition(wx.Point(int(round(self.RealConnectors["Outputs"][i] * width)), height))
else:
output.SetPosition(wx.Point(int(round(float(position.x)*float(width)/float(self.Size[0]))), height))
output.MoveConnected()
self.Size = wx.Size(width, height)
self.RefreshBoundingBox()
# Returns the divergence minimum size
def RefreshBoundingBox(self):
if len(self.Elements) > 0:
bbox = self.Elements[0].GetBoundingBox()
minx, miny = bbox.x, bbox.y
maxx = bbox.x + bbox.width
maxy = bbox.y + bbox.height
for element in self.Elements[1:]:
bbox = element.GetBoundingBox()
minx = min(minx, bbox.x)
miny = min(miny, bbox.y)
maxx = max(maxx, bbox.x + bbox.width)
maxy = max(maxy, bbox.y + bbox.height)
self.BoundingBox = wx.Rect(minx, miny, maxx - minx, maxy - miny)
else:
self.BoundingBox = wx.Rect(0, 0, 0, 0)
self.Pos = wx.Point(self.BoundingBox.x, self.BoundingBox.y)
self.Size = wx.Size(self.BoundingBox.width, self.BoundingBox.height)
# Forbids to change the group position
def DrawHighlightment(self, dc):
scalex, scaley = dc.GetUserScale()
dc.SetUserScale(1, 1)
dc.SetPen(MiterPen(HIGHLIGHTCOLOR))
dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
dc.SetLogicalFunction(wx.AND)
left = (self.Pos.x - 1) * scalex - 2
right = (self.Pos.x + self.Size[0] + 1) * scalex + 2
top = (self.Pos.y - 1) * scaley - 2
bottom = (self.Pos.y + self.Size[1] + 1) * scaley + 2
angle_top = (self.Pos.x + self.Size[0] - 9) * scalex + 2
angle_right = (self.Pos.y + 9) * scaley - 2
polygon = [wx.Point(left, top), wx.Point(angle_top, top),
wx.Point(right, angle_right), wx.Point(right, bottom),
wx.Point(left, bottom)]
dc.DrawPolygon(polygon)
dc.SetLogicalFunction(wx.COPY)
dc.SetUserScale(scalex, scaley)
# Draws the comment and its content
def MoveConnector(self, connector, movey):
position = connector.GetRelPosition()
connector.SetPosition(wx.Point(position.x, position.y + movey))
miny = self.Size[1]
maxy = 0
for connect in self.Connectors:
connect_pos = connect.GetRelPosition()
miny = min(miny, connect_pos.y - self.Extensions[0])
maxy = max(maxy, connect_pos.y - self.Extensions[0])
min_pos = self.Pos.y + miny
self.Pos.y = min(min_pos, self.Pos.y)
if min_pos == self.Pos.y:
for connect in self.Connectors:
connect_pos = connect.GetRelPosition()
connect.SetPosition(wx.Point(connect_pos.x, connect_pos.y - miny))
self.Connectors.sort(lambda x, y: cmp(x.Pos.y, y.Pos.y))
maxy = 0
for connect in self.Connectors:
connect_pos = connect.GetRelPosition()
maxy = max(maxy, connect_pos.y)
self.Size[1] = max(maxy + self.Extensions[1], self.Size[1])
connector.MoveConnected()
self.RefreshBoundingBox()
# Returns the index in connectors list for the connector given
def RefreshConnectors(self):
scaling = self.Parent.GetScaling()
# Calculate the size for the connector lines
lines = max(len(self.Inputs), len(self.Outputs))
if lines > 0:
linesize = max((self.Size[1] - BLOCK_LINE_SIZE) / lines, BLOCK_LINE_SIZE)
# Update inputs and outputs positions
position = BLOCK_LINE_SIZE + linesize / 2
for i in xrange(lines):
if scaling is not None:
ypos = round_scaling(self.Pos.y + position, scaling[1]) - self.Pos.y
else:
ypos = position
if i < len(self.Inputs):
self.Inputs[i].SetPosition(wx.Point(0, ypos))
if i < len(self.Outputs):
self.Outputs[i].SetPosition(wx.Point(self.Size[0], ypos))
position += linesize
self.RefreshConnected()
# Refresh the positions of wires connected to inputs and outputs
def SetType(self, type, value_type):
if type != self.Type:
self.Type = type
# Create an input or output connector according to variable type
if self.Type != INPUT:
if self.Input is None:
self.Input = Connector(self, "", value_type, wx.Point(0, 0), WEST, onlyone=True)
elif self.Input:
self.Input.UnConnect(delete=True)
self.Input = None
if self.Type != OUTPUT:
if self.Output is None:
self.Output = Connector(self, "", value_type, wx.Point(0, 0), EAST)
elif self.Output:
self.Output.UnConnect(delete=True)
self.Output = None
self.RefreshConnectors()
self.RefreshBoundingBox()
elif value_type != self.ValueType:
if self.Input:
self.Input.SetType(value_type)
if self.Output:
self.Output.SetType(value_type)
# Returns the variable type
def OnRightClick(self, event):
menu = wx.Menu()
tPopupID0 = wx.NewId()
tPopupID1 = wx.NewId()
tPopupID2 = wx.NewId()
tPopupID3 = wx.NewId()
tPopupID4 = wx.NewId()
tPopupID5 = wx.NewId()
menu.Append(tPopupID2, "Edit")
menu.Append(tPopupID0, "New")
menu.Append(tPopupID1, "Copy")
menu.AppendSeparator()
menu.Append(tPopupID3, "Delete")
menu.Append(tPopupID4, "Delete All")
wx.EVT_MENU(self, tPopupID2, self.OnPopupEdit)
wx.EVT_MENU(self, tPopupID0, self.OnPopupNew)
wx.EVT_MENU(self, tPopupID1, self.OnPopupCopy)
wx.EVT_MENU(self, tPopupID3, self.OnPopupDelete)
wx.EVT_MENU(self, tPopupID4, self.OnPopupDeleteAll)
if len(self.itemDataMap) == 0:
for m in menu.GetMenuItems():
m.Enable(False)
m = menu.FindItemById(tPopupID0)
m.Enable(True)
self.PopupMenu(menu, wx.Point(self.x, self.y))
menu.Destroy()
event.Skip()
def __init__(self, parent, name):
wxskinDialog.__init__(self, parent, -1, "Phonebook import")
self.SetAutoLayout(True)
self.function = 0
# Main window resizer object
border = wx.BoxSizer(wx.VERTICAL)
label = wx.StaticText(self, -1, "Name '%s' already exists in SIM phonebook.\n\nDo you want to overwrite exisiting, duplicate or skip!?" % (name))
border.Add(label, 1, wx.ALL, 10)
buttons = wx.BoxSizer(wx.HORIZONTAL)
buttons.Add(wx.Button(self, ID_BUTTON_OVERWRITE, "Overwrite"), 1, wx.ALIGN_LEFT | wx.ALL, 20)
buttons.Add(wx.Button(self, ID_BUTTON_COPY, "Duplicate"), 1, wx.ALIGN_RIGHT | wx.ALL, 20)
buttons.Add(wx.Button(self, ID_BUTTON_SKIP, "Skip"), 1, wx.ALIGN_RIGHT | wx.ALL, 20)
buttons.Add(wx.Button(self, wx.ID_CANCEL, "Cancel"), 1, wx.ALIGN_RIGHT | wx.ALL, 20)
border.Add(buttons, 1, wx.ALL)
self.applyAll = wx.CheckBox(self, ID_CHECKBOX_APPLY_ALL, " Apply to all", wx.Point(65, 40), wx.Size(150, 20), wx.NO_BORDER)
border.Add(self.applyAll, 1, wx.ALIGN_CENTER | wx.ALL)
wx.EVT_BUTTON(self, ID_BUTTON_OVERWRITE, self.onOverwrite)
wx.EVT_BUTTON(self, ID_BUTTON_COPY, self.onDuplicate)
wx.EVT_BUTTON(self, ID_BUTTON_SKIP, self.onSkip)
self.SetAutoLayout(1);
self.SetSizer(border)
border.Fit(self)
self.Layout()
def OnRightClick(self, event):
menu = wx.Menu()
tPopupID0 = wx.NewId()
tPopupID1 = wx.NewId()
tPopupID2 = wx.NewId()
tPopupID3 = wx.NewId()
tPopupID4 = wx.NewId()
tPopupID5 = wx.NewId()
menu.Append(tPopupID2, "Edit")
menu.Append(tPopupID0, "New")
menu.Append(tPopupID1, "Copy")
menu.AppendSeparator()
menu.Append(tPopupID3, "Delete")
menu.Append(tPopupID4, "Delete All")
wx.EVT_MENU(self, tPopupID2, self.OnPopupEdit)
wx.EVT_MENU(self, tPopupID0, self.OnPopupNew)
wx.EVT_MENU(self, tPopupID1, self.OnPopupCopy)
wx.EVT_MENU(self, tPopupID3, self.OnPopupDelete)
wx.EVT_MENU(self, tPopupID4, self.OnPopupDeleteAll)
if len(self.itemDataMap) == 0:
for m in menu.GetMenuItems():
m.Enable(False)
m = menu.FindItemById(tPopupID0)
m.Enable(True)
self.PopupMenu(menu, wx.Point(self.x, self.y))
menu.Destroy()
event.Skip()
def __init__(self, parent, name):
wxskinDialog.__init__(self, parent, -1, "Phonebook import")
self.SetAutoLayout(True)
self.function = 0
# Main window resizer object
border = wx.BoxSizer(wx.VERTICAL)
label = wx.StaticText(self, -1, "Name '%s' already exists in SIM phonebook.\n\nDo you want to overwrite exisiting, duplicate or skip!?" % (name))
border.Add(label, 1, wx.ALL, 10)
buttons = wx.BoxSizer(wx.HORIZONTAL)
buttons.Add(wx.Button(self, ID_BUTTON_OVERWRITE, "Overwrite"), 1, wx.ALIGN_LEFT | wx.ALL, 20)
buttons.Add(wx.Button(self, ID_BUTTON_COPY, "Duplicate"), 1, wx.ALIGN_RIGHT | wx.ALL, 20)
buttons.Add(wx.Button(self, ID_BUTTON_SKIP, "Skip"), 1, wx.ALIGN_RIGHT | wx.ALL, 20)
buttons.Add(wx.Button(self, wx.ID_CANCEL, "Cancel"), 1, wx.ALIGN_RIGHT | wx.ALL, 20)
border.Add(buttons, 1, wx.ALL)
self.applyAll = wx.CheckBox(self, ID_CHECKBOX_APPLY_ALL, " Apply to all", wx.Point(65, 40), wx.Size(150, 20), wx.NO_BORDER)
border.Add(self.applyAll, 1, wx.ALIGN_CENTER | wx.ALL)
wx.EVT_BUTTON(self, ID_BUTTON_OVERWRITE, self.onOverwrite)
wx.EVT_BUTTON(self, ID_BUTTON_COPY, self.onDuplicate)
wx.EVT_BUTTON(self, ID_BUTTON_SKIP, self.onSkip)
self.SetAutoLayout(1);
self.SetSizer(border)
border.Fit(self)
self.Layout()
def OnRightClick(self, event):
tsubPopupID1 = 10
tsubPopupID2 = 11
tsubPopupID3 = 12
submenu = wx.Menu()
submenu.Append(tsubPopupID1, "Read")
submenu.Append(tsubPopupID2, "Unread")
submenu.Append(tsubPopupID3, "Deleted")
wx.EVT_MENU(self, tsubPopupID1, self.OnPopupMarkRead)
wx.EVT_MENU(self, tsubPopupID2, self.OnPopupMarkUnread)
wx.EVT_MENU(self, tsubPopupID3, self.OnPopupMarkDeleted)
menu = wx.Menu()
tPopupID0 = wx.NewId()
tPopupID1 = wx.NewId()
tPopupID2 = wx.NewId()
tPopupID3 = wx.NewId()
tPopupID4 = wx.NewId()
tPopupID5 = wx.NewId()
menu.AppendMenu(tPopupID1, "Mark as", submenu)
menu.AppendSeparator()
menu.Append(tPopupID2, "Edit")
menu.Append(tPopupID0, "New")
menu.Append(tPopupID1, "Copy")
menu.AppendSeparator()
menu.Append(tPopupID3, "Delete")
menu.Append(tPopupID4, "Delete All")
wx.EVT_MENU(self, tPopupID2, self.OnPopupEdit)
wx.EVT_MENU(self, tPopupID0, self.OnPopupNew)
wx.EVT_MENU(self, tPopupID1, self.OnPopupCopy)
wx.EVT_MENU(self, tPopupID3, self.OnPopupDelete)
wx.EVT_MENU(self, tPopupID4, self.OnPopupDeleteAll)
self.PopupMenu(menu, wx.Point(self.x, self.y))
menu.Destroy()
event.Skip()
def SetPosition(self, value):
"""
Sets the tab position.
:param `value`: the new tab position, an instance of :class:`Point`.
"""
self._pos = value
def HitTest(self, pt):
"""
Returns the index of the tab at the specified position or ``wx.NOT_FOUND``
if ``None``, plus the flag style of :meth:`~ImageContainerBase.HitTest`.
:param `pt`: an instance of :class:`Point`, to test for hits.
:return: The index of the tab at the specified position plus the hit test
flag, which can be one of the following bits:
====================== ======= ================================
HitTest Flags Value Description
====================== ======= ================================
``IMG_OVER_IMG`` 0 The mouse is over the tab icon
``IMG_OVER_PIN`` 1 The mouse is over the pin button
``IMG_OVER_EW_BORDER`` 2 The mouse is over the east-west book border
``IMG_NONE`` 3 Nowhere
====================== ======= ================================
"""
style = self.GetParent().GetAGWWindowStyleFlag()
for i in reversed( xrange(len(self._pagesInfoVec)) ) :
if self._pagesInfoVec[i].GetPosition() == wx.Point(-1, -1):
break
# For Web Hover style, we test the TextRect
if not self.HasAGWFlag(INB_WEB_HILITE):
buttonRect = wx.RectPS(self._pagesInfoVec[i].GetPosition(), self._pagesInfoVec[i].GetSize())
else:
buttonRect = self._pagesInfoVec[i].GetTextRect()
if buttonRect.Contains(pt):
return i, IMG_OVER_IMG
return -1, IMG_NONE
def set_xy_limits(self, center=wx.Point(-9999, -9999)):
self.axes.set_xlim([center[0] - self.size_npix_xy[0]/2.0, center[0] + self.size_npix_xy[0]/2.0])
self.axes.set_ylim([center[1] - self.size_npix_xy[1]/2.0, center[1] + self.size_npix_xy[1]/2.0])
if getattr(self, "crosshair", None) is None:
self.crosshair = self.axes.plot([center[0]], [center[1]], 'gx', zorder=100, markersize=7)
else:
self.crosshair[0].set_data([center[0]], [center[1]])
self.figure.canvas.draw()
def set_xy_limits(self, center=wx.Point(-9999, -9999)):
self.axes.set_xlim([center[0] - self.size_npix_xy[0]/2.0, center[0] + self.size_npix_xy[0]/2.0])
self.axes.set_ylim([center[1] - self.size_npix_xy[1]/2.0, center[1] + self.size_npix_xy[1]/2.0])
if getattr(self, "crosshair", None) is None:
self.crosshair = self.axes.plot([center[0]], [center[1]], 'gx', zorder=100, markersize=7)
else:
self.crosshair[0].set_data([center[0]], [center[1]])
self.figure.canvas.draw()
def _init_ctrls(self, prnt):
wx.Frame.__init__(self, id=ID_HTMLFRAME, name='HtmlFrame',
parent=prnt, pos=wx.Point(320, 231), size=wx.Size(853, 616),
style=wx.DEFAULT_FRAME_STYLE, title='')
self.SetIcon(prnt.icon)
self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
self.HtmlContent = UrlClickHtmlWindow(id=ID_HTMLFRAMEHTMLCONTENT,
name='HtmlContent', parent=self, pos=wx.Point(0, 0),
size=wx.Size(-1, -1), style=wx.html.HW_SCROLLBAR_AUTO | wx.html.HW_NO_SELECTION)
self.HtmlContent.Bind(HtmlWindowUrlClick, self.OnLinkClick)
def __init__(self, parent, name, library, default=None):
wx.Dialog.__init__(self,
name='BrowseValueDialog', parent=parent,
style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
title=_('Browse %s values library') % name)
self.staticText1 = wx.StaticText(
label=_('Choose a value for %s:') % name, name='staticText1', parent=self,
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.ValuesLibrary = wx.TreeCtrl(
name='ValuesLibrary', parent=self, pos=wx.Point(0, 0),
size=wx.Size(400, 200), style=wx.TR_HAS_BUTTONS | wx.TR_SINGLE | wx.SUNKEN_BORDER | wx.TR_HIDE_ROOT | wx.TR_LINES_AT_ROOT)
self.ButtonSizer = self.CreateButtonSizer(wx.OK | wx.CANCEL | wx.CENTRE)
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10)
self.flexGridSizer1.AddWindow(self.staticText1, 0, border=20, flag=wx.GROW | wx.TOP | wx.LEFT | wx.RIGHT)
self.flexGridSizer1.AddWindow(self.ValuesLibrary, 0, border=20, flag=wx.GROW | wx.LEFT | wx.RIGHT)
self.flexGridSizer1.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT)
self.flexGridSizer1.AddGrowableCol(0)
self.flexGridSizer1.AddGrowableRow(1)
self.SetSizer(self.flexGridSizer1)
self.Fit()
root = self.ValuesLibrary.AddRoot("")
self.GenerateValuesLibraryBranch(root, library, default)
def OnProjectTreeMotion(self, event):
if not event.Dragging():
pt = wx.Point(event.GetX(), event.GetY())
item, flags = self.ProjectTree.HitTest(pt)
if item is not None and item.IsOk() and flags & wx.TREE_HITTEST_ONITEMLABEL:
item_infos = self.ProjectTree.GetPyData(item)
if item != self.LastToolTipItem and self.LastToolTipItem is not None:
self.ProjectTree.SetToolTip(None)
self.LastToolTipItem = None
if self.LastToolTipItem != item and \
item_infos["type"] in [ITEM_POU, ITEM_TRANSITION, ITEM_ACTION]:
bodytype = self.Controler.GetEditedElementBodyType(
item_infos["tagname"])
if item_infos["type"] == ITEM_POU:
block_type = {
"program": _("Program"),
"functionBlock": _("Function Block"),
"function": _("Function")
}[self.Controler.GetPouType(item_infos["name"])]
elif item_infos["type"] == ITEM_TRANSITION:
block_type = "Transition"
else:
block_type = "Action"
self.LastToolTipItem = item
wx.CallAfter(self.ProjectTree.SetToolTipString,
"%s : %s : %s" % (
block_type, bodytype, item_infos["name"]))
elif self.LastToolTipItem is not None:
self.ProjectTree.SetToolTip(None)
self.LastToolTipItem = None
event.Skip()
def ArrowPoints(direction, width, height, xoffset, yoffset):
if direction == wx.TOP:
return [wx.Point(xoffset + 1, yoffset + height - 2),
wx.Point(xoffset + width / 2, yoffset + 1),
wx.Point(xoffset + width - 1, yoffset + height - 2)]
else:
return [wx.Point(xoffset + 1, yoffset - height + 1),
wx.Point(xoffset + width / 2, yoffset - 2),
wx.Point(xoffset + width - 1, yoffset - height + 1)]
def __init__(self, label, callback):
self.Position = wx.Point(0, 0)
self.Size = wx.Size(*BUTTON_SIZE)
self.Label = label
self.Shown = True
self.Callback = callback
def SetPosition(self, x, y):
self.Position = wx.Point(x, y)