Exemplo n.º 1
0
class _StartDate(object):
    def __init__(
            self,
            parent,
            label,
            input_values,
            # Temporary workaround for bug #332
            filename,
            id_):
        self.box = wx.BoxSizer(wx.HORIZONTAL)

        self.slabel = wx.StaticText(parent, label=label)
        self.box.Add(self.slabel,
                     flag=wx.ALIGN_CENTER_VERTICAL | wx.RIGHT,
                     border=4)

        self.startw = DateHourCtrl(parent)
        self.startw.set_values(input_values['start_year'],
                               input_values['start_month'],
                               input_values['start_day'],
                               input_values['start_hour'],
                               input_values['start_minute'])
        self.box.Add(self.startw.get_main_panel())

        # Temporary workaround for bug #332
        # This widget is always placed at the top, so the previous
        #  Tab-traversal element is always the OK button
        wxgui_api.Bug332Workaround(
            self.startw.datectrl,
            wxscheduler_api.work_around_bug332(filename, id_),
            self.startw.hourctrl.hourctrl)

    def get_main_window(self):
        return self.box

    def get_first_column_width(self):
        return self.slabel.GetSizeTuple()[0]

    def set_first_column_width(self, width):
        sminh = self.slabel.GetMinHeight()
        self.slabel.SetMinSize((width, sminh))

    def get_values(self, values):
        start = self.startw.get_unix_time()
        utcoffset = timeaux.UTCOffset.compute2(start)
        ostart = self.startw.get_unix_time() - utcoffset

        return {
            'utc_offset': utcoffset,
            'start_unix_time': ostart,
            'start_relative_time': ostart % 86400,
            'start_year': self.startw.get_year(),
            'start_month': self.startw.get_month(),
            'start_day': self.startw.get_day(),
            'start_hour': self.startw.get_hour(),
            'start_minute': self.startw.get_minute()
        }
Exemplo n.º 2
0
class _StartDate(object):
    def __init__(
        self,
        parent,
        label,
        input_values,
        # Temporary workaround for bug #332
        filename,
        id_,
    ):
        self.box = wx.BoxSizer(wx.HORIZONTAL)

        self.slabel = wx.StaticText(parent, label=label)
        self.box.Add(self.slabel, flag=wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, border=4)

        self.startw = DateHourCtrl(parent)
        self.startw.set_values(
            input_values["start_year"],
            input_values["start_month"],
            input_values["start_day"],
            input_values["start_hour"],
            input_values["start_minute"],
        )
        self.box.Add(self.startw.get_main_panel())

        # Temporary workaround for bug #332
        # This widget is always placed at the top, so the previous
        #  Tab-traversal element is always the OK button
        wxgui_api.Bug332Workaround(
            self.startw.datectrl, wxscheduler_api.work_around_bug332(filename, id_), self.startw.hourctrl.hourctrl
        )

    def get_main_window(self):
        return self.box

    def get_first_column_width(self):
        return self.slabel.GetSizeTuple()[0]

    def set_first_column_width(self, width):
        sminh = self.slabel.GetMinHeight()
        self.slabel.SetMinSize((width, sminh))

    def get_values(self, values):
        start = self.startw.get_unix_time()
        utcoffset = timeaux.UTCOffset.compute2(start)
        ostart = self.startw.get_unix_time() - utcoffset

        return {
            "utc_offset": utcoffset,
            "start_unix_time": ostart,
            "start_relative_time": ostart % 86400,
            "start_year": self.startw.get_year(),
            "start_month": self.startw.get_month(),
            "start_day": self.startw.get_day(),
            "start_hour": self.startw.get_hour(),
            "start_minute": self.startw.get_minute(),
        }