Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import sys
- import os
- import re
- import string
- import array
- import wx
- class myPanel(wx.Panel): #(vinz)-Bon ca commence mal, mais les classes j'ai jamais utilise... je vois a peu pret mais le concept est flou... t'as une definition simple? la difference avec une 'def'
- def __init__(self, parent, id=wx.ID_ANY): #(vinz)-Est ce que ca a un rapport avec la class de definir une fonction __init__ ?
- wx.Panel.__init__(self, parent, id) # (vinz)-Ca ouvre un panel, celui qui apparait au lancement?
- self.value = 'User input' # (vinz)-Ca cree une variable 'value' avec 'User input' dedans?
- self.SetSizer( wx.BoxSizer( wx.HORIZONTAL )) # (vinz)-A priori un truc pour placer les fenetres? mais je comprends pas le contenu.
- button = wx.Button (self, wx.ID_ANY, 'Click Me') # (vinz)-Declare un bouton 'button' avec 'Click me ecrit dessus?
- button.Bind (wx.EVT_BUTTON, self.OnUserInput) # (vinz)-Lance la fonction 'OnUserInput' quand on clique sur 'button' ?
- self.GetSizer().Add( button ) # (vinz)-La je comprends pas trop... en fait le truc du sizer...
- self.label = wx.StaticText( self, wx.ID_ANY, self.value ) #(vinz)-Ca cree un StaticText avec 'value' dedans?
- self.GetSizer().Add( self.label ) #(vinz)-A priori ca doit placer les elements automatiquement, le sizer?
- vSizer = wx.BoxSizer( wx.VERTICAL ) )
- self.GetSizer().Add( vSizer )
- bToolA = wx.Button (self, wx.ID_ANY, 'Tool A')
- bToolB.Bind (wx.EVT_BUTTON, self.OnToolA)
- vSizer.Add( bToolA )
- bToolB = wx.Button (self, wx.ID_ANY, 'Tool B')
- bToolB.Bind (wx.EVT_BUTTON, self.OnToolB)
- vSizer.Add( bToolB )
- def OnUserInput(self, event):
- print event
- dialog = wx.TextEntryDialog( #(vinz)-Ca doit creer la boite entiere avec un TextEntry?
- self, 'Please Enter Text', 'User Input Dialog',
- self.value
- )
- if dialog.ShowModal() != wx.ID_OK: #(vinz)-Je vois que ca test le bouton cancel, mais je comprends pas comment...
- wx.MessageBox("Canceled !")
- else:
- self.value = dialog.GetValue() # (vinz)- Ca recupere la valeur entree?
- dialog.Destroy()
- self.label.SetLabel( self.value ) # (vinz)-Ca rebalance la value dans label de la premiere boite? la je comprends pas... est ce que 'label'est partout parce qu'il appartient a la class?
- if __name__ == '__main__': #(vinz)-Comprends pas du tout. hehe...tout le bloc!
- app = wx.PySimpleApp()
- f = wx.Frame(None)
- mp = myPanel( f )
- f.Show()
- app.MainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement