Пример #1
0
def category_wise_crime(dataframe, crimes_obj):
	'''Handles the functionalities of crimes by different categories'''

	GUI3.start_user_interface(dataframe)
	category, specific_choice = GUI3.get_choices()
	crimes_per_student_by_category = handlers.average_crimes_per_student_by_category(dataframe, category, crimes_obj, overall_average = True)

	pltparam = plotting.pltParam()
	answers_obj = plots.Answers(crimes_obj, None, pltparam, None, None, None)

	bar_chart = answers_obj.simpleBarChart(crimes_per_student_by_category, specific_choice)

	return bar_chart, specific_choice
Пример #2
0
def category_wise_crime(dataframe, crimes_obj):
    '''Handles the functionalities of crimes by different categories'''

    GUI3.start_user_interface(dataframe)
    category, specific_choice = GUI3.get_choices()
    crimes_per_student_by_category = handlers.average_crimes_per_student_by_category(
        dataframe, category, crimes_obj, overall_average=True)

    pltparam = plotting.pltParam()
    answers_obj = plots.Answers(crimes_obj, None, pltparam, None, None, None)

    bar_chart = answers_obj.simpleBarChart(crimes_per_student_by_category,
                                           specific_choice)

    return bar_chart, specific_choice
Пример #3
0
    def addAnalogOut(self, name, idx):
        """ Adds another channel into the GUI and returns a container with the widgets"""
        newChannel = GUI3.AnalogOutPanel(self, name, idx)
        self.analogOutSizer.Add(newChannel, 0,
                                wx.TOP | wx.LEFT | wx.RIGHT | wx.EXPAND, 5)
        newChannel.Layout()
        self.Layout()
        self.Fit()
        # wrap necessary widgets into a container class for access
        widgets = AnalogOutWidgets()
        widgets.panel = newChannel
        widgets.channelName = newChannel.channelName
        widgets.channelValue = newChannel.outputPwr
        widgets.startBtn = newChannel.startBtn
        widgets.runForBtn = newChannel.runForBtn
        widgets.progressBar = newChannel.progressBar
        widgets.timerText = newChannel.timer
        widgets.recordBtn = newChannel.recordBtn

        # create closures for handler functions
        def this_PwrChange(event):
            self.On_ValueChange(event, idx)

        def this_Record(event):
            self.On_Record(event, idx)

        def this_StartStop(event):
            self.On_StartStop(event, idx)

        def this_RunFor(event):
            self.On_RunFor(event, idx)

        # now bind all widgets to handler functions
        widgets.channelValue.Bind(wx.EVT_KILL_FOCUS, this_PwrChange)
        widgets.channelValue.Bind(wx.EVT_TEXT_ENTER, this_PwrChange)
        widgets.recordBtn.Bind(wx.EVT_BUTTON, this_Record)
        widgets.startBtn.Bind(wx.EVT_BUTTON, this_StartStop)
        widgets.runForBtn.Bind(wx.EVT_BUTTON, this_RunFor)

        # return
        return widgets
Пример #4
0
    def addDigital(self, name, idx, n):
        """ Addr another channel into the GUI and returns a container with the widgets"""
        newChannel = GUI3.DigitalPanel(self, name, idx, n)
        self.digitalSizer.Add(newChannel, 0,
                              wx.TOP | wx.LEFT | wx.RIGHT | wx.EXPAND, 5)
        newChannel.Layout()
        self.Layout()
        self.Fit()
        # wrap necessary widgets into a container class for access
        widgets = DigitalWidgets()
        widgets.panel = newChannel
        widgets.channelName = newChannel.channelName
        widgets.recordBtn = newChannel.recordBtn

        widgets.lights = newChannel.lights
        widgets.switches = newChannel.switches

        # create closures for handler functions
        def this_Record(event):
            self.On_Record(event, idx)

        def this_Switch(event):
            self.On_Switch(event, idx)

        def this_Light(event):
            self.On_Light(event, idx)

        widgets.recordBtn.Bind(wx.EVT_BUTTON, this_Record)
        # now bind all widgets to handler functions
        for l in widgets.lights:
            l.Bind(wx.EVT_BUTTON, this_Light)
        for s in widgets.switches:
            s.Bind(wx.EVT_BUTTON, this_Switch)

        # return
        return widgets
Пример #5
0
    def On_RunFor(self, event, idx):
        global device
        cHrs = self.widgets[idx].timerText.GetLabel()[:3]
        cMin = self.widgets[idx].timerText.GetLabel()[4:6]
        cSec = self.widgets[idx].timerText.GetLabel()[7:9]
        runForBox = GUI3.RunForDialog(self, cHrs, cMin, cSec)
        runForBox.ShowModal()
        if runForBox.cancelled:
            return
        else:

            runForSeconds = runForBox.hours.GetValue(
            ) * 2400 + runForBox.minutes.GetValue(
            ) * 60 + runForBox.seconds.GetValue()
            timer = []
            timer.append(runForBox.seconds.GetValue())
            timer.append(runForBox.minutes.GetValue())
            timer.append(runForBox.hours.GetValue())
            timeFormat = "{0:03}:{1:02}:{2:02}".format(
                runForBox.hours.GetValue(), runForBox.minutes.GetValue(),
                runForBox.seconds.GetValue())
            self.widgets[idx].timerText.SetLabel(timeFormat)
            self.widgets[idx].timerText.Enable(True)

            self.widgets[idx].progressBar.SetRange(PROGRESS_PRECISION)
            self.widgets[idx].progressBar.SetValue(0)

            def decTimer():

                timer[0] -= 1
                if timer[0] < 0:
                    timer[1] -= 1
                    timer[0] = 59
                if timer[1] < 0:
                    timer[2] -= 1
                    timer[1] = 59
                    timer[0] = 59
                if timer[2] < 0:
                    timer[2] = 0
                    timer[1] = 0
                    timer[0] = 0

                timeFormat = "{0:03}:{1:02}:{2:02}".format(
                    timer[2], timer[1], timer[0])
                self.widgets[idx].timerText.SetLabel(timeFormat)

            def incGauge():
                newVal = self.widgets[idx].progressBar.GetValue() + 1
                self.widgets[idx].progressBar.SetValue(newVal)

            self.widgets[idx].progressTimers = []
            self.widgets[idx].progressTimers.append(
                RepeatTimer.Timer(1, True, decTimer))
            for n in range(logger.options["progress_precision"] - 1):
                self.widgets[idx].progressTimers.append(
                    threading.Timer(
                        (n + 1) * (float(runForSeconds) /
                                   logger.options["progress_precision"]),
                        incGauge))

            def onStop():
                # TODO is GUI still alive???
                self.widgets[idx].timerText.Enable(False)
                for t in self.widgets[idx].progressTimers:
                    t.cancel()
                self.progressTimers = []
                self.widgets[idx].runForTimer = None
                self.widgets[idx].progressBar.SetRange(100)
                self.widgets[idx].progressBar.SetValue(100)
                device.channels[idx].stop()

            self.widgets[idx].runForTimer = threading.Timer(
                runForSeconds, onStop)
Пример #6
0
def category_wise_crime(dataframe):
    '''Handles the functionalities of crimes by different categories'''

    GUI3.start_user_interface(dataframe)
    print GUI3.get_choices()
Пример #7
0
def category_wise_crime(dataframe):
	'''Handles the functionalities of crimes by different categories'''

	GUI3.start_user_interface(dataframe)
	print GUI3.get_choices()
Пример #8
0
def Ex3():
    GUI3.main()