From 2315a7175b1e9ae236ae045e6b4ea8b848803ce6 Mon Sep 17 00:00:00 2001 From: cbeytas Date: Sun, 6 Jan 2019 23:16:20 -0500 Subject: [PATCH 01/32] Merge item hiding to CustomTreeCtrl Move item hiding from HyperTreeList to CustomTreeCtrl so that both trees can have the feature. Add a HideItemWindows() method to hide windows only for a specific item and its children. This is much faster than calling HideWindows(). Add context menu options to the CustomTreeCtrl demo so that Hiding can be tested. --- demo/agw/CustomTreeCtrl.py | 21 +++++++++ wx/lib/agw/customtreectrl.py | 84 +++++++++++++++++++++++++++++++++--- wx/lib/agw/hypertreelist.py | 74 ++++++------------------------- 3 files changed, 113 insertions(+), 66 deletions(-) diff --git a/demo/agw/CustomTreeCtrl.py b/demo/agw/CustomTreeCtrl.py index 8e0e04bd..bb47d199 100644 --- a/demo/agw/CustomTreeCtrl.py +++ b/demo/agw/CustomTreeCtrl.py @@ -1621,6 +1621,9 @@ class CustomTreeCtrl(CT.CustomTreeCtrl): item7 = menu.Append(wx.ID_ANY, "Disable item") + menu.AppendSeparator() + item14 = menu.Append(wx.ID_ANY, "Hide Item") + item15 = menu.Append(wx.ID_ANY, "Unhide All Items") menu.AppendSeparator() item8 = menu.Append(wx.ID_ANY, "Change item icons") menu.AppendSeparator() @@ -1648,6 +1651,8 @@ class CustomTreeCtrl(CT.CustomTreeCtrl): self.Bind(wx.EVT_MENU, self.OnItemPrepend, item11) self.Bind(wx.EVT_MENU, self.OnItemAppend, item12) self.Bind(wx.EVT_MENU, self.OnSeparatorInsert, item13) + self.Bind(wx.EVT_MENU, self.OnHideItem, item14) + self.Bind(wx.EVT_MENU, self.OnUnhideItems, item15) self.PopupMenu(menu) menu.Destroy() @@ -1724,6 +1729,22 @@ class CustomTreeCtrl(CT.CustomTreeCtrl): self.EnableItem(self.current, False) + def OnHideItem(self, event): + + self.HideItem(self.current) + event.Skip() + + + def OnUnhideItems(self, event): + + item = self.GetRootItem() + while item: + if item.IsHidden(): + self.HideItem(item, False) + item = self.GetNext(item) + event.Skip() + + def OnItemIcons(self, event): bitmaps = [self.itemdict["normal"], self.itemdict["selected"], diff --git a/wx/lib/agw/customtreectrl.py b/wx/lib/agw/customtreectrl.py index 0315aeb0..7f28cc03 100644 --- a/wx/lib/agw/customtreectrl.py +++ b/wx/lib/agw/customtreectrl.py @@ -100,6 +100,7 @@ to the standard :class:`TreeCtrl` behaviour this class supports: style (`New in version 0.9.3`); * Tooltips on long items when the horizontal space is low, via the ``TR_TOOLTIP_ON_LONG_ITEMS`` style (`New in version 0.9.3`). +* Hiding items And a lot more. Check the demo for an almost complete review of the functionalities. @@ -1650,6 +1651,7 @@ class GenericTreeItem(object): self._enabled = True # flag to enable/disable an item self._hypertext = False # indicates if the item is hypertext self._visited = False # visited state for an hypertext item + self._hidden = False # hidden items are not painted if self._type > 0: # do not construct the array for normal items @@ -2143,6 +2145,24 @@ class GenericTreeItem(object): return self._hypertext + def IsHidden(self): + """ Returns whether the item is hidden or not. """ + + return self._hidden + + + def Hide(self, hide): + """ + Hides/shows the item. Internal use only. + + :param `hide`: ``True`` to hide the item, ``False`` to show it. + + :note: Always use :meth:`CustomTreeCtrl.HideItem` instead to update the tree properly. + """ + + self._hidden = hide + + def GetParent(self): """ Gets the item parent (another instance of :class:`GenericTreeItem` or ``None`` for @@ -2216,11 +2236,12 @@ class GenericTreeItem(object): def IsExpanded(self): """ - Returns whether the item is expanded or not. + Returns whether the item is expanded or not. Hidden items always return False. :return: ``True`` if the item is expanded, ``False`` if it is collapsed. """ - + if self.IsHidden(): + return False return not self._isCollapsed @@ -2379,11 +2400,12 @@ class GenericTreeItem(object): def IsEnabled(self): """ - Returns whether the item is enabled or not. + Returns whether the item is enabled or not. Hidden items always return False. :return: ``True`` if the item is enabled, ``False`` if it is disabled. """ - + if self.IsHidden(): + return False return self._enabled @@ -2545,6 +2567,9 @@ class GenericTreeItem(object): :see: :meth:`CustomTreeCtrl.HitTest() ` method for the flags explanation. """ + # Hidden items are never evaluated. + if self.IsHidden(): + return None, flags # for a hidden root node, don't evaluate it, but do evaluate children if not (level == 0 and theCtrl.HasAGWFlag(TR_HIDE_ROOT)): @@ -4456,13 +4481,16 @@ class CustomTreeCtrl(wx.ScrolledWindow): def IsVisible(self, item): """ Returns whether the item is visible or not (i.e., its hierarchy is expanded - enough to show the item). + enough to show the item, and it has not been hidden). :param `item`: an instance of :class:`GenericTreeItem`. :return: ``True`` if the item is visible, ``False`` if it is hidden. """ - + # Hidden items are never visible. + if item.IsHidden(): + return False + # An item is only visible if it's not a descendant of a collapsed item parent = item.GetParent() @@ -5583,6 +5611,39 @@ class CustomTreeCtrl(wx.ScrolledWindow): wnd.Hide() + def HideItemWindows(self, item): + """Hide all windows belonging to the item and its children.""" + wnd = item.GetWindow() + if wnd: + wnd.Hide() + for child in item.GetChildren(): + self.HideItemWindows(child) + + + def HideItem(self, item, hide=True): + """ + Hides/shows an item. + + :param `item`: an instance of :class:`GenericTreeItem`; + :param `hide`: ``True`` to hide the item, ``False`` to show it. + + :note: A hidden item always reports that it is collapsed and disabled. + """ + if hide == item.IsHidden(): + # Item already in correct state. Don't do anything. + return + item.Hide(hide) + + if hide is True and self._hasWindows: + # Hide all windows for this item and its children. + self.HideItemWindows(item) + + # Refresh the tree. + self.CalculatePositions() + self.Refresh() + self.AdjustMyScrollbars() + + def Unselect(self): """ Unselects the current selection. """ @@ -6865,6 +6926,9 @@ class CustomTreeCtrl(wx.ScrolledWindow): =============== ========================================= """ + # Don't paint hidden items. + if item.IsHidden(): + return y x = level*self._indent @@ -8222,6 +8286,11 @@ class CustomTreeCtrl(wx.ScrolledWindow): """ + if item.IsHidden(): + # Hidden items have a height of 0. + item.SetHeight(0) + return + attr = item.GetAttributes() if attr and attr.HasFont(): @@ -8336,6 +8405,9 @@ class CustomTreeCtrl(wx.ScrolledWindow): # set its position item.SetX(x+self._spacing) item.SetY(y) + # hidden items don't get a height (height=0). + if item.IsHidden(): + return y height = self.GetLineHeight(item) wnd = item.GetWindow() diff --git a/wx/lib/agw/hypertreelist.py b/wx/lib/agw/hypertreelist.py index 3143de20..892c6bd3 100644 --- a/wx/lib/agw/hypertreelist.py +++ b/wx/lib/agw/hypertreelist.py @@ -87,6 +87,7 @@ class supports: * Using an image as a :class:`HyperTreeList` background (currently only in "tile" mode); * Ellipsization of long items when the horizontal space is low, via the ``TR_ELLIPSIZE_LONG_ITEMS`` style (`New in version 0.9.3`). +* Hiding items And a lot more. Check the demo for an almost complete review of the functionalities. @@ -1325,7 +1326,6 @@ class TreeListItem(GenericTreeItem): self._col_images = [] self._owner = mainWin - self._hidden = False # We don't know the height here yet. self._text_x = 0 @@ -1338,23 +1338,6 @@ class TreeListItem(GenericTreeItem): self.SetWindow(wnd) - def IsHidden(self): - """ Returns whether the item is hidden or not. """ - - return self._hidden - - - def Hide(self, hide): - """ - Hides/shows the :class:`TreeListItem`. - - :param `hide`: ``True`` to hide the item, ``False`` to show it. - :note: Always use :meth:`~HyperTreeList.HideItem` instead to update the tree properly. - """ - - self._hidden = hide - - def DeleteChildren(self, tree): """ Deletes the item children. @@ -1783,27 +1766,6 @@ class TreeListItem(GenericTreeItem): return self._wnd[column].GetSize() - def IsExpanded(self): - """ - Returns whether the item is expanded or not. - - :return: ``True`` if the item is expanded, ``False`` if it is collapsed or hidden. - """ - if self.IsHidden(): - return False - return not self._isCollapsed - - - def IsEnabled(self): - """ - Returns whether the item is enabled or not. - - :return: ``True`` if the item is enabled, ``False`` if it is disabled or hidden. - """ - if self.IsHidden(): - return False - return self._enabled - #----------------------------------------------------------------------------- # EditTextCtrl (internal) #----------------------------------------------------------------------------- @@ -2308,8 +2270,6 @@ class TreeListMainWindow(CustomTreeCtrl): :param `item`: an instance of :class:`TreeListItem`; """ - if item.IsHidden(): - return False # An item is only visible if it's not a descendant of a collapsed item parent = item.GetParent() @@ -2624,6 +2584,18 @@ class TreeListMainWindow(CustomTreeCtrl): wnd.Hide() + def HideItemWindows(self, item): + """Hides all windows belonging to given item and its children.""" + # Hide windows for this item. + for column in range(self.GetColumnCount()): + wnd = item.GetWindow(column) + if wnd and wnd.IsShown(): + wnd.Hide() + # Hide its child windows. + for child in item.GetChildren(): + self.HideItemWindows(child) + + def EnableItem(self, item, enable=True, torefresh=True): """ Enables/disables an item. @@ -3124,7 +3096,7 @@ class TreeListMainWindow(CustomTreeCtrl): :param `y`: the current vertical position in the :class:`ScrolledWindow`; :param `x_maincol`: the horizontal position of the main column. """ - + # Don't paint hidden items. if item.IsHidden(): return y, x_maincol @@ -4151,24 +4123,6 @@ class TreeListMainWindow(CustomTreeCtrl): return max(10, width) # Prevent zero column width - def HideItem(self, item, hide=True): - """ - Hides/shows an item. - - :param `item`: an instance of :class:`TreeListItem`; - :param `hide`: ``True`` to hide the item, ``False`` to show it. - """ - - item.Hide(hide) - # Recalculate positions and hide child windows. - self.CalculatePositions() - if self._hasWindows: - self.HideWindows() - # Refresh the tree. - self.Refresh() - self.AdjustMyScrollbars() - - #---------------------------------------------------------------------------- # TreeListCtrl - the multicolumn tree control #---------------------------------------------------------------------------- From 91536178d689e99d118970f3bd7e8784f8f7ba2d Mon Sep 17 00:00:00 2001 From: cbeytas Date: Sun, 6 Jan 2019 23:26:16 -0500 Subject: [PATCH 02/32] Update CustomTreeCtrl and HyperTreeList docstrings Fix Sphinx formatting errors, eliminate duplication, and add a lot of notes and links. Document Drag/Drop, TR_HAS_VARIABLE_ROW_HEIGHT, and method delegation in HyperTreeList. --- wx/lib/agw/customtreectrl.py | 234 ++++++++++++-------- wx/lib/agw/hypertreelist.py | 414 ++++++++++++++++++++++------------- 2 files changed, 404 insertions(+), 244 deletions(-) diff --git a/wx/lib/agw/customtreectrl.py b/wx/lib/agw/customtreectrl.py index 7f28cc03..6a1adaf1 100644 --- a/wx/lib/agw/customtreectrl.py +++ b/wx/lib/agw/customtreectrl.py @@ -40,8 +40,8 @@ """ -:class:`~wx.lib.agw.customtreectrl.CustomTreeCtrl` is a class that mimics the behaviour of :class:`TreeCtrl`, with some more -enhancements. +The ``customtreectrl`` module contains the :class:`~wx.lib.agw.customtreectrl.CustomTreeCtrl` class +which mimics the behaviour of :class:`TreeCtrl`, with some more enhancements. Description @@ -219,6 +219,30 @@ And to hyperlink-type items: after the ``EVT_TREE_SEL_CHANGED`` event). +Drag and Drop +============= + +A simplified drag and drop is available and can be initiated by calling +``event.Allow`` on the ``EVT_TREE_BEGIN_DRAG`` or ``EVT_TREE_BEGIN_RDRAG`` +events. When the event handler returns, a ``wx.DragImage`` of the item will be +generated and the user can drag it to other items within the tree. When the +user releases the drag button a ``EVT_TREE_END_DRAG`` event will be sent and +``event.GetItem`` can be called to find out which item the drag ended at. +This simplified method is best when only a single item at a time needs to +be dragged (i.e. ``TR_MULTIPLE`` not set) and only for dragging items within +the tree control. + +Alternately, the normal wxPython drag/drop can be invoked in the ``EVT_TREE_BEGIN_DRAG`` +handler in which a :class:`wx.DropSource` must be generated, followed by a call +to :meth:`~wx.DropSource.DoDragDrop` which will block until the drag is finished. +This is much more flexible but more complicated to implement. + +:note: The class value _DRAG_TIMER_TICKS controls how long the mouse must + linger before the drag can start. It defaults to 250 milliseconds which can + be far too long for today's quick 'swiping' generation. It can be lowered for + a more responsive drag. + + Supported Platforms =================== @@ -231,33 +255,56 @@ Supported Platforms Window Styles ============= -This class supports the following window styles: +This class takes in a regular wxPython ``style`` and an extended ``agwStyle``. +The ``style`` can be used with normal wxPython styles such as ``wx.WANTS_CHARS`` +while the ``agwStyle`` specifies the behavior of the tree itself. +It supports the following ``agwStyle`` flags: -============================== =========== ================================================== -Window Styles Hex Value Description -============================== =========== ================================================== -``TR_NO_BUTTONS`` 0x0 For convenience to document that no buttons are to be drawn. -``TR_SINGLE`` 0x0 For convenience to document that only one item may be selected at a time. Selecting another item causes the current selection, if any, to be deselected. This is the default. -``TR_HAS_BUTTONS`` 0x1 Use this style to show + and - buttons to the left of parent items. -``TR_NO_LINES`` 0x4 Use this style to hide vertical level connectors. -``TR_LINES_AT_ROOT`` 0x8 Use this style to show lines between root nodes. Only applicable if ``TR_HIDE_ROOT`` is set and ``TR_NO_LINES`` is not set. -``TR_DEFAULT_STYLE`` 0x9 The set of flags that are closest to the defaults for the native control for a particular toolkit. -``TR_TWIST_BUTTONS`` 0x10 Use old Mac-twist style buttons. -``TR_MULTIPLE`` 0x20 Use this style to allow a range of items to be selected. If a second range is selected, the current range, if any, is deselected. -``TR_EXTENDED`` 0x40 Use this style to allow disjoint items to be selected. (Only partially implemented; may not work in all cases). -``TR_HAS_VARIABLE_ROW_HEIGHT`` 0x80 Use this style to cause row heights to be just big enough to fit the content. If not set, all rows use the largest row height. The default is that this flag is unset. -``TR_EDIT_LABELS`` 0x200 Use this style if you wish the user to be able to edit labels in the tree control. -``TR_ROW_LINES`` 0x400 Use this style to draw a contrasting border between displayed rows. -``TR_HIDE_ROOT`` 0x800 Use this style to suppress the display of the root node, effectively causing the first-level nodes to appear as a series of root nodes. -``TR_FULL_ROW_HIGHLIGHT`` 0x2000 Use this style to have the background colour and the selection highlight extend over the entire horizontal row of the tree control window. -``TR_AUTO_CHECK_CHILD`` 0x4000 Only meaningful for checkbox-type items: when a parent item is checked/unchecked its children are checked/unchecked as well. -``TR_AUTO_TOGGLE_CHILD`` 0x8000 Only meaningful for checkbox-type items: when a parent item is checked/unchecked its children are toggled accordingly. -``TR_AUTO_CHECK_PARENT`` 0x10000 Only meaningful for checkbox-type items: when a child item is checked/unchecked its parent item is checked/unchecked as well. -``TR_ALIGN_WINDOWS`` 0x20000 Flag used to align windows (in items with windows) at the same horizontal position. -``TR_ALIGN_WINDOWS_RIGHT`` 0x40000 Flag used to align windows (in items with windows) to the rightmost edge of :class:`CustomTreeCtrl`. -``TR_ELLIPSIZE_LONG_ITEMS`` 0x80000 Flag used to ellipsize long items when the horizontal space for :class:`CustomTreeCtrl` is low. -``TR_TOOLTIP_ON_LONG_ITEMS`` 0x100000 Flag used to show tooltips on long items when the horizontal space for :class:`CustomTreeCtrl` is low. -============================== =========== ================================================== +================================= =========== ================================================== +Window agwStyle Flags Hex Value Description +================================= =========== ================================================== +**wx.TR_DEFAULT_STYLE** *varies* The set of flags that are closest to the defaults for the native control for a particular toolkit. Should always be used. +``wx.TR_NO_BUTTONS`` 0x0 For convenience to document that no buttons are to be drawn. +``wx.TR_SINGLE`` 0x0 For convenience to document that only one item may be selected at a time. Selecting another item causes the current selection, if any, to be deselected. This is the default. +``wx.TR_HAS_BUTTONS`` 0x1 Use this style to show + and - buttons to the left of parent items. +``wx.TR_NO_LINES`` 0x4 Use this style to hide vertical level connectors. +``wx.TR_LINES_AT_ROOT`` 0x8 Use this style to show lines between root nodes. Only applicable if ``TR_HIDE_ROOT`` is set and ``TR_NO_LINES`` is not set. +``wx.TR_TWIST_BUTTONS`` 0x10 Use old Mac-twist style buttons. +``wx.TR_MULTIPLE`` 0x20 Use this style to allow a range of items to be selected. If a second range is selected, the current range, if any, is deselected. +``wx.TR_HAS_VARIABLE_ROW_HEIGHT`` 0x80 Use this style to cause row heights to be just big enough to fit the content. If not set, all rows use the largest row height. The default is that this flag is unset. +``wx.TR_EDIT_LABELS`` 0x200 Use this style if you wish the user to be able to edit labels in the tree control. +``wx.TR_ROW_LINES`` 0x400 Use this style to draw a contrasting border between displayed rows. +``wx.TR_HIDE_ROOT`` 0x800 Use this style to suppress the display of the root node, effectively causing the first-level nodes to appear as a series of root nodes. +``wx.TR_FULL_ROW_HIGHLIGHT`` 0x2000 Use this style to have the background colour and the selection highlight extend over the entire horizontal row of the tree control window. +**Styles from customtreectrl:** +``TR_EXTENDED`` 0x40 Use this style to allow disjoint items to be selected. (Only partially implemented; may not work in all cases). +``TR_AUTO_CHECK_CHILD`` 0x4000 Only meaningful for checkbox-type items: when a parent item is checked/unchecked its children are checked/unchecked as well. +``TR_AUTO_TOGGLE_CHILD`` 0x8000 Only meaningful for checkbox-type items: when a parent item is checked/unchecked its children are toggled accordingly. +``TR_AUTO_CHECK_PARENT`` 0x10000 Only meaningful for checkbox-type items: when a child item is checked/unchecked its parent item is checked/unchecked as well. +``TR_ALIGN_WINDOWS`` 0x20000 Flag used to align windows (in items with windows) at the same horizontal position. +``TR_ALIGN_WINDOWS_RIGHT`` 0x40000 Flag used to align windows (in items with windows) to the rightmost edge of :class:`CustomTreeCtrl`. +``TR_ELLIPSIZE_LONG_ITEMS`` 0x80000 Flag used to ellipsize long items when the horizontal space for :class:`CustomTreeCtrl` is low. +``TR_TOOLTIP_ON_LONG_ITEMS`` 0x100000 Flag used to show tooltips on long items when the horizontal space for :class:`CustomTreeCtrl` is low. +================================= =========== ================================================== + +The ``wx.TR_HAS_VARIABLE_LINE_HEIGHT`` style should be set if item rows might +not all be the same height. This can happen if certain rows have a larger font +size, multi-line text, or windows added to them. This style will automatically +adjust each item's height to be just big enough to show its contents. + +When the ``wx.TR_HAS_VARIABLE_LINE_HEIGHT`` is not set, adding a new item with +multi-line text or with a window specified will throw an exception. However the +tree won't prevent you from adding multiline text with :meth:`~TreeListMainWindow.SetItemText` +or assigning a window with :meth:`~TreeListMainWindow.SetItemWindow` to an +existing item. It's generally a bad idea to do either of these without this +style as it will result in an ugly tree. By default the ``wx.TR_HAS_VARIABLE_LINE_HEIGHT`` +is not set. This means that all item rows will use the same height. This is the +height of the largest item in the tree. If an item with a larger height is +added or revealed, ALL row heights will increase to this larger size. The +larger row height remains persistent even if the large items are hidden or +deleted. You must call :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.CalculateLineHeight` +to reset the row height. This somewhat bizarre behavior is why the ``wx.TR_HAS_VARIABLE_LINE_HEIGHT`` +style is almost always used. Events Processing @@ -1700,10 +1747,11 @@ class GenericTreeItem(object): :return: A Python list containing instances of :class:`GenericTreeItem`, representing this item's children. + :note: The returned value is a reference to the list of children - used internally by the tree. It is advised not to change this list - and to make a copy before calling other tree methods as they could - change the contents of the list. + used internally by the tree. It is advised not to change this list + and to make a copy before calling other tree methods as they could + change the contents of the list. """ return self._children @@ -1797,7 +1845,8 @@ class GenericTreeItem(object): :param integer `which`: the image kind. :see: :meth:`~GenericTreeItem.GetImage` for a description of the `which` parameter. - :note: Call :meth:`~CustomTreeCtrl.SetItemImage` instead to refresh the tree properly. + + :note: Call :meth:`CustomTreeCtrl.SetItemImage` instead to refresh the tree properly. """ self._images[which] = image @@ -1810,7 +1859,8 @@ class GenericTreeItem(object): :param integer `image`: an index within the left image list specifying the image to use for the item in the leftmost part of the client area. - :note: Call :meth:`~CustomTreeCtrl.SetItemLeftImage` instead to refresh the tree properly. + + :note: Call :meth:`CustomTreeCtrl.SetItemLeftImage` instead to refresh the tree properly. """ self._leftimage = image @@ -1831,7 +1881,8 @@ class GenericTreeItem(object): Sets whether an item has the 'plus' button. :param bool `has`: ``True`` to set the 'plus' button on the item, ``False`` otherwise. - :note: Call :meth:`~CustomTreeCtrl.SetItemHasChildren` instead to refresh the tree properly. + + :note: Call :meth:`CustomTreeCtrl.SetItemHasChildren` instead to refresh the tree properly. """ self._hasPlus = has @@ -1842,7 +1893,8 @@ class GenericTreeItem(object): Sets the item font bold. :parameter bool `bold`: ``True`` to have a bold font item, ``False`` otherwise. - :note: Call :meth:`~CustomTreeCtrl.SetItemBold` instead to refresh the tree properly. + + :note: Call :meth:`CustomTreeCtrl.SetItemBold` instead to refresh the tree properly. """ self._isBold = bold @@ -1853,7 +1905,8 @@ class GenericTreeItem(object): Sets the item font italic. :parameter bool `italic`: ``True`` to have an italic font item, ``False`` otherwise. - :note: Call :meth:`~CustomTreeCtrl.SetItemItalic` instead to refresh the tree properly. + + :note: Call :meth:`CustomTreeCtrl.SetItemItalic` instead to refresh the tree properly. """ self._isItalic = italic @@ -1892,20 +1945,29 @@ class GenericTreeItem(object): def GetHeight(self): - """ Returns the height of the item, in pixels. """ + """ Returns the height of the item, in pixels. + + This will be 0 when the item is first created and always 0 for hidden + items. It is updated when the item is calculated. + """ return self._height def GetWidth(self): - """ Returns the width of the item, in pixels. """ + """ Returns the width of the item's contents, in pixels. + + This is the width of the item's text plus the widths of the item's + image, checkbox, and window (if they exist). + A separator's width is the width of the entire client area. + """ return self._width def SetHeight(self, h): """ - Sets the item's height. + Sets the item's height. Used internally. :param integer `h`: an integer specifying the item's height, in pixels. """ @@ -1915,7 +1977,7 @@ class GenericTreeItem(object): def SetWidth(self, w): """ - Sets the item's width. + Sets the item's width. Used internally. :param integer `w`: an integer specifying the item's width, in pixels. """ @@ -1934,7 +1996,8 @@ class GenericTreeItem(object): on the left of text and overlapping the image. New in wxPython 4.0.4. :raise: `Exception` if the input `item` is a separator and `wnd` is not ``None``. - :note: Always use :meth:`~CustomTreeCtrl.SetItemWindow` instead to update the tree properly. + + :note: Always use :meth:`CustomTreeCtrl.SetItemWindow` instead to update the tree properly. """ if self.IsSeparator() and wnd is not None: @@ -1986,7 +2049,7 @@ class GenericTreeItem(object): def DeleteWindow(self): """ Deletes the window associated to the item (if any). Internal use only. - :note: Always use :meth:`~CustomTreeCtrl.DeleteItemWindow` instead to update the tree properly. + :note: Always use :meth:`CustomTreeCtrl.DeleteItemWindow` instead to update the tree properly. """ if self._wnd: @@ -2105,7 +2168,8 @@ class GenericTreeItem(object): must be unchecked. - If a radiobutton node becomes unchecked, then all of its child nodes will become inactive. - :note: Call :meth:`~CustomTreeCtrl.SetItemType` instead to refresh the tree properly. + + :note: Call :meth:`CustomTreeCtrl.SetItemType` instead to refresh the tree properly. """ self._type = ct_type @@ -2116,7 +2180,8 @@ class GenericTreeItem(object): Sets whether the item is hypertext or not. :param bool `hyper`: ``True`` to set hypertext behaviour, ``False`` otherwise. - :note: Call :meth:`~CustomTreeCtrl.SetItemHyperText` instead to refresh the tree properly. + + :note: Call :meth:`CustomTreeCtrl.SetItemHyperText` instead to refresh the tree properly. """ self._hypertext = hyper @@ -2127,7 +2192,8 @@ class GenericTreeItem(object): Sets whether an hypertext item was visited or not. :param bool `visited`: ``True`` to set a hypertext item as visited, ``False`` otherwise. - :note: Call :meth:`~CustomTreeCtrl.SetItemVisited` instead to refresh the tree properly. + + :note: Call :meth:`CustomTreeCtrl.SetItemVisited` instead to refresh the tree properly. """ self._visited = visited @@ -2188,7 +2254,7 @@ class GenericTreeItem(object): def Expand(self): """ Expands the item. Internal use only. - :note: Always use :meth:`~CustomTreeCtrl.Expand` instead to update the tree properly and send events. + :note: Always use :meth:`CustomTreeCtrl.Expand` instead to update the tree properly and send events. """ self._isCollapsed = False @@ -2197,7 +2263,7 @@ class GenericTreeItem(object): def Collapse(self): """ Collapses the item. Internal use only. - :note: Always use :meth:`~CustomTreeCtrl.Collapse` instead to update the tree properly and send events. + :note: Always use :meth:`CustomTreeCtrl.Collapse` instead to update the tree properly and send events. """ self._isCollapsed = True @@ -2208,7 +2274,8 @@ class GenericTreeItem(object): Sets the item focus/unfocus. :param bool `set`: ``True`` to set the focus to the item, ``False`` otherwise. - :note: Call :meth:`~CustomTreeCtrl.SelectItem` instead to update the tree properly and send events. + + :note: Call :meth:`CustomTreeCtrl.SelectItem` instead to update the tree properly and send events. """ self._hasHilight = set @@ -2351,7 +2418,8 @@ class GenericTreeItem(object): :param bool `checked`: ``True`` to check an item, ``False`` to uncheck it. :note: This is meaningful only for checkbox-like and radiobutton-like items. - :note: Always use :meth:`~CustomTreeCtrl.CheckItem` instead to update the tree properly and send events. + + :note: Always use :meth:`CustomTreeCtrl.CheckItem` instead to update the tree properly and send events. """ self._checked = checked @@ -2392,7 +2460,8 @@ class GenericTreeItem(object): Enables/disables the item. :param bool `enable`: ``True`` to enable the item, ``False`` to disable it. - :note: Call :meth:`~CustomTreeCtrl.EnableItem` instead to update the tree properly. + + :note: Call :meth:`CustomTreeCtrl.EnableItem` instead to update the tree properly. """ self._enabled = enable @@ -2464,7 +2533,8 @@ class GenericTreeItem(object): Deletes the item children. Internal use only. :param `tree`: the main :class:`CustomTreeCtrl` instance. - :note: Always use :meth:`~CustomTreeCtrl.DeleteChildren` instead to update the tree properly. + + :note: Always use :meth:`CustomTreeCtrl.DeleteChildren` instead to update the tree properly. """ for child in self._children: @@ -2497,7 +2567,8 @@ class GenericTreeItem(object): :param string `text`: the new item label. :raise: `Exception` if the item is a separator. - :note: Call :meth:`~CustomTreeCtrl.SetItemText` to refresh the tree properly. + + :note: Call :meth:`CustomTreeCtrl.SetItemText` to refresh the tree properly. """ if self.IsSeparator(): @@ -2566,6 +2637,8 @@ class GenericTreeItem(object): :param integer `level`: the item's level inside the tree hierarchy. :see: :meth:`CustomTreeCtrl.HitTest() ` method for the flags explanation. + + :return: A 2-tuple of (item, flags). The item may be ``None``. """ # Hidden items are never evaluated. if self.IsHidden(): @@ -2744,35 +2817,8 @@ class CustomTreeCtrl(wx.ScrolledWindow): chosen by either the windowing system or wxPython, depending on platform; :type `size`: tuple or :class:`wx.Size` :param integer `style`: the underlying :class:`ScrolledWindow` style; - :param integer `agwStyle`: the AGW-specific window style for :class:`CustomTreeCtrl`. It can be a - combination of the following bits: - - ============================== =========== ================================================== - Window Styles Hex Value Description - ============================== =========== ================================================== - ``TR_NO_BUTTONS`` 0x0 For convenience to document that no buttons are to be drawn. - ``TR_SINGLE`` 0x0 For convenience to document that only one item may be selected at a time. Selecting another item causes the current selection, if any, to be deselected. This is the default. - ``TR_HAS_BUTTONS`` 0x1 Use this style to show + and - buttons to the left of parent items. - ``TR_NO_LINES`` 0x4 Use this style to hide vertical level connectors. - ``TR_LINES_AT_ROOT`` 0x8 Use this style to show lines between root nodes. Only applicable if ``TR_HIDE_ROOT`` is set and ``TR_NO_LINES`` is not set. - ``TR_DEFAULT_STYLE`` 0x9 The set of flags that are closest to the defaults for the native control for a particular toolkit. - ``TR_TWIST_BUTTONS`` 0x10 Use old Mac-twist style buttons. - ``TR_MULTIPLE`` 0x20 Use this style to allow a range of items to be selected. If a second range is selected, the current range, if any, is deselected. - ``TR_EXTENDED`` 0x40 Use this style to allow disjoint items to be selected. (Only partially implemented; may not work in all cases). - ``TR_HAS_VARIABLE_ROW_HEIGHT`` 0x80 Use this style to cause row heights to be just big enough to fit the content. If not set, all rows use the largest row height. The default is that this flag is unset. - ``TR_EDIT_LABELS`` 0x200 Use this style if you wish the user to be able to edit labels in the tree control. - ``TR_ROW_LINES`` 0x400 Use this style to draw a contrasting border between displayed rows. - ``TR_HIDE_ROOT`` 0x800 Use this style to suppress the display of the root node, effectively causing the first-level nodes to appear as a series of root nodes. - ``TR_FULL_ROW_HIGHLIGHT`` 0x2000 Use this style to have the background colour and the selection highlight extend over the entire horizontal row of the tree control window. - ``TR_AUTO_CHECK_CHILD`` 0x4000 Only meaningful for checkbox-type items: when a parent item is checked/unchecked its children are checked/unchecked as well. - ``TR_AUTO_TOGGLE_CHILD`` 0x8000 Only meaningful for checkbox-type items: when a parent item is checked/unchecked its children are toggled accordingly. - ``TR_AUTO_CHECK_PARENT`` 0x10000 Only meaningful for checkbox-type items: when a child item is checked/unchecked its parent item is checked/unchecked as well. - ``TR_ALIGN_WINDOWS`` 0x20000 Flag used to align windows (in items with windows) at the same horizontal position. - ``TR_ALIGN_WINDOWS_RIGHT`` 0x40000 Flag used to align windows (in items with windows) to the rightmost edge of :class:`CustomTreeCtrl`. - ``TR_ELLIPSIZE_LONG_ITEMS`` 0x80000 Flag used to ellipsize long items when the horizontal space for :class:`CustomTreeCtrl` is low. - ``TR_TOOLTIP_ON_LONG_ITEMS`` 0x100000 Flag used to show tooltips on long items when the horizontal space for :class:`CustomTreeCtrl` is low. - ============================== =========== ================================================== - + :param integer `agwStyle`: can be a combination of various bits. See + :mod:`~wx.lib.agw.customtreectrl` for a full list of flags. :param wx.Validator `validator`: window validator; :param string `name`: window name. """ @@ -3062,14 +3108,13 @@ class CustomTreeCtrl(wx.ScrolledWindow): def GetSelection(self): """ - Returns the current selection. + Returns the current selected item (i.e. focused item). :return: An instance of :class:`GenericTreeItem`. - :note: - - This method is valid only with the style ``TR_SINGLE`` set. Use - :meth:`~CustomTreeCtrl.GetSelections` for multiple-selections trees. + :note: Similar to GetFocusedItem of wx.TreeCtrl. Use + :meth:`~CustomTreeCtrl.GetSelections` for obtaining all items + selected in multiple-selection trees (i.e. TR_MULTIPLE flag set). """ return self._current @@ -6135,7 +6180,13 @@ class CustomTreeCtrl(wx.ScrolledWindow): def CalculateLineHeight(self): - """ Calculates the height of a line. """ + """Calculates the base height for all lines in the tree. + + Only used if the TR_HAS_VARIABLE_ROW_HEIGHT style is not used. + This base line height gets adjusted to the max line height + of all items as they are displayed. All rows use this largest + height until this method is called to reset it. + """ dc = wx.ClientDC(self) self._lineHeight = dc.GetCharHeight() @@ -7750,6 +7801,13 @@ class CustomTreeCtrl(wx.ScrolledWindow): :note: The rectangle coordinates are logical, not physical ones. So, for example, the `x` coordinate may be negative if the tree has a horizontal scrollbar and its position is not ``0``. + + .. warning:: The ``textOnly`` flag is currently ignored and this method + always returns the rectangle including the item's image, checkbox, + and window (if they exist) along with the item's text. A separator's + bounding box stretches the width of the entire client area. The height + may be 0 for newly added items until :meth:`CustomTreeCtrl.CalculateSize` + is called while the tree is not frozen. """ i = item @@ -7803,7 +7861,7 @@ class CustomTreeCtrl(wx.ScrolledWindow): def GetEditControl(self): """ - Returns a pointer to the edit :class:`TreeTextCtrl` if the item is being edited or + Returns a reference to the edit :class:`TreeTextCtrl` if the item is being edited or ``None`` otherwise (it is assumed that no more than one item may be edited simultaneously). """ diff --git a/wx/lib/agw/hypertreelist.py b/wx/lib/agw/hypertreelist.py index 892c6bd3..9df036e6 100644 --- a/wx/lib/agw/hypertreelist.py +++ b/wx/lib/agw/hypertreelist.py @@ -42,10 +42,23 @@ """ -:class:`~wx.lib.agw.hypertreelist.HyperTreeList` is a class that combines the -multicolumn features of a :class:`wx.ListCtrl` in report mode with the -hierarchical features of a :class:`wx.TreeCtrl`. Although it looks more like a -:class:`wx.ListCtrl`, the API tends to follow the API of :class:`wx.TreeCtrl`. +The ``hypertreelist`` module contains the :class:`~wx.lib.agw.hypertreelist.HyperTreeList` class +that combines the multicolumn features of a :class:`wx.ListCtrl` in report mode +with the hierarchical features of a :class:`wx.TreeCtrl`. Although it looks +more like a :class:`wx.ListCtrl`, the API tends to follow the API of +:class:`wx.TreeCtrl`. + +The :class:`~wx.lib.agw.hypertreelist.HyperTreeList` class actually consists of +two sub-windows: + +* :class:`TreeListHeaderWindow` displays the column headers. +* :class:`TreeListMainWindow` is the main tree list based off :class:`~wx.lib.agw.customtreectrl.CustomTreeCtrl`. + +These widgets can be obtained by the :meth:`~HyperTreeList.GetHeaderWindow` +and :meth:`~HyperTreeList.GetMainWindow` methods respectively althought this +shouldn't be needed in normal usage because most of the methods of the +sub-windows are monkey-patched and can be called directly from the +:class:`~wx.lib.agw.hypertreelist.HyperTreeList` itself. Description @@ -80,7 +93,7 @@ class supports: * Column headers are fully customizable in terms of icons, colour, font, alignment etc...; * Default selection style, gradient (horizontal/vertical) selection style and Windows Vista selection style; -* Customized drag and drop images built on the fly; +* Customized drag and drop images built on the fly (see :mod:`~wx.lib.agw.customtreectrl` for more info); * Setting the :class:`HyperTreeList` item buttons to a personalized imagelist; * Setting the :class:`HyperTreeList` check/radio item icons to a personalized imagelist; * Changing the style of the lines that connect the items (in terms of :class:`wx.Pen` styles); @@ -95,7 +108,7 @@ And a lot more. Check the demo for an almost complete review of the functionalit Base Functionalities ==================== -:class:`HyperTreeList` supports all the :class:`wx.TreeCtrl` styles, except: +:class:`HyperTreeList` supports all the :mod:`~wx.lib.agw.customtreectrl` styles, except: - ``TR_EXTENDED``: supports for this style is on the todo list (Am I sure of this?). @@ -131,30 +144,32 @@ Usage example:: class MyFrame(wx.Frame): - def __init__(self, parent): + def __init__(self): + wx.Frame.__init__(self, None, title="HyperTreeList Demo") - wx.Frame.__init__(self, parent, -1, "HyperTreeList Demo") + tree = HTL.HyperTreeList(self, agwStyle=wx.TR_DEFAULT_STYLE | + HTL.TR_ELLIPSIZE_LONG_ITEMS) + tree.AddColumn("Tree Column", width=200) + tree.AddColumn("Column 1", width=200, flag=wx.ALIGN_LEFT) + root = tree.AddRoot("Root") - tree_list = HTL.HyperTreeList(self) + parent = tree.AppendItem(root, "First child") + tree.SetItemText(parent, "Child of root", column=1) + + child = tree.AppendItem(parent, "First Grandchild") + tree.SetItemText(child, "Column1 Text", column=1) - tree_list.AddColumn("First column") - - root = tree_list.AddRoot("Root") - - parent = tree_list.AppendItem(root, "First child") - child = tree_list.AppendItem(parent, "First Grandchild") - - tree_list.AppendItem(root, "Second child") + child2 = tree.AppendItem(root, "Second child") + button = wx.Button(tree.GetMainWindow(), label="Button1") + tree.SetItemWindow(child2, button, column=1) # our normal wxApp-derived class, as usual - - app = wx.App(0) - - frame = MyFrame(None) + app = wx.App(redirect=False) + locale = wx.Locale(wx.LANGUAGE_DEFAULT) + frame = MyFrame() app.SetTopWindow(frame) frame.Show() - app.MainLoop() @@ -162,8 +177,8 @@ Usage example:: Events ====== -All the events supported by :class:`wx.TreeCtrl` and some from :class:`wx.ListCtrl` are -also available in :class:`HyperTreeList`, with a few exceptions: +All the events supported by :mod:`~wx.lib.agw.customtreectrl` are also +available in :class:`HyperTreeList`, with a few exceptions: - ``EVT_TREE_GET_INFO`` (don't know what this means); - ``EVT_TREE_SET_INFO`` (don't know what this means); @@ -193,34 +208,40 @@ Supported Platforms Window Styles ============= -This class supports the following window styles: +The :class:`HyperTreeList` class takes a regular wxPython ``style`` and an +extended ``agwStyle``. The ``style`` can be used with normal wxPython styles +such as ``wx.WANTS_CHARS`` while the ``agwStyle`` specifies the behavior of the +tree itself. It supports the following ``agwStyle`` flags: -============================== =========== ================================================== -Window Styles Hex Value Description -============================== =========== ================================================== -``TR_NO_BUTTONS`` 0x0 For convenience to document that no buttons are to be drawn. -``TR_SINGLE`` 0x0 For convenience to document that only one item may be selected at a time. Selecting another item causes the current selection, if any, to be deselected. This is the default. -``TR_HAS_BUTTONS`` 0x1 Use this style to show + and - buttons to the left of parent items. -``TR_NO_LINES`` 0x4 Use this style to hide vertical level connectors. -``TR_LINES_AT_ROOT`` 0x8 Use this style to show lines between root nodes. Only applicable if ``TR_HIDE_ROOT`` is set and ``TR_NO_LINES`` is not set. -``TR_DEFAULT_STYLE`` 0x9 The set of flags that are closest to the defaults for the native control for a particular toolkit. -``TR_TWIST_BUTTONS`` 0x10 Use old Mac-twist style buttons. -``TR_MULTIPLE`` 0x20 Use this style to allow a range of items to be selected. If a second range is selected, the current range, if any, is deselected. -``TR_EXTENDED`` 0x40 Use this style to allow disjoint items to be selected. (Only partially implemented; may not work in all cases). -``TR_HAS_VARIABLE_ROW_HEIGHT`` 0x80 Use this style to cause row heights to be just big enough to fit the content. If not set, all rows use the largest row height. The default is that this flag is unset. -``TR_EDIT_LABELS`` 0x200 Use this style if you wish the user to be able to edit labels in the tree control. -``TR_ROW_LINES`` 0x400 Use this style to draw a contrasting border between displayed rows. -``TR_HIDE_ROOT`` 0x800 Use this style to suppress the display of the root node, effectively causing the first-level nodes to appear as a series of root nodes. -``TR_COLUMN_LINES`` 0x1000 Use this style to draw a contrasting border between displayed columns. -``TR_FULL_ROW_HIGHLIGHT`` 0x2000 Use this style to have the background colour and the selection highlight extend over the entire horizontal row of the tree control window. -``TR_AUTO_CHECK_CHILD`` 0x4000 Only meaningful for checkbox-type items: when a parent item is checked/unchecked its children are checked/unchecked as well. -``TR_AUTO_TOGGLE_CHILD`` 0x8000 Only meaningful for checkbox-type items: when a parent item is checked/unchecked its children are toggled accordingly. -``TR_AUTO_CHECK_PARENT`` 0x10000 Only meaningful for checkbox-type items: when a child item is checked/unchecked its parent item is checked/unchecked as well. -``TR_ALIGN_WINDOWS`` 0x20000 Flag used to align windows (in items with windows) at the same horizontal position. -``TR_NO_HEADER`` 0x40000 Use this style to hide the columns header. -``TR_ELLIPSIZE_LONG_ITEMS`` 0x80000 Flag used to ellipsize long items when the horizontal space for :class:`HyperTreeList` columns is low. -``TR_VIRTUAL`` 0x100000 :class:`HyperTreeList` will have virtual behaviour. -============================== =========== ================================================== +================================= =========== ================================================== +Window agwStyle Flags Hex Value Description +================================= =========== ================================================== +**wx.TR_DEFAULT_STYLE** *varies* The set of flags that are closest to the defaults for the native control for a particular toolkit. Should always be used. +``wx.TR_NO_BUTTONS`` 0x0 For convenience to document that no buttons are to be drawn. +``wx.TR_SINGLE`` 0x0 For convenience to document that only one item may be selected at a time. Selecting another item causes the current selection, if any, to be deselected. This is the default. +``wx.TR_HAS_BUTTONS`` 0x1 Use this style to show + and - buttons to the left of parent items. +``wx.TR_NO_LINES`` 0x4 Use this style to hide vertical level connectors. +``wx.TR_LINES_AT_ROOT`` 0x8 Use this style to show lines between root nodes. Only applicable if ``TR_HIDE_ROOT`` is set and ``TR_NO_LINES`` is not set. +``wx.TR_TWIST_BUTTONS`` 0x10 Use old Mac-twist style buttons. +``wx.TR_MULTIPLE`` 0x20 Use this style to allow a range of items to be selected. If a second range is selected, the current range, if any, is deselected. +``wx.TR_HAS_VARIABLE_ROW_HEIGHT`` 0x80 Use this style to cause row heights to be just big enough to fit the content. If not set, all rows use the largest row height. The default is that this flag is unset. +``wx.TR_EDIT_LABELS`` 0x200 Use this style if you wish the user to be able to edit labels in the tree control. +``wx.TR_ROW_LINES`` 0x400 Use this style to draw a contrasting border between displayed rows. +``wx.TR_HIDE_ROOT`` 0x800 Use this style to suppress the display of the root node, effectively causing the first-level nodes to appear as a series of root nodes. +``wx.TR_FULL_ROW_HIGHLIGHT`` 0x2000 Use this style to have the background colour and the selection highlight extend over the entire horizontal row of the tree control window. +**Styles from hypertreelist:** +``TR_EXTENDED`` 0x40 Use this style to allow disjoint items to be selected. (Only partially implemented; may not work in all cases). +``TR_COLUMN_LINES`` 0x1000 Use this style to draw a contrasting border between displayed columns. +``TR_AUTO_CHECK_CHILD`` 0x4000 Only meaningful for checkbox-type items: when a parent item is checked/unchecked its children are checked/unchecked as well. +``TR_AUTO_TOGGLE_CHILD`` 0x8000 Only meaningful for checkbox-type items: when a parent item is checked/unchecked its children are toggled accordingly. +``TR_AUTO_CHECK_PARENT`` 0x10000 Only meaningful for checkbox-type items: when a child item is checked/unchecked its parent item is checked/unchecked as well. +``TR_ALIGN_WINDOWS`` 0x20000 Has no effect in HyperTreeList. +``TR_NO_HEADER`` 0x40000 Use this style to hide the columns header. +``TR_ELLIPSIZE_LONG_ITEMS`` 0x80000 Flag used to ellipsize long items when the horizontal space for :class:`HyperTreeList` columns is low. +``TR_VIRTUAL`` 0x100000 :class:`HyperTreeList` will have virtual behaviour. +================================= =========== ================================================== + +See :mod:`~wx.lib.agw.customtreectrl` for more information on styles. Events Processing @@ -236,7 +257,7 @@ Event Name Description ``EVT_LIST_COL_DRAGGING`` The divider between columns is being dragged. ``EVT_LIST_COL_END_DRAG`` A column has been resized by the user. ``EVT_LIST_COL_RIGHT_CLICK`` A column has been right-clicked. -``EVT_TREE_BEGIN_DRAG`` Begin dragging with the left mouse button. +``EVT_TREE_BEGIN_DRAG`` Begin dragging with the left mouse button. See :mod:`wx.lib.agw.customtreectrl` Drag/Drop section for more information. ``EVT_TREE_BEGIN_LABEL_EDIT`` Begin editing a label. This can be prevented by calling :meth:`TreeEvent.Veto() `. ``EVT_TREE_BEGIN_RDRAG`` Begin dragging with the right mouse button. ``EVT_TREE_DELETE_ITEM`` Delete an item. @@ -660,7 +681,7 @@ class TreeListHeaderWindow(wx.Window): :param `buffered`: ``True`` to use double-buffering, ``False`` otherwise. - :note: Currently we are using double-buffering only on Windows XP. + :note: Currently double-buffering is only enabled by default for Windows XP. """ self._buffered = buffered @@ -1380,6 +1401,8 @@ class TreeListItem(GenericTreeItem): :param `level`: the item's level inside the tree hierarchy. :see: :meth:`TreeListMainWindow.HitTest() ` method for the flags explanation. + + :return: A 3-tuple of (item, flags, column). The item may be ``None``. """ # Hidden items are never evaluated. if self.IsHidden(): @@ -1569,7 +1592,8 @@ class TreeListItem(GenericTreeItem): :param `column`: if not ``None``, an integer specifying the column index. If it is ``None``, the main column index is used; :param `text`: a string specifying the new item label. - :note: Call :meth:`~HyperTreeList.SetItemText` instead to refresh the tree properly. + + :note: Call :meth:`~TreeListMainWindow.SetItemText` instead to refresh the tree properly. """ column = (column is not None and [column] or [self._owner.GetMainColumn()])[0] @@ -1591,7 +1615,8 @@ class TreeListItem(GenericTreeItem): :param `which`: the item state. :see: :meth:`~TreeListItem.GetImage` for a list of valid item states. - :note: Call :meth:`~HyperTreeList.SetItemImage` instead to refresh the tree properly. + + :note: Call :meth:`~TreeListMainWindow.SetItemImage` instead to refresh the tree properly. """ column = (column is not None and [column] or [self._owner.GetMainColumn()])[0] @@ -1629,7 +1654,8 @@ class TreeListItem(GenericTreeItem): :param `wnd`: a non-toplevel window to be displayed next to the item; :param `column`: if not ``None``, an integer specifying the column index. If it is ``None``, the main column index is used. - :note: Always use :meth:`~HyperTreeList.SetItemWindow` instead to update the tree properly. + + :note: Always use :meth:`~TreeListMainWindow.SetItemWindow` instead to update the tree properly. """ column = (column is not None and [column] or [self._owner.GetMainColumn()])[0] @@ -2039,35 +2065,8 @@ class TreeListMainWindow(CustomTreeCtrl): :param `size`: the control size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxPython, depending on platform; :param `style`: the underlying :class:`ScrolledWindow` style; - :param `agwStyle`: the AGW-specific :class:`TreeListMainWindow` window style. This can be a - combination of the following bits: - - ============================== =========== ================================================== - Window Styles Hex Value Description - ============================== =========== ================================================== - ``TR_NO_BUTTONS`` 0x0 For convenience to document that no buttons are to be drawn. - ``TR_SINGLE`` 0x0 For convenience to document that only one item may be selected at a time. Selecting another item causes the current selection, if any, to be deselected. This is the default. - ``TR_HAS_BUTTONS`` 0x1 Use this style to show + and - buttons to the left of parent items. - ``TR_NO_LINES`` 0x4 Use this style to hide vertical level connectors. - ``TR_LINES_AT_ROOT`` 0x8 Use this style to show lines between root nodes. Only applicable if ``TR_HIDE_ROOT`` is set and ``TR_NO_LINES`` is not set. - ``TR_DEFAULT_STYLE`` 0x9 The set of flags that are closest to the defaults for the native control for a particular toolkit. - ``TR_TWIST_BUTTONS`` 0x10 Use old Mac-twist style buttons. - ``TR_MULTIPLE`` 0x20 Use this style to allow a range of items to be selected. If a second range is selected, the current range, if any, is deselected. - ``TR_EXTENDED`` 0x40 Use this style to allow disjoint items to be selected. (Only partially implemented; may not work in all cases). - ``TR_HAS_VARIABLE_ROW_HEIGHT`` 0x80 Use this style to cause row heights to be just big enough to fit the content. If not set, all rows use the largest row height. The default is that this flag is unset. - ``TR_EDIT_LABELS`` 0x200 Use this style if you wish the user to be able to edit labels in the tree control. - ``TR_ROW_LINES`` 0x400 Use this style to draw a contrasting border between displayed rows. - ``TR_HIDE_ROOT`` 0x800 Use this style to suppress the display of the root node, effectively causing the first-level nodes to appear as a series of root nodes. - ``TR_FULL_ROW_HIGHLIGHT`` 0x2000 Use this style to have the background colour and the selection highlight extend over the entire horizontal row of the tree control window. - ``TR_AUTO_CHECK_CHILD`` 0x4000 Only meaningful for checkbox-type items: when a parent item is checked/unchecked its children are checked/unchecked as well. - ``TR_AUTO_TOGGLE_CHILD`` 0x8000 Only meaningful for checkbox-type items: when a parent item is checked/unchecked its children are toggled accordingly. - ``TR_AUTO_CHECK_PARENT`` 0x10000 Only meaningful for checkbox-type items: when a child item is checked/unchecked its parent item is checked/unchecked as well. - ``TR_ALIGN_WINDOWS`` 0x20000 Flag used to align windows (in items with windows) at the same horizontal position. - ``TR_NO_HEADER`` 0x40000 Use this style to hide the columns header. - ``TR_ELLIPSIZE_LONG_ITEMS`` 0x80000 Flag used to ellipsize long items when the horizontal space for :class:`~wx.lib.agw.customtreectrl.CustomTreeCtrl` is low. - ``TR_VIRTUAL`` 0x100000 :class:`HyperTreeList` will have virtual behaviour. - ============================== =========== ================================================== - + :param `agwStyle`: can be a combination of various bits. See + :mod:`~wx.lib.agw.hypertreelist` for a full list of flags. :param `validator`: window validator; :param `name`: window name. """ @@ -2222,9 +2221,9 @@ class TreeListMainWindow(CustomTreeCtrl): :param `column`: if not ``None``, an integer specifying the column index. If it is ``None``, the main column index is used. - :note: The window parent should not be the :class:`HyperTreeList` itself, but actually - an instance of :class:`TreeListMainWindow`. The current solution here is to reparent - the window to this class. + :note: The window being added should have its parent set to the :class:`TreeListMainWindow` + which can be obtained with :meth:`~HyperTreeList.GetHeaderWindow`. If this is not the case + the window will be re-parented which may cause some flicker. """ # Reparent the window to ourselves @@ -4127,6 +4126,8 @@ class TreeListMainWindow(CustomTreeCtrl): # TreeListCtrl - the multicolumn tree control #---------------------------------------------------------------------------- +## Monkey patch methods. Be sure to modify the docstring for HyperTreeList +## to reflect any changes to this list. _methods = ["GetIndent", "SetIndent", "GetSpacing", "SetSpacing", "GetImageList", "GetStateImageList", "GetButtonsImageList", "AssignImageList", "AssignStateImageList", "AssignButtonsImageList", "SetImageList", "SetButtonsImageList", "SetStateImageList", @@ -4165,16 +4166,171 @@ class HyperTreeList(wx.Control): as it is a full owner-drawn tree-list control. It manages two widgets internally: - :class:`TreeListHeaderWindow` - :class:`TreeListMainWindow` based off :class:`CustomTreeCtrl` + + * :class:`TreeListHeaderWindow` displays the column headers. + * :class:`TreeListMainWindow` is the main tree list based off :class:`~wx.lib.agw.customtreectrl.CustomTreeCtrl`. + These widgets can be obtained by the :meth:`~HyperTreeList.GetHeaderWindow` and :meth:`~HyperTreeList.GetMainWindow` methods respectively althought this shouldn't be needed in normal usage. - Please note that although the methods are not explicitly defined or - documented here, most of the API in :class:`TreeListMainWindow` and - :class:`CustomTreeCtrl` can be called directly from :class:`HyperTreeList` - via monkey-patched delegates. + Please note that in addition to the defined methods of :class:`HyperTreeList` + many more methods are delegated to the internal :class:`TreeListMainWindow` + and its subclass :class:`~wx.lib.agw.customtreectrl.CustomTreeCtrl`. These + methods can be called directly from the ``HyperTreeList`` class: + + ================================================================================ ================================================================================== + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.AddRoot` Adds a root item to the :class:`TreeListMainWindow`. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.AppendItem` Appends an item as a last child of its parent. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.AssignButtonsImageList` Assigns the button image list. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.AssignImageList` Assigns the normal image list. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.AssignStateImageList` Assigns the state image list. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.AutoCheckChild` Transverses the tree and checks/unchecks the items. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.AutoCheckParent` Traverses up the tree and checks/unchecks parent items. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.AutoToggleChild` Transverses the tree and toggles the items. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.CheckChilds` Programatically check/uncheck item children. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.CheckItem` Actually checks/uncheks an item, sending the two related events. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.CheckItem2` Used internally to avoid ``EVT_TREE_ITEM_CHECKED`` events. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.CheckSameLevel` Uncheck radio items which are on the same level of the checked one. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.Collapse` Collapse an item, sending the two related events. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.CollapseAndReset` Collapse the given item and deletes its children. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.Delete` Deletes an item. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.DeleteAllItems` Delete all items in the :class:`TreeListMainWindow`. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.DeleteChildren` Delete all the item's children. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.DeleteItemWindow` Deletes the window in the column associated to an item (if any). + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.DeleteRoot` Removes the tree root item (and subsequently all the items in the tree). + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.EditLabel` Starts editing an item label. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.EnableChildren` Enables/disables the item children. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.EnableItem` Enables/disables an item. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.EnableSelectionGradient` Globally enables/disables drawing of gradient selections. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.EnableSelectionVista` Globally enables/disables drawing of Windows Vista selections. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.EnsureVisible` Scrolls and/or expands items to ensure that the given item is visible. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.Expand` Expands an item, sending the two related events. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.ExpandAll` Expands all :class:`TreeListMainWindow` items. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.ExpandAllChildren` Expands all the items children of the input item. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.FindItem` Finds the first item starting with the given prefix after the given parent. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetBackgroundImage` Returns the :class:`TreeListMainWindow` background image (if any). + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetBorderPen` Returns the pen used to draw the selected item border. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetBoundingRect` Retrieves the rectangle bounding the item. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetButtonsImageList` Returns the buttons image list associated with :class:`TreeListMainWindow`. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetChildrenCount` Returns the item children count. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.GetColumnCount` Returns the total number of columns. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetConnectionPen` Returns the pen used to draw the connecting lines between items. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetCount` Returns the global number of items in the tree. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.GetCurrentItem` Returns the current item. Simply calls :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetSelection`. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetDisabledColour` Returns the colour for items in a disabled state. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetEditControl` Returns a reference to the edit :class:`~wx.lib.agw.customtreectrl.TreeTextCtrl` if the item is being edited. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetFirstChild` Returns the item's first child and an integer value 'cookie'. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.GetFirstExpandedItem` Returns the first item which is in the expanded state. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetFirstGradientColour` Returns the first gradient colour for gradient-style selections. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.GetFirstVisibleItem` Returns the first visible item. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetGradientStyle` Returns the gradient style for gradient-style selections. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetHilightFocusColour` Returns the colour used to highlight focused selected items. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetHilightNonFocusColour` Returns the colour used to highlight unfocused selected items. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetHyperTextFont` Returns the font used to render hypertext items. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetHyperTextNewColour` Returns the colour used to render a non-visited hypertext item. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetHyperTextVisitedColour` Returns the colour used to render a visited hypertext item. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetImageList` Returns the normal image list associated with :class:`TreeListMainWindow`. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetImageListCheck` Returns the ``wx.ImageList`` used for the check/radio buttons in :class:`TreeListMainWindow`. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetIndent` Returns the item indentation, in pixels. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetItem3StateValue` Gets the state of a 3-state checkbox item. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetItemBackgroundColour` Returns the item background colour. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetItemFont` Returns the item font. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.GetItemImage` Returns the item image. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetItemParent` Returns the item parent (can be ``None`` for root items). + GetItemPyData Another name for :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetPyData` + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.GetItemText` Returns the item text label. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetItemTextColour` Returns the item text colour or separator horizontal line colour. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetItemType` Returns the item type. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetItemVisited` Returns whether an hypertext item was visited. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.GetItemWindow` Returns the window associated with an item. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.GetItemWindowEnabled` Returns whether the window associated with an item is enabled or not. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetLastChild` Returns the item last child. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetNext` Returns the next item. Only for internal use right now. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetNextChild` Returns the item's next child. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.GetNextExpanded` Returns the next expanded item after the input one. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetNextShown` Returns the next displayed item in the tree, visible or not. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetNextSibling` Returns the next sibling of an item. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetNextVisible` Returns the next item that is visible to the user. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetPrev` Returns the previous item. Only for internal use right now. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.GetPrevChild` Returns the previous child of an item. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.GetPrevExpanded` Returns the previous expanded item before the input one. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetPrevShown` Returns the previous displayed item in the tree, visible or not. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetPrevSibling` Returns the previous sibling of an item. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.GetPrevVisible` Returns the previous item visible to the user. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetPyData` Returns the data associated to an item. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetRootItem` Returns the root item, an instance of :class:`GenericTreeItem`. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetSecondGradientColour` Returns the second gradient colour for gradient-style selections. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetSelection` Returns the current selection. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetSelections` Returns a list of selected items. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetSpacing` Returns the spacing between the start and the text, in pixels. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetStateImageList` Returns the state image list associated with :class:`TreeListMainWindow`. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.HasChildren` Returns whether an item has children or not. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.HideItem` Hides/shows an item. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.HitTest` Finds which (if any) item is under the given point, returning the item plus flags. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.InsertItem` Inserts an item after the given previous. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.IsBold` Returns whether the item font is bold or not. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.IsDescendantOf` Checks if the given item is under another one in the tree hierarchy. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.IsExpanded` Returns whether the item is expanded or not. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.IsItem3State` Returns whether or not the checkbox item is a 3-state checkbox. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.IsItemChecked` Returns whether an item is checked or not. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.IsItemEnabled` Returns whether an item is enabled or disabled. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.IsItemHyperText` Returns whether an item is hypertext or not. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.IsItemVisible` Returns whether the item is visible or not. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.IsSelected` Returns whether the item is selected or not. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.ItemHasChildren` Returns whether the item has children or not. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.PrependItem` Prepends an item as a first child of parent. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.ScrollTo` Scrolls the specified item into view. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SelectAll` Selects all the item in the tree. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SelectAllChildren` Selects all the children of the given item. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SelectItem` Selects/deselects an item. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetBackgroundImage` Sets the :class:`TreeListMainWindow` background image. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetBorderPen` Sets the pen used to draw the selected item border. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetButtonsImageList` Sets the buttons image list for :class:`TreeListMainWindow`. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetConnectionPen` Sets the pen used to draw the connecting lines between items. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetDisabledColour` Sets the colour for items in a disabled state. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.SetDragItem` Sets the specified item as member of a current drag and drop operation. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetFirstGradientColour` Sets the first gradient colour for gradient-style selections. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetGradientStyle` Sets the gradient style for gradient-style selections. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetHilightFocusColour` Sets the colour used to highlight focused selected items. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetHilightNonFocusColour` Sets the colour used to highlight unfocused selected items. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetHyperTextFont` Sets the font used to render hypertext items. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetHyperTextNewColour` Sets the colour used to render a non-visited hypertext item. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetHyperTextVisitedColour` Sets the colour used to render a visited hypertext item. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetImageList` Sets the normal image list for :class:`TreeListMainWindow`. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetImageListCheck` Sets the checkbox/radiobutton image list. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetIndent` Currently has no effect on ``HyperTreeList``. The indent is auto-calculated. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItem3State` Sets whether the item has a 3-state value checkbox assigned to it or not. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItem3StateValue` Sets the checkbox item to the given `state`. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemBackgroundColour` Sets the item background colour. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemBold` Sets the item font as bold/unbold. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemDropHighlight` Gives the item the visual feedback for drag and drop operations. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemFont` Sets the item font. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemHasChildren` Forces the appearance/disappearance of the button next to the item. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemHyperText` Sets whether the item is hypertext or not. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.SetItemImage` Sets the item image for a particular item state. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemItalic` Sets the item font as italic/non-italic. + SetItemPyData Another name for :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetPyData` + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.SetItemText` Sets the item text label. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemTextColour` Sets the item text colour or separator horizontal line colour. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemType` Sets the item type. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemVisited` Sets whether an hypertext item was visited. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.SetItemWindow` Sets the window associated to an item. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.SetItemWindowEnabled` Sets whether the window associated with an item is enabled or not. + :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.SetMainColumn` Sets the :class:`HyperTreeList` main column (i.e. the column of the tree). + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetPyData` Sets the data associated to an item. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetSecondGradientColour` Sets the second gradient colour for gradient-style selections. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetSpacing` Currently has no effect on ``HyperTreeList``. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetStateImageList` Sets the state image list for :class:`TreeListMainWindow` + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.ShouldInheritColours` Return ``True`` to allow the window colours to be changed by `InheritAttributes`. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.Toggle` Toggles the item state (collapsed/expanded). + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.ToggleItemSelection` Toggles the item selection. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.UnCheckRadioParent` Used internally to handle radio node parent correctly. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.Unselect` Unselects the current selection. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.UnselectAll` Unselect all the items. + ================================================================================ ================================================================================== + + """ def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, @@ -4190,36 +4346,8 @@ class HyperTreeList(wx.Control): :param `size`: the control size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxPython, depending on platform; :param `style`: the underlying :class:`wx.Control` style; - :param `agwStyle`: the AGW-specific :class:`HyperTreeList` window style. This can be a combination - of the following bits: - - ============================== =========== ================================================== - Window Styles Hex Value Description - ============================== =========== ================================================== - ``TR_NO_BUTTONS`` 0x0 For convenience to document that no buttons are to be drawn. - ``TR_SINGLE`` 0x0 For convenience to document that only one item may be selected at a time. Selecting another item causes the current selection, if any, to be deselected. This is the default. - ``TR_HAS_BUTTONS`` 0x1 Use this style to show + and - buttons to the left of parent items. - ``TR_NO_LINES`` 0x4 Use this style to hide vertical level connectors. - ``TR_LINES_AT_ROOT`` 0x8 Use this style to show lines between root nodes. Only applicable if ``TR_HIDE_ROOT`` is set and ``TR_NO_LINES`` is not set. - ``TR_DEFAULT_STYLE`` 0x9 The set of flags that are closest to the defaults for the native control for a particular toolkit. - ``TR_TWIST_BUTTONS`` 0x10 Use old Mac-twist style buttons. - ``TR_MULTIPLE`` 0x20 Use this style to allow a range of items to be selected. If a second range is selected, the current range, if any, is deselected. - ``TR_EXTENDED`` 0x40 Use this style to allow disjoint items to be selected. (Only partially implemented; may not work in all cases). - ``TR_HAS_VARIABLE_ROW_HEIGHT`` 0x80 Use this style to cause row heights to be just big enough to fit the content. If not set, all rows use the largest row height. The default is that this flag is unset. - ``TR_EDIT_LABELS`` 0x200 Use this style if you wish the user to be able to edit labels in the tree control. - ``TR_ROW_LINES`` 0x400 Use this style to draw a contrasting border between displayed rows. - ``TR_HIDE_ROOT`` 0x800 Use this style to suppress the display of the root node, effectively causing the first-level nodes to appear as a series of root nodes. - ``TR_COLUMN_LINES`` 0x1000 Use this style to draw a contrasting border between displayed columns. - ``TR_FULL_ROW_HIGHLIGHT`` 0x2000 Use this style to have the background colour and the selection highlight extend over the entire horizontal row of the tree control window. - ``TR_AUTO_CHECK_CHILD`` 0x4000 Only meaningful for checkbox-type items: when a parent item is checked/unchecked its children are checked/unchecked as well. - ``TR_AUTO_TOGGLE_CHILD`` 0x8000 Only meaningful for checkbox-type items: when a parent item is checked/unchecked its children are toggled accordingly. - ``TR_AUTO_CHECK_PARENT`` 0x10000 Only meaningful for checkbox-type items: when a child item is checked/unchecked its parent item is checked/unchecked as well. - ``TR_ALIGN_WINDOWS`` 0x20000 Flag used to align windows (in items with windows) at the same horizontal position. - ``TR_NO_HEADER`` 0x40000 Use this style to hide the columns header. - ``TR_ELLIPSIZE_LONG_ITEMS`` 0x80000 Flag used to ellipsize long items when the horizontal space for :class:`~wx.lib.agw.customtreectrl.CustomTreeCtrl` is low. - ``TR_VIRTUAL`` 0x100000 :class:`HyperTreeList` will have virtual behaviour. - ============================== =========== ================================================== - + :param `agwStyle`: the AGW-specific :class:`HyperTreeList` window style. + see :mod:`~wx.lib.agw.hypertreelist` for a full list of flags. :param `validator`: window validator; :param `name`: window name. """ @@ -4352,34 +4480,8 @@ class HyperTreeList(wx.Control): """ Sets the window style for :class:`HyperTreeList`. - :param `agwStyle`: can be a combination of the following bits: - - ============================== =========== ================================================== - Window Styles Hex Value Description - ============================== =========== ================================================== - ``TR_NO_BUTTONS`` 0x0 For convenience to document that no buttons are to be drawn. - ``TR_SINGLE`` 0x0 For convenience to document that only one item may be selected at a time. Selecting another item causes the current selection, if any, to be deselected. This is the default. - ``TR_HAS_BUTTONS`` 0x1 Use this style to show + and - buttons to the left of parent items. - ``TR_NO_LINES`` 0x4 Use this style to hide vertical level connectors. - ``TR_LINES_AT_ROOT`` 0x8 Use this style to show lines between root nodes. Only applicable if ``TR_HIDE_ROOT`` is set and ``TR_NO_LINES`` is not set. - ``TR_DEFAULT_STYLE`` 0x9 The set of flags that are closest to the defaults for the native control for a particular toolkit. - ``TR_TWIST_BUTTONS`` 0x10 Use old Mac-twist style buttons. - ``TR_MULTIPLE`` 0x20 Use this style to allow a range of items to be selected. If a second range is selected, the current range, if any, is deselected. - ``TR_EXTENDED`` 0x40 Use this style to allow disjoint items to be selected. (Only partially implemented; may not work in all cases). - ``TR_HAS_VARIABLE_ROW_HEIGHT`` 0x80 Use this style to cause row heights to be just big enough to fit the content. If not set, all rows use the largest row height. The default is that this flag is unset. - ``TR_EDIT_LABELS`` 0x200 Use this style if you wish the user to be able to edit labels in the tree control. - ``TR_ROW_LINES`` 0x400 Use this style to draw a contrasting border between displayed rows. - ``TR_HIDE_ROOT`` 0x800 Use this style to suppress the display of the root node, effectively causing the first-level nodes to appear as a series of root nodes. - ``TR_COLUMN_LINES`` 0x1000 Use this style to draw a contrasting border between displayed columns. - ``TR_FULL_ROW_HIGHLIGHT`` 0x2000 Use this style to have the background colour and the selection highlight extend over the entire horizontal row of the tree control window. - ``TR_AUTO_CHECK_CHILD`` 0x4000 Only meaningful for checkbox-type items: when a parent item is checked/unchecked its children are checked/unchecked as well. - ``TR_AUTO_TOGGLE_CHILD`` 0x8000 Only meaningful for checkbox-type items: when a parent item is checked/unchecked its children are toggled accordingly. - ``TR_AUTO_CHECK_PARENT`` 0x10000 Only meaningful for checkbox-type items: when a child item is checked/unchecked its parent item is checked/unchecked as well. - ``TR_ALIGN_WINDOWS`` 0x20000 Flag used to align windows (in items with windows) at the same horizontal position. - ``TR_NO_HEADER`` 0x40000 Use this style to hide the columns header. - ``TR_ELLIPSIZE_LONG_ITEMS`` 0x80000 Flag used to ellipsize long items when the horizontal space for :class:`~wx.lib.agw.customtreectrl.CustomTreeCtrl` is low. - ``TR_VIRTUAL`` 0x100000 :class:`HyperTreeList` will have virtual behaviour. - ============================== =========== ================================================== + :param `agwStyle`: can be a combination of various bits. See + :mod:`~wx.lib.agw.hypertreelist` for a full list of flags. :note: Please note that some styles cannot be changed after the window creation and that `Refresh()` might need to be be called after changing the others for @@ -4820,9 +4922,9 @@ class HyperTreeList(wx.Control): def OnGetItemText(self, item, column): """ - This function **must** be overloaded in the derived class for a control - with ``TR_VIRTUAL`` style. It should return the string containing the - text of the given column for the specified item. + If the ``TR_VIRTUAL`` style is set this function **must** be overloaded + in the derived class. It should return the string containing the text + of the given column for the specified item. :param `item`: an instance of :class:`TreeListItem`; :param `column`: an integer specifying the column index. @@ -4849,7 +4951,7 @@ class HyperTreeList(wx.Control): def OnCompareItems(self, item1, item2): """ - Returns whether 2 items have the same text. + Returns the comparison of two items. Used for sorting. Override this function in the derived class to change the sort order of the items in the :class:`HyperTreeList`. The function should return a negative, zero or positive From 70464181c98e9ca257ff68ac21d0c8154918b872 Mon Sep 17 00:00:00 2001 From: cbeytas Date: Sun, 6 Jan 2019 23:31:59 -0500 Subject: [PATCH 03/32] Fix tree event exception in HyperTreeList demo The HyperTreeList demo receives events from an embedded TreeCtrl window which reports a different item type (TreeItemId) than the HyperTreeList events (TreeListItem). This throws an exception: AttributeError: 'TreeItemId' object has no attribute 'GetText'. Guard against this by only processing events with TreeListItem items. To reproduce, start the HyperTreeList demo and expand "item 0-a" then enable it by clicking the radio button. Selecting any item in the ListCtrl, or expanding/collapsing a tree node will generate exceptions. --- demo/agw/HyperTreeList.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/demo/agw/HyperTreeList.py b/demo/agw/HyperTreeList.py index 7135a4a2..de51446a 100644 --- a/demo/agw/HyperTreeList.py +++ b/demo/agw/HyperTreeList.py @@ -2322,14 +2322,16 @@ class HyperTreeList(HTL.HyperTreeList): def OnItemExpanded(self, event): item = event.GetItem() - if item: + # Ignore wx.TreeCtrl TREE events (item=wx.TreeItemId) from item window. + if item and isinstance(item, HTL.TreeListItem): self.log.write("OnItemExpanded: %s\n" % self.GetItemText(item)) def OnItemExpanding(self, event): item = event.GetItem() - if item: + # Ignore wx.TreeCtrl TREE events (item=wx.TreeItemId) from item window. + if item and isinstance(item, HTL.TreeListItem): self.log.write("OnItemExpanding: %s\n" % self.GetItemText(item)) event.Skip() @@ -2338,14 +2340,16 @@ class HyperTreeList(HTL.HyperTreeList): def OnItemCollapsed(self, event): item = event.GetItem() - if item: + # Ignore wx.TreeCtrl TREE events (item=wx.TreeItemId) from item window. + if item and isinstance(item, HTL.TreeListItem): self.log.write("OnItemCollapsed: %s" % self.GetItemText(item)) def OnItemCollapsing(self, event): item = event.GetItem() - if item: + # Ignore wx.TreeCtrl TREE events (item=wx.TreeItemId) from item window. + if item and isinstance(item, HTL.TreeListItem): self.log.write("OnItemCollapsing: %s\n" % self.GetItemText(item)) event.Skip() @@ -2353,8 +2357,11 @@ class HyperTreeList(HTL.HyperTreeList): def OnSelChanged(self, event): - self.item = event.GetItem() - if self.item: + item = event.GetItem() + # Ignore wx.TreeCtrl TREE events (item=wx.TreeItemId) from item window. + if item and isinstance(item, HTL.TreeListItem): + # This event was from the HyperTreeList and not the TreeCtrl. + self.item = item self.log.write("OnSelChanged: %s" % self.GetItemText(self.item)) if wx.Platform == '__WXMSW__': self.log.write(", BoundingRect: %s\n" % self.GetBoundingRect(self.item, True)) @@ -2367,9 +2374,10 @@ class HyperTreeList(HTL.HyperTreeList): def OnSelChanging(self, event): item = event.GetItem() - olditem = event.GetOldItem() - - if item: + # Ignore wx.TreeCtrl TREE events (item=wx.TreeItemId) from item window. + if item and isinstance(item, HTL.TreeListItem): + # This event was from the HyperTreeList and not the TreeCtrl. + olditem = event.GetOldItem() if not olditem: olditemtext = "None" else: From c5ee2412372675afb0d4e471e8b5baf5683aca97 Mon Sep 17 00:00:00 2001 From: cbeytas Date: Sun, 6 Jan 2019 23:33:12 -0500 Subject: [PATCH 04/32] Fix HyperTreeList headers if child window selected If a child window is only partially displayed, and it is clicked on, the window will scroll to the right so that it is fully visible. This doesn't send an EVT_SCROLLWIN event which means the column headers don't get updated. As a workaround we manually refresh the headers whenever a child window gets focus. Problem can be seen in the demo by expanding out "item 0-a", enabling it, then clicking on the embedded TreeCtrl. The window will scroll to reveal the entire TreeCtrl, but the column headers won't scroll and will no longer be aligned with the columns of the tree. --- wx/lib/agw/hypertreelist.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wx/lib/agw/hypertreelist.py b/wx/lib/agw/hypertreelist.py index 9df036e6..67bb8b9e 100644 --- a/wx/lib/agw/hypertreelist.py +++ b/wx/lib/agw/hypertreelist.py @@ -1695,6 +1695,8 @@ class TreeListItem(GenericTreeItem): treectrl = self._owner select = treectrl.GetSelection() + # Refresh header window since child focus could have moved scrollbars. + treectrl.GetParent().GetHeaderWindow().Refresh() # If the window is associated to an item that currently is selected # (has focus) we don't kill the focus. Otherwise we do it. From 933107e472f867e8cced189aab03a5854592ba35 Mon Sep 17 00:00:00 2001 From: cbeytas Date: Sun, 6 Jan 2019 23:44:15 -0500 Subject: [PATCH 05/32] Improve CustomTreeCtrl update speed when frozen If CustomTreeCtrl or HyperTreeList are frozen, skip the CalculateSize(), CalculatePositions(), and AdjustMyScrollBars() methods. These methods are quite slow and are called repeatedly whenever changes are made to the tree. Skipping constant re-calculating allows rapid changes to be made to the tree while it is frozen. The self._dirty flag is set to indicate recalculation is necessary in the next idle handler. --- wx/lib/agw/customtreectrl.py | 17 ++++++++++++++++- wx/lib/agw/hypertreelist.py | 13 +++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/wx/lib/agw/customtreectrl.py b/wx/lib/agw/customtreectrl.py index 6a1adaf1..43463732 100644 --- a/wx/lib/agw/customtreectrl.py +++ b/wx/lib/agw/customtreectrl.py @@ -6475,6 +6475,11 @@ class CustomTreeCtrl(wx.ScrolledWindow): def AdjustMyScrollbars(self): """ Internal method used to adjust the :class:`ScrolledWindow` scrollbars. """ + if self._freezeCount: + # Skip if frozen. Set dirty flag to adjust when thawed. + self._dirty = True + return + if self._anchor: x, y = self._anchor.GetSize(0, 0, self) @@ -8344,6 +8349,10 @@ class CustomTreeCtrl(wx.ScrolledWindow): """ + if self._freezeCount: + # Skip calculate if frozen. Set dirty flag to do this when thawed. + self._dirty = True + return if item.IsHidden(): # Hidden items have a height of 0. item.SetHeight(0) @@ -8499,6 +8508,10 @@ class CustomTreeCtrl(wx.ScrolledWindow): if not self._anchor: return + if self._freezeCount: + # Don't calculate positions if frozen as it is CPU intensive. + self._dirty = True + return self.absoluteWindows = {} @@ -8630,7 +8643,9 @@ class CustomTreeCtrl(wx.ScrolledWindow): for all controls so it is mostly just a hint to wxWidgets and not a mandatory directive. """ - + ## Note: We manage freezing ourselves because a normal call to + ## Freeze() also freezes all child item windows and for + ## some reason this can cause them to glitch out. self._freezeCount = self._freezeCount + 1 diff --git a/wx/lib/agw/hypertreelist.py b/wx/lib/agw/hypertreelist.py index 67bb8b9e..ac1dd781 100644 --- a/wx/lib/agw/hypertreelist.py +++ b/wx/lib/agw/hypertreelist.py @@ -2737,6 +2737,11 @@ class TreeListMainWindow(CustomTreeCtrl): def AdjustMyScrollbars(self): """ Internal method used to adjust the :class:`ScrolledWindow` scrollbars. """ + if self._freezeCount: + # Skip if frozen. Set dirty flag to adjust when thawed. + self._dirty = True + return + if self._anchor: xUnit, yUnit = self.GetScrollPixelsPerUnit() if xUnit == 0: @@ -3830,6 +3835,10 @@ class TreeListMainWindow(CustomTreeCtrl): :param `item`: an instance of :class:`TreeListItem`; :param `dc`: an instance of :class:`wx.DC`. """ + if self._freezeCount: + # Skip calculate if frozen. Set dirty flag to do this when thawed. + self._dirty = True + return if item.IsHidden(): # Hidden items have a height of 0. item.SetHeight(0) @@ -3971,6 +3980,10 @@ class TreeListMainWindow(CustomTreeCtrl): if not self._anchor: return + if self._freezeCount: + # Skip calculate if frozen. Set dirty flag to do this when thawed. + self._dirty = True + return dc = wx.ClientDC(self) self.PrepareDC(dc) From 514997df81389a441fa1d4a6562810c7b6e95e54 Mon Sep 17 00:00:00 2001 From: cbeytas Date: Sun, 6 Jan 2019 23:44:38 -0500 Subject: [PATCH 06/32] Allow freezing the tree in HyperTreeList Calling Freeze/Thaw on HyperTreeList does not trigger the Freeze() method in the TreeListMainWindow (inherited from CustomTreeCtrl). This prevents the internal freeze logic from working properly. Also, without this change, a normal call to Freeze() will freeze all child windows including those assigned to items. For some reason this can cause the item windows to glitch out when the tree is thawed. Often they will simply not draw themselves. Unsure why this happens. I assume this is the original reason for the custom freeze handler. --- wx/lib/agw/hypertreelist.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/wx/lib/agw/hypertreelist.py b/wx/lib/agw/hypertreelist.py index ac1dd781..b7426223 100644 --- a/wx/lib/agw/hypertreelist.py +++ b/wx/lib/agw/hypertreelist.py @@ -4406,6 +4406,35 @@ class HyperTreeList(wx.Control): self._header_win.SetBuffered(buffered) + def Freeze(self): + """ + Freeze :class:`HyperTreeList` to allow rapid changes to the tree. + + Freezes the HyperTreeList main (tree) and and header windows. + This prevents any re-calculation or updates from taking place + allowing mass updates to the tree very quickly. :meth:`~Thaw` + must be called to reenable updates. Calls to these two + functions may be nested. + """ + self._main_win.Freeze() + self._header_win.Freeze() + + + def Thaw(self): + """ + Thaw :class:`HyperTreeList`. + + Reenables updates to the main (tree) and header windows after a + previous call to :meth:`~Freeze`. To really thaw the control, it + must be called exactly the same number of times as :meth:`~Freeze`. + When fully thawed the tree will re-calculate and update itself. + + :raise: `Exception` if :meth:`~Thaw` has been called without an un-matching :meth:`~Freeze`. + """ + self._main_win.Thaw() + self._header_win.Thaw() + + def CalculateAndSetHeaderHeight(self): """ Calculates the best header height and stores it. """ From 8113033d6e534918e5afa65f42e65a4267bfd07a Mon Sep 17 00:00:00 2001 From: cbeytas Date: Sun, 6 Jan 2019 23:47:57 -0500 Subject: [PATCH 07/32] Recalculate CustomTreeCtrl on multiline text In CustomTreeCtrl and HyperTreeList the SetItemText method recalculates the size of the item row in which the text was changed. If the number of lines in the text changes the entire tree must be recalculated as all items below must be shifted to compensate. This change attempts to recalculate the entire tree only when necessary (when number of lines change) in order not to slow down existing code that performs a lot of SetItemText() operations on an unfrozen tree. Add a "Change Item Text" option to the CustomTreeCtrl and HyperTreeList demos so that this can be tested. Before this fix, changing the number of lines of text in an item would leave gaps or create overlaps between items in the tree. --- demo/agw/CustomTreeCtrl.py | 18 ++++++++++++++++-- demo/agw/HyperTreeList.py | 20 +++++++++++++++++++- wx/lib/agw/customtreectrl.py | 11 +++++++++-- wx/lib/agw/hypertreelist.py | 11 +++++++++-- 4 files changed, 53 insertions(+), 7 deletions(-) diff --git a/demo/agw/CustomTreeCtrl.py b/demo/agw/CustomTreeCtrl.py index bb47d199..b52dce63 100644 --- a/demo/agw/CustomTreeCtrl.py +++ b/demo/agw/CustomTreeCtrl.py @@ -1581,7 +1581,7 @@ class CustomTreeCtrl(CT.CustomTreeCtrl): menu = wx.Menu() - item1 = menu.Append(wx.ID_ANY, "Change item background colour") + item1 = menu.Append(wx.ID_ANY, "Change Item Text") item2 = menu.Append(wx.ID_ANY, "Modify item text colour") menu.AppendSeparator() @@ -1592,6 +1592,7 @@ class CustomTreeCtrl(CT.CustomTreeCtrl): item3 = menu.Append(wx.ID_ANY, strs) item4 = menu.Append(wx.ID_ANY, "Change item font") + item16 = menu.Append(wx.ID_ANY, "Change Item Background Colour") menu.AppendSeparator() if ishtml: @@ -1638,7 +1639,7 @@ class CustomTreeCtrl(CT.CustomTreeCtrl): item11 = menu.Append(wx.ID_ANY, "Prepend an item") item12 = menu.Append(wx.ID_ANY, "Append an item") - self.Bind(wx.EVT_MENU, self.OnItemBackground, item1) + self.Bind(wx.EVT_MENU, self.OnItemText, item1) self.Bind(wx.EVT_MENU, self.OnItemForeground, item2) self.Bind(wx.EVT_MENU, self.OnItemBold, item3) self.Bind(wx.EVT_MENU, self.OnItemFont, item4) @@ -1653,11 +1654,24 @@ class CustomTreeCtrl(CT.CustomTreeCtrl): self.Bind(wx.EVT_MENU, self.OnSeparatorInsert, item13) self.Bind(wx.EVT_MENU, self.OnHideItem, item14) self.Bind(wx.EVT_MENU, self.OnUnhideItems, item15) + self.Bind(wx.EVT_MENU, self.OnItemBackground, item16) self.PopupMenu(menu) menu.Destroy() + def OnItemText(self, event): + + diag = wx.TextEntryDialog(self, "Item Text", caption="Input Item Text", + value=self.GetItemText(self.current), + style=wx.OK | wx.CANCEL | wx.TE_MULTILINE) + reply = diag.ShowModal() + text = diag.GetValue() + diag.Destroy() + if reply in (wx.OK, wx.ID_OK): + self.SetItemText(self.current, text) + + def OnItemBackground(self, event): colourdata = wx.ColourData() diff --git a/demo/agw/HyperTreeList.py b/demo/agw/HyperTreeList.py index de51446a..5f46b35d 100644 --- a/demo/agw/HyperTreeList.py +++ b/demo/agw/HyperTreeList.py @@ -2041,7 +2041,7 @@ class HyperTreeList(HTL.HyperTreeList): "itemtype": itemtype, "text": text, "pydata": pydata, "enabled": enabled} menu = wx.Menu() - + item1 = menu.Append(wx.ID_ANY, "Change Item Text") item2 = menu.Append(wx.ID_ANY, "Modify Item Text Colour") menu.AppendSeparator() if isbold: @@ -2076,6 +2076,7 @@ class HyperTreeList(HTL.HyperTreeList): item11 = menu.Append(wx.ID_ANY, "Prepend An Item") item12 = menu.Append(wx.ID_ANY, "Append An Item") + self.Bind(wx.EVT_MENU, self.OnItemText, item1) self.Bind(wx.EVT_MENU, self.OnItemForeground, item2) self.Bind(wx.EVT_MENU, self.OnItemBold, item3) self.Bind(wx.EVT_MENU, self.OnItemFont, item4) @@ -2095,6 +2096,23 @@ class HyperTreeList(HTL.HyperTreeList): event.Skip() + def OnItemText(self, event): + + col = wx.GetNumberFromUser("Choose column number to change text", + "Col", "Column To Modify", 0, 0, + self.GetColumnCount() - 1, self) + if col >= 0 and col < self.GetColumnCount(): + diag = wx.TextEntryDialog(self, "%s Text" % self.GetColumnText(col), + caption="Input text for column %d" % col, + value=self.GetItemText(self.current,col), + style=wx.OK | wx.CANCEL | wx.TE_MULTILINE) + reply = diag.ShowModal() + text = diag.GetValue() + diag.Destroy() + if reply in (wx.OK, wx.ID_OK): + self.SetItemText(self.current, text, col) + + def OnItemForeground(self, event): colourdata = wx.ColourData() diff --git a/wx/lib/agw/customtreectrl.py b/wx/lib/agw/customtreectrl.py index 43463732..214180cc 100644 --- a/wx/lib/agw/customtreectrl.py +++ b/wx/lib/agw/customtreectrl.py @@ -3817,9 +3817,16 @@ class CustomTreeCtrl(wx.ScrolledWindow): raise Exception("Separator items can not have text") dc = wx.ClientDC(self) + oldtext = item.GetText() item.SetText(text) - self.CalculateSize(item, dc) - self.RefreshLine(item) + # Avoid Calculating tree unless number of lines changed (slow). + if oldtext.count('\n') != text.count('\n'): + self.CalculatePositions() + self.Refresh() + self.AdjustMyScrollbars() + else: + self.CalculateSize(item, dc) + self.RefreshLine(item) def SetItemImage(self, item, image, which=TreeItemIcon_Normal): diff --git a/wx/lib/agw/hypertreelist.py b/wx/lib/agw/hypertreelist.py index b7426223..51a2f464 100644 --- a/wx/lib/agw/hypertreelist.py +++ b/wx/lib/agw/hypertreelist.py @@ -4011,9 +4011,16 @@ class TreeListMainWindow(CustomTreeCtrl): """ dc = wx.ClientDC(self) + oldtext = item.GetText(column) item.SetText(column, text) - self.CalculateSize(item, dc) - self.RefreshLine(item) + # Avoid Calculating tree unless number of lines changed (slow). + if oldtext.count('\n') != text.count('\n'): + self.CalculatePositions() + self.Refresh() + self.AdjustMyScrollbars() + else: + self.CalculateSize(item, dc) + self.RefreshLine(item) def GetItemText(self, item, column=None): From ccdfc24805c06d50eaf6f1ce42513a633f02a783 Mon Sep 17 00:00:00 2001 From: cbeytas Date: Sun, 6 Jan 2019 23:51:01 -0500 Subject: [PATCH 08/32] Fix HyperTreeList ellipsized text alignment If the TR_ELLIPSIZE_LONG_ITEMS flag is set the HyperTreeList will not center or right-align text properly if it is too long since the size calculation of the text is performed before the call to ChopText(). This change flips the calculation to be after ChopText(). Can be seen in the HyperTreeList demo on columns with long text (will have enter long text manually). Make sure the TR_ELLIPSIZE_LONG_ITEMS checkbox is enabled and change the alignment to wx.CENTER. Adjust the column width and text placement will be too far to the right. --- wx/lib/agw/hypertreelist.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wx/lib/agw/hypertreelist.py b/wx/lib/agw/hypertreelist.py index 51a2f464..6ff29c16 100644 --- a/wx/lib/agw/hypertreelist.py +++ b/wx/lib/agw/hypertreelist.py @@ -3044,11 +3044,6 @@ class TreeListMainWindow(CustomTreeCtrl): item.GetY() + ((total_h > hcheck) and [(total_h-hcheck)//2] or [0])[0]+1, wx.IMAGELIST_DRAW_TRANSPARENT) - text_w, text_h, dummy = dc.GetFullMultiLineTextExtent(text) - text_extraH = (total_h > text_h and [(total_h - text_h)//2] or [0])[0] - text_y = item.GetY() + text_extraH - textrect = wx.Rect(text_x, text_y, text_w, text_h) - if self.HasAGWFlag(TR_ELLIPSIZE_LONG_ITEMS): if i == self.GetMainColumn(): maxsize = col_w - text_x - _MARGIN @@ -3057,6 +3052,11 @@ class TreeListMainWindow(CustomTreeCtrl): text = ChopText(dc, text, maxsize) + text_w, text_h, dummy = dc.GetFullMultiLineTextExtent(text) + text_extraH = (total_h > text_h and [(total_h - text_h)//2] or [0])[0] + text_y = item.GetY() + text_extraH + textrect = wx.Rect(text_x, text_y, text_w, text_h) + if not item.IsEnabled(): foreground = dc.GetTextForeground() dc.SetTextForeground(self._disabledColour) From 2449ef259637f468e87ecf554c8b20e483732f09 Mon Sep 17 00:00:00 2001 From: cbeytas Date: Sun, 6 Jan 2019 23:53:10 -0500 Subject: [PATCH 09/32] Fix CustomTreeCtrl exception with UTF-8 text If the TR_ELLIPSIZE_LONG_ITEMS flag is set and UTF-8 text is used on any item in the tree, an exception will be thrown in the `ChopText` function since chopping UTF-8 generates invalid sequences. Make `ChopText` convert text to Unicode before chopping. This bug has also been reported here: https://groups.google.com/d/msg/wxpython-dev/irD_PDHhQHk/FWuBqxlKAAAJ --- wx/lib/agw/customtreectrl.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wx/lib/agw/customtreectrl.py b/wx/lib/agw/customtreectrl.py index 214180cc..1a7d1313 100644 --- a/wx/lib/agw/customtreectrl.py +++ b/wx/lib/agw/customtreectrl.py @@ -684,12 +684,16 @@ def ChopText(dc, text, max_size): .. versionadded:: 0.9.3 """ - # first check if the text fits with no problems + # first check if the text fits with no problems (converts to Unicode). x, y, dummy = dc.GetFullMultiLineTextExtent(text) if x <= max_size: return text + # We cannot chop text that is UTF-8, as it could produce invalid sequences. + if isinstance(text, bytes): + # Convert UTF-8 (Phoenix's mandatory encoding) to Unicode. + text = text.decode('utf-8') textLen = len(text) last_good_length = 0 From e03448c341d2b253b30eb961348f2a775b0beb5b Mon Sep 17 00:00:00 2001 From: cbeytas Date: Sun, 6 Jan 2019 23:56:25 -0500 Subject: [PATCH 10/32] Fix HyperTreeList column width calculation The calculation for item width was not adding in the width of the item's control (checkbox, radiobutton) or margin. This can be seen in the demo by deleting 'Item 1' and expanding the other items to reveal items with checkboxes and radiobuttons. Then auto-size the tree column by double-clicking on the column separator. The column will auto-size too small, cutting off text for the items with radiobuttons or checkboxes. --- wx/lib/agw/hypertreelist.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wx/lib/agw/hypertreelist.py b/wx/lib/agw/hypertreelist.py index 6ff29c16..f7c5c714 100644 --- a/wx/lib/agw/hypertreelist.py +++ b/wx/lib/agw/hypertreelist.py @@ -4069,13 +4069,16 @@ class TreeListMainWindow(CustomTreeCtrl): # calculate width width = w + 2*_MARGIN if column == self.GetMainColumn(): - width += _MARGIN + width += 2*_MARGIN if self.HasAGWFlag(wx.TR_LINES_AT_ROOT): width += _LINEATROOT if self.HasButtons(): width += self._btnWidth + _LINEATROOT if item.GetCurrentImage() != _NO_IMAGE: width += self._imgWidth + if item.GetType() != 0 and self._imageListCheck: + wcheck, hcheck = self._imageListCheck.GetSize(item.GetType()) + width += wcheck # count indent level level = 0 From 88959263cf5726eea3b1bd2c5413bba14b17bf90 Mon Sep 17 00:00:00 2001 From: cbeytas Date: Sun, 6 Jan 2019 23:58:29 -0500 Subject: [PATCH 11/32] Fix HyperTreeList exception on item drag in GTK The call to wx.DragImage.BeginDrag() captures the mouse. At this point the tree has already captured the mouse. This is not a problem in MSW or MacOS but in GTK it throws a wx._core.wxAssertionError: C++ assertion "!wxMouseCapture::IsInCaptureStack(this)" failed at /tmp/pip-build-OWOug_/wxPython/ext/wxWidgets/src/common/wincmn.cpp (3271) in CaptureMouse(): Recapturing the mouse in the same window? Can be seen in the demo by enabling the EVT_TREE_BEGIN_DRAG checkbox and trying to drag an item on a Linux/GTK platform. --- wx/lib/agw/hypertreelist.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wx/lib/agw/hypertreelist.py b/wx/lib/agw/hypertreelist.py index f7c5c714..d2c1d8f5 100644 --- a/wx/lib/agw/hypertreelist.py +++ b/wx/lib/agw/hypertreelist.py @@ -3576,6 +3576,9 @@ class TreeListMainWindow(CustomTreeCtrl): if not self._dragImage: # Create the custom draw image from the icons and the text of the item self._dragImage = DragImage(self, self._current or item) + # BeginDrag captures mouse. GTK cannot capture mouse twice. + if self.HasCapture() is True: + self.ReleaseMouse() self._dragImage.BeginDrag(wx.Point(0,0), self) self._dragImage.Show() From 3d52c7c97ec6422a94888dcb4d857b2809625f94 Mon Sep 17 00:00:00 2001 From: cbeytas Date: Mon, 7 Jan 2019 00:00:12 -0500 Subject: [PATCH 12/32] Pass focus properly in HyperTreeList When HyperTreeList gets focus, pass the focus to the TreeListMainWindow control (based off CustomTreeCtrl). This allows keyboard controls to work when the HyperTreeList is tabbed to. Note: CustomTreeCtrl has its own OnSetFocus handler which will also run when TreeListMainWindow gets the focus. --- wx/lib/agw/hypertreelist.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/wx/lib/agw/hypertreelist.py b/wx/lib/agw/hypertreelist.py index d2c1d8f5..5b827321 100644 --- a/wx/lib/agw/hypertreelist.py +++ b/wx/lib/agw/hypertreelist.py @@ -4401,6 +4401,7 @@ class HyperTreeList(wx.Control): self.CalculateAndSetHeaderHeight() self.Bind(wx.EVT_SIZE, self.OnSize) + self.Bind(wx.EVT_SET_FOCUS, self.OnHTLFocus) self.SetBuffered(IsBufferingSupported()) self._main_win.SetAGWWindowStyleFlag(agwStyle) @@ -4487,6 +4488,16 @@ class HyperTreeList(wx.Control): self.DoHeaderLayout() + def OnHTLFocus(self, event): + """ + Handles the ``wx.EVT_SET_FOCUS`` event for :class:`HyperTreeList`. + + :param `event`: a :class:`wx.SizeEvent` event to be processed. + """ + # Pass focus to TreeListMainWindow so keyboard controls work. + self.GetMainWindow().SetFocus() + + def SetFont(self, font): """ Sets the default font for the header window and the main window. From 683c434d3e70e6b7aa8cc105a710824888eeaff8 Mon Sep 17 00:00:00 2001 From: cbeytas Date: Mon, 7 Jan 2019 00:00:48 -0500 Subject: [PATCH 13/32] Fix CustomTreeCtrl ENTER key with no selection CustomTreeCtrl and HyperTreeList with throw an exception if the ENTER key is pressed while no item is selected. This usually happens after a selected item is deleted (self._current = None). --- wx/lib/agw/customtreectrl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wx/lib/agw/customtreectrl.py b/wx/lib/agw/customtreectrl.py index 1a7d1313..5f996a5c 100644 --- a/wx/lib/agw/customtreectrl.py +++ b/wx/lib/agw/customtreectrl.py @@ -7400,7 +7400,7 @@ class CustomTreeCtrl(wx.ScrolledWindow): elif keyCode in (wx.WXK_RETURN, wx.WXK_SPACE, wx.WXK_NUMPAD_ENTER): - if not self.IsItemEnabled(self._current): + if not self._current or not self.IsItemEnabled(self._current): event.Skip() return From 5613666b4a04c237d5ffd4b9211a10c43bfafefa Mon Sep 17 00:00:00 2001 From: cbeytas Date: Mon, 7 Jan 2019 00:03:51 -0500 Subject: [PATCH 14/32] Fix ListEvent properties in HyperTreeList The EVT_LIST_XXX event member properties are no longer public, according to the migration guide: https://docs.wxpython.org/MigrationGuide.html#wx-listctrl HyperTreeList does things the old way so the getter methods don't work. This fix adds calls to the Setter functions so the getters work. --- wx/lib/agw/hypertreelist.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wx/lib/agw/hypertreelist.py b/wx/lib/agw/hypertreelist.py index 5b827321..e87b373e 100644 --- a/wx/lib/agw/hypertreelist.py +++ b/wx/lib/agw/hypertreelist.py @@ -1160,6 +1160,9 @@ class TreeListHeaderWindow(wx.Window): # window, so why should it get positions relative to it? le.m_pointDrag.y -= self.GetSize().y le.m_col = self._column + # Set point/column with Setters for Phoenix compatibility. + le.SetPoint(le.m_pointDrag) + le.SetColumn(self._column) parent.GetEventHandler().ProcessEvent(le) From 72b27d7f4a5b539dbb282e6b1c89f0ee4b660e9e Mon Sep 17 00:00:00 2001 From: cbeytas Date: Mon, 7 Jan 2019 00:07:08 -0500 Subject: [PATCH 15/32] Fix item window alignment in HyperTreeList If wx.ALIGN_LEFT or wx.ALIGN_RIGHT are used on columns with item windows they won't be placed properly and will extend outside their column. Affects both items with text and without. This fix aligns the windows properly under all conditions. Can be seen in the HyperTreeList demo by expanding 'Item 0' and 'item 0-a', double-clicking on all column separators to autosize the columns to their contents, and enabling the TR_COLUMN_LINES style. The demo window size should be increased to show all list controls and make 'item 0-d' and its two items visible. Changing the alignment between LEFT/CENTER/RIGHT will show poor placement of the windows. --- wx/lib/agw/hypertreelist.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/wx/lib/agw/hypertreelist.py b/wx/lib/agw/hypertreelist.py index e87b373e..f94184b9 100644 --- a/wx/lib/agw/hypertreelist.py +++ b/wx/lib/agw/hypertreelist.py @@ -3073,9 +3073,23 @@ class TreeListMainWindow(CustomTreeCtrl): wnd = item.GetWindow(i) if wnd: if text_w == 0: - wndx = text_x + # No text. Honor column alignment for window. + if alignment == wx.ALIGN_RIGHT: + # text_x = right edge of window + wndx = text_x - wnd.GetSize().width + elif alignment == wx.ALIGN_CENTER: + # text_x = center of window + wndx = text_x - (wnd.GetSize().width // 2) + else: + # text_x = left of window (default). + wndx = text_x else: - wndx = text_x + text_w + 2*_MARGIN + if alignment == wx.ALIGN_RIGHT: + # Place window left of text with 2*_MARGIN in between. + wndx = text_x - 2*_MARGIN - wnd.GetSize().width + else: + # Place window at end of text plus 2*_MARGIN (default). + wndx = text_x + text_w + 2*_MARGIN xa, ya = self.CalcScrolledPosition(0, item.GetY()) wndx += xa if item.GetHeight() > item.GetWindowSize(i)[1]: From ac0f578a01e4e4fc9c1e50a349a154367217d05d Mon Sep 17 00:00:00 2001 From: cbeytas Date: Mon, 7 Jan 2019 00:12:00 -0500 Subject: [PATCH 16/32] Fix CustomTreeCtrl/HyperTreeList background color CustomTreeCtrl and HyperTreeList use wx.SYS_COLOUR_LISTBOX for their default background colors. This defaults to dank Grey on MSW/GTK/MacOS even though the TreeCtrl and ListCtrl on all three platforms default to a white background. Use a trick from UltimateListCtrl to take default colors from wx.ListCtrl. This can be seen in the demos, except that the CustomTreeCtrl demo forces its background to wx.WHITE. With these changes forcing the background color is no longer necessary and allows the controls to take on the native background color for themes that change it. --- demo/agw/CustomTreeCtrl.py | 2 -- demo/agw/HyperTreeList.py | 2 +- wx/lib/agw/customtreectrl.py | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/demo/agw/CustomTreeCtrl.py b/demo/agw/CustomTreeCtrl.py index b52dce63..44aaffc5 100644 --- a/demo/agw/CustomTreeCtrl.py +++ b/demo/agw/CustomTreeCtrl.py @@ -1293,8 +1293,6 @@ class CustomTreeCtrl(CT.CustomTreeCtrl): CT.CustomTreeCtrl.__init__(self, parent, id, pos, size, style, agwStyle) - self.SetBackgroundColour(wx.WHITE) - alldata = dir(CT) treestyles = [] diff --git a/demo/agw/HyperTreeList.py b/demo/agw/HyperTreeList.py index 5f46b35d..f795e72c 100644 --- a/demo/agw/HyperTreeList.py +++ b/demo/agw/HyperTreeList.py @@ -1052,7 +1052,7 @@ class HyperTreeListDemo(wx.Frame): splitter.SplitVertically(self.leftpanel, panel, 300) splitter.SetMinimumPaneSize(120) - self.leftpanel.SetBackgroundColour(wx.WHITE) + #self.leftpanel.SetBackgroundColour(wx.WHITE) self.leftpanel.SetScrollRate(20, 20) self.Fit() diff --git a/wx/lib/agw/customtreectrl.py b/wx/lib/agw/customtreectrl.py index 5f996a5c..943395bf 100644 --- a/wx/lib/agw/customtreectrl.py +++ b/wx/lib/agw/customtreectrl.py @@ -2969,7 +2969,7 @@ class CustomTreeCtrl(wx.ScrolledWindow): self.SetValidator(validator) - attr = self.GetDefaultAttributes() + attr = wx.ListCtrl.GetClassDefaultAttributes() self.SetOwnForegroundColour(attr.colFg) self.SetOwnBackgroundColour(attr.colBg) From 41d222ca60bb190ab927f3c3fcb97ef3ea72b733 Mon Sep 17 00:00:00 2001 From: cbeytas Date: Mon, 7 Jan 2019 00:16:19 -0500 Subject: [PATCH 17/32] Fix non-native text color forcing in HyperTreeList When painting the tree HyperTreeList forces the text color to wx.BLACK. If items don't have their own text color they should use the native text color. This change saves the native color and restores it. Can be seen in the demo on MSW by selecting the "High Contrast 1" theme. Text color of all items should be yellow on black. Only the root item gets the native color while all following items are black on black. As a comparison CustomTreeCtrl doesn't have this problem. --- wx/lib/agw/hypertreelist.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wx/lib/agw/hypertreelist.py b/wx/lib/agw/hypertreelist.py index f94184b9..b2f5b18c 100644 --- a/wx/lib/agw/hypertreelist.py +++ b/wx/lib/agw/hypertreelist.py @@ -3123,6 +3123,9 @@ class TreeListMainWindow(CustomTreeCtrl): if item.IsHidden(): return y, x_maincol + # Save window text color. + colText = wx.Colour(*dc.GetTextForeground()) + # Handle hide root (only level 0) if self.HasAGWFlag(wx.TR_HIDE_ROOT) and level == 0: for child in item.GetChildren(): @@ -3250,7 +3253,7 @@ class TreeListMainWindow(CustomTreeCtrl): # restore DC objects dc.SetBrush(wx.WHITE_BRUSH) dc.SetPen(self._dottedPen) - dc.SetTextForeground(wx.BLACK) + dc.SetTextForeground(colText) if item.IsExpanded(): From 845a4097d330a4a28117123c1a83da049e671db0 Mon Sep 17 00:00:00 2001 From: cbeytas Date: Mon, 7 Jan 2019 00:18:17 -0500 Subject: [PATCH 18/32] Update HyperTreeList IsItemVisible method This method is a direct copy of CustomTreeCtrl.IsVisible(), just has a different name. Eliminate the code duplication and update docstring. --- wx/lib/agw/hypertreelist.py | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/wx/lib/agw/hypertreelist.py b/wx/lib/agw/hypertreelist.py index b2f5b18c..9fe9288d 100644 --- a/wx/lib/agw/hypertreelist.py +++ b/wx/lib/agw/hypertreelist.py @@ -2273,32 +2273,10 @@ class TreeListMainWindow(CustomTreeCtrl): Returns whether the item is visible or not. :param `item`: an instance of :class:`TreeListItem`; + + :note: This method is renamed from :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.IsVisible` """ - # An item is only visible if it's not a descendant of a collapsed item - parent = item.GetParent() - - while parent: - - if not parent.IsExpanded(): - return False - - parent = parent.GetParent() - - startX, startY = self.GetViewStart() - clientSize = self.GetClientSize() - - rect = self.GetBoundingRect(item) - - if not rect: - return False - if rect.GetWidth() == 0 or rect.GetHeight() == 0: - return False - if rect.GetBottom() < 0 or rect.GetTop() > clientSize.y: - return False - if rect.GetRight() < 0 or rect.GetLeft() > clientSize.x: - return False - - return True + return self.IsVisible(item) def GetPrevChild(self, item, cookie): @@ -2356,7 +2334,7 @@ class TreeListMainWindow(CustomTreeCtrl): return None if not self.HasAGWFlag(TR_HIDE_ROOT): - if self.IsVisible(root): + if self.IsItemVisible(root): return root return self.GetNextVisible(root) From fd57321cb3cd994a7dcfdc90fd6ad5cdcfd46892 Mon Sep 17 00:00:00 2001 From: cbeytas Date: Mon, 7 Jan 2019 00:21:13 -0500 Subject: [PATCH 19/32] Add GetFocusedItem method to CustomTreeCtrl The GetSelection() method of CustomTreeCtrl and HyperTreeList have the same behavior as the GetFocusedItem() method of wx.TreeCtrl. The GetCurrentItem() method of HyperTreeList also does the exact same thing. Try to consolidate and document these methods. The CustomTreeCtrl "Basic Functionalites" section states that "All the methods available in TreeCtrl are also available in CustomTreeCtrl", this brings it one step closer to reality. --- wx/lib/agw/customtreectrl.py | 2 ++ wx/lib/agw/hypertreelist.py | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/wx/lib/agw/customtreectrl.py b/wx/lib/agw/customtreectrl.py index 943395bf..01660c3b 100644 --- a/wx/lib/agw/customtreectrl.py +++ b/wx/lib/agw/customtreectrl.py @@ -3123,6 +3123,8 @@ class CustomTreeCtrl(wx.ScrolledWindow): return self._current + GetFocusedItem = GetSelection + def ToggleItemSelection(self, item): """ diff --git a/wx/lib/agw/hypertreelist.py b/wx/lib/agw/hypertreelist.py index 9fe9288d..263e3930 100644 --- a/wx/lib/agw/hypertreelist.py +++ b/wx/lib/agw/hypertreelist.py @@ -2620,9 +2620,12 @@ class TreeListMainWindow(CustomTreeCtrl): def GetCurrentItem(self): - """ Returns the current item. """ + """Returns the current item. - return self._current + This is the same as :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetSelection`. + """ + + return self.GetSelection() def GetColumnCount(self): @@ -4162,7 +4165,7 @@ _methods = ["GetIndent", "SetIndent", "GetSpacing", "SetSpacing", "GetImageList" "SetItemHasChildren", "SetItemBackgroundColour", "SetItemFont", "IsItemVisible", "HasChildren", "IsExpanded", "IsSelected", "IsBold", "GetCount", "GetChildrenCount", "GetRootItem", "GetSelection", "GetSelections", "GetItemParent", "GetFirstChild", "GetNextChild", "GetPrevChild", "GetLastChild", "GetNextSibling", - "GetPrevSibling", "GetNext", "GetFirstExpandedItem", "GetNextExpanded", "GetPrevExpanded", + "GetPrevSibling", "GetNext", "GetFirstExpandedItem", "GetNextExpanded", "GetPrevExpanded", "GetFocusedItem", "GetFirstVisibleItem", "GetNextVisible", "GetPrevVisible", "AddRoot", "PrependItem", "InsertItem", "AppendItem", "Delete", "DeleteChildren", "DeleteRoot", "Expand", "ExpandAll", "ExpandAllChildren", "Collapse", "CollapseAndReset", "Toggle", "Unselect", "UnselectAll", "SelectItem", "SelectAll", @@ -4250,6 +4253,7 @@ class HyperTreeList(wx.Control): :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.GetFirstExpandedItem` Returns the first item which is in the expanded state. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetFirstGradientColour` Returns the first gradient colour for gradient-style selections. :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.GetFirstVisibleItem` Returns the first visible item. + GetFocusedItem Another name for :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetSelection` :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetGradientStyle` Returns the gradient style for gradient-style selections. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetHilightFocusColour` Returns the colour used to highlight focused selected items. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetHilightNonFocusColour` Returns the colour used to highlight unfocused selected items. From 4ed3e536e5c9746f5e6cb982054ab67efffc734b Mon Sep 17 00:00:00 2001 From: cbeytas Date: Mon, 7 Jan 2019 00:23:45 -0500 Subject: [PATCH 20/32] Add sort icon support to HyperTreeList Feature addition. Add SetColumnSortIcon() method to HyperTreeList so that a native sort arrow can be easily shown in the header columns. For some reason does not work on GTK (won't draw arrow) but works great on Windows/MacOS. Modify the demo with LIST_COL_CLICK event options so it can be tested. --- demo/agw/HyperTreeList.py | 20 +++++++++- wx/lib/agw/hypertreelist.py | 76 ++++++++++++++++++++++++++++++++++++- 2 files changed, 93 insertions(+), 3 deletions(-) diff --git a/demo/agw/HyperTreeList.py b/demo/agw/HyperTreeList.py index f795e72c..324079bb 100644 --- a/demo/agw/HyperTreeList.py +++ b/demo/agw/HyperTreeList.py @@ -1707,6 +1707,7 @@ class HyperTreeList(HTL.HyperTreeList): for evt in ["EVT_TREE_GET_INFO", "EVT_TREE_SET_INFO", "EVT_TREE_ITEM_MIDDLE_CLICK", "EVT_TREE_STATE_IMAGE_CLICK"]: events.remove(evt) + events.extend(('EVT_LIST_COL_CLICK', 'EVT_LIST_COL_RIGHT_CLICK')) treestyles = treestyles + [i for i in dir(wx) if i.startswith("TR_")] treeset = {} @@ -1717,6 +1718,8 @@ class HyperTreeList(HTL.HyperTreeList): self.events = events self.styles = treestyles self.item = None + self.sortIcon = wx.HDR_SORT_ICON_NONE + self.sortColumn = 0 il = wx.ImageList(16, 16) @@ -1847,7 +1850,8 @@ class HyperTreeList(HTL.HyperTreeList): 'EVT_TREE_ITEM_EXPANDING': self.OnItemExpanding, 'EVT_TREE_ITEM_GETTOOLTIP': self.OnToolTip, 'EVT_TREE_ITEM_MENU': self.OnItemMenu, 'EVT_TREE_ITEM_RIGHT_CLICK': self.OnRightDown, 'EVT_TREE_KEY_DOWN': self.OnKey, 'EVT_TREE_SEL_CHANGED': self.OnSelChanged, - 'EVT_TREE_SEL_CHANGING': self.OnSelChanging, "EVT_TREE_ITEM_HYPERLINK": self.OnHyperLink} + 'EVT_TREE_SEL_CHANGING': self.OnSelChanging, "EVT_TREE_ITEM_HYPERLINK": self.OnHyperLink, + 'EVT_LIST_COL_CLICK': self.OnColClick, 'EVT_LIST_COL_RIGHT_CLICK': self.OnColRightClick} mainframe = wx.GetTopLevelParent(self) @@ -2404,6 +2408,20 @@ class HyperTreeList(HTL.HyperTreeList): event.Skip() + def OnColClick(self, event): + column = event.GetColumn() + self.log.write("OnColClick: Column %d clicked" % column) + # Cycle through the sort icons. + if column != self.sortColumn: + self.sortIcon = wx.HDR_SORT_ICON_NONE + self.sortColumn = column + self.sortIcon = wx.HDR_SORT_ICON_DOWN if self.sortIcon == wx.HDR_SORT_ICON_UP else wx.HDR_SORT_ICON_UP + self.SetColumnSortIcon(column, self.sortIcon) + + def OnColRightClick(self, event): + column = event.GetColumn() + self.log.write("OnColRightClick: Column %d clicked" % column) + self.SetColumnSortIcon(column, wx.HDR_SORT_ICON_NONE) def OnBeginDrag(self, event): diff --git a/wx/lib/agw/hypertreelist.py b/wx/lib/agw/hypertreelist.py index 263e3930..979891a8 100644 --- a/wx/lib/agw/hypertreelist.py +++ b/wx/lib/agw/hypertreelist.py @@ -472,7 +472,8 @@ class TreeListColumnInfo(object): self._edit = input._edit self._colour = input._colour self._font = input._font - + self._sort_icon = wx.HDR_SORT_ICON_NONE + self._sort_icon_colour = None # get/set def GetText(self): @@ -633,6 +634,33 @@ class TreeListColumnInfo(object): return self._font + def GetSortIcon(self): + """ Returns the column sort icon displayed in the header. """ + + return self._sort_icon + + + def SetSortIcon(self, sortIcon, colour=None): + """ + Sets the column sort icon displayed in the header. + + :param `sortIcon`: the sort icon to display, one of ``wx.HDR_SORT_ICON_NONE``, + ``wx.HDR_SORT_ICON_UP``, ``wx.HDR_SORT_ICON_DOWN``. + :param `colour`: the colour of the sort icon as a wx.Colour. Optional. + Set to ``None`` to restore native colour. + """ + + self._sort_icon = sortIcon + self._sort_icon_colour = colour + return self + + + def GetSortIconColour(self): + """Return the colour of the sort icon (``None`` = Default). """ + + return self._sort_icon_colour + + #----------------------------------------------------------------------------- # TreeListHeaderWindow (internal) #----------------------------------------------------------------------------- @@ -902,6 +930,10 @@ class TreeListHeaderWindow(wx.Window): params.m_labelText = column.GetText() params.m_labelAlignment = column.GetAlignment() + sortIcon = column.GetSortIcon() + sortIconColour = column.GetSortIconColour() + if sortIconColour: + params.m_arrowColour = sortIconColour image = column.GetImage() imageList = self._owner.GetImageList() @@ -913,7 +945,7 @@ class TreeListHeaderWindow(wx.Window): self._headerCustomRenderer.DrawHeaderButton(dc, rect, flags, params) else: wx.RendererNative.Get().DrawHeaderButton(self, dc, rect, flags, - wx.HDR_SORT_ICON_NONE, params) + sortIcon, params) # Fill up any unused space to the right of the columns if x < w: @@ -1298,6 +1330,30 @@ class TreeListHeaderWindow(wx.Window): self._owner._dirty = True + def SetSortIcon(self, column, sortIcon, colour=None): + """ + Sets the sort icon to be displayed in the column header. + + The sort icon will be displayed in the specified column number + and all other columns will have the sort icon cleared. + + :param `column`: an integer specifying the column index; + :param `sortIcon`: the sort icon to display, one of ``wx.HDR_SORT_ICON_NONE``, + ``wx.HDR_SORT_ICON_UP``, ``wx.HDR_SORT_ICON_DOWN``. + :param `colour`: the colour of the sort icon as a wx.Colour. Optional. + Set to ``None`` to restore native colour. + """ + if column < 0 or column >= self.GetColumnCount(): + raise Exception("Invalid column") + + for num in range(self.GetColumnCount()): + if num == column: + self.GetColumn(num).SetSortIcon(sortIcon, colour) + else: + self.GetColumn(num).SetSortIcon(wx.HDR_SORT_ICON_NONE, colour) + self.Refresh() + + # --------------------------------------------------------------------------- # TreeListItem # --------------------------------------------------------------------------- @@ -4940,6 +4996,22 @@ class HyperTreeList(wx.Control): return self._header_win.GetColumn(column).GetFont() + def SetColumnSortIcon(self, column, sortIcon, colour=None): + """ + Sets the sort icon to be displayed in the column header. + + The sort icon will be displayed in the specified column number + and all other columns will have the sort icon cleared. + + :param `column`: an integer specifying the column index; + :param `sortIcon`: the sort icon to display, one of ``wx.HDR_SORT_ICON_NONE``, + ``wx.HDR_SORT_ICON_UP``, ``wx.HDR_SORT_ICON_DOWN``. + :param `colour`: the colour of the sort icon as a wx.Colour. Optional. + Set to ``None`` to restore native colour. + """ + return self._header_win.SetSortIcon(column, sortIcon, colour) + + def Refresh(self, erase=True, rect=None): """ Causes this window, and all of its children recursively (except under wxGTK1 From 0eb68d793f6151868e0b76f0f0f565a68c329852 Mon Sep 17 00:00:00 2001 From: cbeytas Date: Mon, 7 Jan 2019 00:24:12 -0500 Subject: [PATCH 21/32] Prevent wxAssertionError in demo components Initialize the locale in Main.py and run.py in the wxPython demo files. Prevents wx._core.wxAssertionError: C++ assertion "strcmp(setlocale(LC_ALL, NULL), "C") == 0" failed at ..\..\src\common\intl.cpp(1579) in wxLocale::GetInfo() --- demo/Main.py | 1 + demo/run.py | 1 + 2 files changed, 2 insertions(+) diff --git a/demo/Main.py b/demo/Main.py index 00fcffb8..d33e561a 100644 --- a/demo/Main.py +++ b/demo/Main.py @@ -2697,6 +2697,7 @@ def main(): except: pass app = MyApp(False) + locale = wx.Locale(wx.LANGUAGE_DEFAULT) app.MainLoop() #--------------------------------------------------------------------------- diff --git a/demo/run.py b/demo/run.py index 1142e9c5..aab7de6a 100755 --- a/demo/run.py +++ b/demo/run.py @@ -160,6 +160,7 @@ def main(argv): app = RunDemoApp(name, module, useShell) + locale = wx.Locale(wx.LANGUAGE_DEFAULT) app.MainLoop() From b7d118df0f2741196b939f1382a96487cc509a94 Mon Sep 17 00:00:00 2001 From: cbeytas Date: Mon, 7 Jan 2019 00:26:28 -0500 Subject: [PATCH 22/32] Add fullscreen option to CustomTreeCtrl Drag/Drop Feature addition Add SetDragFullScreen and GetDragFullScreen methods which changes the way the simplified drag/drop works in the tree. This flag is passed to the wx.DragImage.BeginDrag() method when it is called. Also add this option to HyperTreeList. Modify the CustomTreeCtrl and HyperTreeList demos so it can be tested. --- demo/agw/CustomTreeCtrl.py | 26 ++++++++++++++++++------- demo/agw/HyperTreeList.py | 25 +++++++++++++++++------- wx/lib/agw/customtreectrl.py | 37 +++++++++++++++++++++++++++++++++++- wx/lib/agw/hypertreelist.py | 13 ++++++++++--- 4 files changed, 83 insertions(+), 18 deletions(-) diff --git a/demo/agw/CustomTreeCtrl.py b/demo/agw/CustomTreeCtrl.py index 44aaffc5..8d954ab1 100644 --- a/demo/agw/CustomTreeCtrl.py +++ b/demo/agw/CustomTreeCtrl.py @@ -979,10 +979,14 @@ class CustomTreeCtrlDemo(wx.Panel): self.checkvista = wx.CheckBox(pnl, -1, "Windows Vista Theme") self.checkvista.Bind(wx.EVT_CHECKBOX, self.OnVista) + self.dragFullScreen = wx.CheckBox(pnl, -1, "Fullscreen Drag/Drop") + self.dragFullScreen.Bind(wx.EVT_CHECKBOX, self.OnDragFullScreen) + themessizer.Add(sizera, 0, wx.EXPAND) themessizer.Add(sizerb, 0, wx.EXPAND) themessizer.Add((0, 5)) themessizer.Add(self.checkvista, 0, wx.EXPAND|wx.ALL, 3) + themessizer.Add(self.dragFullScreen, 0, wx.EXPAND|wx.ALL, 3) mainsizer.Add(stylesizer, 0, wx.EXPAND|wx.ALL, 5) mainsizer.Add(colourssizer, 0, wx.EXPAND|wx.ALL, 5) @@ -1280,6 +1284,12 @@ class CustomTreeCtrlDemo(wx.Panel): event.Skip() + def OnDragFullScreen(self, event): + + self.tree.SetDragFullScreen(event.IsChecked()) + event.Skip() + + #--------------------------------------------------------------------------- # CustomTreeCtrl Demo Implementation #--------------------------------------------------------------------------- @@ -2005,8 +2015,7 @@ class CustomTreeCtrl(CT.CustomTreeCtrl): self.item = event.GetItem() if self.item: - self.log.write("Beginning Drag..." + "\n") - + self.log.write("Beginning Drag... fullscreen=%s\n" % self.GetDragFullScreen()) event.Allow() @@ -2014,16 +2023,19 @@ class CustomTreeCtrl(CT.CustomTreeCtrl): self.item = event.GetItem() if self.item: - self.log.write("Beginning Right Drag..." + "\n") - + self.log.write("Beginning Right Drag... fullscreen=%s\n" % self.GetDragFullScreen()) event.Allow() def OnEndDrag(self, event): - self.item = event.GetItem() - if self.item: - self.log.write("Ending Drag!" + "\n") + if self.GetDragFullScreen() is True: + wnd = wx.FindWindowAtPoint(self.ClientToScreen(event.GetPoint())) + self.log.write("Ending Drag! window=%s\n" % repr(wnd)) + else: + self.item = event.GetItem() + name = self.GetItemText(self.item) if self.item else 'None' + self.log.write("Ending Drag! item=%s\n" % name) event.Skip() diff --git a/demo/agw/HyperTreeList.py b/demo/agw/HyperTreeList.py index 324079bb..f739df9e 100644 --- a/demo/agw/HyperTreeList.py +++ b/demo/agw/HyperTreeList.py @@ -1323,10 +1323,14 @@ class HyperTreeListDemo(wx.Frame): self.checkvista = wx.CheckBox(self.leftpanel, -1, "Windows Vista Theme") self.checkvista.Bind(wx.EVT_CHECKBOX, self.OnVista) + self.dragFullScreen = wx.CheckBox(self.leftpanel, -1, "Fullscreen Drag/Drop") + self.dragFullScreen.Bind(wx.EVT_CHECKBOX, self.OnDragFullScreen) + themessizer.Add(sizera, 0, wx.EXPAND) themessizer.Add(sizerb, 0, wx.EXPAND) themessizer.Add((0, 5)) themessizer.Add(self.checkvista, 0, wx.EXPAND|wx.ALL, 3) + themessizer.Add(self.dragFullScreen, 0, wx.EXPAND|wx.ALL, 3) mainsizer.Add(stylesizer, 0, wx.EXPAND|wx.ALL, 5) mainsizer.Add(columnssizer, 0, wx.EXPAND|wx.ALL, 5) @@ -1679,6 +1683,11 @@ class HyperTreeListDemo(wx.Frame): event.Skip() + def OnDragFullScreen(self, event): + + self.tree.SetDragFullScreen(event.IsChecked()) + event.Skip() + #--------------------------------------------------------------------------- # HyperTreeList Implementation @@ -2427,8 +2436,7 @@ class HyperTreeList(HTL.HyperTreeList): self.item = event.GetItem() if self.item: - self.log.write("Beginning Drag...\n") - + self.log.write("Beginning Drag... fullscreen=%s\n" % self.GetDragFullScreen()) event.Allow() @@ -2436,16 +2444,19 @@ class HyperTreeList(HTL.HyperTreeList): self.item = event.GetItem() if self.item: - self.log.write("Beginning Right Drag...\n") - + self.log.write("Beginning Right Drag... fullscreen=%s\n" % self.GetDragFullScreen()) event.Allow() def OnEndDrag(self, event): - self.item = event.GetItem() - if self.item: - self.log.write("Ending Drag!\n") + if self.GetDragFullScreen() is True: + wnd = wx.FindWindowAtPoint(self.ClientToScreen(event.GetPoint())) + self.log.write("Ending Drag! window=%s\n" % repr(wnd)) + else: + self.item = event.GetItem() + name = self.GetItemText(self.item) if self.item else 'None' + self.log.write("Ending Drag! item=%s\n" % name) event.Skip() diff --git a/wx/lib/agw/customtreectrl.py b/wx/lib/agw/customtreectrl.py index 01660c3b..86c424d7 100644 --- a/wx/lib/agw/customtreectrl.py +++ b/wx/lib/agw/customtreectrl.py @@ -2859,6 +2859,7 @@ class CustomTreeCtrl(wx.ScrolledWindow): self._isDragging = False self._dropTarget = self._oldSelection = None self._dragImage = None + self._dragFullScreen = False self._underMouse = None # EditCtrl initial settings for editable items @@ -4532,6 +4533,36 @@ class CustomTreeCtrl(wx.ScrolledWindow): self.Refresh() + def GetDragFullScreen(self): + """ + Returns whether built-in drag/drop will be full screen or not. + + :return: ``True`` if the drag/drop operation will be full screen, or + ``False`` if only within the tree. + """ + + return self._dragFullScreen + + + def SetDragFullScreen(self, fullScreen=False): + """ + Sets whether a drag operation will be performed full screen or not. + + A full screen drag allows the user to drag outside of the tree to + other controls. When the drag is finished the destination will have + to be found manually in the ``EVT_TREE_END_DRAG`` handler with + something like: + + example:: + + wnd = wx.FindWindowAtPoint(self.ClientToScreen(event.GetPoint())) + + :param bool `fullScreen`: False (default) to drag within tree only. + """ + + self._dragFullScreen = bool(fullScreen) + + # ----------------------------------------------------------------------------- # item status inquiries # ----------------------------------------------------------------------------- @@ -8071,7 +8102,7 @@ class CustomTreeCtrl(wx.ScrolledWindow): # Create the custom draw image from the icons and the text of the item self._dragImage = DragImage(self, self._current) - self._dragImage.BeginDrag(wx.Point(0,0), self) + self._dragImage.BeginDrag(wx.Point(0,0), self, fullScreen=self._dragFullScreen) self._dragImage.Show() self._dragImage.Move(self.CalcScrolledPosition(*pt)) @@ -8079,6 +8110,10 @@ class CustomTreeCtrl(wx.ScrolledWindow): self._dragImage.Move(self.CalcScrolledPosition(*pt)) + if self._dragFullScreen is True: + # Don't highlight target items if dragging full-screen. + return + if self._countDrag == 0 and item: self._oldItem = item diff --git a/wx/lib/agw/hypertreelist.py b/wx/lib/agw/hypertreelist.py index 979891a8..3c655354 100644 --- a/wx/lib/agw/hypertreelist.py +++ b/wx/lib/agw/hypertreelist.py @@ -3636,11 +3636,15 @@ class TreeListMainWindow(CustomTreeCtrl): # BeginDrag captures mouse. GTK cannot capture mouse twice. if self.HasCapture() is True: self.ReleaseMouse() - self._dragImage.BeginDrag(wx.Point(0,0), self) + self._dragImage.BeginDrag(wx.Point(0,0), self, fullScreen=self._dragFullScreen) self._dragImage.Show() self._dragImage.Move(p) + if self._dragFullScreen is True: + # Don't highlight target items if dragging full-screen. + return + if self._countDrag == 0 and item: self._oldItem = self._current self._oldSelection = self._current @@ -3694,6 +3698,7 @@ class TreeListMainWindow(CustomTreeCtrl): # we're going to drag this item self._isDragging = True + self._left_down_selection = True # Stop DoSelect on drag end. if not self.HasCapture(): self.CaptureMouse() self.RefreshSelected() @@ -4238,8 +4243,8 @@ _methods = ["GetIndent", "SetIndent", "GetSpacing", "SetSpacing", "GetImageList" "CheckChilds", "CheckSameLevel", "GetItemWindowEnabled", "SetItemWindowEnabled", "GetItemType", "IsDescendantOf", "SetItemHyperText", "IsItemHyperText", "SetItemBold", "SetItemDropHighlight", "SetItemItalic", "GetEditControl", "ShouldInheritColours", "GetItemWindow", "SetItemWindow", "DeleteItemWindow", "SetItemTextColour", - "HideItem", "DeleteAllItems", "ItemHasChildren", "ToggleItemSelection", "SetItemType", "GetCurrentItem", - "SetItem3State", "SetItem3StateValue", "GetItem3StateValue", "IsItem3State", "GetPrev", + "HideItem", "DeleteAllItems", "ItemHasChildren", "ToggleItemSelection", "SetItemType", "GetDragFullScreen", "SetDragFullScreen", + "GetCurrentItem", "SetItem3State", "SetItem3StateValue", "GetItem3StateValue", "IsItem3State", "GetPrev", "GetNextShown", "GetPrevShown"] @@ -4304,6 +4309,7 @@ class HyperTreeList(wx.Control): :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetCount` Returns the global number of items in the tree. :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.GetCurrentItem` Returns the current item. Simply calls :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetSelection`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetDisabledColour` Returns the colour for items in a disabled state. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetDragFullScreen` Returns whether built-in drag/drop will be full screen or not. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetEditControl` Returns a reference to the edit :class:`~wx.lib.agw.customtreectrl.TreeTextCtrl` if the item is being edited. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetFirstChild` Returns the item's first child and an integer value 'cookie'. :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.GetFirstExpandedItem` Returns the first item which is in the expanded state. @@ -4375,6 +4381,7 @@ class HyperTreeList(wx.Control): :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetButtonsImageList` Sets the buttons image list for :class:`TreeListMainWindow`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetConnectionPen` Sets the pen used to draw the connecting lines between items. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetDisabledColour` Sets the colour for items in a disabled state. + :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetDragFullScreen` Sets whether a drag operation will be performed full screen or not. :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.SetDragItem` Sets the specified item as member of a current drag and drop operation. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetFirstGradientColour` Sets the first gradient colour for gradient-style selections. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetGradientStyle` Sets the gradient style for gradient-style selections. From 4000d30dc1a9f606c82007b3aa235f9c791a7f89 Mon Sep 17 00:00:00 2001 From: cbeytas Date: Mon, 7 Jan 2019 00:27:44 -0500 Subject: [PATCH 23/32] Update build.py to run 'touch' command in Windows Allows the `touch` command to be run in a Windows environment. Uses the old "copy /B FILENAME +,," trick to update the timestamps. --- build.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build.py b/build.py index caa08801..41f4c2cf 100755 --- a/build.py +++ b/build.py @@ -1181,7 +1181,12 @@ def cmd_sip(options, args): def cmd_touch(options, args): cmdTimer = CommandTimer('touch') pwd = pushDir(phoenixDir()) - runcmd('touch etg/*.py') + if isWindows: + # Windows touch + runcmd('cd etg && for %f in (*.py) do copy /B %f +,,') + else: + # Linux touch + runcmd('touch etg/*.py') From bb32d62f71af4b661b4c9cb134d4c9e08ebac73a Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 11 Jan 2021 11:56:13 -0800 Subject: [PATCH 24/32] Update wxWidgets revision to current master --- ext/wxWidgets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/wxWidgets b/ext/wxWidgets index bf6fee0a..8eab460c 160000 --- a/ext/wxWidgets +++ b/ext/wxWidgets @@ -1 +1 @@ -Subproject commit bf6fee0af9b4cf7b4ff0a289992fa4f02488b27d +Subproject commit 8eab460c0dc3fe870a102416bf267b1d823cc437 From 927b00f0833b0a7976778d2ff74795fd859d0be0 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 11 Jan 2021 11:56:39 -0800 Subject: [PATCH 25/32] Add wx.ImageDataObject --- docs/sphinx/itemToModuleMap.json | 1 + etg/dataobj.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/sphinx/itemToModuleMap.json b/docs/sphinx/itemToModuleMap.json index 84e17e9e..34a703bd 100644 --- a/docs/sphinx/itemToModuleMap.json +++ b/docs/sphinx/itemToModuleMap.json @@ -1927,6 +1927,7 @@ "IdleMode":"wx.", "Image":"wx.", "ImageAlphaBlendMode":"wx.", +"ImageDataObject":"wx.", "ImageFileProperty":"wx.propgrid.", "ImageFromBitmap":"wx.", "ImageFromBuffer":"wx.", diff --git a/etg/dataobj.py b/etg/dataobj.py index e59632df..e6b00b3e 100644 --- a/etg/dataobj.py +++ b/etg/dataobj.py @@ -28,6 +28,7 @@ ITEMS = [ 'wxDataFormat', 'wxURLDataObject', 'wxFileDataObject', 'wxHTMLDataObject', + 'wxImageDataObject' ] @@ -391,6 +392,11 @@ def run(): addBaseVirtuals(c) addSimpleVirtuals(c) + #------------------------------------------------------------ + c = module.find('wxImageDataObject') + addGetAllFormats(c) + addBaseVirtuals(c) + #------------------------------------------------------------ c = module.find('wxFileDataObject') addGetAllFormats(c) @@ -404,7 +410,6 @@ def run(): addSimpleVirtuals(c) - #------------------------------------------------------------ module.addPyCode("PyDataObjectSimple = wx.deprecated(DataObjectSimple), 'Use DataObjectSimple instead.'") module.addPyCode("PyTextDataObject = wx.deprecated(TextDataObject, 'Use TextDataObject instead.')") From 7854e314065743ae39f186164a08d09608a00da0 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 11 Jan 2021 12:28:52 -0800 Subject: [PATCH 26/32] Update wxWidgets revision to current master --- ext/wxWidgets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/wxWidgets b/ext/wxWidgets index 8eab460c..0df1d81a 160000 --- a/ext/wxWidgets +++ b/ext/wxWidgets @@ -1 +1 @@ -Subproject commit 8eab460c0dc3fe870a102416bf267b1d823cc437 +Subproject commit 0df1d81acd6f1be8624022f8eecb51679008ca40 From 843a99eb1de322539f10abc101e42a4a2fc20f27 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 11 Jan 2021 12:35:12 -0800 Subject: [PATCH 27/32] wx.DF_PNG has been added --- docs/sphinx/itemToModuleMap.json | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/sphinx/itemToModuleMap.json b/docs/sphinx/itemToModuleMap.json index 34a703bd..5fa174fb 100644 --- a/docs/sphinx/itemToModuleMap.json +++ b/docs/sphinx/itemToModuleMap.json @@ -802,6 +802,7 @@ "DF_OEMTEXT":"wx.", "DF_PALETTE":"wx.", "DF_PENDATA":"wx.", +"DF_PNG":"wx.", "DF_PRIVATE":"wx.", "DF_RIFF":"wx.", "DF_SYLK":"wx.", From 3714437611097874fc791447995dbc7994f13520 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Sat, 16 Jan 2021 15:33:57 -0800 Subject: [PATCH 28/32] Pythonize wx.GenericDirCtrl.GetPaths --- etg/dirctrl.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/etg/dirctrl.py b/etg/dirctrl.py index 586b7355..da3bc4d9 100644 --- a/etg/dirctrl.py +++ b/etg/dirctrl.py @@ -38,6 +38,16 @@ def run(): assert isinstance(c, etgtools.ClassDef) tools.fixTopLevelWindowClass(c) + c.find('GetPaths').ignore() + c.addCppMethod('wxArrayString*', 'GetPaths', '()', pyArgsString="() -> list", + doc='Returns a list of the currently selected paths.', + body="""\ + wxArrayString* paths = new wxArrayString; + self->GetPaths(*paths); + return paths; + """ + ) + module.addPyCode("""\ EVT_DIRCTRL_SELECTIONCHANGED = wx.PyEventBinder( wxEVT_DIRCTRL_SELECTIONCHANGED, 1 ) EVT_DIRCTRL_FILEACTIVATED = wx.PyEventBinder( wxEVT_DIRCTRL_FILEACTIVATED, 1 ) From 40e454d179d3e7b342ee38888133c370d3cfa1f5 Mon Sep 17 00:00:00 2001 From: Kevin Schlosser Date: Mon, 11 Jan 2021 14:20:07 -0700 Subject: [PATCH 29/32] Fixes floating point math in wx.lib.agw.aui wx.lib.agw.aui was never converted to run on Python 3 and as a result the division operator forces a conversion of the used values to a float. Floats cannot be used in functions like `range`. This caused quite number of things to not function properly and produce tracebacks. The other thing is when wx.lib.agw.aui was written pixels could not be rendered using coordinates that were floats so now passing floats could cause rendering alignment problems because the layout of the various bits were done so in a manner that would have the alignment correct using integers. --- wx/lib/agw/aui/aui_switcherdialog.py | 4 +- wx/lib/agw/aui/aui_utilities.py | 17 +- wx/lib/agw/aui/auibar.py | 44 +- wx/lib/agw/aui/auibook.py | 6 +- wx/lib/agw/aui/framemanager.py | 1003 +++++++++----------------- wx/lib/agw/aui/tabart.py | 104 +-- 6 files changed, 409 insertions(+), 769 deletions(-) diff --git a/wx/lib/agw/aui/aui_switcherdialog.py b/wx/lib/agw/aui/aui_switcherdialog.py index 219db324..72604273 100644 --- a/wx/lib/agw/aui/aui_switcherdialog.py +++ b/wx/lib/agw/aui/aui_switcherdialog.py @@ -621,12 +621,12 @@ class SwitcherItems(object): and item.GetBitmap().GetHeight() <= 16: x -= textMarginX dc.DrawBitmap(item.GetBitmap(), x, item.GetRect().y + \ - (item.GetRect().height - item.GetBitmap().GetHeight())/2, + (item.GetRect().height - item.GetBitmap().GetHeight())//2, True) x += 16 + textMarginX #x += textMarginX - y = item.GetRect().y + (item.GetRect().height - h)/2 + y = item.GetRect().y + (item.GetRect().height - h)//2 dc.DrawText(item.GetTitle(), x, y) dc.DestroyClippingRegion() diff --git a/wx/lib/agw/aui/aui_utilities.py b/wx/lib/agw/aui/aui_utilities.py index dfcf66e6..7bad7351 100644 --- a/wx/lib/agw/aui/aui_utilities.py +++ b/wx/lib/agw/aui/aui_utilities.py @@ -322,9 +322,9 @@ def DarkenBitmap(bmp, caption_colour, new_colour): """ image = bmp.ConvertToImage() - red = caption_colour.Red()/float(new_colour.Red()) - green = caption_colour.Green()/float(new_colour.Green()) - blue = caption_colour.Blue()/float(new_colour.Blue()) + red = caption_colour.Red()/new_colour.Red() + green = caption_colour.Green()/new_colour.Green() + blue = caption_colour.Blue()/new_colour.Blue() image = image.AdjustChannels(red, green, blue) return image.ConvertToBitmap() @@ -584,13 +584,13 @@ def RescaleScreenShot(bmp, thumbnail_size=200): if bmpW > bmpH: if bmpW > thumbnail_size: - ratio = bmpW/float(thumbnail_size) - newW, newH = int(bmpW/ratio), int(bmpH/ratio) + ratio = bmpW/thumbnail_size + newW, newH = bmpW//ratio, bmpH//ratio img.Rescale(newW, newH, wx.IMAGE_QUALITY_HIGH) else: if bmpH > thumbnail_size: - ratio = bmpH/float(thumbnail_size) - newW, newH = int(bmpW/ratio), int(bmpH/ratio) + ratio = bmpH/thumbnail_size + newW, newH = bmpW//ratio, bmpH//ratio img.Rescale(newW, newH, wx.IMAGE_QUALITY_HIGH) newBmp = img.ConvertToBitmap() @@ -667,3 +667,6 @@ def CopyAttributes(newArt, oldArt): return newArt + + + diff --git a/wx/lib/agw/aui/auibar.py b/wx/lib/agw/aui/auibar.py index 39b92982..b159e2ee 100644 --- a/wx/lib/agw/aui/auibar.py +++ b/wx/lib/agw/aui/auibar.py @@ -979,16 +979,16 @@ class AuiDefaultToolBarArt(object): if orient == AUI_TBTOOL_HORIZONTAL: text_x = rect.x - text_y = rect.y + (rect.height-text_height)/2 + text_y = rect.y + (rect.height-text_height)//2 dc.DrawText(item.GetLabel(), text_x, text_y) elif orient == AUI_TBTOOL_VERT_CLOCKWISE: - text_x = rect.x + (rect.width+text_width)/2 + text_x = rect.x + (rect.width+text_width)//2 text_y = rect.y dc.DrawRotatedText(item.GetLabel(), text_x, text_y, 270) elif AUI_TBTOOL_VERT_COUNTERCLOCKWISE: - text_x = rect.x + (rect.width-text_width)/2 + text_x = rect.x + (rect.width-text_width)//2 text_y = rect.y + text_height dc.DrawRotatedText(item.GetLabel(), text_x, text_y, 90) @@ -1086,8 +1086,8 @@ class AuiDefaultToolBarArt(object): dropbmp_width = dropbmp_height dropbmp_height = tmp - dropbmp_x = dropdown_rect.x + (dropdown_rect.width/2) - dropbmp_width/2 - dropbmp_y = dropdown_rect.y + (dropdown_rect.height/2) - dropbmp_height/2 + dropbmp_x = dropdown_rect.x + (dropdown_rect.width//2) - dropbmp_width//2 + dropbmp_y = dropdown_rect.y + (dropdown_rect.height//2) - dropbmp_height//2 bmp_rect, text_rect = self.GetToolsPosition(dc, item, button_rect) @@ -1171,7 +1171,7 @@ class AuiDefaultToolBarArt(object): # set the label's text colour dc.SetTextForeground(wx.BLACK) - text_x = rect.x + (rect.width/2) - (text_width/2) + 1 + text_x = rect.x + (rect.width//2) - (text_width//2) + 1 text_y = rect.y + rect.height - text_height - 1 if self._agwFlags & AUI_TB_TEXT and item.GetLabel() != "": @@ -1264,18 +1264,18 @@ class AuiDefaultToolBarArt(object): if horizontal: - rect.x += (rect.width/2) + rect.x += (rect.width//2) rect.width = 1 - new_height = (rect.height*3)/4 - rect.y += (rect.height/2) - (new_height/2) + new_height = (rect.height*3)//4 + rect.y += (rect.height//2) - (new_height//2) rect.height = new_height else: - rect.y += (rect.height/2) + rect.y += (rect.height//2) rect.height = 1 - new_width = (rect.width*3)/4 - rect.x += (rect.width/2) - (new_width/2) + new_width = (rect.width*3)//4 + rect.x += (rect.width//2) - (new_width//2) rect.width = new_width start_colour = StepColour(self._base_colour, 80) @@ -1359,8 +1359,8 @@ class AuiDefaultToolBarArt(object): dc.SetBrush(wx.Brush(light_gray_bg)) dc.DrawRectangle(rect.x+1, rect.y, rect.width, rect.height) - x = rect.x + 1 + (rect.width-self._overflow_bmp.GetWidth())/2 - y = rect.y + 1 + (rect.height-self._overflow_bmp.GetHeight())/2 + x = rect.x + 1 + (rect.width-self._overflow_bmp.GetWidth())//2 + y = rect.y + 1 + (rect.height-self._overflow_bmp.GetHeight())//2 dc.DrawBitmap(self._overflow_bmp, x, y, True) @@ -1492,21 +1492,21 @@ class AuiDefaultToolBarArt(object): bmp_x = bmp_y = text_x = text_y = 0 if horizontal and text_bottom: - bmp_x = rect.x + (rect.width/2) - (bmp_width/2) + bmp_x = rect.x + (rect.width//2) - (bmp_width//2) bmp_y = rect.y + 3 - text_x = rect.x + (rect.width/2) - (text_width/2) + text_x = rect.x + (rect.width//2) - (text_width//2) text_y = rect.y + ((bmp_y - rect.y) * 2) + bmp_height elif horizontal and text_right: bmp_x = rect.x + 3 - bmp_y = rect.y + (rect.height/2) - (bmp_height / 2) + bmp_y = rect.y + (rect.height//2) - (bmp_height // 2) text_x = rect.x + ((bmp_x - rect.x) * 2) + bmp_width - text_y = rect.y + (rect.height/2) - (text_height/2) + text_y = rect.y + (rect.height//2) - (text_height//2) elif not horizontal and text_bottom: - bmp_x = rect.x + (rect.width / 2) - (bmp_width / 2) + bmp_x = rect.x + (rect.width // 2) - (bmp_width // 2) bmp_y = rect.y + 3 - text_x = rect.x + (rect.width / 2) - (text_width / 2) + text_x = rect.x + (rect.width // 2) - (text_width // 2) text_y = rect.y + ((bmp_y - rect.y) * 2) + bmp_height bmp_rect = wx.Rect(bmp_x, bmp_y, bmp_width, bmp_height) @@ -3257,9 +3257,6 @@ class AuiToolBar(wx.Control): def DoIdleUpdate(self): """ Updates the toolbar during idle times. """ - if not self: - return # The action Destroyed the toolbar! - handler = self.GetEventHandler() if not handler: return @@ -4031,3 +4028,4 @@ class AuiToolBar(wx.Control): manager = self.GetAuiManager() manager.StopPreviewTimer() + diff --git a/wx/lib/agw/aui/auibook.py b/wx/lib/agw/aui/auibook.py index 2095ab6f..ba7cf472 100644 --- a/wx/lib/agw/aui/auibook.py +++ b/wx/lib/agw/aui/auibook.py @@ -175,7 +175,7 @@ class TabTextCtrl(ExpandoTextCtrl): x += image_w w -= image_w + 4 - y = (self._tabEdited.rect.height - h)/2 + 1 + y = (self._tabEdited.rect.height - h)//2 + 1 expandoStyle = wx.WANTS_CHARS if wx.Platform in ["__WXGTK__", "__WXMAC__"]: @@ -864,7 +864,7 @@ class TabNavigatorWindow(wx.Dialog): # Draw the caption title and place the bitmap # get the bitmap optimal position, and draw it bmpPt, txtPt = wx.Point(), wx.Point() - bmpPt.y = (rect.height - self._props.Icon.GetHeight())/2 + bmpPt.y = (rect.height - self._props.Icon.GetHeight())//2 bmpPt.x = 3 mem_dc.DrawBitmap(self._props.Icon, bmpPt.x, bmpPt.y, True) @@ -875,7 +875,7 @@ class TabNavigatorWindow(wx.Dialog): fontHeight = mem_dc.GetCharHeight() txtPt.x = bmpPt.x + self._props.Icon.GetWidth() + 4 - txtPt.y = (rect.height - fontHeight)/2 + txtPt.y = (rect.height - fontHeight)//2 mem_dc.SetTextForeground(wx.WHITE) mem_dc.DrawText("Opened tabs:", txtPt.x, txtPt.y) mem_dc.SelectObject(wx.NullBitmap) diff --git a/wx/lib/agw/aui/framemanager.py b/wx/lib/agw/aui/framemanager.py index e8216f67..a3f2e431 100644 --- a/wx/lib/agw/aui/framemanager.py +++ b/wx/lib/agw/aui/framemanager.py @@ -95,10 +95,10 @@ is by running the AUI sample (`AUI.py`). __author__ = "Andrea Gavana " __date__ = "31 March 2009" - import wx # just for isinstance from time import time + try: from time import perf_counter except ImportError: # clock is removed in py3.8 @@ -125,6 +125,7 @@ _winxptheme = False if wx.Platform == "__WXMSW__": try: import winxptheme + _winxptheme = True except ImportError: pass @@ -177,6 +178,7 @@ EVT_AUI_PANE_ACTIVATED = wx.PyEventBinder(wxEVT_AUI_PANE_ACTIVATED, 0) EVT_AUI_PERSPECTIVE_CHANGED = wx.PyEventBinder(wxEVT_AUI_PERSPECTIVE_CHANGED, 0) """ The layout in `AuiManager` has been changed. """ + # ---------------------------------------------------------------------------- # class AuiDockInfo(object): @@ -201,7 +203,6 @@ class AuiDockInfo(object): self.rect = wx.Rect() self.panes = [] - def IsOk(self): """ Returns whether a dock is valid or not. @@ -211,13 +212,11 @@ class AuiDockInfo(object): return self.dock_direction != 0 - def IsHorizontal(self): """ Returns whether the dock is horizontal or not. """ return self.dock_direction in [AUI_DOCK_TOP, AUI_DOCK_BOTTOM] - def IsVertical(self): """ Returns whether the dock is vertical or not. """ @@ -245,7 +244,6 @@ class AuiDockingGuideInfo(object): # dock direction (top, bottom, left, right, center) self.dock_direction = AUI_DOCK_NONE - def Assign(self, other): """ Assigns the properties of the `other` :class:`AuiDockingGuideInfo` to `self`. @@ -256,7 +254,6 @@ class AuiDockingGuideInfo(object): self.host = other.host self.dock_direction = other.dock_direction - def Host(self, h): """ Hosts a docking guide window. @@ -267,42 +264,36 @@ class AuiDockingGuideInfo(object): self.host = h return self - def Left(self): """ Sets the guide window to left docking. """ self.dock_direction = AUI_DOCK_LEFT return self - def Right(self): """ Sets the guide window to right docking. """ self.dock_direction = AUI_DOCK_RIGHT return self - def Top(self): """ Sets the guide window to top docking. """ self.dock_direction = AUI_DOCK_TOP return self - def Bottom(self): """ Sets the guide window to bottom docking. """ self.dock_direction = AUI_DOCK_BOTTOM return self - def Center(self): """ Sets the guide window to center docking. """ self.dock_direction = AUI_DOCK_CENTER return self - def Centre(self): """ Sets the guide window to centre docking. """ @@ -376,7 +367,6 @@ class AuiManagerEvent(wx.PyCommandEvent): self.canveto_flag = True self.dc = None - def SetManager(self, mgr): """ Associates a :class:`AuiManager` to the current event. @@ -386,7 +376,6 @@ class AuiManagerEvent(wx.PyCommandEvent): self.manager = mgr - def SetDC(self, pdc): """ Associates a :class:`wx.DC` device context to this event. @@ -396,7 +385,6 @@ class AuiManagerEvent(wx.PyCommandEvent): self.dc = pdc - def SetPane(self, p): """ Associates a :class:`AuiPaneInfo` instance to this event. @@ -406,7 +394,6 @@ class AuiManagerEvent(wx.PyCommandEvent): self.pane = p - def SetButton(self, b): """ Associates a :class:`AuiPaneButton` instance to this event. @@ -416,31 +403,26 @@ class AuiManagerEvent(wx.PyCommandEvent): self.button = b - def GetManager(self): """ Returns the associated :class:`AuiManager` (if any). """ return self.manager - def GetDC(self): """ Returns the associated :class:`wx.DC` device context (if any). """ return self.dc - def GetPane(self): """ Returns the associated :class:`AuiPaneInfo` structure (if any). """ return self.pane - def GetButton(self): """ Returns the associated :class:`AuiPaneButton` instance (if any). """ return self.button - def Veto(self, veto=True): """ Prevents the change announced by this event from happening. @@ -454,13 +436,11 @@ class AuiManagerEvent(wx.PyCommandEvent): self.veto_flag = veto - def GetVeto(self): """ Returns whether the event has been vetoed or not. """ return self.veto_flag - def SetCanVeto(self, can_veto): """ Sets whether the event can be vetoed or not. @@ -470,11 +450,10 @@ class AuiManagerEvent(wx.PyCommandEvent): self.canveto_flag = can_veto - def CanVeto(self): """ Returns whether the event can be vetoed and has been vetoed. """ - return self.canveto_flag and self.veto_flag + return self.canveto_flag and self.veto_flag # ---------------------------------------------------------------------------- # @@ -487,47 +466,46 @@ class AuiPaneInfo(object): size, minimum size, caption text among many other parameters. """ - optionFloating = 2**0 - optionHidden = 2**1 - optionLeftDockable = 2**2 - optionRightDockable = 2**3 - optionTopDockable = 2**4 - optionBottomDockable = 2**5 - optionFloatable = 2**6 - optionMovable = 2**7 - optionResizable = 2**8 - optionPaneBorder = 2**9 - optionCaption = 2**10 - optionGripper = 2**11 - optionDestroyOnClose = 2**12 - optionToolbar = 2**13 - optionActive = 2**14 - optionGripperTop = 2**15 - optionMaximized = 2**16 - optionDockFixed = 2**17 - optionNotebookDockable = 2**18 - optionMinimized = 2**19 - optionLeftSnapped = 2**20 - optionRightSnapped = 2**21 - optionTopSnapped = 2**22 - optionBottomSnapped = 2**23 - optionFlyOut = 2**24 - optionCaptionLeft = 2**25 + optionFloating = 2 ** 0 + optionHidden = 2 ** 1 + optionLeftDockable = 2 ** 2 + optionRightDockable = 2 ** 3 + optionTopDockable = 2 ** 4 + optionBottomDockable = 2 ** 5 + optionFloatable = 2 ** 6 + optionMovable = 2 ** 7 + optionResizable = 2 ** 8 + optionPaneBorder = 2 ** 9 + optionCaption = 2 ** 10 + optionGripper = 2 ** 11 + optionDestroyOnClose = 2 ** 12 + optionToolbar = 2 ** 13 + optionActive = 2 ** 14 + optionGripperTop = 2 ** 15 + optionMaximized = 2 ** 16 + optionDockFixed = 2 ** 17 + optionNotebookDockable = 2 ** 18 + optionMinimized = 2 ** 19 + optionLeftSnapped = 2 ** 20 + optionRightSnapped = 2 ** 21 + optionTopSnapped = 2 ** 22 + optionBottomSnapped = 2 ** 23 + optionFlyOut = 2 ** 24 + optionCaptionLeft = 2 ** 25 - buttonClose = 2**26 - buttonMaximize = 2**27 - buttonMinimize = 2**28 - buttonPin = 2**29 + buttonClose = 2 ** 26 + buttonMaximize = 2 ** 27 + buttonMinimize = 2 ** 28 + buttonPin = 2 ** 29 - buttonCustom1 = 2**30 - buttonCustom2 = 2**31 - buttonCustom3 = 2**32 - - savedHiddenState = 2**33 # used internally - actionPane = 2**34 # used internally - wasMaximized = 2**35 # used internally - needsRestore = 2**36 # used internally + buttonCustom1 = 2 ** 30 + buttonCustom2 = 2 ** 31 + buttonCustom3 = 2 ** 32 + savedHiddenState = 2 ** 33 # used internally + actionPane = 2 ** 34 # used internally + wasMaximized = 2 ** 35 # used internally + needsRestore = 2 ** 36 # used internally def __init__(self): """ Default class constructor. """ @@ -561,7 +539,6 @@ class AuiPaneInfo(object): self.DefaultPane() - def dock_direction_get(self): """ Getter for the `dock_direction`. @@ -574,7 +551,6 @@ class AuiPaneInfo(object): else: return self._dock_direction - def dock_direction_set(self, value): """ Setter for the `dock_direction`. @@ -609,55 +585,46 @@ class AuiPaneInfo(object): return self.window is not None - def IsMaximized(self): """ Returns ``True`` if the pane is maximized. """ return self.HasFlag(self.optionMaximized) - def IsMinimized(self): """ Returns ``True`` if the pane is minimized. """ return self.HasFlag(self.optionMinimized) - def IsFixed(self): """ Returns ``True`` if the pane cannot be resized. """ return not self.HasFlag(self.optionResizable) - def IsResizeable(self): """ Returns ``True`` if the pane can be resized. """ return self.HasFlag(self.optionResizable) - def IsShown(self): """ Returns ``True`` if the pane is currently shown. """ return not self.HasFlag(self.optionHidden) - def IsFloating(self): """ Returns ``True`` if the pane is floating. """ return self.HasFlag(self.optionFloating) - def IsDocked(self): """ Returns ``True`` if the pane is docked. """ return not self.HasFlag(self.optionFloating) - def IsToolbar(self): """ Returns ``True`` if the pane contains a toolbar. """ return self.HasFlag(self.optionToolbar) - def IsTopDockable(self): """ Returns ``True`` if the pane can be docked at the top @@ -666,7 +633,6 @@ class AuiPaneInfo(object): return self.HasFlag(self.optionTopDockable) - def IsBottomDockable(self): """ Returns ``True`` if the pane can be docked at the bottom @@ -675,7 +641,6 @@ class AuiPaneInfo(object): return self.HasFlag(self.optionBottomDockable) - def IsLeftDockable(self): """ Returns ``True`` if the pane can be docked at the left @@ -684,7 +649,6 @@ class AuiPaneInfo(object): return self.HasFlag(self.optionLeftDockable) - def IsRightDockable(self): """ Returns ``True`` if the pane can be docked at the right @@ -693,14 +657,12 @@ class AuiPaneInfo(object): return self.HasFlag(self.optionRightDockable) - def IsDockable(self): """ Returns ``True`` if the pane can be docked. """ return self.IsTopDockable() or self.IsBottomDockable() or self.IsLeftDockable() or \ self.IsRightDockable() or self.IsNotebookDockable() - def IsFloatable(self): """ Returns ``True`` if the pane can be undocked and displayed as a @@ -709,7 +671,6 @@ class AuiPaneInfo(object): return self.HasFlag(self.optionFloatable) - def IsMovable(self): """ Returns ``True`` if the docked frame can be undocked or moved to @@ -718,7 +679,6 @@ class AuiPaneInfo(object): return self.HasFlag(self.optionMovable) - def IsDestroyOnClose(self): """ Returns ``True`` if the pane should be destroyed when it is closed. @@ -730,7 +690,6 @@ class AuiPaneInfo(object): return self.HasFlag(self.optionDestroyOnClose) - def IsNotebookDockable(self): """ Returns ``True`` if a pane can be docked on top to another to create a @@ -739,86 +698,72 @@ class AuiPaneInfo(object): return self.HasFlag(self.optionNotebookDockable) - def IsTopSnappable(self): """ Returns ``True`` if the pane can be snapped at the top of the managed frame. """ return self.HasFlag(self.optionTopSnapped) - def IsBottomSnappable(self): """ Returns ``True`` if the pane can be snapped at the bottom of the managed frame. """ return self.HasFlag(self.optionBottomSnapped) - def IsLeftSnappable(self): """ Returns ``True`` if the pane can be snapped on the left of the managed frame. """ return self.HasFlag(self.optionLeftSnapped) - def IsRightSnappable(self): """ Returns ``True`` if the pane can be snapped on the right of the managed frame. """ return self.HasFlag(self.optionRightSnapped) - def IsSnappable(self): """ Returns ``True`` if the pane can be snapped. """ return self.IsTopSnappable() or self.IsBottomSnappable() or self.IsLeftSnappable() or \ self.IsRightSnappable() - def IsFlyOut(self): """ Returns ``True`` if the floating pane has a "fly-out" effect. """ return self.HasFlag(self.optionFlyOut) - def HasCaption(self): """ Returns ``True`` if the pane displays a caption. """ return self.HasFlag(self.optionCaption) - def HasCaptionLeft(self): """ Returns ``True`` if the pane displays a caption on the left (rotated by 90 degrees). """ return self.HasFlag(self.optionCaptionLeft) - def HasGripper(self): """ Returns ``True`` if the pane displays a gripper. """ return self.HasFlag(self.optionGripper) - def HasBorder(self): """ Returns ``True`` if the pane displays a border. """ return self.HasFlag(self.optionPaneBorder) - def HasCloseButton(self): """ Returns ``True`` if the pane displays a button to close the pane. """ return self.HasFlag(self.buttonClose) - def HasMaximizeButton(self): """ Returns ``True`` if the pane displays a button to maximize the pane. """ return self.HasFlag(self.buttonMaximize) - def HasMinimizeButton(self): """ Returns ``True`` if the pane displays a button to minimize the pane. """ return self.HasFlag(self.buttonMinimize) - def GetMinimizeMode(self): """ Returns the minimization style for this pane. @@ -854,19 +799,16 @@ class AuiPaneInfo(object): return self.minimize_mode - def HasPinButton(self): """ Returns ``True`` if the pane displays a button to float the pane. """ return self.HasFlag(self.buttonPin) - def HasGripperTop(self): """ Returns ``True`` if the pane displays a gripper at the top. """ return self.HasFlag(self.optionGripperTop) - def Window(self, w): """ Associate a :class:`wx.Window` derived window to this pane. @@ -881,7 +823,6 @@ class AuiPaneInfo(object): self.window = w return self - def Name(self, name): """ Sets the name of the pane so it can be referenced in lookup functions. @@ -901,7 +842,6 @@ class AuiPaneInfo(object): self.name = name return self - def Caption(self, caption): """ Sets the caption of the pane. @@ -912,7 +852,6 @@ class AuiPaneInfo(object): self.caption = caption return self - def Left(self): """ Sets the pane dock position to the left side of the frame. @@ -924,7 +863,6 @@ class AuiPaneInfo(object): self.dock_direction = AUI_DOCK_LEFT return self - def Right(self): """ Sets the pane dock position to the right side of the frame. @@ -936,7 +874,6 @@ class AuiPaneInfo(object): self.dock_direction = AUI_DOCK_RIGHT return self - def Top(self): """ Sets the pane dock position to the top of the frame. @@ -948,7 +885,6 @@ class AuiPaneInfo(object): self.dock_direction = AUI_DOCK_TOP return self - def Bottom(self): """ Sets the pane dock position to the bottom of the frame. @@ -960,7 +896,6 @@ class AuiPaneInfo(object): self.dock_direction = AUI_DOCK_BOTTOM return self - def Center(self): """ Sets the pane to the center position of the frame. @@ -975,7 +910,6 @@ class AuiPaneInfo(object): self.dock_direction = AUI_DOCK_CENTER return self - def Centre(self): """ Sets the pane to the center position of the frame. @@ -990,7 +924,6 @@ class AuiPaneInfo(object): self.dock_direction = AUI_DOCK_CENTRE return self - def Direction(self, direction): """ Determines the direction of the docked pane. It is functionally the @@ -1005,7 +938,6 @@ class AuiPaneInfo(object): self.dock_direction = direction return self - def Layer(self, layer): """ Determines the layer of the docked pane. @@ -1020,7 +952,6 @@ class AuiPaneInfo(object): self.dock_layer = layer return self - def Row(self, row): """ Determines the row of the docked pane. @@ -1031,7 +962,6 @@ class AuiPaneInfo(object): self.dock_row = row return self - def Position(self, pos): """ Determines the position of the docked pane. @@ -1042,7 +972,6 @@ class AuiPaneInfo(object): self.dock_pos = pos return self - def MinSize(self, arg1=None, arg2=None): """ Sets the minimum size of the pane. @@ -1061,11 +990,10 @@ class AuiPaneInfo(object): elif isinstance(arg1, six.integer_types) and arg2 is not None: ret = self.MinSize2(arg1, arg2) else: - raise Exception("Invalid argument passed to `MinSize`: arg1=%s, arg2=%s"%(repr(arg1), repr(arg2))) + raise Exception("Invalid argument passed to `MinSize`: arg1=%s, arg2=%s" % (repr(arg1), repr(arg2))) return ret - def MinSize1(self, size): """ Sets the minimum size of the pane. @@ -1075,7 +1003,6 @@ class AuiPaneInfo(object): self.min_size = size return self - def MinSize2(self, x, y): """ Sets the minimum size of the pane. @@ -1086,7 +1013,6 @@ class AuiPaneInfo(object): self.min_size = wx.Size(x, y) return self - def MaxSize(self, arg1=None, arg2=None): """ Sets the maximum size of the pane. @@ -1105,11 +1031,10 @@ class AuiPaneInfo(object): elif isinstance(arg1, six.integer_types) and arg2 is not None: ret = self.MaxSize2(arg1, arg2) else: - raise Exception("Invalid argument passed to `MaxSize`: arg1=%s, arg2=%s"%(repr(arg1), repr(arg2))) + raise Exception("Invalid argument passed to `MaxSize`: arg1=%s, arg2=%s" % (repr(arg1), repr(arg2))) return ret - def MaxSize1(self, size): """ Sets the maximum size of the pane. @@ -1120,7 +1045,6 @@ class AuiPaneInfo(object): self.max_size = size return self - def MaxSize2(self, x, y): """ Sets the maximum size of the pane. @@ -1128,10 +1052,9 @@ class AuiPaneInfo(object): :see: :meth:`MaxSize` for an explanation of input parameters. """ - self.max_size.Set(x,y) + self.max_size.Set(x, y) return self - def BestSize(self, arg1=None, arg2=None): """ Sets the ideal size for the pane. The docking manager will attempt to use @@ -1151,11 +1074,10 @@ class AuiPaneInfo(object): elif isinstance(arg1, six.integer_types) and arg2 is not None: ret = self.BestSize2(arg1, arg2) else: - raise Exception("Invalid argument passed to `BestSize`: arg1=%s, arg2=%s"%(repr(arg1), repr(arg2))) + raise Exception("Invalid argument passed to `BestSize`: arg1=%s, arg2=%s" % (repr(arg1), repr(arg2))) return ret - def BestSize1(self, size): """ Sets the best size of the pane. @@ -1166,7 +1088,6 @@ class AuiPaneInfo(object): self.best_size = size return self - def BestSize2(self, x, y): """ Sets the best size of the pane. @@ -1174,10 +1095,9 @@ class AuiPaneInfo(object): :see: :meth:`BestSize` for an explanation of input parameters. """ - self.best_size.Set(x,y) + self.best_size.Set(x, y) return self - def FloatingPosition(self, pos): """ Sets the position of the floating pane. @@ -1188,7 +1108,6 @@ class AuiPaneInfo(object): self.floating_pos = wx.Point(*pos) return self - def FloatingSize(self, size): """ Sets the size of the floating pane. @@ -1199,13 +1118,11 @@ class AuiPaneInfo(object): self.floating_size = wx.Size(*size) return self - def Maximize(self): """ Makes the pane take up the full area.""" return self.SetFlag(self.optionMaximized, True) - def Minimize(self): """ Makes the pane minimized in a :class:`~wx.lib.agw.aui.auibar.AuiToolBar`. @@ -1221,7 +1138,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionMinimized, True) - def MinimizeMode(self, mode): """ Sets the expected minimized mode if the minimize button is visible. @@ -1261,7 +1177,6 @@ class AuiPaneInfo(object): self.minimize_mode = mode return self - def MinimizeTarget(self, toolbarPane): """ Minimizes the panes using a :class:`AuiPaneInfo` as a target. As :class:`AuiPaneInfo` properties @@ -1282,13 +1197,11 @@ class AuiPaneInfo(object): self.minimize_target = toolbarPane.name return self - def Restore(self): """ Is the reverse of :meth:`Maximize` and :meth:`Minimize`.""" return self.SetFlag(self.optionMaximized | self.optionMinimized, False) - def Fixed(self): """ Forces a pane to be fixed size so that it cannot be resized. @@ -1297,7 +1210,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionResizable, False) - def Resizable(self, resizable=True): """ Allows a pane to be resizable if `resizable` is ``True``, and forces @@ -1310,7 +1222,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionResizable, resizable) - def Transparent(self, alpha): """ Makes the pane transparent when floating. @@ -1319,12 +1230,11 @@ class AuiPaneInfo(object): """ if alpha < 0 or alpha > 255: - raise Exception("Invalid transparency value (%s)"%repr(alpha)) + raise Exception("Invalid transparency value (%s)" % repr(alpha)) self.transparent = alpha self.needsTransparency = True - def Dock(self): """ Indicates that a pane should be docked. It is the opposite of :meth:`Float`. """ @@ -1334,7 +1244,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionFloating, False) - def Float(self): """ Indicates that a pane should be floated. It is the opposite of :meth:`Dock`. """ @@ -1344,7 +1253,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionFloating, True) - def Hide(self): """ Indicates that a pane should be hidden. @@ -1354,7 +1262,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionHidden, True) - def Show(self, show=True): """ Indicates that a pane should be shown. @@ -1364,7 +1271,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionHidden, not show) - # By defaulting to 1000, the tab will get placed at the end def NotebookPage(self, id, tab_position=1000): """ @@ -1385,7 +1291,6 @@ class AuiPaneInfo(object): return self - def NotebookControl(self, id): """ Forces a pane to be a notebook control (:class:`~wx.lib.agw.aui.auibook.AuiNotebook`). @@ -1402,34 +1307,29 @@ class AuiPaneInfo(object): return self - def HasNotebook(self): """ Returns whether a pane has a :class:`~wx.lib.agw.aui.auibook.AuiNotebook` or not. """ return self.notebook_id >= 0 - def IsNotebookPage(self): """ Returns whether the pane is a notebook page in a :class:`~wx.lib.agw.aui.auibook.AuiNotebook`. """ return self.notebook_id >= 0 and self.dock_direction == AUI_DOCK_NOTEBOOK_PAGE - def IsNotebookControl(self): """ Returns whether the pane is a notebook control (:class:`~wx.lib.agw.aui.auibook.AuiNotebook`). """ return not self.IsNotebookPage() and self.HasNotebook() - def SetNameFromNotebookId(self): """ Sets the pane name once docked in a :class:`~wx.lib.agw.aui.auibook.AuiNotebook` using the notebook id. """ if self.notebook_id >= 0: - self.name = "__notebook_%d"%self.notebook_id + self.name = "__notebook_%d" % self.notebook_id return self - def CaptionVisible(self, visible=True, left=False): """ Indicates that a pane caption should be visible. If `visible` is ``False``, no pane @@ -1446,7 +1346,6 @@ class AuiPaneInfo(object): self.SetFlag(self.optionCaptionLeft, False) return self.SetFlag(self.optionCaption, visible) - def PaneBorder(self, visible=True): """ Indicates that a border should be drawn for the pane. @@ -1456,7 +1355,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionPaneBorder, visible) - def Gripper(self, visible=True): """ Indicates that a gripper should be drawn for the pane. @@ -1466,7 +1364,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionGripper, visible) - def GripperTop(self, attop=True): """ Indicates that a gripper should be drawn at the top of the pane. @@ -1476,7 +1373,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionGripperTop, attop) - def CloseButton(self, visible=True): """ Indicates that a close button should be drawn for the pane. @@ -1486,7 +1382,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.buttonClose, visible) - def MaximizeButton(self, visible=True): """ Indicates that a maximize button should be drawn for the pane. @@ -1496,7 +1391,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.buttonMaximize, visible) - def MinimizeButton(self, visible=True): """ Indicates that a minimize button should be drawn for the pane. @@ -1506,7 +1400,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.buttonMinimize, visible) - def PinButton(self, visible=True): """ Indicates that a pin button should be drawn for the pane. @@ -1516,7 +1409,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.buttonPin, visible) - def DestroyOnClose(self, b=True): """ Indicates whether a pane should be destroyed when it is closed. @@ -1530,7 +1422,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionDestroyOnClose, b) - def TopDockable(self, b=True): """ Indicates whether a pane can be docked at the top of the frame. @@ -1540,7 +1431,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionTopDockable, b) - def BottomDockable(self, b=True): """ Indicates whether a pane can be docked at the bottom of the frame. @@ -1550,7 +1440,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionBottomDockable, b) - def LeftDockable(self, b=True): """ Indicates whether a pane can be docked on the left of the frame. @@ -1560,7 +1449,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionLeftDockable, b) - def RightDockable(self, b=True): """ Indicates whether a pane can be docked on the right of the frame. @@ -1570,7 +1458,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionRightDockable, b) - def Floatable(self, b=True): """ Sets whether the user will be able to undock a pane and turn it @@ -1581,7 +1468,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionFloatable, b) - def Movable(self, b=True): """ Indicates whether a pane can be moved. @@ -1591,7 +1477,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionMovable, b) - def NotebookDockable(self, b=True): """ Indicates whether a pane can be docked in an automatic :class:`~wx.lib.agw.aui.auibook.AuiNotebook`. @@ -1601,7 +1486,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionNotebookDockable, b) - def DockFixed(self, b=True): """ Causes the containing dock to have no resize sash. This is useful @@ -1613,7 +1497,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionDockFixed, b) - def Dockable(self, b=True): """ Specifies whether a frame can be docked or not. It is the same as specifying @@ -1624,7 +1507,6 @@ class AuiPaneInfo(object): return self.TopDockable(b).BottomDockable(b).LeftDockable(b).RightDockable(b) - def TopSnappable(self, b=True): """ Indicates whether a pane can be snapped at the top of the main frame. @@ -1634,7 +1516,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionTopSnapped, b) - def BottomSnappable(self, b=True): """ Indicates whether a pane can be snapped at the bottom of the main frame. @@ -1644,7 +1525,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionBottomSnapped, b) - def LeftSnappable(self, b=True): """ Indicates whether a pane can be snapped on the left of the main frame. @@ -1654,7 +1534,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionLeftSnapped, b) - def RightSnappable(self, b=True): """ Indicates whether a pane can be snapped on the right of the main frame. @@ -1664,7 +1543,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionRightSnapped, b) - def Snappable(self, b=True): """ Indicates whether a pane can be snapped on the main frame. This is @@ -1675,7 +1553,6 @@ class AuiPaneInfo(object): return self.TopSnappable(b).BottomSnappable(b).LeftSnappable(b).RightSnappable(b) - def FlyOut(self, b=True): """ Indicates whether a pane, when floating, has a "fly-out" effect @@ -1686,7 +1563,6 @@ class AuiPaneInfo(object): return self.SetFlag(self.optionFlyOut, b) - # Copy over the members that pertain to docking position def SetDockPos(self, source): """ @@ -1707,7 +1583,6 @@ class AuiPaneInfo(object): return self - def DefaultPane(self): """ Specifies that the pane should adopt the default pane settings. """ @@ -1721,7 +1596,6 @@ class AuiPaneInfo(object): self.state = state return self - def CentrePane(self): """ Specifies that the pane should adopt the default center pane settings. @@ -1732,7 +1606,6 @@ class AuiPaneInfo(object): return self.CenterPane() - def CenterPane(self): """ Specifies that the pane should adopt the default center pane settings. @@ -1744,7 +1617,6 @@ class AuiPaneInfo(object): self.state = 0 return self.Center().PaneBorder().Resizable() - def ToolbarPane(self): """ Specifies that the pane should adopt the default toolbar pane settings. """ @@ -1761,7 +1633,6 @@ class AuiPaneInfo(object): return self - def Icon(self, icon): """ Specifies whether an icon is drawn on the left of the caption text when @@ -1778,7 +1649,6 @@ class AuiPaneInfo(object): self.icon = icon return self - def SetFlag(self, flag, option_state): """ Turns the property given by `flag` on or off with the `option_state` @@ -1802,7 +1672,6 @@ class AuiPaneInfo(object): return self - def HasFlag(self, flag): """ Returns ``True`` if the the property specified by flag is active for the pane. @@ -1812,7 +1681,6 @@ class AuiPaneInfo(object): return (self.state & flag and [True] or [False])[0] - def ResetButtons(self): """ Resets all the buttons and recreates them from scratch depending on the @@ -1838,7 +1706,6 @@ class AuiPaneInfo(object): button = AuiPaneButton(AUI_BUTTON_CLOSE) self.buttons.append(button) - def CountButtons(self): """ Returns the number of visible buttons in the docked pane. """ @@ -1859,7 +1726,6 @@ class AuiPaneInfo(object): return n - def IsHorizontal(self): """ Returns ``True`` if the pane `dock_direction` is horizontal. """ @@ -1883,7 +1749,7 @@ class AuiDockingGuide(wx.Frame): def __init__(self, parent, id=wx.ID_ANY, title="", pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.FRAME_TOOL_WINDOW | wx.STAY_ON_TOP | - wx.FRAME_NO_TASKBAR | wx.NO_BORDER, name="AuiDockingGuide"): + wx.FRAME_NO_TASKBAR | wx.NO_BORDER, name="AuiDockingGuide"): """ Default class constructor. Used internally, do not call it in your code! @@ -1901,7 +1767,6 @@ class AuiDockingGuide(wx.Frame): wx.Frame.__init__(self, parent, id, title, pos, size, style, name=name) - def HitTest(self, x, y): """ To be overridden by parent classes. @@ -1912,7 +1777,6 @@ class AuiDockingGuide(wx.Frame): return 0 - def ValidateNotebookDocking(self, valid): """ To be overridden by parent classes. @@ -1923,6 +1787,7 @@ class AuiDockingGuide(wx.Frame): return 0 + # ============================================================================ # implementation # ============================================================================ @@ -1962,7 +1827,6 @@ class AuiDockingGuideWindow(wx.Window): self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_PAINT, self.OnPaint) - def SetValid(self, valid): """ Sets the docking direction as valid or invalid. @@ -1972,13 +1836,11 @@ class AuiDockingGuideWindow(wx.Window): self._valid = valid - def IsValid(self): """ Returns whether the docking direction is valid. """ return self._valid - def OnEraseBackground(self, event): """ Handles the ``wx.EVT_ERASE_BACKGROUND`` event for :class:`AuiDockingGuideWindow`. @@ -1990,7 +1852,6 @@ class AuiDockingGuideWindow(wx.Window): pass - def DrawBackground(self, dc): """ Draws the docking guide background. @@ -2014,13 +1875,13 @@ class AuiDockingGuideWindow(wx.Window): if self._direction != wx.CENTER: if not self._center or self._direction != wx.BOTTOM: - dc.DrawLine(left, top, right+1, top) + dc.DrawLine(left, top, right + 1, top) if not self._center or self._direction != wx.RIGHT: - dc.DrawLine(left, top, left, bottom+1) + dc.DrawLine(left, top, left, bottom + 1) if not self._center or self._direction != wx.LEFT: - dc.DrawLine(right, top, right, bottom+1) + dc.DrawLine(right, top, right, bottom + 1) if not self._center or self._direction != wx.TOP: - dc.DrawLine(left, bottom, right+1, bottom) + dc.DrawLine(left, bottom, right + 1, bottom) dc.SetPen(wx.Pen(colourTargetShade)) @@ -2029,7 +1890,6 @@ class AuiDockingGuideWindow(wx.Window): if self._direction != wx.BOTTOM: dc.DrawLine(left + 1, top + 1, right, top + 1) - def DrawDottedLine(self, dc, point, length, vertical): """ Draws a dotted line (not used if the docking guide images are ok). @@ -2047,7 +1907,6 @@ class AuiDockingGuideWindow(wx.Window): else: point.x += 2 - def DrawIcon(self, dc): """ Draws the docking guide icon (not used if the docking guide images are ok). @@ -2074,24 +1933,24 @@ class AuiDockingGuideWindow(wx.Window): rect.Deflate(1, 1) if self._direction == wx.TOP: - rect.height -= rect.height / 2 + rect.height -= rect.height // 2 point = rect.GetBottomLeft() length = rect.width elif self._direction == wx.LEFT: - rect.width -= rect.width / 2 + rect.width -= rect.width // 2 point = rect.GetTopRight() length = rect.height elif self._direction == wx.RIGHT: - rect.x += rect.width / 2 - rect.width -= rect.width / 2 + rect.x += rect.width // 2 + rect.width -= rect.width // 2 point = rect.GetTopLeft() length = rect.height elif self._direction == wx.BOTTOM: - rect.y += rect.height / 2 - rect.height -= rect.height / 2 + rect.y += rect.height // 2 + rect.height -= rect.height // 2 point = rect.GetTopLeft() length = rect.width @@ -2117,7 +1976,6 @@ class AuiDockingGuideWindow(wx.Window): else: self.DrawDottedLine(dc, point, length, True) - def DrawArrow(self, dc): """ Draws the docking guide arrow icon (not used if the docking guide images are ok). @@ -2128,8 +1986,8 @@ class AuiDockingGuideWindow(wx.Window): rect = self.GetClientRect() point = wx.Point() - point.x = (rect.GetLeft() + rect.GetRight()) / 2 - point.y = (rect.GetTop() + rect.GetBottom()) / 2 + point.x = (rect.GetLeft() + rect.GetRight()) // 2 + point.y = (rect.GetTop() + rect.GetBottom()) // 2 rx, ry = wx.Size(), wx.Size() if self._direction == wx.TOP: @@ -2148,33 +2006,32 @@ class AuiDockingGuideWindow(wx.Window): rx = wx.Size(-1, 0) ry = wx.Size(0, -1) - point.x += ry.x*3 - point.y += ry.y*3 + point.x += ry.x * 3 + point.y += ry.y * 3 dc.SetPen(wx.Pen(colourIconArrow)) for i in range(4): - pt1 = wx.Point(point.x - rx.x*i, point.y - rx.y*i) - pt2 = wx.Point(point.x + rx.x*(i+1), point.y + rx.y*(i+1)) + pt1 = wx.Point(point.x - rx.x * i, point.y - rx.y * i) + pt2 = wx.Point(point.x + rx.x * (i + 1), point.y + rx.y * (i + 1)) dc.DrawLine(pt1, pt2) point.x += ry.x point.y += ry.y - def OnPaint(self, event): """ Handles the ``wx.EVT_PAINT`` event for :class:`AuiDockingGuideWindow`. :param `event`: a :class:`PaintEvent` to be processed. """ - dc = wx.AutoBufferedPaintDC(self) + if self._currentImage.IsOk() and self._valid: dc.DrawBitmap(self._currentImage, 0, 0, True) else: + dc = wx.AutoBufferedPaintDC(self) self.Draw(dc) - def Draw(self, dc): """ Draws the whole docking guide window (not used if the docking guide images are ok). @@ -2188,7 +2045,6 @@ class AuiDockingGuideWindow(wx.Window): self.DrawIcon(dc) self.DrawArrow(dc) - def UpdateDockGuide(self, pos): """ Updates the docking guide images depending on the mouse position, using focused @@ -2280,7 +2136,6 @@ class AuiSingleDockingGuide(AuiDockingGuide): self.target = AuiDockingGuideWindow(self, self.rect, direction, False, useAero) - def CreateShapesWithStyle(self, useWhidbey): """ Creates the docking guide window shape based on which docking bitmaps are used. @@ -2299,10 +2154,8 @@ class AuiSingleDockingGuide(AuiDockingGuide): useAero = (useWhidbey and [2] or [1])[0] bmp, dummy = GetDockingImage(self._direction, useAero, False) region = wx.Region(bmp) - self.region = region - def AeroMove(self, pos): """ Moves the docking window to the new position. Overridden in children classes. @@ -2312,7 +2165,6 @@ class AuiSingleDockingGuide(AuiDockingGuide): pass - def SetGuideShape(self, event=None): """ Sets the correct shape for the docking guide window. @@ -2327,7 +2179,6 @@ class AuiSingleDockingGuide(AuiDockingGuide): event.Skip() wx.CallAfter(wx.SafeYield, self, True) - def SetShape(self, region): """ If the platform supports it, sets the shape of the window to that depicted by `region`. @@ -2346,7 +2197,6 @@ class AuiSingleDockingGuide(AuiDockingGuide): else: super(AuiSingleDockingGuide, self).SetShape(region) - def SetValid(self, valid): """ Sets the docking direction as valid or invalid. @@ -2356,13 +2206,11 @@ class AuiSingleDockingGuide(AuiDockingGuide): self._valid = valid - def IsValid(self): """ Returns whether the docking direction is valid. """ return self._valid - def UpdateDockGuide(self, pos): """ Updates the docking guide images depending on the mouse position, using focused @@ -2374,7 +2222,6 @@ class AuiSingleDockingGuide(AuiDockingGuide): self.target.UpdateDockGuide(pos) - def HitTest(self, x, y): """ Checks if the mouse position is inside the target window rect. @@ -2405,7 +2252,7 @@ class AuiCenterDockingGuide(AuiDockingGuide): """ AuiDockingGuide.__init__(self, parent, style=wx.FRAME_TOOL_WINDOW | wx.STAY_ON_TOP | - wx.FRAME_NO_TASKBAR | wx.NO_BORDER | wx.FRAME_SHAPED, + wx.FRAME_NO_TASKBAR | wx.NO_BORDER | wx.FRAME_SHAPED, name="auiCenterDockTarget") self.Hide() @@ -2423,7 +2270,6 @@ class AuiCenterDockingGuide(AuiDockingGuide): self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_PAINT, self.OnPaint) - def CreateShapesWithStyle(self): """ Creates the docking guide window shape based on which docking bitmaps are used. """ @@ -2445,7 +2291,7 @@ class AuiCenterDockingGuide(AuiDockingGuide): rectLeft = wx.Rect(0, sizeY, sizeY, sizeX) rectTop = wx.Rect(sizeY, 0, sizeX, sizeY) - rectRight = wx.Rect(sizeY+sizeX, sizeY, sizeY, sizeX) + rectRight = wx.Rect(sizeY + sizeX, sizeY, sizeY, sizeX) rectBottom = wx.Rect(sizeY, sizeX + sizeY, sizeX, sizeY) rectCenter = wx.Rect(sizeY, sizeY, sizeX, sizeX) @@ -2457,29 +2303,28 @@ class AuiCenterDockingGuide(AuiDockingGuide): self.targetBottom = AuiDockingGuideWindow(self, rectBottom, wx.BOTTOM, True, useAero) self.targetCenter = AuiDockingGuideWindow(self, rectCenter, wx.CENTER, True, useAero) - # top-left diamond - tld = [wx.Point(rectTop.x, rectTop.y+rectTop.height-8), - wx.Point(rectLeft.x+rectLeft.width-8, rectLeft.y), + tld = [wx.Point(rectTop.x, rectTop.y + rectTop.height - 8), + wx.Point(rectLeft.x + rectLeft.width - 8, rectLeft.y), rectTop.GetBottomLeft()] # bottom-left diamond - bld = [wx.Point(rectLeft.x+rectLeft.width-8, rectLeft.y+rectLeft.height), - wx.Point(rectBottom.x, rectBottom.y+8), + bld = [wx.Point(rectLeft.x + rectLeft.width - 8, rectLeft.y + rectLeft.height), + wx.Point(rectBottom.x, rectBottom.y + 8), rectBottom.GetTopLeft()] # top-right diamond - trd = [wx.Point(rectTop.x+rectTop.width, rectTop.y+rectTop.height-8), - wx.Point(rectRight.x+8, rectRight.y), + trd = [wx.Point(rectTop.x + rectTop.width, rectTop.y + rectTop.height - 8), + wx.Point(rectRight.x + 8, rectRight.y), rectRight.GetTopLeft()] # bottom-right diamond - brd = [wx.Point(rectRight.x+8, rectRight.y+rectRight.height), - wx.Point(rectBottom.x+rectBottom.width, rectBottom.y+8), + brd = [wx.Point(rectRight.x + 8, rectRight.y + rectRight.height), + wx.Point(rectBottom.x + rectBottom.width, rectBottom.y + 8), rectBottom.GetTopRight()] self._triangles = [tld[0:2], bld[0:2], - [wx.Point(rectTop.x+rectTop.width-1, rectTop.y+rectTop.height-8), - wx.Point(rectRight.x+7, rectRight.y)], - [wx.Point(rectRight.x+7, rectRight.y+rectRight.height), - wx.Point(rectBottom.x+rectBottom.width-1, rectBottom.y+8)]] + [wx.Point(rectTop.x + rectTop.width - 1, rectTop.y + rectTop.height - 8), + wx.Point(rectRight.x + 7, rectRight.y)], + [wx.Point(rectRight.x + 7, rectRight.y + rectRight.height), + wx.Point(rectBottom.x + rectBottom.width - 1, rectBottom.y + 8)]] region = wx.Region() region.Union(rectLeft) @@ -2516,10 +2361,8 @@ class AuiCenterDockingGuide(AuiDockingGuide): self._aeroRects = [rectLeft, rectTop, rectRight, rectBottom, rectCenter] self._valid = True - self.region = region - def SetGuideShape(self, event=None): """ Sets the correct shape for the docking guide window. @@ -2534,7 +2377,6 @@ class AuiCenterDockingGuide(AuiDockingGuide): event.Skip() wx.CallAfter(wx.SafeYield, self, True) - def UpdateDockGuide(self, pos): """ Updates the docking guides images depending on the mouse position, using focused @@ -2565,7 +2407,6 @@ class AuiCenterDockingGuide(AuiDockingGuide): self._aeroBmp = self._allAeroBmps[-1] self.Refresh() - def HitTest(self, x, y): """ Checks if the mouse position is inside the target windows rect. @@ -2590,12 +2431,11 @@ class AuiCenterDockingGuide(AuiDockingGuide): lenRects = len(self._aeroRects) for indx, rect in enumerate(self._aeroRects): if rect.Contains((x, y)): - if indx < lenRects or (indx == lenRects-1 and self._valid): + if indx < lenRects or (indx == lenRects - 1 and self._valid): return constants[indx] return -1 - def ValidateNotebookDocking(self, valid): """ Sets whether a pane can be docked on top of another to create an automatic @@ -2614,7 +2454,6 @@ class AuiCenterDockingGuide(AuiDockingGuide): self._valid = valid self.Refresh() - def AeroMove(self, pos): """ Moves the docking guide window to the new position. @@ -2635,7 +2474,7 @@ class AuiCenterDockingGuide(AuiDockingGuide): size = self.GetSize() leftRect, topRect, rightRect, bottomRect, centerRect = self._aeroRects - thePos = pos + wx.Point((size.x-sizeY)/2, (size.y-sizeX)/2) + thePos = pos + wx.Point((size.x - sizeY) // 2, (size.y - sizeX) // 2) centerRect.SetTopLeft(thePos) @@ -2644,7 +2483,6 @@ class AuiCenterDockingGuide(AuiDockingGuide): rightRect.SetTopLeft(thePos + wx.Point(sizeX, 0)) bottomRect.SetTopLeft(thePos + wx.Point(0, sizeX)) - def OnEraseBackground(self, event): """ Handles the ``wx.EVT_ERASE_BACKGROUND`` event for :class:`AuiCenterDockingGuide`. @@ -2656,7 +2494,6 @@ class AuiCenterDockingGuide(AuiDockingGuide): pass - def OnPaint(self, event): """ Handles the ``wx.EVT_PAINT`` event for :class:`AuiCenterDockingGuide`. @@ -2681,8 +2518,8 @@ class AuiCenterDockingGuide(AuiDockingGuide): if not self._valid: diff = (self._useAero == 2 and [1] or [0])[0] bmpX, bmpY = self._deniedBitmap.GetWidth(), self._deniedBitmap.GetHeight() - xPos, yPos = (rect.x + (rect.width)/2 - bmpX/2), (rect.y + (rect.height)/2 - bmpY/2) - dc.DrawBitmap(self._deniedBitmap, xPos+1, yPos+diff, True) + xPos, yPos = (rect.x + (rect.width) // 2 - bmpX // 2), (rect.y + (rect.height) // 2 - bmpY // 2) + dc.DrawBitmap(self._deniedBitmap, xPos + 1, yPos + diff, True) return @@ -2700,7 +2537,7 @@ class AuiDockingHintWindow(wx.Frame): def __init__(self, parent, id=wx.ID_ANY, title="", pos=wx.DefaultPosition, size=wx.Size(1, 1), style=wx.FRAME_TOOL_WINDOW | wx.FRAME_FLOAT_ON_PARENT | - wx.FRAME_NO_TASKBAR | wx.NO_BORDER | wx.FRAME_SHAPED, + wx.FRAME_NO_TASKBAR | wx.NO_BORDER | wx.FRAME_SHAPED, name="auiHintWindow"): """ Default class constructor. Used internally, do not call it in your code! @@ -2744,7 +2581,6 @@ class AuiDockingHintWindow(wx.Frame): self.Bind(wx.EVT_SIZE, self.OnSize) - def MakeVenetianBlinds(self): """ Creates the "venetian blind" effect if :class:`AuiManager` has the ``AUI_MGR_VENETIAN_BLINDS_HINT`` @@ -2765,13 +2601,12 @@ class AuiDockingHintWindow(wx.Frame): ## region.Union(0, y, size_x, 1) region_Union = region.Union # local opt [region_Union(0, y, size_x, 1) for y in range(size_y) - if 16 * ((y & 8 and [1] or [0])[0] | (y & 4 and [2] or [0])[0] | - (y & 2 and [4] or [0])[0] | (y & 1 and [8] or [0])[0]) - + 8 < amount] + if 16 * ((y & 8 and [1] or [0])[0] | (y & 4 and [2] or [0])[0] | + (y & 2 and [4] or [0])[0] | (y & 1 and [8] or [0])[0]) + + 8 < amount] self.SetShape(region) - def SetBlindMode(self, agwFlags): """ Sets whether venetian blinds or transparent hints will be shown as docking hint. @@ -2793,7 +2628,6 @@ class AuiDockingHintWindow(wx.Frame): else: self.SetTransparent(0) - def SetShape(self, region): """ If the platform supports it, sets the shape of the window to that depicted by `region`. @@ -2812,7 +2646,6 @@ class AuiDockingHintWindow(wx.Frame): else: super(AuiDockingHintWindow, self).SetShape(region) - def Show(self, show=True): """ Show the hint window. @@ -2836,7 +2669,6 @@ class AuiDockingHintWindow(wx.Frame): # Need to manually do layout since its a borderless frame. self.Layout() - def OnSize(self, event): """ Handles the ``wx.EVT_SIZE`` event for :class:`AuiDockingHintWindow`. @@ -2849,7 +2681,6 @@ class AuiDockingHintWindow(wx.Frame): self.Refresh() - def OnPaint(self, event): """ Handles the ``wx.EVT_PAINT`` event for :class:`AuiDockingHintWindow`. @@ -2877,7 +2708,7 @@ class AuiFloatingFrame(wx.MiniFrame): def __init__(self, parent, owner_mgr, pane=None, id=wx.ID_ANY, title="", style=wx.FRAME_TOOL_WINDOW | wx.FRAME_FLOAT_ON_PARENT | - wx.FRAME_NO_TASKBAR | wx.CLIP_CHILDREN): + wx.FRAME_NO_TASKBAR | wx.CLIP_CHILDREN): """ Default class constructor. Used internally, do not call it in your code! @@ -2946,7 +2777,6 @@ class AuiFloatingFrame(wx.MiniFrame): self._mgr.SetArtProvider(owner_mgr.GetArtProvider()) self._mgr.SetAGWFlags(owner_mgr.GetAGWFlags()) - def CopyAttributes(self, pane): """ Copies all the attributes of the input `pane` into another :class:`AuiPaneInfo`. @@ -2982,7 +2812,6 @@ class AuiFloatingFrame(wx.MiniFrame): return contained_pane - def SetPaneWindow(self, pane): """ Sets all the properties of a pane. @@ -3001,9 +2830,9 @@ class AuiFloatingFrame(wx.MiniFrame): contained_pane = self.CopyAttributes(pane) contained_pane.Dock().Center().Show(). \ - CaptionVisible(False). \ - PaneBorder(False). \ - Layer(0).Row(0).Position(0) + CaptionVisible(False). \ + PaneBorder(False). \ + Layer(0).Row(0).Position(0) if not contained_pane.HasGripper() and not self._useNativeMiniframes: contained_pane.CaptionVisible(True) @@ -3018,30 +2847,31 @@ class AuiFloatingFrame(wx.MiniFrame): pane_best_size = contained_pane.best_size if pane_best_size.IsFullySpecified() and (pane_best_size.x < pane_min_size.x or \ pane_best_size.y < pane_min_size.y): - pane_min_size = pane_best_size self._pane_window.SetMinSize(pane_min_size) # if the frame window's max size is greater than the min size # then set the max size to the min size as well cur_max_size = self.GetMaxSize() - if cur_max_size.IsFullySpecified() and (cur_max_size.x < pane_min_size.x or \ - cur_max_size.y < pane_min_size.y): + if cur_max_size.IsFullySpecified() and (cur_max_size.x < pane_min_size.x or \ + cur_max_size.y < pane_min_size.y): self.SetMaxSize(pane_min_size) art_provider = self._mgr.GetArtProvider() caption_size = art_provider.GetMetric(AUI_DOCKART_CAPTION_SIZE) button_size = art_provider.GetMetric(AUI_DOCKART_PANE_BUTTON_SIZE) + \ - 4*art_provider.GetMetric(AUI_DOCKART_PANE_BORDER_SIZE) + 4 * art_provider.GetMetric(AUI_DOCKART_PANE_BORDER_SIZE) min_size = pane.window.GetMinSize() if min_size.y < caption_size or min_size.x < button_size: new_x, new_y = min_size.x, min_size.y if min_size.y < caption_size: - new_y = (pane.IsResizeable() and [2*wx.SystemSettings.GetMetric(wx.SYS_EDGE_Y)+caption_size] or [1])[0] + new_y = \ + (pane.IsResizeable() and [2 * wx.SystemSettings.GetMetric(wx.SYS_EDGE_Y) + caption_size] or [1])[0] if min_size.x < button_size: - new_x = (pane.IsResizeable() and [2*wx.SystemSettings.GetMetric(wx.SYS_EDGE_X)+button_size] or [1])[0] + new_x = (pane.IsResizeable() and [2 * wx.SystemSettings.GetMetric(wx.SYS_EDGE_X) + button_size] or [1])[ + 0] self.SetMinSize((new_x, new_y)) else: @@ -3084,20 +2914,18 @@ class AuiFloatingFrame(wx.MiniFrame): self._owner_mgr._panes[indx] = pane self._fly_step = abs(pane.floating_size.y - \ - (caption_size + 2*wx.SystemSettings.GetMetric(wx.SYS_EDGE_Y)))/10 + (caption_size + 2 * wx.SystemSettings.GetMetric(wx.SYS_EDGE_Y))) // 10 self._floating_size = wx.Size(*self.GetSize()) if pane.IsFlyOut(): self._check_fly_timer.Start(50) - def GetOwnerManager(self): """ Returns the :class:`AuiManager` that manages the pane. """ return self._owner_mgr - def OnSize(self, event): """ Handles the ``wx.EVT_SIZE`` event for :class:`AuiFloatingFrame`. @@ -3108,7 +2936,6 @@ class AuiFloatingFrame(wx.MiniFrame): if self._owner_mgr and self._send_size and self.IsShownOnScreen(): self._owner_mgr.OnFloatingPaneResized(self._pane_window, event.GetSize()) - def OnClose(self, event): """ Handles the ``wx.EVT_CLOSE`` event for :class:`AuiFloatingFrame`. @@ -3134,7 +2961,6 @@ class AuiFloatingFrame(wx.MiniFrame): self._mgr.UnInit() self.Destroy() - def OnActivate(self, event): """ Handles the ``wx.EVT_ACTIVATE`` event for :class:`AuiFloatingFrame`. @@ -3145,7 +2971,6 @@ class AuiFloatingFrame(wx.MiniFrame): if self._owner_mgr and event.GetActive(): self._owner_mgr.OnFloatingPaneActivated(self._pane_window) - def OnMove(self, event): """ Handles the ``wx.EVT_MOVE`` event for :class:`AuiFloatingFrame`. @@ -3162,7 +2987,6 @@ class AuiFloatingFrame(wx.MiniFrame): if self._owner_mgr: self._owner_mgr.OnFloatingPaneMoved(self._pane_window, event) - def OnMoveEvent(self, event): """ Handles the ``wx.EVT_MOVE`` and ``wx.EVT_MOVING`` events for :class:`AuiFloatingFrame`. @@ -3244,7 +3068,6 @@ class AuiFloatingFrame(wx.MiniFrame): else: self.OnMoving(wx.Rect(event.GetPosition(), self.GetSize()), dir) - def OnIdle(self, event): """ Handles the ``wx.EVT_IDLE`` event for :class:`AuiFloatingFrame`. @@ -3265,7 +3088,6 @@ class AuiFloatingFrame(wx.MiniFrame): else: event.RequestMore() - def OnMoveStart(self, event): """ The user has just started moving the floating pane. @@ -3294,7 +3116,6 @@ class AuiFloatingFrame(wx.MiniFrame): self._owner_mgr._action_offset = action_offset self._owner_mgr.OnMotion_DragFloatingPane(point) - def OnMoving(self, rect, direction): """ The user is moving the floating pane. @@ -3313,7 +3134,6 @@ class AuiFloatingFrame(wx.MiniFrame): self.OnMoveStart(None) self._lastDirection = direction - def OnMoveFinished(self): """ The user has just finished moving the floating pane. @@ -3336,7 +3156,6 @@ class AuiFloatingFrame(wx.MiniFrame): self._owner_mgr.OnFloatingPaneMoved(self._pane_window, point) - def OnCheckFlyTimer(self, event): """ Handles the ``wx.EVT_TIMER`` event for :class:`AuiFloatingFrame`. @@ -3352,7 +3171,6 @@ class AuiFloatingFrame(wx.MiniFrame): if self.IsShownOnScreen(): self.FlyOut() - def OnFindManager(self, event): """ Handles the ``EVT_AUI_FIND_MANAGER`` event for :class:`AuiFloatingFrame`. @@ -3362,7 +3180,6 @@ class AuiFloatingFrame(wx.MiniFrame): event.SetManager(self._owner_mgr) - def FlyOut(self): """ Starts the flying in and out of a floating pane. """ @@ -3386,7 +3203,6 @@ class AuiFloatingFrame(wx.MiniFrame): self._send_size = False self._fly_timer.Start(5) - def OnFlyTimer(self, event): """ Handles the ``wx.EVT_TIMER`` event for :class:`AuiFloatingFrame`. @@ -3404,7 +3220,7 @@ class AuiFloatingFrame(wx.MiniFrame): min_size = self._mgr.GetArtProvider().GetMetric(AUI_DOCKART_CAPTION_SIZE) if wx.Platform != "__WXMSW__": - min_size += 2*wx.SystemSettings.GetMetric(wx.SYS_EDGE_Y) + min_size += 2 * wx.SystemSettings.GetMetric(wx.SYS_EDGE_Y) if current_size.y - self._fly_step <= min_size: self.SetClientSize((current_size.x, min_size)) @@ -3412,7 +3228,7 @@ class AuiFloatingFrame(wx.MiniFrame): self._fly_timer.Stop() self._send_size = True else: - self.SetClientSize((current_size.x, current_size.y-self._fly_step)) + self.SetClientSize((current_size.x, current_size.y - self._fly_step)) else: if current_size.y + self._fly_step >= floating_size.y: @@ -3421,12 +3237,11 @@ class AuiFloatingFrame(wx.MiniFrame): self._fly_timer.Stop() self._send_size = True else: - self.SetClientSize((current_size.x, current_size.y+self._fly_step)) + self.SetClientSize((current_size.x, current_size.y + self._fly_step)) self.Update() self.Refresh() - def FadeOut(self): """ Actually starts the fading out of the floating pane. """ @@ -3594,7 +3409,7 @@ def GetMaxRow(panes, dock_direction, dock_layer): for pane in panes: if pane.dock_direction == dock_direction and pane.dock_layer == dock_layer and \ - pane.dock_row > max_row: + pane.dock_row > max_row: max_row = pane.dock_row return max_row @@ -3633,7 +3448,7 @@ def DoInsertDockRow(panes, dock_direction, dock_layer, dock_row): for pane in panes: if not pane.IsFloating() and pane.dock_direction == dock_direction and \ - pane.dock_layer == dock_layer and pane.dock_row >= dock_row: + pane.dock_layer == dock_layer and pane.dock_row >= dock_row: pane.dock_row += 1 return panes @@ -3654,8 +3469,8 @@ def DoInsertPane(panes, dock_direction, dock_layer, dock_row, dock_pos): for ii in range(len(panes)): pane = panes[ii] if not pane.IsFloating() and pane.dock_direction == dock_direction and \ - pane.dock_layer == dock_layer and pane.dock_row == dock_row and \ - pane.dock_pos >= dock_pos: + pane.dock_layer == dock_layer and pane.dock_row == dock_row and \ + pane.dock_pos >= dock_pos: pane.dock_pos = pane.dock_pos + 1 panes[ii] = pane @@ -3678,7 +3493,7 @@ def FindDocks(docks, dock_direction, dock_layer=-1, dock_row=-1, reverse=False): matchDocks = [(d.dock_layer, d.dock_row, d.dock_direction, d) for d in docks if \ (dock_direction == -1 or dock_direction == d.dock_direction) and \ ((dock_layer == -1 or dock_layer == d.dock_layer) and \ - (dock_row == -1 or dock_row == d.dock_row))] + (dock_row == -1 or dock_row == d.dock_row))] arr = [x[-1] for x in sorted(matchDocks, reverse=reverse)] @@ -3809,7 +3624,7 @@ def CheckEdgeDrop(window, docks, pt): return wx.LEFT if pt.x >= clientSize.x - auiLayerInsertOffset and \ - pt.x < clientSize.x - auiLayerInsertOffset + auiLayerInsertPixels: + pt.x < clientSize.x - auiLayerInsertOffset + auiLayerInsertPixels: return wx.RIGHT if screenPt.x >= frameRect.GetLeft() and screenPt.x < frameRect.GetRight(): @@ -3817,7 +3632,7 @@ def CheckEdgeDrop(window, docks, pt): return wx.TOP if pt.y >= clientSize.y - auiLayerInsertOffset and \ - pt.y < clientSize.y - auiLayerInsertOffset + auiLayerInsertPixels: + pt.y < clientSize.y - auiLayerInsertOffset + auiLayerInsertPixels: return wx.BOTTOM return -1 @@ -4137,6 +3952,7 @@ class AuiManager(wx.EvtHandler): ``AUI_MGR_AUTONB_NO_CAPTION`` Panes that merge into an automatic notebook will not have the pane caption visible ==================================== ================================== + Default value for `agwFlags` is: ``AUI_MGR_DEFAULT`` = ``AUI_MGR_ALLOW_FLOATING`` | ``AUI_MGR_TRANSPARENT_HINT`` | ``AUI_MGR_HINT_FADE`` | ``AUI_MGR_NO_VENETIAN_BLINDS_FADE`` @@ -4239,7 +4055,6 @@ class AuiManager(wx.EvtHandler): self.Bind(auibook.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnTabPageClose) self.Bind(auibook.EVT_AUINOTEBOOK_PAGE_CHANGED, self.OnTabSelected) - def CreateFloatingFrame(self, parent, pane_info): """ Creates a floating frame for the windows. @@ -4250,7 +4065,6 @@ class AuiManager(wx.EvtHandler): return AuiFloatingFrame(parent, self, pane_info) - def CanDockPanel(self, p): """ Returns whether a pane can be docked or not. @@ -4266,7 +4080,6 @@ class AuiManager(wx.EvtHandler): # don't dock the window return not (wx.GetKeyState(wx.WXK_CONTROL) or wx.GetKeyState(wx.WXK_ALT)) - def GetPaneByWidget(self, window): """ This version of :meth:`GetPane` looks up a pane based on a 'pane window'. @@ -4282,7 +4095,6 @@ class AuiManager(wx.EvtHandler): return NonePaneInfo - def GetPaneByName(self, name): """ This version of :meth:`GetPane` looks up a pane based on a 'pane name'. @@ -4298,7 +4110,6 @@ class AuiManager(wx.EvtHandler): return NonePaneInfo - def GetPane(self, item): """ Looks up a :class:`AuiPaneInfo` structure based on the supplied window pointer. Upon failure, @@ -4316,13 +4127,11 @@ class AuiManager(wx.EvtHandler): else: return self.GetPaneByWidget(item) - def GetAllPanes(self): """ Returns a reference to all the pane info structures. """ return self._panes - def ShowPane(self, window, show): """ Shows or hides a pane based on the window passed as input. @@ -4354,7 +4163,6 @@ class AuiManager(wx.EvtHandler): self.Update() - def HitTest(self, x, y): """ This is an internal function which determines @@ -4386,7 +4194,6 @@ class AuiManager(wx.EvtHandler): return result - def PaneHitTest(self, panes, pt): """ Similar to :meth:`HitTest`, but it checks in which :class:`AuiManager` rectangle the @@ -4402,7 +4209,6 @@ class AuiManager(wx.EvtHandler): return NonePaneInfo - # SetAGWFlags() and GetAGWFlags() allow the owner to set various # options which are global to AuiManager @@ -4451,7 +4257,6 @@ class AuiManager(wx.EvtHandler): if self._hint_window and agwFlags & AUI_MGR_RECTANGLE_HINT == 0: self.CreateHintWindow() - def GetAGWFlags(self): """ Returns the current manager's flags. @@ -4461,7 +4266,6 @@ class AuiManager(wx.EvtHandler): return self._agwFlags - def SetManagedWindow(self, managed_window): """ Called to specify the frame or window which is to be managed by :class:`AuiManager`. @@ -4505,13 +4309,11 @@ class AuiManager(wx.EvtHandler): self.AddPane(client_window, AuiPaneInfo().Name("mdiclient"). CenterPane().PaneBorder(False)) - def GetManagedWindow(self): """ Returns the window being managed by :class:`AuiManager`. """ return self._frame - def SetFrame(self, managed_window): """ Called to specify the frame or window which is to be managed by :class:`AuiManager`. @@ -4528,7 +4330,6 @@ class AuiManager(wx.EvtHandler): DeprecationWarning("This method is deprecated, use SetManagedWindow instead.") return self.SetManagedWindow(managed_window) - def GetFrame(self): """ Returns the window being managed by :class:`AuiManager`. @@ -4540,7 +4341,6 @@ class AuiManager(wx.EvtHandler): DeprecationWarning("This method is deprecated, use GetManagedWindow instead.") return self._frame - def CreateGuideWindows(self): """ Creates the VS2005 HUD guide windows. """ @@ -4557,7 +4357,6 @@ class AuiManager(wx.EvtHandler): self._guides.append(AuiDockingGuideInfo().Centre(). Host(AuiCenterDockingGuide(self._frame))) - def DestroyGuideWindows(self): """ Destroys the VS2005 HUD guide windows. """ for guide in self._guides: @@ -4565,7 +4364,6 @@ class AuiManager(wx.EvtHandler): guide.host.Destroy() self._guides = [] - def CreateHintWindow(self): """ Creates the standard wxAUI hint window. """ @@ -4574,7 +4372,6 @@ class AuiManager(wx.EvtHandler): self._hint_window = AuiDockingHintWindow(self._frame) self._hint_window.SetBlindMode(self._agwFlags) - def DestroyHintWindow(self): """ Destroys the standard wxAUI hint window. """ @@ -4582,7 +4379,6 @@ class AuiManager(wx.EvtHandler): self._hint_window.Destroy() self._hint_window = None - def UnInit(self): """ Uninitializes the framework and should be called before a managed frame or @@ -4603,7 +4399,6 @@ class AuiManager(wx.EvtHandler): if isinstance(handler, AuiManager): klass.RemoveEventHandler(handler) - def OnClose(self, event): """Called when the managed window is closed. Makes sure that :meth:`UnInit` is called. @@ -4613,8 +4408,7 @@ class AuiManager(wx.EvtHandler): if event.GetEventObject() == self._frame: wx.CallAfter(self.UnInit) - - def OnDestroy(self, event) : + def OnDestroy(self, event): """Called when the managed window is destroyed. Makes sure that :meth:`UnInit` is called. """ @@ -4622,13 +4416,11 @@ class AuiManager(wx.EvtHandler): if self._frame == event.GetEventObject(): self.UnInit() - def GetArtProvider(self): """ Returns the current art provider being used. """ return self._art - def ProcessMgrEvent(self, event): """ Process the AUI events sent to the manager. @@ -4643,7 +4435,6 @@ class AuiManager(wx.EvtHandler): self.ProcessEvent(event) - def FireEvent(self, evtType, pane, canVeto=False): """ Fires one of the ``EVT_AUI_PANE_FLOATED`` / ``FLOATING`` / ``DOCKING`` / ``DOCKED`` / ``ACTIVATED`` event. @@ -4660,7 +4451,6 @@ class AuiManager(wx.EvtHandler): return event - def CanUseModernDockArt(self): """ Returns whether :class:`dockart` can be used (Windows XP / Vista / 7 only, @@ -4679,7 +4469,6 @@ class AuiManager(wx.EvtHandler): return True - def SetArtProvider(self, art_provider): """ Instructs :class:`AuiManager` to use art provider specified by the parameter @@ -4702,7 +4491,6 @@ class AuiManager(wx.EvtHandler): pane.frame._mgr.SetArtProvider(art_provider) pane.frame._mgr.Update() - def AddPane(self, window, arg1=None, arg2=None, target=None): """ Tells the frame manager to start managing a child window. There @@ -4739,7 +4527,6 @@ class AuiManager(wx.EvtHandler): else: return self.AddPane1(window, arg1) - def AddPane1(self, window, pane_info): """ See comments on :meth:`AddPane`. """ @@ -4755,7 +4542,7 @@ class AuiManager(wx.EvtHandler): # bug in the library user's application already_exists = False if pane_info.name != "" and self.GetPane(pane_info.name).IsOk(): - warnings.warn("A pane with the name '%s' already exists in the manager!"%pane_info.name) + warnings.warn("A pane with the name '%s' already exists in the manager!" % pane_info.name) already_exists = True # if the new pane is docked then we should undo maximize @@ -4835,7 +4622,6 @@ class AuiManager(wx.EvtHandler): return True - def AddPane2(self, window, direction, caption): """ See comments on :meth:`AddPane`. """ @@ -4855,7 +4641,6 @@ class AuiManager(wx.EvtHandler): return self.AddPane(window, pinfo) - def AddPane3(self, window, pane_info, drop_pos): """ See comments on :meth:`AddPane`. """ @@ -4870,7 +4655,6 @@ class AuiManager(wx.EvtHandler): return True - def AddPane4(self, window, pane_info, target): """ See comments on :meth:`AddPane`. """ @@ -4896,7 +4680,6 @@ class AuiManager(wx.EvtHandler): return True - def InsertPane(self, window, pane_info, insert_level=AUI_INSERT_PANE): """ This method is used to insert either a previously unmanaged pane window @@ -4960,7 +4743,6 @@ class AuiManager(wx.EvtHandler): return True - def DetachPane(self, window): """ Tells the :class:`AuiManager` to stop managing the pane specified @@ -5015,7 +4797,6 @@ class AuiManager(wx.EvtHandler): return False - def ClosePane(self, pane_info): """ Destroys or hides the pane depending on its flags. @@ -5065,7 +4846,6 @@ class AuiManager(wx.EvtHandler): pane_info.window.Reparent(self._frame) pane_info.Dock().Hide() - # now we need to either destroy or hide the pane to_destroy = 0 if pane_info.IsDestroyOnClose(): @@ -5080,7 +4860,7 @@ class AuiManager(wx.EvtHandler): if pane_info.IsNotebookControl(): notebook = self._notebooks[pane_info.notebook_id] - for idx in range(notebook.GetPageCount()-1, -1, -1): + for idx in range(notebook.GetPageCount() - 1, -1, -1): window = notebook.GetPage(idx) info = self.GetPane(window) # close page if its IsDestroyOnClose flag is set @@ -5129,7 +4909,6 @@ class AuiManager(wx.EvtHandler): if pane_info.window and not pane_info.window.IsShown(): pane_info.window.Show(True) - def SavePreviousDockSizes(self, pane_info): """ Stores the previous dock sizes, to be used in a "restore" action later. @@ -5144,7 +4923,6 @@ class AuiManager(wx.EvtHandler): if pane_info is not p: p.SetFlag(p.needsRestore, True) - def RestorePane(self, pane_info): """ Restores the input pane from a previous maximized or minimized state. @@ -5168,7 +4946,6 @@ class AuiManager(wx.EvtHandler): if pane_info.window and not pane_info.window.IsShown(): pane_info.window.Show(True) - def RestoreMaximizedPane(self): """ Restores the current maximized pane (if any). """ @@ -5178,7 +4955,6 @@ class AuiManager(wx.EvtHandler): self.RestorePane(p) break - def ActivatePane(self, window): """ Activates the pane to which `window` is associated. @@ -5197,7 +4973,6 @@ class AuiManager(wx.EvtHandler): self.RefreshCaptions() self.FireEvent(wxEVT_AUI_PANE_ACTIVATED, window, canVeto=False) - def CreateNotebook(self): """ Creates an automatic :class:`~wx.lib.agw.aui.auibook.AuiNotebook` when a pane is docked on @@ -5213,7 +4988,6 @@ class AuiManager(wx.EvtHandler): return notebook - def SetAutoNotebookTabArt(self, art): """ Sets the default tab art provider for automatic notebooks. @@ -5228,13 +5002,11 @@ class AuiManager(wx.EvtHandler): self._autoNBTabArt = art - def GetAutoNotebookTabArt(self): """ Returns the default tab art provider for automatic notebooks. """ return self._autoNBTabArt - def SetAutoNotebookStyle(self, agwStyle): """ Sets the default AGW-specific window style for automatic notebooks. @@ -5280,7 +5052,6 @@ class AuiManager(wx.EvtHandler): self._autoNBStyle = agwStyle - def GetAutoNotebookStyle(self): """ Returns the default AGW-specific window style for automatic notebooks. @@ -5290,7 +5061,6 @@ class AuiManager(wx.EvtHandler): return self._autoNBStyle - def SavePaneInfo(self, pane): """ This method is similar to :meth:`SavePerspective`, with the exception @@ -5303,28 +5073,27 @@ class AuiManager(wx.EvtHandler): result = "name=" + EscapeDelimiters(pane.name) + ";" result += "caption=" + EscapeDelimiters(pane.caption) + ";" - result += "state=%u;"%pane.state - result += "dir=%d;"%pane.dock_direction - result += "layer=%d;"%pane.dock_layer - result += "row=%d;"%pane.dock_row - result += "pos=%d;"%pane.dock_pos - result += "prop=%d;"%pane.dock_proportion - result += "bestw=%d;"%pane.best_size.x - result += "besth=%d;"%pane.best_size.y - result += "minw=%d;"%pane.min_size.x - result += "minh=%d;"%pane.min_size.y - result += "maxw=%d;"%pane.max_size.x - result += "maxh=%d;"%pane.max_size.y - result += "floatx=%d;"%pane.floating_pos.x - result += "floaty=%d;"%pane.floating_pos.y - result += "floatw=%d;"%pane.floating_size.x - result += "floath=%d;"%pane.floating_size.y - result += "notebookid=%d;"%pane.notebook_id - result += "transparent=%d"%pane.transparent + result += "state=%u;" % pane.state + result += "dir=%d;" % pane.dock_direction + result += "layer=%d;" % pane.dock_layer + result += "row=%d;" % pane.dock_row + result += "pos=%d;" % pane.dock_pos + result += "prop=%d;" % pane.dock_proportion + result += "bestw=%d;" % pane.best_size.x + result += "besth=%d;" % pane.best_size.y + result += "minw=%d;" % pane.min_size.x + result += "minh=%d;" % pane.min_size.y + result += "maxw=%d;" % pane.max_size.x + result += "maxh=%d;" % pane.max_size.y + result += "floatx=%d;" % pane.floating_pos.x + result += "floaty=%d;" % pane.floating_pos.y + result += "floatw=%d;" % pane.floating_size.x + result += "floath=%d;" % pane.floating_size.y + result += "notebookid=%d;" % pane.notebook_id + result += "transparent=%d" % pane.transparent return result - def LoadPaneInfo(self, pane_part, pane): """ This method is similar to to :meth:`LoadPerspective`, with the exception that @@ -5405,7 +5174,6 @@ class AuiManager(wx.EvtHandler): return pane - def SavePerspective(self): """ Saves the entire user interface layout into an encoded string, which can then @@ -5421,13 +5189,12 @@ class AuiManager(wx.EvtHandler): result += self.SavePaneInfo(pane) + "|" for dock in self._docks: - result = result + ("dock_size(%d,%d,%d)=%d|")%(dock.dock_direction, - dock.dock_layer, - dock.dock_row, - dock.size) + result = result + ("dock_size(%d,%d,%d)=%d|") % (dock.dock_direction, + dock.dock_layer, + dock.dock_row, + dock.size) return result - def LoadPerspective(self, layout, update=True, restorecaption=False): """ Loads a layout which was saved with :meth:`SavePerspective`. @@ -5448,13 +5215,13 @@ class AuiManager(wx.EvtHandler): # 'layout2' = wxAUI 0.9.2 (wxWidgets 2.8) index = input.find("|") part = input[0:index].strip() - input = input[index+1:] + input = input[index + 1:] if part != "layout2": return False # mark all panes currently managed as docked and hidden - saveCapt = {} # see restorecaption param + saveCapt = {} # see restorecaption param for pane in self._panes: # dock the notebook pages @@ -5483,7 +5250,7 @@ class AuiManager(wx.EvtHandler): pane = AuiPaneInfo() index = input.find("|") pane_part = input[0:index].strip() - input = input[index+1:] + input = input[index + 1:] # if the string is empty, we're done parsing if pane_part == "": @@ -5492,10 +5259,10 @@ class AuiManager(wx.EvtHandler): if pane_part[0:9] == "dock_size": index = pane_part.find("=") val_name = pane_part[0:index] - value = pane_part[index+1:] + value = pane_part[index + 1:] index = val_name.find("(") - piece = val_name[index+1:] + piece = val_name[index + 1:] index = piece.find(")") piece = piece[0:index] @@ -5556,7 +5323,6 @@ class AuiManager(wx.EvtHandler): return True - def GetPanePositionsAndSizes(self, dock): """ Returns all the panes positions and sizes in a dock. @@ -5590,7 +5356,7 @@ class AuiManager(wx.EvtHandler): size = 0 if pane.HasBorder(): - size += pane_border_size*2 + size += pane_border_size * 2 if dock.IsHorizontal(): if pane.HasGripper() and not pane.HasGripperTop(): @@ -5617,8 +5383,8 @@ class AuiManager(wx.EvtHandler): if action_pane == -1: return positions, sizes - for pane_i in range(action_pane-1, -1, -1): - amount = positions[pane_i+1] - (positions[pane_i] + sizes[pane_i]) + for pane_i in range(action_pane - 1, -1, -1): + amount = positions[pane_i + 1] - (positions[pane_i] + sizes[pane_i]) if amount >= 0: pass else: @@ -5638,7 +5404,6 @@ class AuiManager(wx.EvtHandler): return positions, sizes - def LayoutAddPane(self, cont, dock, pane, uiparts, spacer_only): """ Adds a pane into the existing layout (in an existing dock). @@ -5650,7 +5415,7 @@ class AuiManager(wx.EvtHandler): :param bool `spacer_only`: whether to add a simple spacer or a real window. """ - #sizer_item = wx.SizerItem() + # sizer_item = wx.SizerItem() caption_size = self._art.GetMetric(AUI_DOCKART_CAPTION_SIZE) gripper_size = self._art.GetMetric(AUI_DOCKART_GRIPPER_SIZE) pane_border_size = self._art.GetMetric(AUI_DOCKART_PANE_BORDER_SIZE) @@ -5689,7 +5454,7 @@ class AuiManager(wx.EvtHandler): uiparts.append(part) button_count = len(pane.buttons) - button_width_total = button_count*pane_button_size + button_width_total = button_count * pane_button_size if button_count >= 1: button_width_total += 3 @@ -5701,7 +5466,7 @@ class AuiManager(wx.EvtHandler): # add pane buttons to the caption dummy_parts = [] - for btn_id in range(len(pane.buttons)-1, -1, -1): + for btn_id in range(len(pane.buttons) - 1, -1, -1): sizer_item = caption_sizer.Add((caption_size, pane_button_size), 0, wx.EXPAND) part = AuiDockUIPart() part.type = AuiDockUIPart.typePaneButton @@ -5805,7 +5570,7 @@ class AuiManager(wx.EvtHandler): pane_proportion = 0 if min_size != wx.Size(-1, -1): - vert_pane_sizer.SetItemMinSize(len(vert_pane_sizer.GetChildren())-1, (min_size.x, min_size.y)) + vert_pane_sizer.SetItemMinSize(len(vert_pane_sizer.GetChildren()) - 1, (min_size.x, min_size.y)) # add the vertical/horizontal sizer (caption, pane window) to the # horizontal sizer (gripper, vertical sizer) @@ -5830,7 +5595,6 @@ class AuiManager(wx.EvtHandler): return uiparts - def LayoutAddDock(self, cont, dock, uiparts, spacer_only): """ Adds a dock into the existing layout. @@ -5841,7 +5605,7 @@ class AuiManager(wx.EvtHandler): :param bool `spacer_only`: whether to add a simple spacer or a real window. """ -# sizer_item = wx.SizerItem() + # sizer_item = wx.SizerItem() part = AuiDockUIPart() sash_size = self._art.GetMetric(AUI_DOCKART_SASH_SIZE) @@ -5849,8 +5613,7 @@ class AuiManager(wx.EvtHandler): # resizable bottom and right docks have a sash before them if not self._has_maximized and not dock.fixed and \ - dock.dock_direction in [AUI_DOCK_BOTTOM, AUI_DOCK_RIGHT]: - + dock.dock_direction in [AUI_DOCK_BOTTOM, AUI_DOCK_RIGHT]: sizer_item = cont.Add((sash_size, sash_size), 0, wx.EXPAND) part.type = AuiDockUIPart.typeDockSizer @@ -5897,7 +5660,7 @@ class AuiManager(wx.EvtHandler): part.dock = dock part.pane = None part.button = None - part.orientation = (orientation==wx.HORIZONTAL and \ + part.orientation = (orientation == wx.HORIZONTAL and \ [wx.VERTICAL] or [wx.HORIZONTAL])[0] part.cont_sizer = dock_sizer part.sizer_item = sizer_item @@ -5937,9 +5700,9 @@ class AuiManager(wx.EvtHandler): part = AuiDockUIPart() part.type = AuiDockUIPart.typePaneSizer part.dock = dock - part.pane = dock.panes[pane_i-1] + part.pane = dock.panes[pane_i - 1] part.button = None - part.orientation = (orientation==wx.HORIZONTAL and \ + part.orientation = (orientation == wx.HORIZONTAL and \ [wx.VERTICAL] or [wx.HORIZONTAL])[0] part.cont_sizer = dock_sizer part.sizer_item = sizer_item @@ -5969,8 +5732,7 @@ class AuiManager(wx.EvtHandler): # top and left docks have a sash after them if not self._has_maximized and not dock.fixed and \ - dock.dock_direction in [AUI_DOCK_TOP, AUI_DOCK_LEFT]: - + dock.dock_direction in [AUI_DOCK_TOP, AUI_DOCK_LEFT]: sizer_item = cont.Add((sash_size, sash_size), 0, wx.EXPAND) part = AuiDockUIPart() @@ -5985,7 +5747,6 @@ class AuiManager(wx.EvtHandler): return uiparts - def LayoutAll(self, panes, docks, uiparts, spacer_only=False, oncheck=True): """ Layouts all the UI structures in the interface. @@ -6055,8 +5816,8 @@ class AuiManager(wx.EvtHandler): frameRect = GetInternalFrameRect(self._frame, self._docks) # set max size allowing for sashes and absolute minimum - maxsize = frameRect[2:][isHor] - sum(sizes) - (len(sizes)*10) - (sashSize*len(sizes)) - dock.size = min(p.previousDockSize,maxsize) + maxsize = frameRect[2:][isHor] - sum(sizes) - (len(sizes) * 10) - (sashSize * len(sizes)) + dock.size = min(p.previousDockSize, maxsize) else: dock.size = 0 @@ -6094,8 +5855,8 @@ class AuiManager(wx.EvtHandler): # dock position (dock_pos), in ascending order dock_pane_count = len(dock.panes) if dock_pane_count > 1: - #~ dock.panes.sort(PaneSortFunc) - dock.panes.sort(key = lambda pane: pane.dock_pos) + # ~ dock.panes.sort(PaneSortFunc) + dock.panes.sort(key=lambda pane: pane.dock_pos) # for newly created docks, set up their initial size if dock.size == 0: @@ -6115,7 +5876,7 @@ class AuiManager(wx.EvtHandler): # if at least one pane inside the dock has a pane border for pane in dock.panes: if pane.HasBorder(): - size = size + pane_border_size*2 + size = size + pane_border_size * 2 break # if pane is on the top or bottom, add the caption height, @@ -6133,8 +5894,8 @@ class AuiManager(wx.EvtHandler): # new dock's size may not be more than the dock constraint # parameter specifies. See SetDockSizeConstraint() - max_dock_x_size = int(self._dock_constraint_x*float(cli_size.x)) - max_dock_y_size = int(self._dock_constraint_y*float(cli_size.y)) + max_dock_x_size = int(self._dock_constraint_x * float(cli_size.x)) + max_dock_y_size = int(self._dock_constraint_y * float(cli_size.y)) if tuple(cli_size) <= tuple(wx.Size(20, 20)): max_dock_x_size = 10000 max_dock_y_size = 10000 @@ -6171,7 +5932,7 @@ class AuiManager(wx.EvtHandler): dock_min_size = pane.min_size.x if plus_border: - dock_min_size += pane_border_size*2 + dock_min_size += pane_border_size * 2 if plus_caption and dock.IsHorizontal(): dock_min_size += caption_size if plus_caption_left and dock.IsVertical(): @@ -6235,8 +5996,8 @@ class AuiManager(wx.EvtHandler): self._docks[ii] = dock # shrink docks if needed -## docks = self.SmartShrink(docks, AUI_DOCK_TOP) -## docks = self.SmartShrink(docks, AUI_DOCK_LEFT) + ## docks = self.SmartShrink(docks, AUI_DOCK_TOP) + ## docks = self.SmartShrink(docks, AUI_DOCK_LEFT) if oncheck: self._docks = docks @@ -6259,7 +6020,7 @@ class AuiManager(wx.EvtHandler): if oncheck: docks = self._docks - for layer in range(max_layer+1): + for layer in range(max_layer + 1): # find any docks in this layer arr = FindDocks(docks, -1, layer, -1) # if there aren't any, skip to the next layer @@ -6294,7 +6055,7 @@ class AuiManager(wx.EvtHandler): arr = FindDocks(docks, AUI_DOCK_CENTER, -1, -1) if arr: for row in arr: - uiparts = self.LayoutAddDock(middle, row, uiparts, spacer_only) + uiparts = self.LayoutAddDock(middle, row, uiparts, spacer_only) elif not self._has_maximized: # there are no center docks, add a background area @@ -6321,7 +6082,7 @@ class AuiManager(wx.EvtHandler): # find any bottom docks in this layer arr = FindDocks(docks, AUI_DOCK_BOTTOM, layer, -1, reverse=True) for row in arr: - uiparts = self.LayoutAddDock(cont, row, uiparts, spacer_only) + uiparts = self.LayoutAddDock(cont, row, uiparts, spacer_only) if not cont: # no sizer available, because there are no docks, @@ -6348,7 +6109,6 @@ class AuiManager(wx.EvtHandler): else: return container, panes, docks, uiparts - def SetDockSizeConstraint(self, width_pct, height_pct): """ When a user creates a new dock by dragging a window into a docked position, @@ -6370,7 +6130,6 @@ class AuiManager(wx.EvtHandler): self._dock_constraint_x = max(0.0, min(1.0, width_pct)) self._dock_constraint_y = max(0.0, min(1.0, height_pct)) - def GetDockSizeConstraint(self): """ Returns the current dock constraint values. @@ -6380,7 +6139,6 @@ class AuiManager(wx.EvtHandler): return self._dock_constraint_x, self._dock_constraint_y - def Update(self): if '__WXGTK__' in wx.PlatformInfo: wx.CallAfter(self.DoUpdate) @@ -6492,7 +6250,7 @@ class AuiManager(wx.EvtHandler): # the dragging is happening right now, then the floating # window should have this style by default if self._action in [actionDragFloatingPane, actionDragToolbarPane] and \ - self._agwFlags & AUI_MGR_TRANSPARENT_DRAG: + self._agwFlags & AUI_MGR_TRANSPARENT_DRAG: frame.SetTransparent(150) frame.SetPaneWindow(p) @@ -6584,8 +6342,6 @@ class AuiManager(wx.EvtHandler): if not self._masterManager: e = self.FireEvent(wxEVT_AUI_PERSPECTIVE_CHANGED, None, canVeto=False) - - def UpdateNotebook(self): """ Updates the automatic :class:`~wx.lib.agw.aui.auibook.AuiNotebook` in the layout (if any exists). """ @@ -6670,7 +6426,7 @@ class AuiManager(wx.EvtHandler): # Delete empty notebooks, and convert notebooks with 1 page to # normal panes... - remap_ids = [-1]*len(self._notebooks) + remap_ids = [-1] * len(self._notebooks) nb_idx = 0 for nb, notebook in enumerate(self._notebooks): @@ -6771,7 +6527,6 @@ class AuiManager(wx.EvtHandler): # todo: remove close - def SmartShrink(self, docks, direction): """ Used to intelligently shrink the docks' size (if needed). @@ -6833,7 +6588,6 @@ class AuiManager(wx.EvtHandler): return docks - def UpdateDockingGuides(self, paneInfo): """ Updates the docking guide windows positions and appearance. @@ -6858,32 +6612,32 @@ class AuiManager(wx.EvtHandler): direction = guide.dock_direction if direction == AUI_DOCK_LEFT: - pt.x = frameRect.x + guide_size.x / 2 + 16 - pt.y = frameRect.y + frameRect.height / 2 + pt.x = frameRect.x + guide_size.x // 2 + 16 + pt.y = frameRect.y + frameRect.height // 2 elif direction == AUI_DOCK_TOP: - pt.x = frameRect.x + frameRect.width / 2 - pt.y = frameRect.y + guide_size.y / 2 + 16 + pt.x = frameRect.x + frameRect.width // 2 + pt.y = frameRect.y + guide_size.y // 2 + 16 elif direction == AUI_DOCK_RIGHT: - pt.x = frameRect.x + frameRect.width - guide_size.x / 2 - 16 - pt.y = frameRect.y + frameRect.height / 2 + pt.x = frameRect.x + frameRect.width - guide_size.x // 2 - 16 + pt.y = frameRect.y + frameRect.height // 2 elif direction == AUI_DOCK_BOTTOM: - pt.x = frameRect.x + frameRect.width / 2 - pt.y = frameRect.y + frameRect.height - guide_size.y / 2 - 16 + pt.x = frameRect.x + frameRect.width // 2 + pt.y = frameRect.y + frameRect.height - guide_size.y // 2 - 16 elif direction == AUI_DOCK_CENTER: rc = paneInfo.window.GetScreenRect() - pt.x = rc.x + rc.width / 2 - pt.y = rc.y + rc.height / 2 + pt.x = rc.x + rc.width // 2 + pt.y = rc.y + rc.height // 2 if paneInfo.HasCaption(): - pt.y -= captionSize / 2 + pt.y -= captionSize // 2 elif paneInfo.HasCaptionLeft(): - pt.x -= captionSize / 2 + pt.x -= captionSize // 2 # guide will be centered around point 'pt' - targetPosition = wx.Point(pt.x - guide_size.x / 2, pt.y - guide_size.y / 2) + targetPosition = wx.Point(pt.x - guide_size.x // 2, pt.y - guide_size.y // 2) if guide.host.GetPosition() != targetPosition: guide.host.Move(targetPosition) @@ -6898,7 +6652,6 @@ class AuiManager(wx.EvtHandler): paneInfo.window.Lower() - def DoFrameLayout(self): """ This is an internal function which invokes :meth:`wx.Sizer.Layout() ` @@ -6943,7 +6696,6 @@ class AuiManager(wx.EvtHandler): if part.type == AuiDockUIPart.typePane: part.pane.rect = part.rect - def GetPanePart(self, wnd): """ Looks up the pane border UI part of the @@ -6955,17 +6707,16 @@ class AuiManager(wx.EvtHandler): for part in self._uiparts: if part.type == AuiDockUIPart.typePaneBorder and \ - part.pane and part.pane.window == wnd: + part.pane and part.pane.window == wnd: return part for part in self._uiparts: if part.type == AuiDockUIPart.typePane and \ - part.pane and part.pane.window == wnd: + part.pane and part.pane.window == wnd: return part return None - def GetDockPixelOffset(self, test): """ This is an internal function which returns a dock's offset in pixels from @@ -6999,8 +6750,8 @@ class AuiManager(wx.EvtHandler): for dock in docks: if test.dock_direction == dock.dock_direction and \ - test.dock_layer == dock.dock_layer and \ - test.dock_row == dock.dock_row: + test.dock_layer == dock.dock_layer and \ + test.dock_row == dock.dock_row: if dock.IsVertical(): return dock.rect.y @@ -7009,7 +6760,6 @@ class AuiManager(wx.EvtHandler): return 0 - def GetPartnerDock(self, dock): """ Returns the partner dock for the input dock. @@ -7044,7 +6794,6 @@ class AuiManager(wx.EvtHandler): return None - def GetPartnerPane(self, dock, pane): """ Returns the partner pane for the input pane. They both need to live @@ -7064,7 +6813,6 @@ class AuiManager(wx.EvtHandler): return None - def GetTotalPixSizeAndProportion(self, dock): """ Returns the dimensions and proportion of the input dock. @@ -7090,16 +6838,15 @@ class AuiManager(wx.EvtHandler): else: totalPixsize += tmpPane.rect.height -## if tmpPane.min_size.IsFullySpecified(): -## -## if dock.IsHorizontal(): -## totalPixsize -= tmpPane.min_size.x -## else: -## totalPixsize -= tmpPane.min_size.y + ## if tmpPane.min_size.IsFullySpecified(): + ## + ## if dock.IsHorizontal(): + ## totalPixsize -= tmpPane.min_size.x + ## else: + ## totalPixsize -= tmpPane.min_size.y return totalPixsize, totalProportion - def GetOppositeDockTotalSize(self, docks, direction): """ Returns the dimensions of the dock which lives opposite of the input dock. @@ -7129,7 +6876,7 @@ class AuiManager(wx.EvtHandler): for tmpPane in tmpDock.panes: - minSize = pane_border_size*2 - sash_size + minSize = pane_border_size * 2 - sash_size if vertical: minSize += tmpPane.min_size.y + caption_size @@ -7153,7 +6900,6 @@ class AuiManager(wx.EvtHandler): return result - def CalculateDockSizerLimits(self, dock): """ Calculates the minimum and maximum sizes allowed for the input dock. @@ -7170,9 +6916,8 @@ class AuiManager(wx.EvtHandler): for tmpDock in docks: if tmpDock.dock_direction == dock.dock_direction and \ - tmpDock.dock_layer == dock.dock_layer and \ - tmpDock.dock_row == dock.dock_row: - + tmpDock.dock_layer == dock.dock_layer and \ + tmpDock.dock_row == dock.dock_row: tmpDock.size = 1 break @@ -7192,9 +6937,8 @@ class AuiManager(wx.EvtHandler): for tmpDock in docks: if tmpDock.dock_direction == dock.dock_direction and \ - tmpDock.dock_layer == dock.dock_layer and \ - tmpDock.dock_row == dock.dock_row: - + tmpDock.dock_layer == dock.dock_layer and \ + tmpDock.dock_row == dock.dock_row: new_dock = tmpDock break @@ -7249,7 +6993,6 @@ class AuiManager(wx.EvtHandler): return minPix, maxPix - def CalculatePaneSizerLimits(self, dock, pane): """ Calculates the minimum and maximum sizes allowed for the input pane. @@ -7309,7 +7052,6 @@ class AuiManager(wx.EvtHandler): return minPix, maxPix - def CheckMovableSizer(self, part): """ Checks if a UI part can be actually resized. @@ -7320,8 +7062,7 @@ class AuiManager(wx.EvtHandler): # a dock may not be resized if it has a single # pane which is not resizable if part.type == AuiDockUIPart.typeDockSizer and part.dock and \ - len(part.dock.panes) == 1 and part.dock.panes[0].IsFixed(): - + len(part.dock.panes) == 1 and part.dock.panes[0].IsFixed(): return False if part.pane: @@ -7334,7 +7075,6 @@ class AuiManager(wx.EvtHandler): return True - def PaneFromTabEvent(self, event): """ Returns a :class:`AuiPaneInfo` from a :class:`~wx.lib.agw.aui.auibook.AuiNotebook` event. @@ -7365,7 +7105,6 @@ class AuiManager(wx.EvtHandler): return NonePaneInfo - def OnTabBeginDrag(self, event): """ Handles the ``EVT_AUINOTEBOOK_BEGIN_DRAG`` event. @@ -7473,7 +7212,6 @@ class AuiManager(wx.EvtHandler): else: event.Skip() - def OnTabSelected(self, event): """ Handles the ``EVT_AUINOTEBOOK_PAGE_CHANGED`` event. @@ -7496,13 +7234,11 @@ class AuiManager(wx.EvtHandler): if paneInfo.IsOk(): notebookRoot = GetNotebookRoot(self._panes, paneInfo.notebook_id) if notebookRoot: - notebookRoot.Caption(paneInfo.caption) self.RefreshCaptions() event.Skip() - def GetNotebooks(self): """ Returns all the automatic :class:`~wx.lib.agw.aui.auibook.AuiNotebook` in the :class:`AuiManager`. """ @@ -7511,7 +7247,6 @@ class AuiManager(wx.EvtHandler): return self._notebooks - def SetMasterManager(self, manager): """ Sets the master manager for an automatic :class:`~wx.lib.agw.aui.auibook.AuiNotebook`. @@ -7521,7 +7256,6 @@ class AuiManager(wx.EvtHandler): self._masterManager = manager - def ProcessDockResult(self, target, new_pos): """ This is a utility function used by :meth:`DoDrop` - it checks @@ -7552,7 +7286,6 @@ class AuiManager(wx.EvtHandler): return allowed, target - def SwitchToolBarOrientation(self, pane): """ Switches the toolbar orientation from vertical to horizontal and vice-versa. @@ -7593,7 +7326,6 @@ class AuiManager(wx.EvtHandler): return pane - def DoDrop(self, docks, panes, target, pt, offset=wx.Point(0, 0)): """ This is an important function. It basically takes a mouse position, @@ -7615,7 +7347,6 @@ class AuiManager(wx.EvtHandler): else: return self.DoDropNonFloatingPane(docks, panes, target, pt) - def CopyTarget(self, target): """ Copies all the attributes of the input `target` into another :class:`AuiPaneInfo`. @@ -7650,7 +7381,6 @@ class AuiManager(wx.EvtHandler): return drop - def DoDropToolbar(self, docks, panes, target, pt, offset): """ Handles the situation in which the dropped pane contains a toolbar. @@ -7703,7 +7433,7 @@ class AuiManager(wx.EvtHandler): Position(pt.x - self.GetDockPixelOffset(drop) - offset.x) if not target.IsFloating() and safeRect.Contains(pt) and \ - target.dock_direction != drop.dock_direction: + target.dock_direction != drop.dock_direction: return False, target return self.ProcessDockResult(target, drop) @@ -7730,7 +7460,7 @@ class AuiManager(wx.EvtHandler): if not dock.fixed or dock.dock_direction == AUI_DOCK_CENTER: if (self._agwFlags & AUI_MGR_ALLOW_FLOATING and drop.IsFloatable()) or \ - dock.dock_direction not in [AUI_DOCK_CENTER, AUI_DOCK_NONE]: + dock.dock_direction not in [AUI_DOCK_CENTER, AUI_DOCK_NONE]: if drop.IsFloatable(): drop.Float() @@ -7748,7 +7478,7 @@ class AuiManager(wx.EvtHandler): Row(dock.dock_row).Position(dockDropOffset) if (pt.y <= dock.rect.GetTop() + 2 and dock.IsHorizontal()) or \ - (pt.x <= dock.rect.GetLeft() + 2 and dock.IsVertical()): + (pt.x <= dock.rect.GetLeft() + 2 and dock.IsVertical()): if dock.dock_direction in [AUI_DOCK_TOP, AUI_DOCK_LEFT]: row = drop.dock_row @@ -7756,15 +7486,15 @@ class AuiManager(wx.EvtHandler): drop.dock_row = row else: - panes = DoInsertDockRow(panes, dock.dock_direction, dock.dock_layer, dock.dock_row+1) + panes = DoInsertDockRow(panes, dock.dock_direction, dock.dock_layer, dock.dock_row + 1) drop.dock_row = dock.dock_row + 1 if (pt.y >= dock.rect.GetBottom() - 2 and dock.IsHorizontal()) or \ - (pt.x >= dock.rect.GetRight() - 2 and dock.IsVertical()): + (pt.x >= dock.rect.GetRight() - 2 and dock.IsVertical()): if dock.dock_direction in [AUI_DOCK_TOP, AUI_DOCK_LEFT]: - panes = DoInsertDockRow(panes, dock.dock_direction, dock.dock_layer, dock.dock_row+1) - drop.dock_row = dock.dock_row+1 + panes = DoInsertDockRow(panes, dock.dock_direction, dock.dock_layer, dock.dock_row + 1) + drop.dock_row = dock.dock_row + 1 else: row = drop.dock_row @@ -7772,12 +7502,11 @@ class AuiManager(wx.EvtHandler): drop.dock_row = row if not target.IsFloating() and safeRect.Contains(pt) and \ - target.dock_direction != drop.dock_direction: + target.dock_direction != drop.dock_direction: return False, target return self.ProcessDockResult(target, drop) - def DoDropFloatingPane(self, docks, panes, target, pt): """ Handles the situation in which the dropped pane contains a normal window. @@ -7800,7 +7529,7 @@ class AuiManager(wx.EvtHandler): # search the dock guides. # reverse order to handle the center first. - for i in range(len(self._guides)-1, -1, -1): + for i in range(len(self._guides) - 1, -1, -1): guide = self._guides[i] # do hit testing on the guide @@ -7809,7 +7538,7 @@ class AuiManager(wx.EvtHandler): if dir == -1: # point was outside of the dock guide continue - if dir == wx.ALL: # target is a single dock guide + if dir == wx.ALL: # target is a single dock guide return self.DoDropLayer(docks, target, guide.dock_direction) elif dir == wx.CENTER: @@ -7820,7 +7549,6 @@ class AuiManager(wx.EvtHandler): continue if not paneInfo.HasNotebook(): - # Add a new notebook pane with the original as a tab... self.CreateNotebookBase(panes, paneInfo) @@ -7851,8 +7579,8 @@ class AuiManager(wx.EvtHandler): if insert_dir == AUI_DOCK_LEFT: - drop_pane = (dir == wx.UP or dir == wx.DOWN) - drop_row = (dir == wx.LEFT or dir == wx.RIGHT) + drop_pane = (dir == wx.UP or dir == wx.DOWN) + drop_row = (dir == wx.LEFT or dir == wx.RIGHT) if dir == wx.RIGHT: insert_row += 1 elif dir == wx.DOWN: @@ -7860,8 +7588,8 @@ class AuiManager(wx.EvtHandler): elif insert_dir == AUI_DOCK_RIGHT: - drop_pane = (dir == wx.UP or dir == wx.DOWN) - drop_row = (dir == wx.LEFT or dir == wx.RIGHT) + drop_pane = (dir == wx.UP or dir == wx.DOWN) + drop_row = (dir == wx.LEFT or dir == wx.RIGHT) if dir == wx.LEFT: insert_row += 1 elif dir == wx.DOWN: @@ -7870,7 +7598,7 @@ class AuiManager(wx.EvtHandler): elif insert_dir == AUI_DOCK_TOP: drop_pane = (dir == wx.LEFT or dir == wx.RIGHT) - drop_row = (dir == wx.UP or dir == wx.DOWN) + drop_row = (dir == wx.UP or dir == wx.DOWN) if dir == wx.DOWN: insert_row += 1 elif dir == wx.RIGHT: @@ -7879,7 +7607,7 @@ class AuiManager(wx.EvtHandler): elif insert_dir == AUI_DOCK_BOTTOM: drop_pane = (dir == wx.LEFT or dir == wx.RIGHT) - drop_row = (dir == wx.UP or dir == wx.DOWN) + drop_row = (dir == wx.UP or dir == wx.DOWN) if dir == wx.UP: insert_row += 1 elif dir == wx.RIGHT: @@ -7898,7 +7626,6 @@ class AuiManager(wx.EvtHandler): return False, target - def DoDropNonFloatingPane(self, docks, panes, target, pt): """ Handles the situation in which the dropped pane is not floating. @@ -7947,59 +7674,58 @@ class AuiManager(wx.EvtHandler): direction = part.pane.dock_direction if direction == AUI_DOCK_TOP: - if pt.y >= part.rect.y and pt.y < part.rect.y+auiInsertRowPixels: + if pt.y >= part.rect.y and pt.y < part.rect.y + auiInsertRowPixels: insert_dock_row = True elif direction == AUI_DOCK_BOTTOM: - if pt.y > part.rect.y+part.rect.height-auiInsertRowPixels and \ - pt.y <= part.rect.y + part.rect.height: + if pt.y > part.rect.y + part.rect.height - auiInsertRowPixels and \ + pt.y <= part.rect.y + part.rect.height: insert_dock_row = True elif direction == AUI_DOCK_LEFT: - if pt.x >= part.rect.x and pt.x < part.rect.x+auiInsertRowPixels: + if pt.x >= part.rect.x and pt.x < part.rect.x + auiInsertRowPixels: insert_dock_row = True elif direction == AUI_DOCK_RIGHT: - if pt.x > part.rect.x+part.rect.width-auiInsertRowPixels and \ - pt.x <= part.rect.x+part.rect.width: + if pt.x > part.rect.x + part.rect.width - auiInsertRowPixels and \ + pt.x <= part.rect.x + part.rect.width: insert_dock_row = True elif direction == AUI_DOCK_CENTER: - # "new row pixels" will be set to the default, but - # must never exceed 20% of the window size - new_row_pixels_x = auiNewRowPixels - new_row_pixels_y = auiNewRowPixels + # "new row pixels" will be set to the default, but + # must never exceed 20% of the window size + new_row_pixels_x = auiNewRowPixels + new_row_pixels_y = auiNewRowPixels - if new_row_pixels_x > (part.rect.width*20)/100: - new_row_pixels_x = (part.rect.width*20)/100 + if new_row_pixels_x > (part.rect.width * 20) // 100: + new_row_pixels_x = (part.rect.width * 20) // 100 - if new_row_pixels_y > (part.rect.height*20)/100: - new_row_pixels_y = (part.rect.height*20)/100 + if new_row_pixels_y > (part.rect.height * 20) // 100: + new_row_pixels_y = (part.rect.height * 20) // 100 - # determine if the mouse pointer is in a location that - # will cause a new row to be inserted. The hot spot positions - # are along the borders of the center pane + # determine if the mouse pointer is in a location that + # will cause a new row to be inserted. The hot spot positions + # are along the borders of the center pane - insert_layer = 0 - insert_dock_row = True - pr = part.rect + insert_layer = 0 + insert_dock_row = True + pr = part.rect - if pt.x >= pr.x and pt.x < pr.x + new_row_pixels_x: - insert_dir = AUI_DOCK_LEFT - elif pt.y >= pr.y and pt.y < pr.y + new_row_pixels_y: - insert_dir = AUI_DOCK_TOP - elif pt.x >= pr.x + pr.width - new_row_pixels_x and pt.x < pr.x + pr.width: - insert_dir = AUI_DOCK_RIGHT - elif pt.y >= pr.y+ pr.height - new_row_pixels_y and pt.y < pr.y + pr.height: - insert_dir = AUI_DOCK_BOTTOM - else: - return False, target + if pt.x >= pr.x and pt.x < pr.x + new_row_pixels_x: + insert_dir = AUI_DOCK_LEFT + elif pt.y >= pr.y and pt.y < pr.y + new_row_pixels_y: + insert_dir = AUI_DOCK_TOP + elif pt.x >= pr.x + pr.width - new_row_pixels_x and pt.x < pr.x + pr.width: + insert_dir = AUI_DOCK_RIGHT + elif pt.y >= pr.y + pr.height - new_row_pixels_y and pt.y < pr.y + pr.height: + insert_dir = AUI_DOCK_BOTTOM + else: + return False, target - insert_row = GetMaxRow(panes, insert_dir, insert_layer) + 1 + insert_row = GetMaxRow(panes, insert_dir, insert_layer) + 1 if insert_dock_row: - panes = DoInsertDockRow(panes, insert_dir, insert_layer, insert_row) drop.Dock().Direction(insert_dir).Layer(insert_layer). \ Row(insert_row).Position(0) @@ -8023,8 +7749,7 @@ class AuiManager(wx.EvtHandler): # if we are in the top/left part of the pane, # insert the pane before the pane being hovered over - if offset <= size/2: - + if offset <= size // 2: drop_position = part.pane.dock_pos panes = DoInsertPane(panes, part.pane.dock_direction, @@ -8034,24 +7759,21 @@ class AuiManager(wx.EvtHandler): # if we are in the bottom/right part of the pane, # insert the pane before the pane being hovered over - if offset > size/2: - - drop_position = part.pane.dock_pos+1 + if offset > size // 2: + drop_position = part.pane.dock_pos + 1 panes = DoInsertPane(panes, part.pane.dock_direction, part.pane.dock_layer, part.pane.dock_row, - part.pane.dock_pos+1) - + part.pane.dock_pos + 1) drop.Dock(). \ - Direction(part.dock.dock_direction). \ - Layer(part.dock.dock_layer).Row(part.dock.dock_row). \ - Position(drop_position) + Direction(part.dock.dock_direction). \ + Layer(part.dock.dock_layer).Row(part.dock.dock_row). \ + Position(drop_position) return self.ProcessDockResult(target, drop) - def DoDropLayer(self, docks, target, dock_direction): """ Handles the situation in which `target` is a single dock guide. @@ -8090,11 +7812,9 @@ class AuiManager(wx.EvtHandler): else: return False, target - drop.Dock().Layer(drop_new_layer) return self.ProcessDockResult(target, drop) - def DoDropPane(self, panes, target, dock_direction, dock_layer, dock_row, dock_pos): """ Drop a pane in the interface. @@ -8113,7 +7833,6 @@ class AuiManager(wx.EvtHandler): drop.Dock().Direction(dock_direction).Layer(dock_layer).Row(dock_row).Position(dock_pos) return self.ProcessDockResult(target, drop) - def DoDropRow(self, panes, target, dock_direction, dock_layer, dock_row): """ Insert a row in the interface before dropping. @@ -8131,7 +7850,6 @@ class AuiManager(wx.EvtHandler): drop.Dock().Direction(dock_direction).Layer(dock_layer).Row(dock_row).Position(0) return self.ProcessDockResult(target, drop) - def ShowHint(self, rect): """ Shows the AUI hint window. @@ -8177,9 +7895,9 @@ class AuiManager(wx.EvtHandler): screendc.SetBrush(brush) screendc.SetPen(wx.TRANSPARENT_PEN) screendc.DrawRectangle(rect.x, rect.y, 5, rect.height) - screendc.DrawRectangle(rect.x+5, rect.y, rect.width-10, 5) - screendc.DrawRectangle(rect.x+rect.width-5, rect.y, 5, rect.height) - screendc.DrawRectangle(rect.x+5, rect.y+rect.height-5, rect.width-10, 5) + screendc.DrawRectangle(rect.x + 5, rect.y, rect.width - 10, 5) + screendc.DrawRectangle(rect.x + rect.width - 5, rect.y, 5, rect.height) + screendc.DrawRectangle(rect.x + 5, rect.y + rect.height - 5, rect.width - 10, 5) RefreshDockingGuides(self._guides) return @@ -8200,13 +7918,12 @@ class AuiManager(wx.EvtHandler): if self._action == actionDragFloatingPane and self._action_window: self._action_window.SetFocus() - if self._hint_fadeamt != self._hint_fademax: # Only fade if we need to + if self._hint_fadeamt != self._hint_fademax: # Only fade if we need to # start fade in timer self._hint_fadetimer.Start(5) self._last_hint = wx.Rect(*rect) - def HideHint(self): """ Hides a transparent window hint if there is one. """ @@ -8217,7 +7934,6 @@ class AuiManager(wx.EvtHandler): self._hint_fadetimer.Stop() self._last_hint = wx.Rect() - def IsPaneButtonVisible(self, part): """ Returns whether a pane button in the pane caption is visible. @@ -8229,13 +7945,12 @@ class AuiManager(wx.EvtHandler): for temp_part in self._uiparts: if temp_part.pane == part.pane and \ - temp_part.type == AuiDockUIPart.typeCaption: + temp_part.type == AuiDockUIPart.typeCaption: captionRect = temp_part.rect break return captionRect.Contains(part.rect) - def DrawPaneButton(self, dc, part, pt): """ Draws a pane button in the caption (convenience function). @@ -8260,7 +7975,6 @@ class AuiManager(wx.EvtHandler): self._art.DrawPaneButton(dc, self._frame, part.button.button_id, state, part.rect, part.pane) - def RefreshButton(self, part): """ Refreshes a pane button in the caption. @@ -8273,7 +7987,6 @@ class AuiManager(wx.EvtHandler): self._frame.Refresh(True, rect) self._frame.Update() - def RefreshCaptions(self): """ Refreshes all pane captions. """ @@ -8282,7 +7995,6 @@ class AuiManager(wx.EvtHandler): self._frame.Refresh(True, part.rect) self._frame.Update() - def CalculateHintRect(self, pane_window, pt, offset): """ Calculates the drop hint rectangle. @@ -8351,14 +8063,14 @@ class AuiManager(wx.EvtHandler): if hint.IsNotebookPage(): id = hint.notebook_id for pane in panes: - if pane.IsNotebookControl() and pane.notebook_id==id: + if pane.IsNotebookControl() and pane.notebook_id == id: sought = pane.name break for part in uiparts: if part.pane and part.pane.name == sought: rect.Union(wx.Rect(part.sizer_item.GetPosition(), - part.sizer_item.GetSize())) + part.sizer_item.GetSize())) sizer.Destroy() @@ -8379,7 +8091,6 @@ class AuiManager(wx.EvtHandler): return rect - def DrawHintRect(self, pane_window, pt, offset): """ Calculates the hint rectangle by calling :meth:`CalculateHintRect`. If there is a @@ -8401,7 +8112,6 @@ class AuiManager(wx.EvtHandler): self.ShowHint(rect) self._hint_rect = wx.Rect(*rect) - def GetPartSizerRect(self, uiparts): """ Returns the rectangle surrounding the specified UI parts. @@ -8414,11 +8124,10 @@ class AuiManager(wx.EvtHandler): for part in self._uiparts: if part.pane and part.pane.name == "__HINT__": rect.Union(wx.Rect(part.sizer_item.GetPosition(), - part.sizer_item.GetSize())) + part.sizer_item.GetSize())) return rect - def GetAttributes(self, pane): """ Returns all the attributes of a :class:`AuiPaneInfo`. @@ -8436,7 +8145,6 @@ class AuiManager(wx.EvtHandler): return attrs - def SetAttributes(self, pane, attrs): """ Sets all the attributes contained in `attrs` to a :class:`AuiPaneInfo`. @@ -8471,7 +8179,6 @@ class AuiManager(wx.EvtHandler): return pane - def OnFloatingPaneResized(self, wnd, size): """ Handles the resizing of a floating pane. @@ -8493,7 +8200,6 @@ class AuiManager(wx.EvtHandler): if pane.IsSnappable(): self.SnapPane(pane, pane.floating_pos, pane.floating_size, True) - def OnFloatingPaneClosed(self, wnd, event): """ Handles the close event of a floating pane. @@ -8525,7 +8231,6 @@ class AuiManager(wx.EvtHandler): if check.IsOk(): self.ClosePane(pane) - def OnFloatingPaneActivated(self, wnd): """ Handles the activation event of a floating pane. @@ -8542,7 +8247,6 @@ class AuiManager(wx.EvtHandler): self.RefreshCaptions() self.FireEvent(wxEVT_AUI_PANE_ACTIVATED, wnd, canVeto=False) - def OnFloatingPaneMoved(self, wnd, eventOrPt): """ Handles the move event of a floating pane. @@ -8567,7 +8271,6 @@ class AuiManager(wx.EvtHandler): self.SnapPane(pane, pane_pos, pane_size, False) - def SnapPane(self, pane, pane_pos, pane_size, toSnap=False): """ Snaps a floating pane to one of the main frame sides. @@ -8594,13 +8297,13 @@ class AuiManager(wx.EvtHandler): diff = wnd_pos.x - (pane_pos.x + pane_size.x) if -snapX <= diff <= snapX: pane.snapped = wx.LEFT - pane.floating_pos = wx.Point(wnd_pos.x-pane_size.x, pane_pos.y) + pane.floating_pos = wx.Point(wnd_pos.x - pane_size.x, pane_pos.y) elif pane.IsTopSnappable(): # Check if we can snap to the top diff = wnd_pos.y - (pane_pos.y + pane_size.y) if -snapY <= diff <= snapY: pane.snapped = wx.TOP - pane.floating_pos = wx.Point(pane_pos.x, wnd_pos.y-pane_size.y) + pane.floating_pos = wx.Point(pane_pos.x, wnd_pos.y - pane_size.y) elif pane.IsRightSnappable(): # Check if we can snap to the right diff = pane_pos.x - (wnd_pos.x + wnd_size.x) @@ -8616,7 +8319,6 @@ class AuiManager(wx.EvtHandler): self.RepositionPane(pane, wnd_pos, wnd_size) - def RepositionPane(self, pane, wnd_pos, wnd_size): """ Repositions a pane after the main frame has been moved/resized. @@ -8646,7 +8348,6 @@ class AuiManager(wx.EvtHandler): pane.frame.SetPosition(pane.floating_pos) self._from_move = False - def OnGripperClicked(self, pane_window, start, offset): """ Handles the mouse click on the pane gripper. @@ -8698,7 +8399,6 @@ class AuiManager(wx.EvtHandler): if paneInfo.IsToolbar(): self._frame.SetCursor(wx.Cursor(wx.CURSOR_SIZING)) - def OnRender(self, event): """ Draws all of the pane captions, sashes, backgrounds, captions, grippers, pane borders and buttons. @@ -8731,7 +8431,6 @@ class AuiManager(wx.EvtHandler): not part.sizer_item.IsSpacer() and \ not part.sizer_item.IsSizer()) or \ not part.sizer_item.IsShown()): - continue ptype = part.type @@ -8754,7 +8453,6 @@ class AuiManager(wx.EvtHandler): elif ptype == AuiDockUIPart.typePaneButton: self.DrawPaneButton(dc, part, point) - def Repaint(self, dc=None): """ Repaints the entire frame decorations (sashes, borders, buttons and so on). @@ -8784,7 +8482,6 @@ class AuiManager(wx.EvtHandler): # Render all the items self.Render(dc) - def Render(self, dc): """ Fires a render event, which is normally handled by :meth:`OnRender`. This allows the @@ -8802,7 +8499,6 @@ class AuiManager(wx.EvtHandler): e.SetDC(dc) self.ProcessMgrEvent(e) - def OnCaptionDoubleClicked(self, pane_window): """ Handles the mouse double click on the pane caption. @@ -8816,7 +8512,7 @@ class AuiManager(wx.EvtHandler): raise Exception("Pane window not found") if not paneInfo.IsFloatable() or not paneInfo.IsDockable() or \ - self._agwFlags & AUI_MGR_ALLOW_FLOATING == 0: + self._agwFlags & AUI_MGR_ALLOW_FLOATING == 0: return indx = self._panes.index(paneInfo) @@ -8870,7 +8566,6 @@ class AuiManager(wx.EvtHandler): pane_rect = paneInfo.window.GetScreenRect() self.AnimateDocking(win_rect, pane_rect) - def OnPaint(self, event): """ Handles the ``wx.EVT_PAINT`` event for :class:`AuiManager`. @@ -8881,7 +8576,6 @@ class AuiManager(wx.EvtHandler): dc = wx.PaintDC(self._frame) self.Repaint(dc) - def OnEraseBackground(self, event): """ Handles the ``wx.EVT_ERASE_BACKGROUND`` event for :class:`AuiManager`. @@ -8895,7 +8589,6 @@ class AuiManager(wx.EvtHandler): if wx.Platform == "__WXMAC__": event.Skip() - def OnSize(self, event): """ Handles the ``wx.EVT_SIZE`` event for :class:`AuiManager`. @@ -8917,7 +8610,7 @@ class AuiManager(wx.EvtHandler): self.Repaint() if isinstance(self._frame, wx.MDIParentFrame) or isinstance(self._frame, tabmdi.AuiMDIClientWindow) \ - or isinstance(self._frame, tabmdi.AuiMDIParentFrame): + or isinstance(self._frame, tabmdi.AuiMDIParentFrame): # for MDI parent frames, this event must not # be "skipped". In other words, the parent frame # must not be allowed to resize the client window @@ -8930,7 +8623,6 @@ class AuiManager(wx.EvtHandler): # For the snap to screen... self.OnMove(None) - def OnFindManager(self, event): """ Handles the ``EVT_AUI_FIND_MANAGER`` event for :class:`AuiManager`. @@ -8949,8 +8641,7 @@ class AuiManager(wx.EvtHandler): # if no, it must be us if not event.GetManager(): - event.SetManager(self) - + event.SetManager(self) def OnSetCursor(self, event): """ @@ -8979,7 +8670,6 @@ class AuiManager(wx.EvtHandler): event.SetCursor(cursor) - def UpdateButtonOnScreen(self, button_ui_part, event): """ Updates/redraws the UI part containing a pane button. @@ -9015,10 +8705,9 @@ class AuiManager(wx.EvtHandler): if hit_test.pane: self._art.DrawPaneButton(cdc, self._frame, - button_ui_part.button.button_id, - state, - button_ui_part.rect, hit_test.pane) - + button_ui_part.button.button_id, + state, + button_ui_part.rect, hit_test.pane) def OnLeftDown(self, event): """ @@ -9050,7 +8739,7 @@ class AuiManager(wx.EvtHandler): # draw the resize hint rect = wx.Rect(self._frame.ClientToScreen(part.rect.GetPosition()), - part.rect.GetSize()) + part.rect.GetSize()) self._action_rect = wx.Rect(*rect) @@ -9090,7 +8779,6 @@ class AuiManager(wx.EvtHandler): if wx.Platform != "__WXMAC__": event.Skip() - def OnLeftDClick(self, event): """ Handles the ``wx.EVT_LEFT_DCLICK`` event for :class:`AuiManager`. @@ -9120,7 +8808,6 @@ class AuiManager(wx.EvtHandler): event.Skip() - def DoEndResizeAction(self, event): """ Ends a resize action, or for live update, resizes the sash. @@ -9133,7 +8820,6 @@ class AuiManager(wx.EvtHandler): return self.RestrictResize(clientPt, screenPt, createDC=False) - def RestrictResize(self, clientPt, screenPt, createDC): """ Common method between :meth:`DoEndResizeAction` and :meth:`OnLeftUp_Resize`. """ @@ -9214,13 +8900,12 @@ class AuiManager(wx.EvtHandler): # adjust for the surplus while (oldPixsize > 0 and totalPixsize > 10 and \ - oldPixsize*totalProportion/totalPixsize < pane.dock_proportion): - + oldPixsize * totalProportion // totalPixsize < pane.dock_proportion): totalPixsize -= 1 # calculate the new proportion of the pane - newProportion = newPixsize*totalProportion/totalPixsize + newProportion = newPixsize * totalProportion // totalPixsize newProportion = Clip(newProportion, 1, totalProportion) deltaProp = newProportion - pane.dock_proportion @@ -9237,7 +8922,6 @@ class AuiManager(wx.EvtHandler): return True - def OnLeftUp(self, event): """ Handles the ``wx.EVT_LEFT_UP`` event for :class:`AuiManager`. @@ -9246,9 +8930,9 @@ class AuiManager(wx.EvtHandler): """ if self._action == actionResize: -## self._frame.Freeze() + ## self._frame.Freeze() self.OnLeftUp_Resize(event) -## self._frame.Thaw() + ## self._frame.Thaw() elif self._action == actionClickButton: self.OnLeftUp_ClickButton(event) @@ -9273,7 +8957,6 @@ class AuiManager(wx.EvtHandler): self._action = actionNone - def OnMotion(self, event): """ Handles the ``wx.EVT_MOTION`` event for :class:`AuiManager`. @@ -9299,7 +8982,6 @@ class AuiManager(wx.EvtHandler): else: self.OnMotion_Other(event) - def OnLeaveWindow(self, event): """ Handles the ``wx.EVT_LEAVE_WINDOW`` event for :class:`AuiManager`. @@ -9311,7 +8993,6 @@ class AuiManager(wx.EvtHandler): self.RefreshButton(self._hover_button) self._hover_button = None - def OnCaptureLost(self, event): """ Handles the ``wx.EVT_MOUSE_CAPTURE_LOST`` event for :class:`AuiManager`. @@ -9324,7 +9005,6 @@ class AuiManager(wx.EvtHandler): self._action = actionNone self.HideHint() - def OnHintFadeTimer(self, event): """ Handles the ``wx.EVT_TIMER`` event for :class:`AuiManager`. @@ -9339,7 +9019,6 @@ class AuiManager(wx.EvtHandler): self._hint_fadeamt += 4 self._hint_window.SetTransparent(self._hint_fadeamt) - def OnMove(self, event): """ Handles the ``wx.EVT_MOVE`` event for :class:`AuiManager`. @@ -9362,7 +9041,6 @@ class AuiManager(wx.EvtHandler): if pane.IsFloating() and pane.IsShown(): self.SnapPane(pane, pane.floating_pos, pane.floating_size, True) - def OnSysColourChanged(self, event): """ Handles the ``wx.EVT_SYS_COLOUR_CHANGED`` event for :class:`AuiManager`. @@ -9379,7 +9057,6 @@ class AuiManager(wx.EvtHandler): self.Update() self._frame.Refresh() - def OnChildFocus(self, event): """ Handles the ``wx.EVT_CHILD_FOCUS`` event for :class:`AuiManager`. @@ -9406,7 +9083,6 @@ class AuiManager(wx.EvtHandler): event.Skip() - def OnMotion_ClickCaption(self, event): """ Sub-handler for the :meth:`OnMotion` event. @@ -9426,7 +9102,6 @@ class AuiManager(wx.EvtHandler): # we need to check if the mouse is now being dragged if not (abs(clientPt.x - self._action_start.x) > drag_x_threshold or \ abs(clientPt.y - self._action_start.y) > drag_y_threshold): - return # dragged -- we need to change the mouse action to 'drag' @@ -9477,10 +9152,10 @@ class AuiManager(wx.EvtHandler): # caption is bigger than the width of the floating frame itself, so # in that case we need to set the action offset to a sensible value frame_size = self._action_pane.frame.GetSize() - if self._action_offset.x > frame_size.x * 2 / 3: - self._action_offset.x = frame_size.x / 2 - if self._action_offset.y > frame_size.y * 2 / 3: - self._action_offset.y = frame_size.y / 2 + if self._action_offset.x > frame_size.x * 2 // 3: + self._action_offset.x = frame_size.x // 2 + if self._action_offset.y > frame_size.y * 2 // 3: + self._action_offset.y = frame_size.y // 2 self.OnMotion_DragFloatingPane(event) if wx.Platform != "__WXGTK__": @@ -9492,7 +9167,6 @@ class AuiManager(wx.EvtHandler): self._action = actionDragMovablePane self._action_window = self._action_pane.window - def OnMotion_Resize(self, event): """ Sub-handler for the :meth:`OnMotion` event. @@ -9549,7 +9223,6 @@ class AuiManager(wx.EvtHandler): DrawResizeHint(dc, hintrect) self._action_rect = wx.Rect(*hintrect) - def OnLeftUp_Resize(self, event): """ Sub-handler for the :meth:`OnLeftUp` event. @@ -9575,7 +9248,6 @@ class AuiManager(wx.EvtHandler): return self.RestrictResize(clientPt, screenPt, createDC=True) - def OnLeftUp_ClickButton(self, event): """ Sub-handler for the :meth:`OnLeftUp` event. @@ -9590,7 +9262,6 @@ class AuiManager(wx.EvtHandler): # make sure we're still over the item that was originally clicked if self._action_part == self.HitTest(*event.GetPosition()): - # fire button-click event e = AuiManagerEvent(wxEVT_AUI_PANE_BUTTON) e.SetManager(self) @@ -9598,7 +9269,6 @@ class AuiManager(wx.EvtHandler): e.SetButton(self._action_part.button.button_id) self.ProcessMgrEvent(e) - def CheckPaneMove(self, pane): """ Checks if a pane has moved by a visible amount. @@ -9620,13 +9290,12 @@ class AuiManager(wx.EvtHandler): # skip if moving too fast to avoid massive redraws and # jumping hint windows if abs(win_rect.x - self._last_rect.x) > 10 or \ - abs(win_rect.y - self._last_rect.y) > 10: + abs(win_rect.y - self._last_rect.y) > 10: self._last_rect = wx.Rect(*win_rect) return False return True - def OnMotion_DragFloatingPane(self, eventOrPt): """ Sub-handler for the :meth:`OnMotion` event. @@ -9654,8 +9323,6 @@ class AuiManager(wx.EvtHandler): if pane.IsFloating(): diff = pane.floating_pos - (screenPt - self._action_offset) pane.floating_pos = screenPt - self._action_offset - else: - diff = wx.Point() framePos = pane.floating_pos @@ -9663,7 +9330,8 @@ class AuiManager(wx.EvtHandler): if pane.frame: if diff.x != 0 or diff.y != 0: - if wx.Platform == "__WXMSW__" and (self._agwFlags & AUI_MGR_TRANSPARENT_DRAG) == 0: # and not self.CheckPaneMove(pane): + if wx.Platform == "__WXMSW__" and ( + self._agwFlags & AUI_MGR_TRANSPARENT_DRAG) == 0: # and not self.CheckPaneMove(pane): # return # HACK: Terrible hack on wxMSW (!) pane.frame.SetTransparent(254) @@ -9712,7 +9380,6 @@ class AuiManager(wx.EvtHandler): wx.CallAfter(self.DrawHintRect, pane.window, clientPt, action_offset) - def OnMotion_DragMovablePane(self, eventOrPt): """ Sub-handler for the :meth:`OnMotion` event. @@ -9736,7 +9403,6 @@ class AuiManager(wx.EvtHandler): # Reduces flicker. self._frame.Update() - def OnLeftUp_DragFloatingPane(self, eventOrPt): """ Sub-handler for the :meth:`OnLeftUp` event. @@ -9811,7 +9477,6 @@ class AuiManager(wx.EvtHandler): self.HideHint() ShowDockingGuides(self._guides, False) - def OnLeftUp_DragMovablePane(self, event): """ Sub-handler for the :meth:`OnLeftUp` event. @@ -9833,7 +9498,7 @@ class AuiManager(wx.EvtHandler): pt = event.GetPosition() # do the drop calculation indx = self._panes.index(paneInfo) - ret, paneInfo = self.DoDrop(self._docks, self._panes, paneInfo, pt, wx.Point(0,0)) + ret, paneInfo = self.DoDrop(self._docks, self._panes, paneInfo, pt, wx.Point(0, 0)) if ret: e = self.FireEvent(wxEVT_AUI_PANE_DOCKING, paneInfo, canVeto=True) @@ -9865,7 +9530,6 @@ class AuiManager(wx.EvtHandler): self._frame.ReleaseMouse() self._action_window = None - def OnMotion_DragToolbarPane(self, eventOrPt): """ Sub-handler for the :meth:`OnMotion` event. @@ -9902,7 +9566,8 @@ class AuiManager(wx.EvtHandler): # move the pane window if pane.frame: - if wx.Platform == "__WXMSW__" and (self._agwFlags & AUI_MGR_TRANSPARENT_DRAG) == 0: # and not self.CheckPaneMove(pane): + if wx.Platform == "__WXMSW__" and ( + self._agwFlags & AUI_MGR_TRANSPARENT_DRAG) == 0: # and not self.CheckPaneMove(pane): # return # HACK: Terrible hack on wxMSW (!) pane.frame.SetTransparent(254) @@ -9925,7 +9590,6 @@ class AuiManager(wx.EvtHandler): self._action = actionNone self.OnLeftUp_DragToolbarPane(eventOrPt) - def OnMotion_Other(self, event): """ Sub-handler for the :meth:`OnMotion` event. @@ -9936,7 +9600,7 @@ class AuiManager(wx.EvtHandler): part = self.HitTest(*event.GetPosition()) if part and part.type == AuiDockUIPart.typePaneButton \ - and self.IsPaneButtonVisible(part): + and self.IsPaneButtonVisible(part): if part != self._hover_button: if self._hover_button: @@ -9954,7 +9618,6 @@ class AuiManager(wx.EvtHandler): self._hover_button = None - def OnLeftUp_DragToolbarPane(self, eventOrPt): """ Sub-handler for the :meth:`OnLeftUp` event. @@ -9994,7 +9657,6 @@ class AuiManager(wx.EvtHandler): pane.state &= ~AuiPaneInfo.actionPane self.Update() - def OnPaneButton(self, event): """ Handles the ``EVT_AUI_PANE_BUTTON`` event for :class:`AuiManager`. @@ -10055,7 +9717,6 @@ class AuiManager(wx.EvtHandler): self.ProcessMgrEvent(e) if not e.GetVeto(): - self.MaximizePane(pane) self.Update() @@ -10068,7 +9729,6 @@ class AuiManager(wx.EvtHandler): self.ProcessMgrEvent(e) if not e.GetVeto(): - self.RestorePane(pane) self.Update() @@ -10084,7 +9744,6 @@ class AuiManager(wx.EvtHandler): self.Update() - def MinimizePane(self, paneInfo, mgrUpdate=True): """ Minimizes a pane in a newly and automatically created :class:`~wx.lib.agw.aui.auibar.AuiToolBar`. @@ -10200,7 +9859,7 @@ class AuiManager(wx.EvtHandler): target = paneInfo.name minimize_toolbar.AddSimpleTool(ID_RESTORE_FRAME, paneInfo.caption, restore_bitmap, - _(six.u("Restore %s"))%paneInfo.caption, target=target) + _(six.u("Restore %s")) % paneInfo.caption, target=target) minimize_toolbar.SetAuiManager(self) minimize_toolbar.Realize() toolpanelname = paneInfo.name + "_min" @@ -10212,27 +9871,27 @@ class AuiManager(wx.EvtHandler): if dockDirection == AUI_DOCK_TOP: self.AddPane(minimize_toolbar, AuiPaneInfo(). \ - Name(toolpanelname).Caption(paneInfo.caption). \ - ToolbarPane().Top().BottomDockable(False). \ - LeftDockable(False).RightDockable(False).DestroyOnClose()) + Name(toolpanelname).Caption(paneInfo.caption). \ + ToolbarPane().Top().BottomDockable(False). \ + LeftDockable(False).RightDockable(False).DestroyOnClose()) elif dockDirection == AUI_DOCK_BOTTOM: self.AddPane(minimize_toolbar, AuiPaneInfo(). \ - Name(toolpanelname).Caption(paneInfo.caption). \ - ToolbarPane().Bottom().TopDockable(False). \ - LeftDockable(False).RightDockable(False).DestroyOnClose()) + Name(toolpanelname).Caption(paneInfo.caption). \ + ToolbarPane().Bottom().TopDockable(False). \ + LeftDockable(False).RightDockable(False).DestroyOnClose()) elif dockDirection == AUI_DOCK_LEFT: self.AddPane(minimize_toolbar, AuiPaneInfo(). \ - Name(toolpanelname).Caption(paneInfo.caption). \ - ToolbarPane().Left().TopDockable(False). \ - BottomDockable(False).RightDockable(False).DestroyOnClose()) + Name(toolpanelname).Caption(paneInfo.caption). \ + ToolbarPane().Left().TopDockable(False). \ + BottomDockable(False).RightDockable(False).DestroyOnClose()) elif dockDirection in [AUI_DOCK_RIGHT, AUI_DOCK_CENTER]: self.AddPane(minimize_toolbar, AuiPaneInfo(). \ - Name(toolpanelname).Caption(paneInfo.caption). \ - ToolbarPane().Right().TopDockable(False). \ - LeftDockable(False).BottomDockable(False).DestroyOnClose()) + Name(toolpanelname).Caption(paneInfo.caption). \ + ToolbarPane().Right().TopDockable(False). \ + LeftDockable(False).BottomDockable(False).DestroyOnClose()) arr = FindDocks(self._docks, paneInfo.dock_direction, paneInfo.dock_layer, paneInfo.dock_row) @@ -10257,7 +9916,6 @@ class AuiManager(wx.EvtHandler): if self._agwFlags & AUI_MGR_ANIMATE_FRAMES: self.AnimateDocking(win_rect, minimize_toolbar.GetScreenRect()) - def OnRestoreMinimizedPane(self, event): """ Handles the ``EVT_AUI_PANE_MIN_RESTORE`` event for :class:`AuiManager`. @@ -10267,7 +9925,6 @@ class AuiManager(wx.EvtHandler): self.RestoreMinimizedPane(event.pane) - def OnPaneDocked(self, event): """ Handles the ``EVT_AUI_PANE_DOCKED`` event for :class:`AuiManager`. @@ -10278,7 +9935,6 @@ class AuiManager(wx.EvtHandler): event.Skip() self.RemoveAutoNBCaption(event.GetPane()) - def CreateNotebookBase(self, panes, paneInfo): """ Creates an auto-notebook base from a pane, and then add that pane as a page. @@ -10301,7 +9957,6 @@ class AuiManager(wx.EvtHandler): # add original pane as tab ... paneInfo.NotebookPage(nbid) - def RemoveAutoNBCaption(self, pane): """ Removes the caption on newly created automatic notebooks. @@ -10325,7 +9980,6 @@ class AuiManager(wx.EvtHandler): wx.CallAfter(RemoveCaption) return True - def RestoreMinimizedPane(self, paneInfo): """ Restores a previously minimized pane. @@ -10357,7 +10011,6 @@ class AuiManager(wx.EvtHandler): if not pane.IsMinimized(): return - if pane.HasFlag(pane.wasMaximized): self.SavePreviousDockSizes(pane) @@ -10380,7 +10033,6 @@ class AuiManager(wx.EvtHandler): self.Update() - def AnimateDocking(self, win_rect, pane_rect): """ Animates the minimization/docking of a pane a la Eclipse, using a :class:`ScreenDC` @@ -10405,10 +10057,10 @@ class AuiManager(wx.EvtHandler): step = self.GetAnimationStep() - wstep = int(abs(win_rect.width - pane_rect.width)/step) - hstep = int(abs(win_rect.height - pane_rect.height)/step) - xstep = int(win_rect.x - pane_rect.x)/step - ystep = int(win_rect.y - pane_rect.y)/step + wstep = int(abs(win_rect.width - pane_rect.width) // step) + hstep = int(abs(win_rect.height - pane_rect.height) // step) + xstep = int(win_rect.x - pane_rect.x) // step + ystep = int(win_rect.y - pane_rect.y) // step dc = wx.ScreenDC() dc.SetLogicalFunction(wx.INVERT) @@ -10416,15 +10068,14 @@ class AuiManager(wx.EvtHandler): dc.SetPen(wx.LIGHT_GREY_PEN) for i in range(int(step)): - width, height = win_rect.width - i*wstep, win_rect.height - i*hstep - x, y = xstart - i*xstep, ystart - i*ystep + width, height = win_rect.width - i * wstep, win_rect.height - i * hstep + x, y = xstart - i * xstep, ystart - i * ystep new_rect = wx.Rect(x, y, width, height) dc.DrawRoundedRectangle(new_rect, 3) wx.SafeYield() wx.MilliSleep(10) dc.DrawRoundedRectangle(new_rect, 3) - def SmoothDock(self, paneInfo): """ This method implements a smooth docking effect for floating panes, similar to @@ -10448,21 +10099,20 @@ class AuiManager(wx.EvtHandler): xstart, ystart = win_rect.x, win_rect.y xend, yend = hint_rect.x, hint_rect.y - step = self.GetAnimationStep()/3 + step = self.GetAnimationStep() // 3 - wstep = int((win_rect.width - hint_rect.width)/step) - hstep = int((win_rect.height - hint_rect.height)/step) - xstep = int((win_rect.x - hint_rect.x))/step - ystep = int((win_rect.y - hint_rect.y))/step + wstep = int((win_rect.width - hint_rect.width) // step) + hstep = int((win_rect.height - hint_rect.height) // step) + xstep = int((win_rect.x - hint_rect.x)) // step + ystep = int((win_rect.y - hint_rect.y)) // step for i in range(int(step)): - width, height = win_rect.width - i*wstep, win_rect.height - i*hstep - x, y = xstart - i*xstep, ystart - i*ystep + width, height = win_rect.width - i * wstep, win_rect.height - i * hstep + x, y = xstart - i * xstep, ystart - i * ystep new_rect = wx.Rect(x, y, width, height) paneInfo.frame.SetRect(new_rect) wx.MilliSleep(10) - def SetSnapLimits(self, x, y): """ Modifies the snap limits used when snapping the `managed_window` to the screen @@ -10480,7 +10130,6 @@ class AuiManager(wx.EvtHandler): self._snap_limits = (x, y) self.Snap() - def Snap(self): """ Snaps the main frame to specified position on the screen. @@ -10500,7 +10149,6 @@ class AuiManager(wx.EvtHandler): if abs(snap_pos.x - wnd_pos.x) < snapX and abs(snap_pos.y - wnd_pos.y) < snapY: managed_window.SetPosition(snap_pos) - def SnapToScreen(self, snap=True, monitor=0, hAlign=wx.RIGHT, vAlign=wx.TOP): """ Snaps the main frame to specified position on the screen. @@ -10517,12 +10165,11 @@ class AuiManager(wx.EvtHandler): displayCount = wx.Display.GetCount() if monitor > displayCount: - raise Exception("Invalid monitor selected: you only have %d monitors"%displayCount) + raise Exception("Invalid monitor selected: you only have %d monitors" % displayCount) self._is_docked = (True, hAlign, vAlign, monitor) self.GetManagedWindow().SetPosition(self.GetSnapPosition()) - def GetSnapPosition(self): """ Returns the main frame snapping position. """ @@ -10536,26 +10183,24 @@ class AuiManager(wx.EvtHandler): if hAlign == wx.LEFT: pos.x = area.x elif hAlign == wx.CENTER: - pos.x = area.x + (area.width - size.x)/2 + pos.x = area.x + (area.width - size.x) // 2 else: pos.x = area.x + area.width - size.x if vAlign == wx.TOP: pos.y = area.y elif vAlign == wx.CENTER: - pos.y = area.y + (area.height - size.y)/2 + pos.y = area.y + (area.height - size.y) // 2 else: pos.y = area.y + area.height - size.y return pos - def GetAnimationStep(self): """ Returns the animation step speed (a float) to use in :meth:`AnimateDocking`. """ return self._animation_step - def SetAnimationStep(self, step): """ Sets the animation step speed (a float) to use in :meth:`AnimateDocking`. @@ -10565,7 +10210,6 @@ class AuiManager(wx.EvtHandler): self._animation_step = float(step) - def RequestUserAttention(self, pane_window): """ Requests the user attention by intermittently highlighting the pane caption. @@ -10593,7 +10237,6 @@ class AuiManager(wx.EvtHandler): self._frame.RefreshRect(part.rect, True) break - def StartPreviewTimer(self, toolbar): """ Starts a timer for sliding in and out a minimized pane. @@ -10613,7 +10256,6 @@ class AuiManager(wx.EvtHandler): self._preview_timer.Start(1000, wx.TIMER_ONE_SHOT) - def StopPreviewTimer(self): """ Stops a timer for sliding in and out a minimized pane. """ @@ -10623,7 +10265,6 @@ class AuiManager(wx.EvtHandler): self.SlideOut() self._sliding_pane = None - def SlideIn(self, event): """ Handles the ``wx.EVT_TIMER`` event for :class:`AuiManager`. @@ -10636,7 +10277,7 @@ class AuiManager(wx.EvtHandler): window = self._sliding_pane.window self._sliding_frame = wx.MiniFrame(None, -1, title=_("Pane Preview"), style=wx.FRAME_TOOL_WINDOW | wx.STAY_ON_TOP | - wx.FRAME_NO_TASKBAR | wx.CAPTION) + wx.FRAME_NO_TASKBAR | wx.CAPTION) window.Reparent(self._sliding_frame) self._sliding_frame.SetSize((0, 0)) window.Show() @@ -10646,7 +10287,7 @@ class AuiManager(wx.EvtHandler): startX, startY, stopX, stopY = GetSlidingPoints(self._sliding_rect, size, self._sliding_direction) - step = stopX/10 + step = stopX // 10 window_size = 0 for i in range(0, stopX, step): @@ -10660,7 +10301,6 @@ class AuiManager(wx.EvtHandler): self._sliding_frame.Refresh() self._sliding_frame.Update() - def SlideOut(self): """ Slides out a preview of a minimized pane. @@ -10676,7 +10316,7 @@ class AuiManager(wx.EvtHandler): startX, startY, stopX, stopY = GetSlidingPoints(self._sliding_rect, size, self._sliding_direction) - step = stopX/10 + step = stopX // 10 window_size = 0 for i in range(stopX, 0, -step): @@ -10684,7 +10324,7 @@ class AuiManager(wx.EvtHandler): self._sliding_frame.SetSize(startX, startY, window_size, stopY) self._sliding_frame.Refresh() self._sliding_frame.Update() - self._frame.RefreshRect(wx.Rect(startX+window_size, startY, step, stopY)) + self._frame.RefreshRect(wx.Rect(startX + window_size, startY, step, stopY)) self._frame.Update() wx.MilliSleep(10) @@ -10712,7 +10352,6 @@ class AuiManager_DCP(AuiManager): AuiManager.__init__(self, *args, **keys) self.hasDummyPane = False - def _createDummyPane(self): """ Creates a Dummy Center Pane (**DCP**). """ @@ -10724,7 +10363,6 @@ class AuiManager_DCP(AuiManager): info = AuiPaneInfo().CenterPane().NotebookDockable(True).Name('dummyCenterPane').DestroyOnClose(True) self.AddPane(dummy, info) - def _destroyDummyPane(self): """ Destroys the Dummy Center Pane (**DCP**). """ @@ -10734,7 +10372,6 @@ class AuiManager_DCP(AuiManager): self.hasDummyPane = False self.ClosePane(self.GetPane('dummyCenterPane')) - def Update(self): """ This method is called after any number of changes are made to any of the @@ -10759,6 +10396,7 @@ class AuiManager_DCP(AuiManager): def do(): self._destroyDummyPane() self.Update() + wx.CallAfter(do) else: # if we get here, there's no center pane, create our dummy @@ -10766,4 +10404,5 @@ class AuiManager_DCP(AuiManager): def do(): self._createDummyPane() self.Update() + wx.CallAfter(do) diff --git a/wx/lib/agw/aui/tabart.py b/wx/lib/agw/aui/tabart.py index 3df56354..d1860e5a 100644 --- a/wx/lib/agw/aui/tabart.py +++ b/wx/lib/agw/aui/tabart.py @@ -301,13 +301,13 @@ class AuiDefaultTabArt(object): tot_width -= self._active_windowlist_bmp.GetWidth() if tab_count > 0: - self._fixed_tab_width = tot_width/tab_count + self._fixed_tab_width = tot_width//tab_count if self._fixed_tab_width < 100: self._fixed_tab_width = 100 - if self._fixed_tab_width > tot_width/2: - self._fixed_tab_width = tot_width/2 + if self._fixed_tab_width > tot_width//2: + self._fixed_tab_width = tot_width//2 if self._fixed_tab_width > 220: self._fixed_tab_width = 220 @@ -474,7 +474,7 @@ class AuiDefaultTabArt(object): dc.DrawPoint(r.x+r.width-2, r.y+1) # set rectangle down a bit for gradient drawing - r.SetHeight(r.GetHeight()/2) + r.SetHeight(r.GetHeight()//2) r.x += 2 r.width -= 2 r.y += r.height @@ -497,7 +497,7 @@ class AuiDefaultTabArt(object): r.x += 3 r.y += 1 r.width -= 4 - r.height /= 2 + r.height //= 2 r.height -= 1 # -- draw top gradient fill for glossy look @@ -555,7 +555,7 @@ class AuiDefaultTabArt(object): # draw bitmap dc.DrawBitmap(pagebitmap, bitmap_offset, - drawn_tab_yoff + (drawn_tab_height/2) - (pagebitmap.GetHeight()/2), + drawn_tab_yoff + (drawn_tab_height//2) - (pagebitmap.GetHeight()//2), True) text_offset = bitmap_offset + pagebitmap.GetWidth() @@ -568,7 +568,7 @@ class AuiDefaultTabArt(object): draw_text = ChopText(dc, caption, tab_width - (text_offset-tab_x) - close_button_width) - ypos = drawn_tab_yoff + (drawn_tab_height)/2 - (texty/2) - 1 + ypos = drawn_tab_yoff + (drawn_tab_height)//2 - (texty//2) - 1 offset_focus = text_offset if control: @@ -609,11 +609,11 @@ class AuiDefaultTabArt(object): shift = (agwFlags & AUI_NB_BOTTOM and [1] or [0])[0] if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT: - rect = wx.Rect(tab_x + 4, tab_y + (tab_height - bmp.GetHeight())/2 - shift, + rect = wx.Rect(tab_x + 4, tab_y + (tab_height - bmp.GetHeight())//2 - shift, close_button_width, tab_height) else: rect = wx.Rect(tab_x + tab_width - close_button_width - 1, - tab_y + (tab_height - bmp.GetHeight())/2 - shift, + tab_y + (tab_height - bmp.GetHeight())//2 - shift, close_button_width, tab_height) rect = IndentPressedBitmap(rect, close_button_state) @@ -777,14 +777,14 @@ class AuiDefaultTabArt(object): if orientation == wx.LEFT: rect.SetX(in_rect.x) - rect.SetY(((in_rect.y + in_rect.height)/2) - (bmp.GetHeight()/2)) + rect.SetY(((in_rect.y + in_rect.height)//2) - (bmp.GetHeight()//2)) rect.SetWidth(bmp.GetWidth()) rect.SetHeight(bmp.GetHeight()) else: rect = wx.Rect(in_rect.x + in_rect.width - bmp.GetWidth(), - ((in_rect.y + in_rect.height)/2) - (bmp.GetHeight()/2), + ((in_rect.y + in_rect.height)//2) - (bmp.GetHeight()//2), bmp.GetWidth(), bmp.GetHeight()) rect = IndentPressedBitmap(rect, button_state) @@ -819,11 +819,11 @@ class AuiDefaultTabArt(object): if page.active and wx.Window.FindFocus() == wnd: - focusRectText = wx.Rect(text_offset, (drawn_tab_yoff + (drawn_tab_height)/2 - (texty/2)), + focusRectText = wx.Rect(text_offset, (drawn_tab_yoff + (drawn_tab_height)//2 - (texty//2)), textx, texty) if page.bitmap.IsOk(): - focusRectBitmap = wx.Rect(bitmap_offset, drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetHeight()/2), + focusRectBitmap = wx.Rect(bitmap_offset, drawn_tab_yoff + (drawn_tab_height//2) - (page.bitmap.GetHeight()//2), page.bitmap.GetWidth(), page.bitmap.GetHeight()) if page.bitmap.IsOk() and draw_text == "": @@ -1110,13 +1110,13 @@ class AuiSimpleTabArt(object): tot_width -= self._active_windowlist_bmp.GetWidth() if tab_count > 0: - self._fixed_tab_width = tot_width/tab_count + self._fixed_tab_width = tot_width//tab_count if self._fixed_tab_width < 100: self._fixed_tab_width = 100 - if self._fixed_tab_width > tot_width/2: - self._fixed_tab_width = tot_width/2 + if self._fixed_tab_width > tot_width//2: + self._fixed_tab_width = tot_width//2 if self._fixed_tab_width > 220: self._fixed_tab_width = 220 @@ -1238,23 +1238,23 @@ class AuiSimpleTabArt(object): close_button_width = self._active_close_bmp.GetWidth() if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT: if control: - text_offset = tab_x + (tab_height/2) + close_button_width - (textx/2) - 2 + text_offset = tab_x + (tab_height//2) + close_button_width - (textx//2) - 2 else: - text_offset = tab_x + (tab_height/2) + ((tab_width+close_button_width)/2) - (textx/2) - 2 + text_offset = tab_x + (tab_height//2) + ((tab_width+close_button_width)//2) - (textx//2) - 2 else: if control: - text_offset = tab_x + (tab_height/2) + close_button_width - (textx/2) + text_offset = tab_x + (tab_height//2) + close_button_width - (textx//2) else: - text_offset = tab_x + (tab_height/2) + ((tab_width-close_button_width)/2) - (textx/2) + text_offset = tab_x + (tab_height//2) + ((tab_width-close_button_width)//2) - (textx//2) else: - text_offset = tab_x + (tab_height/3) + (tab_width/2) - (textx/2) + text_offset = tab_x + (tab_height//3) + (tab_width//2) - (textx//2) if control: if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT: - text_offset = tab_x + (tab_height/3) - (textx/2) + close_button_width + 2 + text_offset = tab_x + (tab_height//3) - (textx//2) + close_button_width + 2 else: - text_offset = tab_x + (tab_height/3) - (textx/2) + text_offset = tab_x + (tab_height//3) - (textx//2) # set minimum text offset if text_offset < tab_x + tab_height: @@ -1267,7 +1267,7 @@ class AuiSimpleTabArt(object): draw_text = ChopText(dc, caption, tab_width - (text_offset-tab_x) - close_button_width) - ypos = (tab_y + tab_height)/2 - (texty/2) + 1 + ypos = (tab_y + tab_height)//2 - (texty//2) + 1 if control: if control.GetPosition() != wx.Point(text_offset+1, ypos): @@ -1290,7 +1290,7 @@ class AuiSimpleTabArt(object): # draw focus rectangle if page.active and wx.Window.FindFocus() == wnd and (agwFlags & AUI_NB_NO_TAB_FOCUS) == 0: - focusRect = wx.Rect(text_offset, ((tab_y + tab_height)/2 - (texty/2) + 1), + focusRect = wx.Rect(text_offset, ((tab_y + tab_height)//2 - (texty//2) + 1), selected_textx, selected_texty) focusRect.Inflate(2, 2) @@ -1310,11 +1310,11 @@ class AuiSimpleTabArt(object): if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT: rect = wx.Rect(tab_x + tab_height - 2, - tab_y + (tab_height/2) - (bmp.GetHeight()/2) + 1, + tab_y + (tab_height//2) - (bmp.GetHeight()//2) + 1, close_button_width, tab_height - 1) else: rect = wx.Rect(tab_x + tab_width - close_button_width - 1, - tab_y + (tab_height/2) - (bmp.GetHeight()/2) + 1, + tab_y + (tab_height//2) - (bmp.GetHeight()//2) + 1, close_button_width, tab_height - 1) self.DrawButtons(dc, rect, bmp, wx.WHITE, close_button_state) @@ -1389,7 +1389,7 @@ class AuiSimpleTabArt(object): controlW, controlH = control.GetSize() tab_width += controlW + 4 - x_extent = tab_width - (tab_height/2) - 1 + x_extent = tab_width - (tab_height//2) - 1 return (tab_width, tab_height), x_extent @@ -1445,14 +1445,14 @@ class AuiSimpleTabArt(object): if orientation == wx.LEFT: rect.SetX(in_rect.x) - rect.SetY(((in_rect.y + in_rect.height)/2) - (bmp.GetHeight()/2)) + rect.SetY(((in_rect.y + in_rect.height)//2) - (bmp.GetHeight()//2)) rect.SetWidth(bmp.GetWidth()) rect.SetHeight(bmp.GetHeight()) else: rect = wx.Rect(in_rect.x + in_rect.width - bmp.GetWidth(), - ((in_rect.y + in_rect.height)/2) - (bmp.GetHeight()/2), + ((in_rect.y + in_rect.height)//2) - (bmp.GetHeight()//2), bmp.GetWidth(), bmp.GetHeight()) self.DrawButtons(dc, rect, bmp, wx.WHITE, button_state) @@ -1753,7 +1753,7 @@ class VC71TabArt(AuiDefaultTabArt): # draw bitmap dc.DrawBitmap(pagebitmap, bitmap_offset, - drawn_tab_yoff + (drawn_tab_height/2) - (pagebitmap.GetHeight()/2) + shift, + drawn_tab_yoff + (drawn_tab_height//2) - (pagebitmap.GetHeight()//2) + shift, True) text_offset = bitmap_offset + pagebitmap.GetWidth() @@ -1778,7 +1778,7 @@ class VC71TabArt(AuiDefaultTabArt): draw_text = ChopText(dc, caption, tab_width - (text_offset-tab_x) - close_button_width) - ypos = drawn_tab_yoff + (drawn_tab_height)/2 - (texty/2) - 1 + shift + ypos = drawn_tab_yoff + (drawn_tab_height)//2 - (texty//2) - 1 + shift offset_focus = text_offset @@ -1821,11 +1821,11 @@ class VC71TabArt(AuiDefaultTabArt): if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT: rect = wx.Rect(tab_x + 4, - drawn_tab_yoff + (drawn_tab_height / 2) - (bmp.GetHeight() / 2) + shift, + drawn_tab_yoff + (drawn_tab_height // 2) - (bmp.GetHeight() // 2) + shift, close_button_width, tab_height) else: rect = wx.Rect(tab_x + tab_width - close_button_width - 3, - drawn_tab_yoff + (drawn_tab_height / 2) - (bmp.GetHeight() / 2) + shift, + drawn_tab_yoff + (drawn_tab_height // 2) - (bmp.GetHeight() // 2) + shift, close_button_width, tab_height) # Indent the button if it is pressed down: @@ -1988,7 +1988,7 @@ class FF2TabArt(AuiDefaultTabArt): # draw bitmap dc.DrawBitmap(pagebitmap, bitmap_offset, - drawn_tab_yoff + (drawn_tab_height/2) - (pagebitmap.GetHeight()/2) + shift, + drawn_tab_yoff + (drawn_tab_height//2) - (pagebitmap.GetHeight()//2) + shift, True) text_offset = bitmap_offset + pagebitmap.GetWidth() @@ -2016,7 +2016,7 @@ class FF2TabArt(AuiDefaultTabArt): else: draw_text = ChopText(dc, caption, tab_width - (text_offset-tab_x) - close_button_width) - ypos = drawn_tab_yoff + drawn_tab_height/2 - texty/2 - 1 + shift + ypos = drawn_tab_yoff + drawn_tab_height//2 - texty//2 - 1 + shift offset_focus = text_offset @@ -2058,11 +2058,11 @@ class FF2TabArt(AuiDefaultTabArt): if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT: rect = wx.Rect(tab_x + 5, - drawn_tab_yoff + (drawn_tab_height / 2) - (bmp.GetHeight() / 2) + shift, + drawn_tab_yoff + (drawn_tab_height // 2) - (bmp.GetHeight() // 2) + shift, close_button_width, tab_height) else: rect = wx.Rect(tab_x + tab_width - close_button_width - 3, - drawn_tab_yoff + (drawn_tab_height / 2) - (bmp.GetHeight() / 2) + shift, + drawn_tab_yoff + (drawn_tab_height // 2) - (bmp.GetHeight() // 2) + shift, close_button_width, tab_height) # Indent the button if it is pressed down: @@ -2093,14 +2093,14 @@ class FF2TabArt(AuiDefaultTabArt): if focus: if upperTabs: - leftPt = wx.Point(rect.x, rect.y + (rect.height / 10)*8) - rightPt = wx.Point(rect.x + rect.width - 2, rect.y + (rect.height / 10)*8) + leftPt = wx.Point(rect.x, rect.y + (rect.height // 10)*8) + rightPt = wx.Point(rect.x + rect.width - 2, rect.y + (rect.height // 10)*8) else: - leftPt = wx.Point(rect.x, rect.y + (rect.height / 10)*5) - rightPt = wx.Point(rect.x + rect.width - 2, rect.y + (rect.height / 10)*5) + leftPt = wx.Point(rect.x, rect.y + (rect.height // 10)*5) + rightPt = wx.Point(rect.x + rect.width - 2, rect.y + (rect.height // 10)*5) else: - leftPt = wx.Point(rect.x, rect.y + (rect.height / 2)) - rightPt = wx.Point(rect.x + rect.width - 2, rect.y + (rect.height / 2)) + leftPt = wx.Point(rect.x, rect.y + (rect.height // 2)) + rightPt = wx.Point(rect.x + rect.width - 2, rect.y + (rect.height // 2)) # Define the top region top = wx.Rect(rect.GetTopLeft(), rightPt) @@ -2324,7 +2324,7 @@ class VC8TabArt(AuiDefaultTabArt): # draw bitmap dc.DrawBitmap(pagebitmap, bitmap_offset, - drawn_tab_yoff + (drawn_tab_height/2) - (pagebitmap.GetHeight()/2) + shift, + drawn_tab_yoff + (drawn_tab_height//2) - (pagebitmap.GetHeight()//2) + shift, True) text_offset = bitmap_offset + pagebitmap.GetWidth() @@ -2351,7 +2351,7 @@ class VC8TabArt(AuiDefaultTabArt): else: draw_text = ChopText(dc, caption, tab_width - (text_offset-tab_x) - close_button_width) - ypos = drawn_tab_yoff + drawn_tab_height/2 - texty/2 - 1 + shift + ypos = drawn_tab_yoff + drawn_tab_height//2 - texty//2 - 1 + shift offset_focus = text_offset @@ -2398,11 +2398,11 @@ class VC8TabArt(AuiDefaultTabArt): if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT: rect = wx.Rect(tab_x + 20, - drawn_tab_yoff + (drawn_tab_height / 2) - (bmp.GetHeight() / 2) + shift, + drawn_tab_yoff + (drawn_tab_height // 2) - (bmp.GetHeight() // 2) + shift, close_button_width, tab_height) else: rect = wx.Rect(xpos, - drawn_tab_yoff + (drawn_tab_height / 2) - (bmp.GetHeight() / 2) + shift, + drawn_tab_yoff + (drawn_tab_height // 2) - (bmp.GetHeight() // 2) + shift, close_button_width, tab_height) # Indent the button if it is pressed down: @@ -2686,7 +2686,7 @@ class ChromeTabArt(AuiDefaultTabArt): # draw bitmap dc.DrawBitmap(pagebitmap, bitmap_offset, - drawn_tab_yoff + (drawn_tab_height/2) - (pagebitmap.GetHeight()/2), + drawn_tab_yoff + (drawn_tab_height//2) - (pagebitmap.GetHeight()//2), True) text_offset = bitmap_offset + pagebitmap.GetWidth() @@ -2714,7 +2714,7 @@ class ChromeTabArt(AuiDefaultTabArt): else: draw_text = ChopText(dc, caption, tab_width - (text_offset-tab_x) - close_button_width - leftw) - ypos = drawn_tab_yoff + drawn_tab_height/2 - texty/2 - 1 + ypos = drawn_tab_yoff + drawn_tab_height//2 - texty//2 - 1 if control: if control.GetPosition() != wx.Point(text_offset+1, ypos): @@ -2748,11 +2748,11 @@ class ChromeTabArt(AuiDefaultTabArt): if agwFlags & AUI_NB_CLOSE_ON_TAB_LEFT: rect = wx.Rect(tab_x + leftw - 2, - drawn_tab_yoff + (drawn_tab_height / 2) - (bmp.GetHeight() / 2) + 1, + drawn_tab_yoff + (drawn_tab_height // 2) - (bmp.GetHeight() // 2) + 1, close_button_width, tab_height) else: rect = wx.Rect(tab_x + tab_width - close_button_width - rightw + 2, - drawn_tab_yoff + (drawn_tab_height / 2) - (bmp.GetHeight() / 2) + 1, + drawn_tab_yoff + (drawn_tab_height // 2) - (bmp.GetHeight() // 2) + 1, close_button_width, tab_height) if agwFlags & AUI_NB_BOTTOM: From eb0156fed3ed7ca2d2a130061537b15624ebfc45 Mon Sep 17 00:00:00 2001 From: Scott Talbert Date: Tue, 12 Jan 2021 23:52:49 -0500 Subject: [PATCH 30/32] Adjust CubeColourDialog's SpinCtrl width when on GTK3 Fixes #1891. --- wx/lib/agw/cubecolourdialog.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/wx/lib/agw/cubecolourdialog.py b/wx/lib/agw/cubecolourdialog.py index f001d1f4..3bd1f455 100644 --- a/wx/lib/agw/cubecolourdialog.py +++ b/wx/lib/agw/cubecolourdialog.py @@ -2944,16 +2944,18 @@ class CubeColourDialog(wx.Dialog): def SetProperties(self): """ Sets some initial properties for :class:`CubeColourDialog` (sizes, values). """ + # Adjust for GTK3's wider SpinButtons + spinWidth = 120 if 'gtk3' in wx.PlatformInfo else 60 self.okButton.SetDefault() self.oldColourPanel.SetMinSize((-1, 50)) self.newColourPanel.SetMinSize((-1, 50)) - self.redSpin.SetMinSize((60, -1)) - self.greenSpin.SetMinSize((60, -1)) - self.blueSpin.SetMinSize((60, -1)) - self.hueSpin.SetMinSize((60, -1)) - self.saturationSpin.SetMinSize((60, -1)) - self.brightnessSpin.SetMinSize((60, -1)) - self.alphaSpin.SetMinSize((60, -1)) + self.redSpin.SetMinSize((spinWidth, -1)) + self.greenSpin.SetMinSize((spinWidth, -1)) + self.blueSpin.SetMinSize((spinWidth, -1)) + self.hueSpin.SetMinSize((spinWidth, -1)) + self.saturationSpin.SetMinSize((spinWidth, -1)) + self.brightnessSpin.SetMinSize((spinWidth, -1)) + self.alphaSpin.SetMinSize((spinWidth, -1)) self.showAlpha.SetValue(1) self.accessCode.SetInitialSize((80, -1)) self.webSafe.SetInitialSize((80, -1)) From ec12b059d78433df4d1af80a9aefb03bc7ef2cb8 Mon Sep 17 00:00:00 2001 From: Kevin Schlosser Date: Mon, 11 Jan 2021 14:03:42 -0700 Subject: [PATCH 31/32] Fixes transparency in the docking guides for wx.lib.agw.aui wx.Region no longer selects all non transparent pixels when a wxBitmap is passed to the constructor. In order to get the region made properly a color bust also be supplied. As luck would have it the way the docking guide images were made we are able to do this because there is only a single color that we needed to use. --- wx/lib/agw/aui/framemanager.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wx/lib/agw/aui/framemanager.py b/wx/lib/agw/aui/framemanager.py index a3f2e431..44910ba5 100644 --- a/wx/lib/agw/aui/framemanager.py +++ b/wx/lib/agw/aui/framemanager.py @@ -2153,7 +2153,8 @@ class AuiSingleDockingGuide(AuiDockingGuide): useAero = (useWhidbey and [2] or [1])[0] bmp, dummy = GetDockingImage(self._direction, useAero, False) - region = wx.Region(bmp) + region = wx.Region(bmp, wx.Colour(0, 0, 0, 0)) + self.region = region def AeroMove(self, pos): @@ -2340,7 +2341,7 @@ class AuiCenterDockingGuide(AuiDockingGuide): elif useAero: self._aeroBmp = aero_dock_pane.GetBitmap() - region = wx.Region(self._aeroBmp) + region = wx.Region(self._aeroBmp, wx.Colour(0, 0, 0, 0)) self._allAeroBmps = [aero_dock_pane_left.GetBitmap(), aero_dock_pane_top.GetBitmap(), aero_dock_pane_right.GetBitmap(), aero_dock_pane_bottom.GetBitmap(), @@ -2352,7 +2353,7 @@ class AuiCenterDockingGuide(AuiDockingGuide): elif useWhidbey: self._aeroBmp = whidbey_dock_pane.GetBitmap() - region = wx.Region(self._aeroBmp) + region = wx.Region(self._aeroBmp, wx.Colour(0, 0, 0, 0)) self._allAeroBmps = [whidbey_dock_pane_left.GetBitmap(), whidbey_dock_pane_top.GetBitmap(), whidbey_dock_pane_right.GetBitmap(), whidbey_dock_pane_bottom.GetBitmap(), From 13cc5db6886d346cb34107ed19674a55dca07ecd Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 18 Jan 2021 15:38:44 -0800 Subject: [PATCH 32/32] I think this wx.Locale() may be unnecessary now that InitLocal has been rewritten... --- demo/Main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/demo/Main.py b/demo/Main.py index 53daf7cf..4edce53a 100644 --- a/demo/Main.py +++ b/demo/Main.py @@ -2720,7 +2720,6 @@ def main(): except: pass app = MyApp(False) - locale = wx.Locale(wx.LANGUAGE_DEFAULT) app.MainLoop() #---------------------------------------------------------------------------