From e8b4959678e39768dd949e6c77c41f14aa84100a Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 5 Sep 2006 01:05:51 +0000 Subject: [PATCH] Some properties for things with lists of items. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41014 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/src/_control.i | 12 ++++++++++++ wxPython/src/_menu.i | 16 ++++++++++++++++ wxPython/src/_statusbar.i | 13 +++++++++++++ 3 files changed, 41 insertions(+) diff --git a/wxPython/src/_control.i b/wxPython/src/_control.i index 9ecfec7c4f..10b7b43f45 100644 --- a/wxPython/src/_control.i +++ b/wxPython/src/_control.i @@ -277,6 +277,18 @@ is selected.", ""); slightly more natural for controls which support multiple selection.", ""); + %pythoncode { + def GetItems(self): + """Return a list of the strings in the control""" + return [self.GetString(i) for i in xrange(self.GetCount())] + + def SetItems(self, items): + """Clear and set the strings in the control from a list""" + self.Clear() + for i in items: + self.Append(i) + } + %property(Items, GetItems, SetItems); }; diff --git a/wxPython/src/_menu.i b/wxPython/src/_menu.i index a0d58d7b40..d1122ce95a 100644 --- a/wxPython/src/_menu.i +++ b/wxPython/src/_menu.i @@ -321,6 +321,22 @@ public: static bool GetAutoWindowMenu() { return false; } } #endif + + %pythoncode { + def GetMenus(self): + """Return a list of (menu, label) items for the menus in the MenuBar. """ + return [(self.GetMenu(i), self.GetLabelTop(i)) + for i in range(self.GetMenuCount())] + + def SetMenus(self, items): + """Clear and add new menus to the MenuBar from a list of (menu, label) items. """ + for i in range(self.GetMenuCount()-1, -1, -1): + self.Remove(i) + for m, l in items: + self.Append(m, l) + } + %property(Menus, GetMenus, SetMenus); + }; //--------------------------------------------------------------------------- diff --git a/wxPython/src/_statusbar.i b/wxPython/src/_statusbar.i index 6988a190a5..f5ddb06411 100644 --- a/wxPython/src/_statusbar.i +++ b/wxPython/src/_statusbar.i @@ -98,6 +98,19 @@ public: static wxVisualAttributes GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); + + %pythoncode { + def GetFields(self): + """Return a list of field values in the status bar. """ + return [self.GetStatusText(i) for i in range(self.GetFieldsCount())] + + def SetFields(self, items): + """Set the values of the statusbar fields from a list of strings. """ + self.SetFieldsCount(len(items)) + for i in range(len(items)): + self.SetStatusText(items[i], i) + } + %property(Fields, GetFields, SetFields); }; -- 2.47.2