def __init__(self, frame): wx.Panel.__init__(self, frame) garlicsim_wx.widgets.WorkspaceWidget.__init__(self, frame) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.pie_ctrl = piectrl.PieCtrl(self, style=wx.NO_BORDER) self.sizer_v = wx.BoxSizer(wx.VERTICAL) self.sizer_h = wx.BoxSizer(wx.HORIZONTAL) self.sizer_v.Add(self.sizer_h, 1, wx.EXPAND) self.sizer_h.Add(self.pie_ctrl, 1, wx.EXPAND) self.SetSizer(self.sizer_v) self.sizer_v.Layout() font = wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, True, 'Arial') self.pie_ctrl.GetLegend().SetLabelFont(font) self.pie_ctrl.SetAngle(math.pi) self.pie_part_dict = {} for player_type in prisoner.players.player_types_list: part = piectrl.PiePart() part.SetLabel(player_type.__name__) part.SetValue(1) part.SetColour(player_type.wx_color) self.pie_ctrl._series.append(part) self.pie_part_dict[player_type] = part self.gui_project.active_node_changed_or_modified_emitter.add_output( lambda: self.show_state(self.gui_project.get_active_state()))
def __init__(self, parent): wx.Frame.__init__(self, parent, -1, "PieCtrl Demo") panel = PanelPieChart(self) return panel.SetBackgroundColour(wx.Colour(18, 86, 133)) # create a simple PieCtrl with 3 sectors mypie = PC.PieCtrl(panel, -1, wx.DefaultPosition, wx.Size(180, 270)) mypie.SetBackColour(wx.Colour(18, 86, 133)) part1 = PC.PiePart() part1.SetLabel("Label 1") part1.SetValue(300) part1.SetColour(wx.Colour(200, 50, 50)) mypie._series.append(part1) part2 = PC.PiePart() part2.SetLabel("Label 2") part2.SetValue(200) part2.SetColour(wx.Colour(50, 200, 50)) mypie._series.append(part2) #part = PC.PiePart() #part.SetLabel("helloworld label 3") #part.SetValue(50) #part.SetColour(wx.Colour(50, 50, 200)) #mypie._series.append(part) part1.SetValue(250) part2.SetValue(250) # create a ProgressPie progress_pie = PC.ProgressPie(panel, 100, 50, -1, wx.DefaultPosition, wx.Size(180, 200), wx.SIMPLE_BORDER) progress_pie.SetBackColour(wx.Colour(150, 200, 255)) progress_pie.SetFilledColour(wx.Colour(255, 0, 0)) progress_pie.SetUnfilledColour(wx.WHITE) progress_pie.SetHeight(20) main_sizer = wx.BoxSizer(wx.HORIZONTAL) main_sizer.Add(mypie, 1, wx.EXPAND | wx.ALL, 5) main_sizer.Add(progress_pie, 1, wx.EXPAND | wx.ALL, 5) panel.SetSizer(main_sizer) main_sizer.Layout()
def test_lib_agw_piectrlMethods(self): # create a simple PieCtrl with 2 sectors mypie = PC.PieCtrl(self.frame) part1 = PC.PiePart() part1.SetLabel("Label 1") part1.SetValue(300) part1.SetColour(wx.Colour(200, 50, 50)) mypie._series.append(part1) part2 = PC.PiePart() part2.SetLabel("Label 2") part2.SetValue(200) part2.SetColour(wx.Colour(50, 200, 50)) mypie._series.append(part2) self.assertEqual(part1.GetLabel(), 'Label 1') self.assertEqual(part2.GetLabel(), 'Label 2') self.assertEqual(part1.GetValue(), 300) self.assertEqual(part2.GetValue(), 200) self.assertEqual(mypie.GetRotationAngle(), 0)
def __init__(self, parent, pnlSize=(320, 320)): wx.Panel.__init__(self, parent, size=pnlSize) self.SetBackgroundColour(wx.Colour(18, 86, 133)) mSizer = wx.BoxSizer(wx.HORIZONTAL) self.mypie = PC.PieCtrl(self, -1, wx.DefaultPosition, wx.Size(180, 270)) self.mypie.SetBackColour(wx.Colour(150, 200, 255)) self.part1 = PC.PiePart() self.part1.SetLabel("Average: 1") self.part1.SetValue(12) self.part1.SetColour(wx.Colour(0, 205, 52)) self.mypie._series.append(self.part1) self.part2 = PC.PiePart() self.part2.SetLabel("Label 2") self.part2.SetValue(100 - 12) self.part2.SetColour(wx.Colour(83, 81, 251)) self.mypie._series.append(self.part2) mSizer.Add(self.mypie, 1, wx.EXPAND | wx.ALL, 5) self.Layout() self.SetSizer(mSizer)
def test_lib_agw_piectrlCtor(self): pie = PC.PieCtrl(self.frame)
def _init_ctrls(self, prnt): # generated method, don't edit wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt, pos=wx.Point(582, 93), size=wx.Size(753, 497), style=wx.DEFAULT_FRAME_STYLE, title='TestLink Case Executor') self.SetClientSize(wx.Size(737, 459)) self.panel1 = wx.Panel(id=wxID_FRAME1PANEL1, name='panel1', parent=self, pos=wx.Point(0, 0), size=wx.Size(737, 459), style=wx.TAB_TRAVERSAL) self.CaseNameList = wx.ListBox(choices=[], id=wxID_FRAME1CASENAMELIST, name='CaseNameList', parent=self.panel1, pos=wx.Point(0, 0), size=wx.Size(392, 352), style=0) self.CaseNameList.Bind(wx.EVT_LISTBOX, self.OnCaseNameListListbox, id=wxID_FRAME1CASENAMELIST) self.sashWindow1 = wx.SashWindow(id=wxID_FRAME1SASHWINDOW1, name='sashWindow1', parent=self.panel1, pos=wx.Point(392, 0), size=wx.Size(344, 120), style=wx.CLIP_CHILDREN | wx.SW_3D) self.TestCaseName = wx.StaticText(id=wxID_FRAME1TESTCASENAME, label='', name='TestCaseName', parent=self.sashWindow1, pos=wx.Point(16, 16), size=wx.Size(240, 24), style=0) self.TestCount = wx.StaticText(id=wxID_FRAME1TESTCOUNT, label='', name='TestCount', parent=self.sashWindow1, pos=wx.Point(280, 16), size=wx.Size(53, 13), style=0) self.PassButton = wx.Button(id=wxID_FRAME1PASSBUTTON, label='PASS', name='PassButton', parent=self.sashWindow1, pos=wx.Point(48, 64), size=wx.Size(75, 23), style=0) self.PassButton.Bind(wx.EVT_BUTTON, self.OnPassButtonButton, id=wxID_FRAME1PASSBUTTON) self.FailButton = wx.Button(id=wxID_FRAME1FAILBUTTON, label='FAIL', name='FailButton', parent=self.sashWindow1, pos=wx.Point(136, 64), size=wx.Size(75, 23), style=0) self.FailButton.Bind(wx.EVT_BUTTON, self.OnFailButtonButton, id=wxID_FRAME1FAILBUTTON) self.BlockButton = wx.Button(id=wxID_FRAME1BLOCKBUTTON, label='BLOCK', name='BlockButton', parent=self.sashWindow1, pos=wx.Point(224, 64), size=wx.Size(75, 23), style=0) self.BlockButton.Bind(wx.EVT_BUTTON, self.OnBlockButtonButton, id=wxID_FRAME1BLOCKBUTTON) self.BackButton = wx.Button(id=wxID_FRAME1BACKBUTTON, label='<-', name='BackButton', parent=self.sashWindow1, pos=wx.Point(16, 64), size=wx.Size(24, 23), style=0) self.BackButton.Bind(wx.EVT_BUTTON, self.OnBackButton, id=wxID_FRAME1BACKBUTTON) self.ForwardButton = wx.Button(id=wxID_FRAME1FORWARDBUTTON, label='->', name='ForwardButton', parent=self.sashWindow1, pos=wx.Point(312, 64), size=wx.Size(24, 23), style=0) self.ForwardButton.Bind(wx.EVT_BUTTON, self.OnForwardButtonButton, id=wxID_FRAME1FORWARDBUTTON) self.window1 = wx.Window(id=wxID_FRAME1WINDOW1, name='window1', parent=self.panel1, pos=wx.Point(0, 352), size=wx.Size(736, 88), style=0) self.htmlWindow1 = wx.html.HtmlWindow(id=wxID_FRAME1HTMLWINDOW1, name='htmlWindow1', parent=self.window1, pos=wx.Point(0,0), size=wx.Size(736, 100), style=wx.html.HW_SCROLLBAR_AUTO) self.GetTestCases = wx.Button(id=wxID_FRAME1GETTESTCASES, label='Create Test Plan', name='GetTestCases', parent=self.sashWindow1, pos=wx.Point(16, 96), size=wx.Size(152, 23), style=0) self.GetTestCases.Bind(wx.EVT_BUTTON, self.OnGetTestCasesButton, id=wxID_FRAME1GETTESTCASES) self.CaseGauge = wx.Gauge(id=wxID_FRAME1CASEGAUGE, name='CaseGauge', parent=self.panel1, pos=wx.Point(8, 440), range=100, size=wx.Size(576, 16), style=wx.GA_HORIZONTAL) self.CaseTracker = wx.StaticText(id=wxID_FRAME1CASETRACKER, label='', name='CaseTracker', parent=self.panel1, pos=wx.Point(600, 443), size=wx.Size(0, 13), style=0) self.LoadTestPlan = wx.Button(id=wxID_FRAME1LOADTESTPLAN, label='Load Test Plan', name='LoadTestPlan', parent=self.sashWindow1, pos=wx.Point(184, 96), size=wx.Size(152, 23), style=0) self.LoadTestPlan.Bind(wx.EVT_BUTTON, self.OnLoadTestPlanButton, id=wxID_FRAME1LOADTESTPLAN) self.staticText1 = wx.StaticText(id=wxID_FRAME1STATICTEXT1, label='Filter', name='staticText1', parent=self.sashWindow1, pos=wx.Point(16, 48), size=wx.Size(25, 13), style=0) self.FilterChoice = wx.Choice(choices=[], id=wxID_FRAME1FILTERCHOICE, name='FilterChoice', parent=self.sashWindow1, pos=wx.Point(48, 40), size=wx.Size(280, 21), style=0) self.FilterChoice.Bind(wx.EVT_CHOICE, self.OnFilterChoiceChoice, id=wxID_FRAME1FILTERCHOICE) self.PiePanel = wx.Panel(id=wxID_FRAME1PIEPANEL, name='PiePanel', parent=self.panel1, pos=wx.Point(392, 120), size=wx.Size(344, 232), style=wx.TAB_TRAVERSAL) self.PieChart = PC.PieCtrl(id=wxID_PIECHART, name='PieChart', parent=self.PiePanel, pos=wx.Point(0, -300), size=wx.Size(344, 820), style=wx.TAB_TRAVERSAL) self.PassPart = PC.PiePart() self.PassPart.SetLabel("Passed") self.PassPart.SetValue(1) self.PassPart.SetColour(wx.Colour(0, 255, 0)) self.PieChart._series.append(self.PassPart) self.FailPart = PC.PiePart() self.FailPart.SetLabel("Failed") self.FailPart.SetValue(1) self.FailPart.SetColour(wx.Colour(255, 0, 0)) self.PieChart._series.append(self.FailPart) self.BlockPart = PC.PiePart() self.BlockPart.SetLabel("Blocked") self.BlockPart.SetValue(1) self.BlockPart.SetColour(wx.Colour(0, 0, 255)) self.PieChart._series.append(self.BlockPart) self.NotRunPart = PC.PiePart() self.NotRunPart.SetLabel("Not Run") self.NotRunPart.SetValue(1) self.NotRunPart.SetColour(wx.Colour(0, 0, 0)) self.PieChart._series.append(self.NotRunPart)