IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

wxPython Discussion :

Faire un Navigateur Web


Sujet :

wxPython

  1. #1
    Membre confirmé Avatar de will97
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    126
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Mars 2007
    Messages : 126
    Par défaut Faire un Navigateur Web
    Bonjour,

    j'aimerais faire un naviguateur web.
    j'ai entendu parler d'un module firefox pour python

    bref je ne sais pas par ou commencer


    je ne savais pas si je devais poster ca dans GUI ou ici (deplacer au besoin)

    merci

  2. #2
    Membre Expert Avatar de pacificator
    Profil pro
    Inscrit en
    Août 2006
    Messages
    1 074
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 1 074
    Par défaut
    Bonjour,
    bref je ne sais pas par ou commencer
    tout depend de ce que tu veux...

    Quel est ton but exactement?
    Créer un navigateur de toutes pièces?
    Insérer un moteur de rendu html dans une application (wx, tk, ..)?
    Automatiser un surf sur internet?

  3. #3
    Membre confirmé Avatar de will97
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    126
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Mars 2007
    Messages : 126
    Par défaut
    Citation Envoyé par pacificator Voir le message
    Insérer un moteur de rendu html dans une application (wx, tk, ..)?
    en plein ca je ne savais pas comment le dire en francais

    peut etre en TK ou Wx , c'est quel le meilleur

  4. #4
    Membre éclairé
    Profil pro
    Inscrit en
    Septembre 2007
    Messages
    328
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2007
    Messages : 328
    Par défaut
    Bon, je m'incruste :

    En WxPython, il y a ce que tu cherches. Télécharge et essaye la DEMO de wxPython. Tu y trouveras un exemple concret.

    A +

  5. #5
    Membre confirmé Avatar de will97
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    126
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Mars 2007
    Messages : 126
    Par défaut
    merci, je vais esseyer

    jai esseyer le demo.
    y a t'il un moyen d'afficher une page avec seulement du code HTML sans avoir recours a une address ou un fichier?

  6. #6
    Membre confirmé Avatar de will97
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    126
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Mars 2007
    Messages : 126
    Par défaut
    je n'arrive pas a lancer l'application:
    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
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    import  wx
     
    if wx.Platform == '__WXMSW__':
        import  wx.lib.iewin    as  iewin
     
    #----------------------------------------------------------------------
     
    class TestPanel(wx.Panel):
        def __init__(self, parent, log, frame=None):
            wx.Panel.__init__(
                self, parent, -1,
                style=wx.TAB_TRAVERSAL|wx.CLIP_CHILDREN|wx.NO_FULL_REPAINT_ON_RESIZE
                )
     
            self.log = log
            self.current = "http://wxPython.org/"
            self.frame = frame
     
            if frame:
                self.titleBase = frame.GetTitle()
     
            sizer = wx.BoxSizer(wx.VERTICAL)
            btnSizer = wx.BoxSizer(wx.HORIZONTAL)
     
            self.ie = iewin.IEHtmlWindow(self, -1, style = wx.NO_FULL_REPAINT_ON_RESIZE)
     
     
            btn = wx.Button(self, -1, "Open", style=wx.BU_EXACTFIT)
            self.Bind(wx.EVT_BUTTON, self.OnOpenButton, btn)
            btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
     
            btn = wx.Button(self, -1, "Home", style=wx.BU_EXACTFIT)
            self.Bind(wx.EVT_BUTTON, self.OnHomeButton, btn)
            btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
     
            btn = wx.Button(self, -1, "<--", style=wx.BU_EXACTFIT)
            self.Bind(wx.EVT_BUTTON, self.OnPrevPageButton, btn)
            btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
     
            btn = wx.Button(self, -1, "-->", style=wx.BU_EXACTFIT)
            self.Bind(wx.EVT_BUTTON, self.OnNextPageButton, btn)
            btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
     
            btn = wx.Button(self, -1, "Stop", style=wx.BU_EXACTFIT)
            self.Bind(wx.EVT_BUTTON, self.OnStopButton, btn)
            btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
     
            btn = wx.Button(self, -1, "Search", style=wx.BU_EXACTFIT)
            self.Bind(wx.EVT_BUTTON, self.OnSearchPageButton, btn)
            btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
     
            btn = wx.Button(self, -1, "Refresh", style=wx.BU_EXACTFIT)
            self.Bind(wx.EVT_BUTTON, self.OnRefreshPageButton, btn)
            btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
     
            txt = wx.StaticText(self, -1, "Location:")
            btnSizer.Add(txt, 0, wx.CENTER|wx.ALL, 2)
     
            self.location = wx.ComboBox(
                                self, -1, "", style=wx.CB_DROPDOWN|wx.PROCESS_ENTER
                                )
     
            self.Bind(wx.EVT_COMBOBOX, self.OnLocationSelect, self.location)
            self.location.Bind(wx.EVT_KEY_UP, self.OnLocationKey)
            self.location.Bind(wx.EVT_CHAR, self.IgnoreReturn)
            btnSizer.Add(self.location, 1, wx.EXPAND|wx.ALL, 2)
     
            sizer.Add(btnSizer, 0, wx.EXPAND)
            sizer.Add(self.ie, 1, wx.EXPAND)
     
            self.ie.LoadUrl(self.current)
            self.location.Append(self.current)
     
            self.SetSizer(sizer)
            # Since this is a wxWindow we have to call Layout ourselves
            self.Bind(wx.EVT_SIZE, self.OnSize)
     
            # Hook up the event handlers for the IE window
            self.Bind(iewin.EVT_BeforeNavigate2, self.OnBeforeNavigate2, self.ie)
            self.Bind(iewin.EVT_NewWindow2, self.OnNewWindow2, self.ie)
            self.Bind(iewin.EVT_DocumentComplete, self.OnDocumentComplete, self.ie)
            ##self.Bind(iewin.EVT_ProgressChange,  self.OnProgressChange, self.ie)
            self.Bind(iewin.EVT_StatusTextChange, self.OnStatusTextChange, self.ie)
            self.Bind(iewin.EVT_TitleChange, self.OnTitleChange, self.ie)
     
     
        def ShutdownDemo(self):
            # put the frame title back
            if self.frame:
                self.frame.SetTitle(self.titleBase)
     
     
        def OnSize(self, evt):
            self.Layout()
     
     
        def OnLocationSelect(self, evt):
            url = self.location.GetStringSelection()
            self.log.write('OnLocationSelect: %s\n' % url)
            self.ie.Navigate(url)
     
        def OnLocationKey(self, evt):
            if evt.GetKeyCode() == wx.WXK_RETURN:
                URL = self.location.GetValue()
                self.location.Append(URL)
                self.ie.Navigate(URL)
            else:
                evt.Skip()
     
     
        def IgnoreReturn(self, evt):
            if evt.GetKeyCode() != wx.WXK_RETURN:
                evt.Skip()
     
        def OnOpenButton(self, event):
            dlg = wx.TextEntryDialog(self, "Open Location",
                                    "Enter a full URL or local path",
                                    self.current, wx.OK|wx.CANCEL)
            dlg.CentreOnParent()
     
            if dlg.ShowModal() == wx.ID_OK:
                self.current = dlg.GetValue()
                self.ie.Navigate(self.current)
     
            dlg.Destroy()
     
        def OnHomeButton(self, event):
            self.ie.GoHome()    ## ET Phone Home!
     
        def OnPrevPageButton(self, event):
            self.ie.GoBack()
     
        def OnNextPageButton(self, event):
            self.ie.GoForward()
     
        def OnStopButton(self, evt):
            self.ie.Stop()
     
        def OnSearchPageButton(self, evt):
            self.ie.GoSearch()
     
        def OnRefreshPageButton(self, evt):
            self.ie.Refresh(iewin.REFRESH_COMPLETELY)
     
     
        def logEvt(self, evt):
            pst = ""
            for name in evt.paramList:
                pst += " %s:%s " % (name, repr(getattr(evt, name)))
            self.log.write('%s: %s\n' % (evt.eventName, pst))
     
     
        def OnBeforeNavigate2(self, evt):
            self.logEvt(evt)
     
        def OnNewWindow2(self, evt):
            self.logEvt(evt)
            # Veto the new window.  Cancel is defined as an "out" param
            # for this event.  See iewin.py
            evt.Cancel = True   
     
        def OnProgressChange(self, evt):
            self.logEvt(evt)
     
        def OnDocumentComplete(self, evt):
            self.logEvt(evt)
            self.current = evt.URL
            self.location.SetValue(self.current)
     
        def OnTitleChange(self, evt):
            self.logEvt(evt)
            if self.frame:
                self.frame.SetTitle(self.titleBase + ' -- ' + evt.Text)
     
        def OnStatusTextChange(self, evt):
            self.logEvt(evt)
            if self.frame:
                self.frame.SetStatusText(evt.Text)

  7. #7
    Membre averti
    Profil pro
    Inscrit en
    Mai 2002
    Messages
    16
    Détails du profil
    Informations personnelles :
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations forums :
    Inscription : Mai 2002
    Messages : 16
    Par défaut
    will97> si vous essayez de lancer directement le code que vous avez publié, c'est normal puisque'il ne s'agit que de la définition de la classe wx.Panel::TestPanel.

    Pour pouvoir l'utiliser, vous devez créer une wx.Frame qui contient votre Test Panel. Puis créer une wx.App qui doit créer votre fenêtre (le "main" de votre application.

    En ajoutant ceci à la fin de votre code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
    class myBrw(wx.App) :
      def OnInit(self) :
      fen = wx.Frame(None,-1)
     
          fen.brw = TestPanel(fen,sys.stdout,frame=None)
          fen.Show(True)
          self.SetTopWindow(fen)
          return True
     
     
    #Début du programme
    app = myBrw()
    app.MainLoop()
    votre mini navigateur doit se lancer (le log est redirigé sur la sortie standard).

    Bon courage

    Dric

  8. #8
    Membre confirmé Avatar de will97
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    126
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Mars 2007
    Messages : 126
    Par défaut
    Merci c'est la premiere fois que je fais du wxPython

  9. #9
    Membre averti
    Profil pro
    Inscrit en
    Mai 2002
    Messages
    16
    Détails du profil
    Informations personnelles :
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations forums :
    Inscription : Mai 2002
    Messages : 16
    Par défaut
    Bienvenue

    vous avez réussi à le faire marcher ? Chez moi ça a fonctionné. Si vous avez des questions n'hésitez pas.


    Dric

  10. #10
    Membre confirmé Avatar de will97
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    126
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Mars 2007
    Messages : 126
    Par défaut
    J'ai reussi moi aussi

    mais y a t il un moyen de faire en sorte que le log s'affiche dans la console

Discussions similaires

  1. faire un navigateur web en VB.net
    Par damaskinos dans le forum Windows Forms
    Réponses: 5
    Dernier message: 24/08/2007, 21h12
  2. Réponses: 3
    Dernier message: 23/10/2006, 04h32
  3. Réponses: 3
    Dernier message: 11/05/2004, 18h39

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo