Re: Even newer wxPython version

Adit Panchal <[email protected]>
Newsgroups gmane.comp.mobile.bitpim.devel
Message-ID <[email protected]>
I think I found where the problem is for the IndexError. If there is no 
widget selected, I just had the function return 0.

While checking this out, I found out that one of the issues stems from 
the fact that there are no default widgets selected when you move from 
tab to tab. This is because the choice boxes are the first widgets 
created in the sizers. I switched the order around, placing the choice 
boxes at the end, and when moving between tabs, it automatically gives 
a focus box around the first text/"editable" box of the sizer. I 
believe this is the same problem you were encountering on Linux in the 
SetFocusOnValue function.

I tested all combinations with and without entries and I believe I have 
sorted out the errors. The diff is attached.

Adit



On Mar 7, 2005, at 02:42, Roger Binns wrote:

>> Additionally, I found out that in the phonebook entry editor, by 
>> default, nothing is selected when you add a new contact. If you press 
>> any of the toolbars (with the exception of add) you get an exception 
>> of an IndexError. I put try and except blocks for these and it takes 
>> care of the problem.
>
> I'll take a closer look at this.  try/except is just sweeping the issue
> under the carpet.
phonebookentryeditor.diff (application/octet-stream, 3.9 KB)
Index: phonebookentryeditor.py
===================================================================
RCS file: /cvsroot/bitpim/bitpim/phonebookentryeditor.py,v
retrieving revision 1.33
diff -u -r1.33 phonebookentryeditor.py
--- phonebookentryeditor.py     3 Mar 2005 08:35:53 -0000       1.33
+++ phonebookentryeditor.py     8 Mar 2005 07:12:21 -0000
@@ -503,18 +503,18 @@
         wx.Panel.__init__(self, parent, -1)
 
         hs=wx.StaticBoxSizer(wx.StaticBox(self, -1, "Number details"), wx.HORIZONTAL)
-        hs.Add(wx.StaticText(self, -1, "Type"), 0, wx.ALIGN_CENTRE|wx.ALL, 5)
 
-        self.type=wx.ComboBox(self, -1, "None", choices=[desc for desc,name in self.choices], style=wx.CB_READONLY)
-        hs.Add(self.type, 0, wx.EXPAND|wx.ALL, 5)
+        hs.Add(wx.StaticText(self, -1, "Number"), 0, wx.ALIGN_CENTRE|wx.ALL, 5)
+        self.number=wx.TextCtrl(self, -1, "")
+        hs.Add(self.number, 1, wx.EXPAND|wx.ALL, 5)
 
         hs.Add(wx.StaticText(self, -1, "SpeedDial"), 0, wx.ALIGN_CENTRE|wx.ALL, 5)
         self.speeddial=wx.TextCtrl(self, -1, "", size=(32,10))
         hs.Add(self.speeddial, 0, wx.EXPAND|wx.ALL, 5)
 
-        hs.Add(wx.StaticText(self, -1, "Number"), 0, wx.ALIGN_CENTRE|wx.ALL, 5)
-        self.number=wx.TextCtrl(self, -1, "")
-        hs.Add(self.number, 1, wx.EXPAND|wx.ALL, 5)
+        hs.Add(wx.StaticText(self, -1, "Type"), 0, wx.ALIGN_CENTRE|wx.ALL, 5)
+        self.type=wx.ComboBox(self, -1, "None", choices=[desc for desc,name in self.choices], style=wx.CB_READONLY)
+        hs.Add(self.type, 0, wx.EXPAND|wx.ALL, 5)
 
         self.SetSizer(hs)
         hs.Fit(self)
@@ -558,11 +558,11 @@
 
         hs=wx.StaticBoxSizer(wx.StaticBox(self, -1, "Email Address"), wx.HORIZONTAL)
 
-        self.type=wx.ComboBox(self, self.ID_TYPE, "", choices=["", "Home", "Business"], style=wx.CB_READONLY)
-        hs.Add(self.type, 0, wx.EXPAND|wx.ALL, 5)
         self.email=wx.TextCtrl(self, -1, "")
         hs.Add(self.email, 1, wx.EXPAND|wx.ALL, 5)
-
+        self.type=wx.ComboBox(self, self.ID_TYPE, "", choices=["", "Home", "Business"], style=wx.CB_READONLY)
+        hs.Add(self.type, 0, wx.EXPAND|wx.ALL, 5)
+        
         self.SetSizer(hs)
         hs.Fit(self)
 
@@ -595,10 +595,10 @@
 
         hs=wx.StaticBoxSizer(wx.StaticBox(self, -1, "URL"), wx.HORIZONTAL)
 
-        self.type=wx.ComboBox(self, self.ID_TYPE, "", choices=["", "Home", "Business"], style=wx.CB_READONLY)
-        hs.Add(self.type, 0, wx.EXPAND|wx.ALL, 5)
         self.url=wx.TextCtrl(self, -1, "")
         hs.Add(self.url, 1, wx.EXPAND|wx.ALL, 5)
+        self.type=wx.ComboBox(self, self.ID_TYPE, "", choices=["", "Home", "Business"], style=wx.CB_READONLY)
+        hs.Add(self.type, 0, wx.EXPAND|wx.ALL, 5)
 
         self.SetSizer(hs)
         hs.Fit(self)
@@ -639,12 +639,12 @@
         vs=wx.StaticBoxSizer(wx.StaticBox(self, -1, "Address Details"), wx.VERTICAL)
 
         hs=wx.BoxSizer(wx.HORIZONTAL)
-        hs.Add(wx.StaticText(self, -1, "Type"), 0, wx.ALIGN_CENTRE|wx.ALL, 5)
-        self.type=wx.ComboBox(self, self.ID_TYPE, "Home", choices=["Home", "Business"], style=wx.CB_READONLY)
-        hs.Add(self.type, 0, wx.EXPAND|wx.ALL, 5)
         hs.Add(wx.StaticText(self, -1, "Company"), 0, wx.ALIGN_CENTRE|wx.ALL, 5)
         self.company=wx.TextCtrl(self, -1, "")
         hs.Add(self.company, 1, wx.EXPAND|wx.ALL, 5)
+        hs.Add(wx.StaticText(self, -1, "Type"), 0, wx.ALIGN_CENTRE|wx.ALL, 5)
+        self.type=wx.ComboBox(self, self.ID_TYPE, "Home", choices=["Home", "Business"], style=wx.CB_READONLY)
+        hs.Add(self.type, 0, wx.EXPAND|wx.ALL, 5)
 
         gs=wx.FlexGridSizer(6,2,2,5)
 
@@ -816,7 +816,8 @@
         while win is not None and win not in self.widgets:
             win=win.GetParent()
         if win is None:
-            raise IndexError("no idea who is selected")
+            # No widget is selected
+            return 0
         if win not in self.widgets:
             raise IndexError("no idea what that thing is")
         pos=self.widgets.index(win)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.