I am trying to achieve the objectives of my project and connect my modules into window application with buttons. I don't know what am I missing so far but for sure something is wrong, because when my program is running then the main frame is crashed, no responding, Shell output works but no possibility to input anything... I guess i should show you all the code because i don't know exactly with part is wrong. I used the boa constructor to save some time to create Frames. The starting application looks like that:
App1:
import wx
import Frame1
modules ={'Frame1': [1, 'Main frame of Application', u'Frame1.py'],
u'botcordxy': [0, u'x, y values', u'botcordxy.py']}
class BoaApp(wx.App):
def OnInit(self):
self.main = Frame1.create(None)
self.main.Show()
self.SetTopWindow(self.main)
return True
def main():
application = BoaApp(0)
application.MainLoop()
if __name__ == '__main__':
main()
I am not sure but i think what is above is correct, tell me if not.
Frame1.py:
import wx
def create(parent):
return Frame1(parent)
[wxID_FRAME1, wxID_FRAME1BUTTON1, wxID_FRAME1PANEL1,
] = [wx.NewId() for _init_ctrls in range(3)]
class Frame1(wx.Frame):
def _init_ctrls(self, prnt):
wx.Frame.__init__(self, id=wxID_FRAME1, name=u'Frame1', parent=prnt,
pos=wx.Point(-1, 291), size=wx.Size(250, 480),
style=wx.DEFAULT_FRAME_STYLE, title=u'ZulithBot')
self.SetClientSize(wx.Size(242, 446))
self.Bind(wx.EVT_BUTTON, self.Firefox, id=wxID_FRAME1BUTTON1)
self.panel1 = wx.Panel(id=wxID_FRAME1PANEL1, name='panel1', parent=self,
pos=wx.Point(0, 0), size=wx.Size(242, 446),
style=wx.TAB_TRAVERSAL)
self.button1 = wx.Button(id=wxID_FRAME1BUTTON1,
label=u'Start Firefox', name='button1', parent=self.panel1,
pos=wx.Point(80, 24), size=wx.Size(88, 23), style=0)
def Firefox(self, event):
import botcordxy
def __init__(self, parent):
self._init_ctrls(parent)
And now, the last:
botcordxy.py
import selenium
from selenium import webdriver
import time
##The name of website has been changed just in care.
driver = webdriver.Firefox()
driver.get('http://example.com//')
def repeat():
while 1 == 1:
botloc = driver.find_element_by_id('botloc').text
botX,botY = map(int,botloc.split(','))
print botX
print botY
print botloc
def checker():
if driver.current_url == 'http://logged.example.com//':
repeat()
else:
time.sleep(5)
checker()
checker()
As for the last part, here began the stairs, a lot of problems, a lot of editing, plenty of time devoted to the activity...
When I run the program and log on in Webdriver browser, the then Shell shows the values that I wanted to get:
32
59
32,59
31
59
31,59
31
58
31,58
over and over is printing botloc, botx and boty so the application is still ruining, but its frozen, no control till i use ctrl + C, Frame1 totally unavailable... Is there a lot of things that are missing? def respond loop can be operated in this a way? Can you please help me to fix that?