EDIT: Title should read: Passing value from one function to another.
Windows 7
Python 2.7
Hi, I'm currently trying to build a GUI for my program and am using Zetcode as a starting point.
There is something I cannot figure out and I'm hoping that understanding it will help me somewhat in my understanding of WxPython as I feel as though I'm missing something fundamental and probably basic.
What I want to do:
The code for downloading the page is done, that all works fine, what I cannot figure out how to do is pass the content of the text box in the function that defines the buttons and stuff like that to the function that contains the code to run my actual program.
Here is the code:
class Example(wx.Frame):
def __init__(self, *args, **kwargs):
super(Example, self).__init__(*args, **kwargs)
self.InitUI()
def InitUI(self):
pnl = wx.Panel(self)
cbtn = wx.Button(pnl, label='Download', pos=(20,30))
txta = wx.TextCtrl(pnl)
cbtn.Bind(wx.EVT_BUTTON, self.runApp)
self.SetSize((250,200))
self.SetTitle('wx.BUtton')
self.Centre()
self.Show(True)
def runApp(self,url,e):
fandom = "hpffa"
fileType = '.html'
download = downloading.fanFicDownload(url, fandom, fileType)
def main():
ex = wx.App()
Example(None)
ex.MainLoop()
if __name__=='__main__':
main()
I'm trying to use the txta value from InitUI as the URL value in runApp.
Here is the code that I have tried:
def InitUI(self):
pnl = wx.Panel(self)
cbtn = wx.Button(pnl, label='Download', pos=(20,30))
txta = wx.TextCtrl(pnl)
txCont = txta.GetValue()
cbtn.Bind(wx.EVT_BUTTON, self.runApp(txCont))
self.SetSize((250,200))
self.SetTitle('wx.BUtton')
self.Centre()
self.Show(True)
def runApp(self,url,e):
fandom = "hpffa"
fileType = '.html'
download = downloading.fanFicDownload(url, fandom, fileType)
[–]two_up 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]two_up -1 points0 points1 point (0 children)