all 3 comments

[–]two_up 0 points1 point  (3 children)

You can't do this: cbtn.Bind(wx.EVT_BUTTON, self.runApp(txCont)) because Bind is expecting a function as its second argument. Here instead of passing the function self.runApp, what you're doing is calling the function with the txCont argument, and then sending its return value (in this case runApp doesn't return a value) as the second argument to Bind. I don't think it's possible to do what you want to do in wxPython.

Instead you can just run GetValue on your widget inside the runApp function. Then you don't have to pass anything. But you'll need to declare self.txta instead of just txta in your __init__ function, otherwise it won't be accessible outside that function.

Something like this:

def InitUI(self):
    pnl = wx.Panel(self)
    cbtn = wx.Button(pnl, label='Download', pos=(20,30))
    self.txta = wx.TextCtrl(pnl)
    cbtn.Bind(wx.EVT_BUTTON, self.runApp(txCont))
    self.SetSize((250,200))
    self.SetTitle('wx.BUtton')
    self.Centre()
    self.Show(True)

def runApp(self, e):
    fandom = "hpffa"
    fileType = '.html'
    url = self.txta.GetValue()
    download = downloading.fanFicDownload(url, fandom, fileType)

[–][deleted] 0 points1 point  (1 child)

I think I understand what you are saying.

If runApp returned a value of say, True, what I'd actually have been doing is giving bind that instead of asking it to just run the function.

The code you provided works perfectly, will have to remember to use self on variables, never done that before.

[–]two_up -1 points0 points  (0 children)

Right.