Bonjour,
je débute en python, et j'ai trouvé un exemple de navigateur graphique :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from wxPython.wx import *
from wxPython.html import *
import httplib
 
class MyApp(wxApp):
	def OnInit(self):
            frame = Myframe(None, -1, "Un navigateur web en Python !!")
            frame.Show(true)
            self.SetTopWindow(frame)
            return true
 
class Myframe(wxFrame):
	def __init__(self, parent, id, title):
		wxFrame.__init__(self,parent,id,title)
		self.SetSize(wxSize(400,400))
		self.Center(wxBOTH)
		StatusBar = wxStatusBar(self, -1)
		StatusBar.SetFieldsCount(2)
		self.SetStatusBar(StatusBar)
		MainMenu = wxMenuBar()
		MenuFichier =wxMenu()
		idNav = wxNewId()
		MenuFichier.Append(idNav, 'Naviguer', 'Page de garde de http://localhost')
		EVT_MENU(self, idNav,self.OnNavigate())
		MenuFichier.Append(wxID_EXIT,self.OnCloseWindow(EVT_MENU))
		MainMenu.Append(MenuFichier, 'Fichier')
		Self.SetMenuBar(MainMenu)
		Self.myhtml_window = MyHtmlWindow(self, -1)
 
        def OnCloseWindow(self, event):
            self.Destroy()
 
        def OnNavigate(self, event):
            self.myhtml_window.GetDoc('/')
 
class MyHtmlWindow(wxHtmlWindow):
	def __init__(self, parent, id):
		wxHtmlWindow.__init__(self, parent, id)
		self.http = httplib.HTTP('localhost')
 
	def GetDoc(self, doc):
		self.http.putrequest('GET', doc)
		self.http.putheader('Accept', '/text/html')
		self.http.purheader('Accept','text/plain')
		self.http.endheaders()
                errcode, errmsg, headers = self.http.getreply()
                if not errcode == 200:
                    self.SetPage("Impossible de charger la page : ",errcode)
                #return
 
                handle = self.http.getfile()
                document = handle.read()
                handle.close()
                print headers
                print document
                self.SetPage(document)
 
        def OnlinkClicked(self, linkinfo):
            self.GetDoc('/' + linkinfo.GetHref())
 
app = MyApp(0)
app.MainLoop()
mais ça ne marche pas. j'obtiens des erreurs :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
Traceback (most recent call last):
  File "F:/[...]/navigGraph.py", line 61, in ?
    app = MyApp(0)
  File "F:\PROGRA~1\PROGRA~1\Python23\Lib\site-packages\wx-2.5.5-msw-ansi\wx\_core.py", line 5691, in __init__
    self._BootstrapApp()
  File "F:\PROGRA~1\PROGRA~1\Python23\Lib\site-packages\wx-2.5.5-msw-ansi\wx\_core.py", line 5343, in _BootstrapApp
    return _core_.PyApp__BootstrapApp(*args, **kwargs)
  File "F:/[...]/navigGraph.py", line 7, in OnInit
    frame = Myframe(None, -1, "Un navigateur web en Python !!")
  File "F:/[...]/navigGraph.py", line 24, in __init__
    EVT_MENU(self, idNav,self.OnNavigate())
TypeError: OnNavigate() takes exactly 2 arguments (1 given)
pour la fonction OnNavigate, je ne sais pas quoi lui passer en paramètre.

Dans la fonctionOnInit, je ne comprends pas ce qui ne va pas.

S'IL VOUS PLAIT A L'AIDE !!! j'y comprends rien !

sinon est-ce que quelqu'un connait un bon tutoriel, précis et en français, pour programmer un navigateur ?

MERCI

Titre modifié par Guigui_