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
| #! /usr/bin/python
# -*- coding: utf-8 -*-
import wx
import time
def toto1(event) :
print " hello world 1"
for parc in range(100) :
gauge1.SetValue(pos=parc)
gauge1.Update()
time.sleep(0.05)
print parc
def toto2(event) :
print " hello world 2"
def toto3(event) :
y=12
yy=(y**3)-(3*487)
print "toto3"
return yy
# ---------------------------------------------------------------
app = wx.App()
# ---------------------------------------------------------------
def essai() :
global frame
frame=wx.Frame(None, title='Essai Perso wxPython', pos=(350,300))
frame.Center()
panel_1=wx.Panel(frame, -1)
# Barre de progression --------------------------------
global gauge1
gauge1=wx.Gauge(panel_1, -1, 100, (10, 70), (350, 25))
gauge1.Update()
# -----------------------------------------------------
b1=wx.Button(panel_1, 1, "Bouton1", (10,20))
b1.Bind(wx.EVT_BUTTON, toto1, id=1)
b1.Show()
b2=wx.Button(panel_1, 2, "Bouton2", (100,20))
b2.Bind(wx.EVT_BUTTON, toto2, id=2)
b2.Show()
b3=wx.Button(panel_1, 3, "Bouton3", (190,20))
b3.Bind(wx.EVT_BUTTON, toto3, id=3)
b3.Show()
frame.Show()
essai()
app.MainLoop() |
Partager