console traceback when clicked on "font"

Bug #394041 reported by DrSlony
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Phatch
Fix Released
High
Stani

Bug Description

Open this action list, doubleclick on "Font: Default", click on the file browser icon for browsing fonts, an empty tooltip pops up which would normally contain a list of fonts, and this appears in the console each time I click on the file browser icon:
Traceback (most recent call last):
  File "/usr/lib64/python2.5/site-packages/phatch/pyWx/lib/popup.py", line 361, in OnBrowse
    defaultFile = self.GetDefaultPath(),
  File "/usr/lib64/python2.5/site-packages/phatch/pyWx/lib/popup.py", line 437, in GetDefaultPath
    return super(FontFileCtrl,self).GetDefaultPath(default_path)
TypeError: GetDefaultPath() takes exactly 1 argument (2 given)

Revision history for this message
DrSlony (drslony) wrote :
Revision history for this message
Nadia Alramli (nadiana) wrote :

Hi,

Thanks for reporting this bug. I was able to reproduce the issue. It was simply because GetDefaultPath is overridden with different number of arguments in subclasses. In python there is no overloading, so if a subclass defines a method with the same name as a method in the parent. That method will override the parent method even if it had different number of arguments. There are two ways to fix this:
1. Explicitly call the base class method _PathCtrl.GetDefaultPath(self, default_path)
2. Change the base class method name to something else and make sure all child methods are updated to use the new name.
I prefer the second solution, but I'll let Stani decide.

Changed in phatch:
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Stani (stani) wrote :

I went for solution 3 which is provide all the GetDefaultPath methods with the same set of arguments. Thanks Nadia for analyzing that saved me time. About the empty dropdown list that is the intended behaviour. The drop down list autocompletes the current text. So if the text is Default and you don't have fonts which start with Default, it is completely normal the dropdown is empty. To check you should empty the font field and than all the available fonts will popup. Please test this, Dr Slony. If you start typing it will filter the list of fonts down to the partial font input.
Thanks for reporting this bug, please test if it is fixed for you from the latest bzr

$ bzr diff
=== modified file 'phatch/pyWx/lib/popup.py'
--- phatch/pyWx/lib/popup.py 2009-06-23 14:43:21 +0000
+++ phatch/pyWx/lib/popup.py 2009-07-01 16:26:56 +0000
@@ -405,10 +405,10 @@
         super(DictionaryFileCtrl,self).__init__(parent,value,size,
             choices = choices, **extra)

- def GetDefaultPath(self):
- value = self.path.GetValue()
- #default_path = os.path.dirname(self.dictionary.get(value,value))
- default_path = self.dictionary.get(value,value)
+ def GetDefaultPath(self,default_path=None):
+ if default_path is None:
+ value = self.path.GetValue()
+ default_path = self.dictionary.get(value,value)
         return super(DictionaryFileCtrl,self).GetDefaultPath(default_path)

 class AutoCompleteDictionaryFileCtrl(DictionaryFileCtrl):
@@ -426,10 +426,10 @@
     _label = _t('Fonts')
     _busy_cursor = True

- def GetDefaultPath(self):
- value = self.path.GetValue()
- #default_path = os.path.dirname(font_dictionary().get(value,value))
- default_path = font_dictionary().get(value,value)
+ def GetDefaultPath(self,default_path=None):
+ if default_path is None:
+ value = self.path.GetValue()
+ default_path = font_dictionary().get(value,value)
         if not os.path.isdir(default_path.strip()):
             for path in FONT_PATHS:
                 if os.path.isdir(path):

$ bzr commit -m "fix GetDefaultPath"
Committing to: /media/16gb/sync/python/phatch/trunk/
modified phatch/pyWx/lib/popup.py
Committed revision 930.

Changed in phatch:
assignee: nobody → stani (stani)
status: Confirmed → Fix Committed
Revision history for this message
DrSlony (drslony) wrote :

It is fixed now, but there is a new problem: I doubleclick on the "Font:" area to open the list of fonts. The moment my mouse cursor moves off the "Font:" area, the list disappears, so I cannot use the mouse to select one of these fonts, only the keyboard up/down keys and once I use the keyboard then I can use the mouse.

I noticed this issue with other things as well - as soon as the mouse leaves the Phatch window the currently opened list or editable text field gets turned off. Gotta remember to move the mouse up/down, not left/right. Annoying.

Stani (stani)
Changed in phatch:
milestone: none → 0.2.1
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.