Upgraded System, New Error Generated

  I've checked the new API docs for DirDialog and FileDialog and ensured
that I'm calling them correctly. But, the function is still not working.

  The latest changes:

    def openFile(self, event):
      wd = wx.DirDialog(None, "Choose a default directory:",
defaultPath=".",
                            style=wx.DD_DEFAULT_STYLE)
      result = wd.ShowModal()
      if result == wx.ID_CANCEL:
            wd.Destroy()
      if result == wx.ID_OK:
        self.appData.dirname = wd.GetPath()
      wd.Destroy()

What is "self" here? Is it a dialog? A window?

I noticed in the traceback that this function lives in a separate file
from its caller. Am I correct in thinking that this function lives in a
separate module from the window class definition, so that it isn't
actually part of the class? Is it part of ANY class? I'm not convinced
this is supposed to work. wxPython wraps the wxWidgets C++ classes in
magical ways. Robin will probably have to give the real story here.

This code will destroy wd twice when you press Cancel, and will always
flow through to the following code. Did you mean this:

    result = wd.ShowModal()
    if result == wx.ID_OK:
        self.addData.dirname = wd.GetPath()
    wd.Destroy()
    if result == wx.ID_CANCEL:
        return

By the way, if "self" is a window, why don't you pass it to the dialog
constructors as the parent, instead of None?

      wildcard = 'Project databases (*.db)|*.db|'
      dlg = wx.FileDialog(None, "Choose a project", self.appData.dirname,
                       wildcard=wildcard,
style=wx.FD_OPEN|wx.FD_CHANGE_DIR)
      result = dlg.ShowModal()
      if result == wx.ID_CANCEL:
        dlg.Destroy()
      if result == wx.ID_OK:
        self.appData.projname=dlg.GetFilename()
        self.appData.dirname=dlg.GetDirectory()
        self.appData.dbFileName=dlg.GetFilename()
        titleStr = self.appData.projname[:-4]
        self.SetTitle(('FuzzyEI-Assessor: - %s') % self.appData.projname)
        dlg.Destroy()

You don't do anything with titleStr here. Is that used later in the
function?

  Now, as soon as the function is called, the console displays this
message:

    (python:9274): Gtk-CRITICAL **: gtk_file_system_unix_get_folder:
    assertion `g_path_is_absolute (filename)' failed

That is probably ignorable. Gtk seems to have an awfully low threshhold
of "critical".

  Pressing the "OK" button does nothing. Pressing the "Cancel" button
closes
the dialog box and brings up the FileDialog. That seems backward to me.

Indeed. Both buttons should have closed the dialog and brought up the
FileDialog, unless the GetPath call failed.

  Regardless, when I then double-click on a file name, rather than
displaying that name in the appropriate widget and loading other data
from
the database tables, the same error message as before is displayed;
that is,

    Traceback (most recent call last):
  File "/data1/eikos/modelPage.py", line 201, in OnOpenMod
    pName = functions.openFile(self, event)
  File "/data1/eikos/functions.py", line 51, in openFile
    self.SetTitle(('FuzzyEI-Assessor: - %s') % self.appData.projname)
AttributeError: 'modModel' object has no attribute 'SetTitle'

This implies that openFile received a "modModel" object as its "self"
parameter. Is a "modModel" supposed to be a window?

···

On Thu, 18 Jan 2007 16:17:12 -0800 (PST), Rich Shepard <rshepard@appl-ecosys.com> wrote:

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

        self.appData.dirname = wd.GetPath()

What is "self" here? Is it a dialog? A window?

Tim,

   'self' is the global reference to an included module. All the variables
that must be visible to several different modules are in config.py.

I noticed in the traceback that this function lives in a separate file
from its caller. Am I correct in thinking that this function lives in a
separate module from the window class definition, so that it isn't
actually part of the class? Is it part of ANY class? I'm not convinced
this is supposed to work. wxPython wraps the wxWidgets C++ classes in
magical ways. Robin will probably have to give the real story here.

   Methods called by buttons and other wxPython widgets are in the
module/class in which the widgets are defined. Functions are in separate
modules and/or classes.

You don't do anything with titleStr here. Is that used later in the
function?

   No, titleStr is used in the calling method.

Indeed. Both buttons should have closed the dialog and brought up the
FileDialog, unless the GetPath call failed.

   Actually, I can print the GetPath() results when the Cancel button is
pressed, but the OK button sits there like a dummy and ignores the action.

   Part of my puzzlement is that this worked just fine with wxPython-2.6.
Since upgrading to -2.8.0.1 last weekend this function fails.

Rich

···

On Fri, 19 Jan 2007, Tim Roberts wrote:

--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc. | Accelerator(TM)
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863