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
| import wx
from math import pi
import os
import sys
import wx.lib.agw.piectrl
from wx.lib.agw.piectrl import PieCtrl,PiePart
class MainFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title="CalendosPOWA",(800,600))
calendos = PieCtrlDemo(self)
class PieCtrlDemo(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
# Create Some Maquillage For The Demo: Icon, StatusBar, MenuBar...
panel = wx.Panel(self, -1)
self._incr = 1
self._hiddenlegend = False
panel.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE))
# Create A Simple PieCtrl With 3 Sectors
self._pie = PieCtrl(panel, -1, wx.DefaultPosition, wx.Size(180,270))
self._pie.GetLegend().SetTransparent(True)
self._pie.GetLegend().SetHorizontalBorder(10)
self._pie.GetLegend().SetWindowStyle(wx.STATIC_BORDER)
self._pie.GetLegend().SetLabelFont(wx.Font(10, wx.FONTFAMILY_DEFAULT,
wx.FONTSTYLE_NORMAL,
wx.FONTWEIGHT_NORMAL,
False, "Courier New"))
self._pie.GetLegend().SetLabelColour(wx.Colour(0, 0, 127))
self._pie.SetHeight(30)
part = PiePart()
part.SetLabel("SeriesLabel_1")
part.SetValue(300)
part.SetColour(wx.Colour(200, 50, 50))
self._pie._series.append(part)
part = PiePart()
part.SetLabel("Series Label 2")
part.SetValue(200)
part.SetColour(wx.Colour(50, 200, 50))
self._pie._series.append(part)
part = PiePart()
part.SetLabel("HelloWorld Label 3")
part.SetValue(50)
part.SetColour(wx.Colour(50, 50, 200))
self._pie._series.append(part)
def OnToggleTransparency(self, event):
self._pie.GetLegend().SetTransparent(not self._pie.GetLegend().IsTransparent())
self._pie.Refresh()
def OnToggleEdges(self, event):
self._pie.SetShowEdges(not self._pie.GetShowEdges())
self._progresspie.SetShowEdges(not self._progresspie.GetShowEdges())
def OnToggleLegend(self, event):
self._hiddenlegend = not self._hiddenlegend
if self._hiddenlegend:
self._pie.GetLegend().Hide()
else:
self._pie.GetLegend().Show()
self._pie.Refresh()
def OnSlider(self, event):
self._pie.SetAngle(float(self._slider.GetValue())/180.0*pi)
self._progresspie.SetAngle(float(self._slider.GetValue())/180.0*pi)
def OnAngleSlider(self, event):
self._pie.SetRotationAngle(float(self._angleslider.GetValue())/180.0*pi)
self._progresspie.SetRotationAngle(float(self._angleslider.GetValue())/180.0*pi)
if __name__ == '__main__':
app = wx.App()
frame = MainFrame() #Instanciation de la frame principale.
frame.Show(True)
app.MainLoop() #Fais tourner l'application. |
Partager