jzaremba / guiqwt

Automatically exported from code.google.com/p/guiqwt
Other
0 stars 1 forks source link

LoadItemsTool fails in interactive mode #33

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Open example tests/loadsavecanvas.py
2. Click on "Load items" button

What is the expected output? What do you see instead?
I expect to get an open file dialog, instead the following error is raised:

Building items and add them to plotting canvas
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\guiqwt\tools.py", line 1239, in activate
    self.activate_command(plot, checked)
  File "C:\Python27\lib\site-packages\guiqwt\tools.py", line 1704, in activate_command
    filename = self.get_filename(plot)
  File "C:\Python27\lib\site-packages\guiqwt\tools.py", line 1667, in get_filename
    self.directory, self.formats)
AttributeError: 'LoadItemsTool' object has no attribute 'directory'

What version of the product are you using? On what operating system?
guiqwt v2.1.5 on Win 7 x64 with Python v2.7.2 (32 bit)

I looked at the source code and found that although LoadItemsTool is derived 
from OpenFileTool it doesn't call the super class' constructor. Hence the 
missing attribute is not created.
Moving the declaration from the constructor the class root fixes the problem:

class OpenFileTool(CommandTool):
    directory = "" # Define it here to fix issue with LoadItemsTool

    def __init__(self, manager, formats='*.*', toolbar_id=DefaultToolbarID):
        CommandTool.__init__(self, manager, _("Open..."),
                             get_std_icon("DialogOpenButton", 16),
                             toolbar_id=toolbar_id)
        self.formats = formats

Original issue reported on code.google.com by j...@lfb.rwth-aachen.de on 22 Aug 2012 at 9:20

GoogleCodeExporter commented 9 years ago
This issue was updated by revision b6156b4d1c59.

Original comment by pierre.raybaut on 7 Nov 2012 at 4:22