ChangeMyName
ChangeMyName

Reputation: 7408

wildcard brings error in wxPython FileDialog

I am trying to build an example from book "wxPython in Action" page 270.

Here is the code:

import wx
import os

if __name__ == "__main__":
    app = wx.App()
    wildcard = "Python source(*.py)|*.py|"\"Compiled Python(*.pyc)|*.pyc|"\"All files(*.*)|*.*"

    dlg = wx.FileDialog(None, "Choose input file", os.getcwd(), "", wildcard, wx.OPEN)

    if dlg.ShowModal() == wx.ID_OK:
        print dlg.GetPath()

    dlg.Destroy()

I saved it as .py source file, and run it in IDLE. But it gives me following error:

There's an error in your program: unexpected character after line comtinuation character

May I know why this example doesn't work? Thanks.

Upvotes: 0

Views: 256

Answers (1)

zhutoulala
zhutoulala

Reputation: 4832

try change

wildcard = "Python source(*.py)|*.py|"\"Compiled Python(*.pyc)|*.pyc|"\"All files(*.*)|*.*"

to

wildcard = "Python source(*.py)|*.py|Compiled Python(*.pyc)|*.pyc|All files(*.*)|*.*"

Upvotes: 1

Related Questions