示例#1
0
    def __init__(self, parent):

        wx.Dialog.__init__(self, parent, title=_('Pick a date ...'))
        panel = wx.Panel(self, -1)

        sizer = wx.BoxSizer(wx.VERTICAL)
        panel.SetSizer(sizer)

        cal = wxcal.CalendarCtrl(panel)

        if sys.platform != 'win32':
            # gtk truncates the year - this fixes it
            w, h = cal.Size
            cal.Size = (w + 25, h)
            cal.MinSize = cal.Size

        sizer.Add(cal, 0)

        button_sizer = wx.BoxSizer(wx.HORIZONTAL)
        button_sizer.Add((0, 0), 1)
        btn_ok = wx.Button(panel, wx.ID_OK)
        btn_ok.SetDefault()
        button_sizer.Add(btn_ok, 0, wx.ALL, 2)
        button_sizer.Add((0, 0), 1)
        btn_can = wx.Button(panel, wx.ID_CANCEL)
        button_sizer.Add(btn_can, 0, wx.ALL, 2)
        button_sizer.Add((0, 0), 1)
        sizer.Add(button_sizer, 1, wx.EXPAND | wx.ALL, 10)
        sizer.Fit(panel)
        self.ClientSize = panel.Size

        cal.Bind(wx.EVT_KEY_DOWN, self.__on_key_down)
        cal.SetFocus()
        self.cal = cal
示例#2
0
 def __initialize_components(self):
     self.cal = cal.CalendarCtrl(self,
                                 -1,
                                 wx.DateTime_Now(),
                                 style=cal.CAL_SEQUENTIAL_MONTH_SELECTION,
                                 pos=(20, 20),
                                 size=(250, 150))
     self.btnOk = wx.Button(self, -1, 'Create', (120, 185))
     self.btnCancel = wx.Button(self, 1, 'Cancel', (200, 185))
示例#3
0
    def CreateCalender(self, xPos, yPos):
        vbox = wx.BoxSizer(wx.VERTICAL)

        calend = cal.CalendarCtrl(self,
                                  -1,
                                  wx.DateTime_Now(),
                                  style=cal.CAL_SHOW_HOLIDAYS
                                  | cal.CAL_SEQUENTIAL_MONTH_SELECTION)
        vbox.Add(calend, 0, wx.EXPAND | wx.ALL, 200)
        #self.Bind(cal.EVT_CALENDAR, self.OnCalSelected, id=calend.GetId())

        vbox.Add((-1, 200))
示例#4
0
文件: main.py 项目: Zelenovin/ontime
 def __init__(self, parent, mytitle):
     wx.Dialog.__init__(self, parent, wx.ID_ANY, mytitle)
     vbox = wx.BoxSizer(wx.VERTICAL)
     self.calendar = cal.CalendarCtrl(self, wx.ID_ANY,
                                      wx.DateTime_Now())
     vbox.Add(self.calendar, 0, wx.EXPAND | wx.ALL, border=20)
     self.calendar.Bind(cal.EVT_CALENDAR, self.onCalSelected)
     button = wx.Button(self, wx.ID_ANY, 'Ok')
     vbox.Add(button, 0, wx.ALL | wx.ALIGN_CENTER, border=20)
     self.Bind(wx.EVT_BUTTON, self.onQuit, button)
     self.SetSizerAndFit(vbox)
     self.Show(True)
     self.Centre()
示例#5
0
    def __init__(self, *_args, **_kwargs):
        apply(pop.PopupControl.__init__, (self, ) + _args, _kwargs)

        self.win = wx.Window(self, -1, pos=(0, 0), style=0)
        self.cal = cal.CalendarCtrl(self.win, -1, pos=(0, 0))

        bz = self.cal.GetBestSize()
        self.win.SetSize(bz)

        # This method is needed to set the contents that will be displayed
        # in the popup
        self.SetPopupContent(self.win)

        # Event registration for date selection
        self.cal.Bind(cal.EVT_CALENDAR_DAY, self.OnCalSelected)
