OpenFileDialog Doesn't appear

The attachment contains two programs written using PyScripter.
The Open File Dialog (OFD) works well in Program 1 but never appears
in Program 2. I believe the OFD code is the same in both programs.
Resulting errors are shown after Program 2.
Any ideas ?
TIA

Bob

wx Users Forum.txt (3.85 KB)

When you start the application you do this:

frame = MyForm().Show()

Then when you create the file dialog you do this:

    openFileDialog = wx.FileDialog(frame, "Open", "", "",

                                  "Text files (*.txt)|*.txt",

                                   wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)

Can you now see why you get this error?:

TypeError: FileDialog(): argument 1 has unexpected type 'bool'

Hint: You probably want to be using self.


<details class='elided'>
<summary title='Show trimmed content'>&#183;&#183;&#183;</summary>

On Wednesday, October 3, 2018 at 2:43:33 PM UTC-7, srfpala wrote:
> The attachment contains two programs written using PyScripter. 
> The Open File Dialog (OFD)  works well in Program 1 but never appears
> in Program 2.  I believe the OFD code is the same in both programs. 
> Resulting errors are shown after Program 2.
> Any ideas ?

--
Robin

Hi,
I believe, the difference might be the scoping regarding "frame"
in the first example, frame remains within the same class (with now
further structuring via functinos etc.) and is accessible for the the
call "wx.FileDialog(frame, ...)"

in the second example, these parts of code belong to separate
functions/method definitions (__init__ and onOpenFile respectively); i
believe making "frame" available within the class like self.frame =
... might solve the immediate problem with displaying a dialog, but
there seem to be other differences as well (it's not clear, whether it
is intended or not).

hth,
  vbr

ยทยทยท

2018-10-02 23:43 GMT-22:00, srfpala <srfpala@gmail.com>:

The attachment contains two programs written using PyScripter.
The Open File Dialog (OFD) works well in Program 1 but never appears
in Program 2. I believe the OFD code is the same in both programs.
Resulting errors are shown after Program 2.
Any ideas ?
TIA
  Bob

--