示例#6
0
    def __init__(self, parent, title, ddate=None):
        wx.Dialog.__init__(self, parent, -1, title, size=(420, 420))
        self.dRet = ddate

        # calendar
        sizer = wx.BoxSizer(wx.VERTICAL)
        box = wx.BoxSizer(wx.HORIZONTAL)

        if ddate == None:
            dd = wx.DateTime_Now()
            debug('iTradeDatePicker() today date = %s' % dd.__str__())
        else:
            debug('iTradeDatePicker() default date = %d %d %d' %
                  (ddate.day, ddate.month, ddate.year))
            dd = wx.DateTimeFromDMY(ddate.day, ddate.month - 1, ddate.year)
            debug('iTradeDatePicker() default date = %s' % dd.__str__())

        self.cal = wxcal.CalendarCtrl(self,
                                      -1,
                                      dd,
                                      pos=(25, 50),
                                      style=wxcal.CAL_SHOW_HOLIDAYS
                                      | wxcal.CAL_MONDAY_FIRST
                                      | wxcal.CAL_SEQUENTIAL_MONTH_SELECTION)

        box.Add(self.cal, 1, wx.ALIGN_CENTRE | wx.ALL, 5)

        sizer.AddSizer(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        # buttons
        box = wx.BoxSizer(wx.HORIZONTAL)
        btn = wx.Button(self, wx.ID_OK, message('valid'))
        btn.SetDefault()
        btn.SetHelpText(message('valid_desc'))
        box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        wx.EVT_BUTTON(self, btn.GetId(), self.OnValid)

        btn = wx.Button(self, wx.ID_CANCEL, message('cancel'))
        btn.SetHelpText(message('cancel_desc'))
        box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        wx.EVT_BUTTON(self, btn.GetId(), self.OnCancel)

        sizer.AddSizer(box, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        wx.EVT_SIZE(self, self.OnSize)

        self.SetAutoLayout(True)
        self.SetSizerAndFit(sizer)
示例#7
0
    def __init__(self, handle, bitmaphandle, formathandle, listener, ndx):

        wx.Frame.__init__(self, None, -1, "Select Date", size=(250, 250))
        self.dp = calendar.CalendarCtrl(self, -1, pos=(0, 10))
        self.Bind(calendar.EVT_CALENDAR_DAY, self.OnDateSelected, self.dp)

        self.handle = handle  # This is the handle to the current image

        self.imbmp = bitmaphandle
        self.fh = formathandle
        self.listener = listener
        self.ndx = ndx

        self.SetInitialSize()
        self.CenterOnParent()
        self.Show()
    def __init__(self, parent, ID, log):
        wx.Panel.__init__(self, parent, ID)
        self.log = log

        native = wxcal.CalendarCtrl(self,
                                    -1,
                                    wx.DateTime.Today(),
                                    style=wxcal.CAL_SEQUENTIAL_MONTH_SELECTION)

        txt = wx.StaticText(self, -1, description)
        txt.Wrap(300)

        cal = self.cal = wxcal.GenericCalendarCtrl(
            self,
            -1,
            wx.DateTime.Today(),
            style=wxcal.CAL_SHOW_HOLIDAYS
            | wxcal.CAL_SUNDAY_FIRST
            | wxcal.CAL_SEQUENTIAL_MONTH_SELECTION)

        cal2 = wxcal.GenericCalendarCtrl(self, -1, wx.DateTime.Today())

        # Track a few holidays
        self.holidays = [(1, 1), (10, 31),
                         (12, 25)]  # (these don't move around)
        self.OnChangeMonth()

        # bind some event handlers to each calendar
        for c in native, cal, cal2:
            c.Bind(wxcal.EVT_CALENDAR, self.OnCalSelected)
            c.Bind(wxcal.EVT_CALENDAR_MONTH, self.OnChangeMonth)
            c.Bind(wxcal.EVT_CALENDAR_SEL_CHANGED, self.OnCalSelChanged)
            c.Bind(wxcal.EVT_CALENDAR_WEEKDAY_CLICKED,
                   self.OnCalWeekdayClicked)

        # create some sizers for layout
        fgs = wx.FlexGridSizer(cols=2, hgap=50, vgap=50)
        fgs.Add(native)
        fgs.Add(txt)
        fgs.Add(cal)
        fgs.Add(cal2)
        box = wx.BoxSizer()
        box.Add(fgs, 1, wx.EXPAND | wx.ALL, 25)
        self.SetSizer(box)
示例#9
0
 def init_controls(self):
     vsizer = wx.BoxSizer(wx.VERTICAL)
     hsizer0 = wx.BoxSizer(wx.HORIZONTAL)
     hsizer1 = wx.BoxSizer(wx.HORIZONTAL)
     self.fname_ctrl = wx.TextCtrl(self)
     browse_button = wx.Button(self, label='Choose file')
     self.fmt_select = wx.ComboBox(self,
                                   choices=writer.backends.keys(),
                                   style=wx.CB_READONLY)
     self.fmt_select.SetValue(writer.backends.keys()[0])
     self.cap_button = wx.ToggleButton(self, label='Capture')
     self.edf_ctrls = {}
     self.edf_ctrls['patient'] = (wx.TextCtrl(self),
                                  wx.StaticText(self, label="Name:"))
     self.edf_ctrls['gender'] = (wx.ComboBox(self,
                                             choices=('male', 'female'),
                                             style=wx.CB_READONLY),
                                 wx.StaticText(self, label="Sex:"))
     self.edf_ctrls['patient_additional'] = (wx.TextCtrl(self),
                                             wx.StaticText(
                                                 self,
                                                 label="Additional info"))
     self.edf_ctrls['birthdate'] = (calendar.CalendarCtrl(self),
                                    wx.StaticText(self, label="Birthdate"))
     self.Bind(wx.EVT_BUTTON, self.on_browse, browse_button)
     self.Bind(wx.EVT_TOGGLEBUTTON, self.on_capture_btn, self.cap_button)
     self.Bind(wx.EVT_COMBOBOX, self.on_fmt_select, self.fmt_select)
     hsizer0.Add(self.fname_ctrl, 1)
     hsizer0.Add(browse_button, 0)
     hsizer0.Add(self.fmt_select, 0)
     hsizer0.Add(self.cap_button, 0, wx.ALIGN_RIGHT)
     vsizer.Add(hsizer0, 0, wx.EXPAND)
     gsizer = wx.GridSizer(len(self.edf_ctrls.keys()))
     for k in self.edf_ctrls:
         ec, lbl = self.edf_ctrls[k]
         gsizer.Add(lbl, 0)
         gsizer.Add(ec, 2, wx.ALIGN_RIGHT)
     vsizer.Add(gsizer)
     self.SetSizer(vsizer)
示例#10
0
    def __init__(self, parent, id, title):
        wx.Dialog.__init__(self, parent, id, title, size=(340, 240))
        
        
        self.datectrl =parent.datectrl

        vbox = wx.BoxSizer(wx.VERTICAL)
        
        calend = cal.CalendarCtrl(self, -1, wx.DateTime_Now(), \
                                  style = cal.CAL_SHOW_HOLIDAYS|\
                                  cal.CAL_SEQUENTIAL_MONTH_SELECTION)
        vbox.Add(calend, 0, wx.EXPAND|wx.ALL, 20)
        self.Bind(cal.EVT_CALENDAR, self.OnCalSelected, \
                  id=calend.GetId())

        vbox.Add((-1, 20))
        hbox = wx.BoxSizer(wx.HORIZONTAL)
        vbox.Add(hbox, 0, wx.LEFT, 8)       
        hbox2 = wx.BoxSizer(wx.HORIZONTAL)
        vbox.Add(hbox2, 0, wx.ALIGN_CENTER|wx.TOP|wx.BOTTOM, 20)     
        self.SetSizer(vbox)
        self.Show(True)
        self.Center()
示例#11
0
    def __init__(self, fold_panel, rule):
        wx.BoxSizer.__init__(self, wx.VERTICAL)

        def h_sizer(st, ctrl):
            szr = wx.BoxSizer(wx.HORIZONTAL)
            szr.Add(st, 0, wx.EXPAND | wx.ALL, 5)
            szr.Add(ctrl, 0, wx.EXPAND | wx.ALL, 5)
            return szr

        name_st = wx.StaticText(fold_panel, -1, 'Name:')
        name_ctrl = wx.TextCtrl(fold_panel, -1, rule.name)
        name_sizer = h_sizer(name_st, name_ctrl)

        enable_st = wx.StaticText(fold_panel, -1, 'Enable:')
        enable_ctrl = wx.CheckBox(fold_panel, -1, '')
        enable_ctrl.SetValue(bool(rule.enabled))
        enable_sizer = h_sizer(enable_st, enable_ctrl)

        top_sizer = h_sizer(name_sizer, enable_sizer)

        day_ctrl = DayPanel(fold_panel, rule.sunday, rule.monday, rule.tuesday,
                            rule.wednesday, rule.thursday, rule.friday,
                            rule.saturday)

        start_time_st = wx.StaticText(fold_panel, -1, 'Start Time:')
        start_time_spin = wx.SpinButton(fold_panel, -1, style=wx.SP_HORIZONTAL)

        start_time_ctrl = timectrl.TimeCtrl(
            fold_panel,
            -1,
            str(datetime.timedelta(seconds=rule.start_time)),
            fmt24hr=True,
            spinButton=start_time_spin)

        start_time_sizer = wx.BoxSizer(wx.VERTICAL)

        start_time_sizer.Add(start_time_ctrl)
        start_time_sizer.Add(start_time_spin)
        start_time_sizer = h_sizer(start_time_st, start_time_sizer)

        end_time_st = wx.StaticText(fold_panel, -1, 'End Time:')
        end_time_spin = wx.SpinButton(fold_panel, -1, style=wx.SP_HORIZONTAL)
        end_time_ctrl = timectrl.TimeCtrl(
            fold_panel,
            -1,
            str(datetime.timedelta(seconds=rule.end_time)),
            fmt24hr=True,
            spinButton=end_time_spin)

        end_time_sizer = wx.BoxSizer(wx.VERTICAL)
        end_time_sizer.Add(end_time_ctrl)
        end_time_sizer.Add(end_time_spin)
        end_time_sizer = h_sizer(end_time_st, end_time_sizer)

        event_top_sizer = wx.BoxSizer(wx.VERTICAL)
        event_top_sizer.Add(start_time_sizer)

        event_bottom_sizer = wx.BoxSizer(wx.VERTICAL)
        event_bottom_sizer.Add(end_time_sizer)

        event_right_sizer = wx.BoxSizer(wx.VERTICAL)
        event_right_sizer.Add(event_top_sizer)
        event_right_sizer.Add(event_bottom_sizer)

        calendar_ctrl = calendar.CalendarCtrl(
            fold_panel,
            -1,
            wx.DateTime().Set(
                day=rule.day,
                month=rule.month - 1,
                year=rule.year,
            ),
            style=(calendar.CAL_SUNDAY_FIRST | calendar.CAL_SHOW_HOLIDAYS
                   | calendar.CAL_SEQUENTIAL_MONTH_SELECTION),
        )

        event_sizer = h_sizer(calendar_ctrl, event_right_sizer)

        repeat_st = wx.StaticText(fold_panel, -1, 'Repeat:')
        repeat_ctrl = wx.Choice(fold_panel,
                                -1,
                                choices=['test1', 'test2', 'test3', 'test4'])
        repeat_ctrl.SetSelection(rule.repeat)

        repeat_sizer = h_sizer(repeat_st, repeat_ctrl)

        def save():
            rule.name = name_ctrl.GetValue()
            rule.enabled = int(enable_ctrl.GetValue())
            (rule.sunday, rule.monday, rule.tuesday, rule.wednesday,
             rule.thursday, rule.friday, rule.saturday) = day_ctrl.GetValue()

            date = calendar_ctrl.GetDate()

            rule.day = date.Day
            rule.month = date.Month + 1
            rule.year = date.Year

            start_time = start_time_ctrl.GetValue().split(':')
            start_time = datetime.timedelta(hours=int(start_time[0]),
                                            minutes=int(start_time[1]),
                                            seconds=int(start_time[2]))

            rule.start_time = start_time.seconds

            end_time = end_time_ctrl.GetValue().split(':')
            end_time = datetime.timedelta(hours=int(end_time[0]),
                                          minutes=int(end_time[1]),
                                          seconds=int(end_time[2]))
            rule.end_time = end_time.seconds
            rule.repeat = repeat_ctrl.GetSelection()

        def reset():
            name_ctrl.SetValue(rule.name)
            enable_ctrl.SetValue(bool(rule.enabled))
            day_ctrl.SetValue(rule.sunday, rule.monday, rule.tuesday,
                              rule.wednesday, rule.thursday, rule.friday,
                              rule.saturday)
            calendar_ctrl.SetDate(wx.DateTime().Set(
                day=rule.day,
                month=rule.month - 1,
                year=rule.year,
            ))
            start_time_ctrl.SetValue(
                str(datetime.timedelta(seconds=rule.start_time)))
            end_time_ctrl.SetValue(
                str(datetime.timedelta(seconds=rule.end_time)))
            repeat_ctrl.SetSelection(rule.repeat)

        if isinstance(fold_panel.GetGrandParent(), ScheduleFoldPanel):
            start_action = rule.start_action
            start_choices = ['Off', 'On']
            if start_action == -1:
                start_action = 2
                start_choices += ['Unknown']

            start_action_st = wx.StaticText(fold_panel, -1, 'Start Action:')
            start_action_ctrl = wx.Choice(fold_panel,
                                          -1,
                                          choices=start_choices)

            start_action_ctrl.SetSelection(start_action)
            start_action_sizer = h_sizer(start_action_st, start_action_ctrl)

            end_choices = ['Off', 'On']
            end_action = rule.end_action
            if end_action is None:
                end_action = 2
                end_choices += ['Unknown']

            end_action_st = wx.StaticText(fold_panel, -1, 'End Action:')
            end_action_ctrl = wx.Choice(fold_panel, -1, choices=end_choices)

            print 'end_action', end_action

            end_action_ctrl.SetSelection(end_action)
            end_action_sizer = h_sizer(end_action_st, end_action_ctrl)
            event_top_sizer.Add(start_action_sizer)
            event_bottom_sizer.Add(end_action_sizer)

            def on_save(_):
                save()
                rule.start_action = start_action_ctrl.GetSelection()
                rule.end_action = end_action_ctrl.GetSelection()
                rule.save()

            def on_cancel(_):
                reset()
                start_action_ctrl.SetSelection(start_action)
                end_action_ctrl.SetSelection(end_action)

        else:
            frequency_st = wx.StaticText(fold_panel, -1, 'Frequency:')
            frequency_ctrl = eg.SpinIntCtrl(fold_panel, -1, rule.frequency)
            frequency_sizer = h_sizer(frequency_st, frequency_ctrl)

            duration_st = wx.StaticText(fold_panel, -1, 'Duration:')
            duration_ctrl = eg.SpinIntCtrl(fold_panel, -1, rule.duration)
            duration_sizer = h_sizer(duration_st, duration_ctrl)

            lastfor_st = wx.StaticText(fold_panel, -1, 'Lasts For:')
            lastfor_ctrl = eg.SpinIntCtrl(fold_panel, -1, rule.lastfor)
            lastfor_sizer = h_sizer(lastfor_st, lastfor_ctrl)

            antitheft_sizer = wx.BoxSizer(wx.VERTICAL)
            antitheft_sizer.Add(frequency_sizer)
            antitheft_sizer.Add(duration_sizer)
            antitheft_sizer.Add(lastfor_sizer)
            event_sizer.Add(antitheft_sizer)

            def on_save(_):
                save()
                rule.frequency = frequency_ctrl.GetValue()
                rule.duration = duration_ctrl.GetValue()
                rule.lastfor = lastfor_ctrl.GetValue()
                rule.save()

            def on_cancel(_):
                reset()
                frequency_ctrl.SetValue(rule.frequency)
                duration_ctrl.SetValue(rule.duration)
                lastfor_ctrl.SetValue(rule.lastfor)

        save_button = wx.Button(fold_panel, wx.ID_SAVE, size=(40, 25))
        cancel_button = wx.Button(fold_panel, wx.ID_CANCEL, size=(40, 25))

        save_button.Bind(wx.EVT_BUTTON, on_save)
        cancel_button.Bind(wx.EVT_BUTTON, on_cancel)

        button_sizer = wx.BoxSizer(wx.HORIZONTAL)
        button_sizer.AddStretchSpacer(1)
        button_sizer.Add(save_button, 0, wx.RIGHT, 20)
        button_sizer.Add(cancel_button)
        button_sizer.AddStretchSpacer(1)

        self.Add(top_sizer)
        self.Add(day_ctrl)
        self.Add(event_sizer)
        self.Add(repeat_sizer)
        self.Add(button_sizer)