Ejemplo n.º 1
0
    def __init__(self, parent, ID, log):
        wx.Panel.__init__(self, parent, ID)
        self.log = log

        cal = wx.calendar.CalendarCtrl(
            self,
            -1,
            wx.DateTime_Now(),
            pos=(25, 50),
            style=wx.calendar.CAL_SHOW_HOLIDAYS
            | wx.calendar.CAL_SUNDAY_FIRST
            | wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION)
        self.cal = cal
        self.Bind(wx.calendar.EVT_CALENDAR, self.OnCalSelected, id=cal.GetId())

        # Set up control to display a set of holidays:
        self.Bind(wx.calendar.EVT_CALENDAR_MONTH, self.OnChangeMonth, cal)
        self.holidays = [(1, 1), (10, 31),
                         (12, 25)]  # (these don't move around)
        self.OnChangeMonth()

        cal2 = wx.calendar.CalendarCtrl(self,
                                        -1,
                                        wx.DateTime_Now(),
                                        pos=(325, 50))
Ejemplo n.º 2
0
def BPFSImageFile(fshandler, location, name=None, img=None, width=-1, height=-1, valign="center", bgcolor=None):
    """Handles image files

    If we have to do any conversion on the file then we return PNG
    data.  This used to be a class derived from wx.FSFile, but due to
    various wxPython bugs it instead returns the parameters to make a
    wx.FSFile since a new one has to be made every time.
    """
    # if this is a bad or non-existing image file, use the dummy one!
    if name is None and img is None:
        name=guihelper.getresourcefile('wallpaper.png')
    # special fast path if we aren't resizing or converting image
    if img is None and width<0 and height<0:
        mime=guihelper.getwxmimetype(name)
        # wxPython 2.5.3 has a new bug and fails to read bmp files returned as a stream
        if mime not in (None, "image/x-bmp"):
            return (open(name, "rb"), location, mime, "", wx.DateTime_Now())

    if img is None:
        img=wx.Image(name)

    if width>0 and height>0:
        b=ScaleImageIntoBitmap(img, width, height, bgcolor, valign)
    else:
        b=img.ConvertToBitmap()

    with common.usetempfile('png') as f:
        if not b.SaveFile(f, wx.BITMAP_TYPE_PNG):
            raise Exception, "Saving to png failed"
        data=open(f, "rb").read()
        return (cStringIO.StringIO(data), location, "image/png", "", wx.DateTime_Now())
Ejemplo n.º 3
0
 def SetDateControls(self, fgs, fgs1):
     self._start_date_chkbox=wx.CheckBox(self, id=wx.NewId(), 
                                          label='Start Date:',
                                          style=wx.ALIGN_RIGHT)
     fgs.Add(self._start_date_chkbox, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTRE_VERTICAL, 0)
     self._start_date=wx.calendar.CalendarCtrl(self, -1, wx.DateTime_Now(),
                                       style = wx.calendar.CAL_SUNDAY_FIRST
                                       | wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION)
     self._start_date.Disable()
     fgs.Add(self._start_date, 1, wx.ALIGN_LEFT, 5)
     self._end_date_chkbox=wx.CheckBox(self, id=wx.NewId(),
                                        label='End Date:',
                                        style=wx.ALIGN_RIGHT)
     fgs.Add(self._end_date_chkbox, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTRE_VERTICAL, 0)
     self._end_date=wx.calendar.CalendarCtrl(self, -1, wx.DateTime_Now(),
                                       style = wx.calendar.CAL_SUNDAY_FIRST
                                       | wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION)
     self._end_date.Disable()
     fgs.Add(self._end_date, 1, wx.ALIGN_LEFT, 5)
     self._preset_date_chkbox=wx.CheckBox(self, -1, label='Preset Duration',
                                          style=wx.ALIGN_RIGHT)
     fgs.Add(self._preset_date_chkbox, 0,
             wx.ALIGN_RIGHT|wx.ALIGN_CENTRE_VERTICAL, 0)
     self._preset_date=wx.Choice(self, -1, choices=('This Week',
                                                    'This Month',
                                                    'This Year',
                                                    'Next 7 Days',))
     self._preset_date.SetSelection(1)
     self._preset_date.Disable()
     fgs.Add(self._preset_date, 0, wx.ALIGN_LEFT, 5)
     wx.EVT_CHECKBOX(self, self._preset_date_chkbox.GetId(),
                     self.OnCheckBox)
Ejemplo n.º 4
0
 def __init__(self, parent, mytitle):
     """Keyword arguments:
     parent : mainframe 
     mytitle : title of dialog box 
     """
     wx.Dialog.__init__(self, parent, wx.ID_ANY, mytitle)
     self.parent = parent
     vbox = wx.BoxSizer(wx.VERTICAL)
     hbox = wx.BoxSizer(wx.HORIZONTAL)
     fgs = wx.FlexGridSizer(0, 0, 9,
                            25)  #3,2  => 0,0 means it grows dynamically
     self.queryTypeLabel = wx.StaticText(self, label='Query type?')
     myChoices = ['Bond', 'Client', 'Salesperson', 'Issuer', 'Country']
     self.queryType = myChoices[0]
     #self.comboBox1 = PromptingComboBox(self,myChoices[0],myChoices)
     self.comboBox1 = wx.ComboBox(self,
                                  wx.ID_ANY,
                                  myChoices[0],
                                  style=wx.CB_DROPDOWN,
                                  choices=myChoices)
     sizerQueryType = wx.BoxSizer(wx.HORIZONTAL)
     sizerQueryType.Add(self.queryTypeLabel, 0, wx.ALL | wx.CENTER, 5)
     sizerQueryType.Add(self.comboBox1, 0, wx.ALL | wx.CENTER, 5)
     self.queryIDLabel = wx.StaticText(self, label='ID?')
     myChoices = parent.bondlist
     self.comboBox2 = PromptingComboBox(self, myChoices[0], myChoices)
     self.Bind(wx.EVT_COMBOBOX, self.editComboBox2, self.comboBox1)
     #self.Bind(wx.EVT_TXT, self.editComboBox2,self.comboBox1)
     sizerQueryID = wx.BoxSizer(wx.HORIZONTAL)
     sizerQueryID.Add(self.queryIDLabel, 0, wx.ALL | wx.CENTER, 5)
     sizerQueryID.Add(self.comboBox2, 0, wx.ALL | wx.CENTER, 5)
     self.startDateLabel = wx.StaticText(self, label='Start date?')
     self.startcalendar = wx.DatePickerCtrl(self, wx.ID_ANY,
                                            wx.DateTime_Now())
     sizerStartDate = wx.BoxSizer(wx.HORIZONTAL)
     sizerStartDate.Add(self.startDateLabel, 0, wx.ALL | wx.CENTER, 5)
     sizerStartDate.Add(self.startcalendar, 0, wx.ALIGN_RIGHT | wx.CENTER,
                        5)
     self.endDateLabel = wx.StaticText(self, label='End date?')
     self.endcalendar = wx.DatePickerCtrl(self, wx.ID_ANY,
                                          wx.DateTime_Now())
     sizerEndDate = wx.BoxSizer(wx.HORIZONTAL)
     sizerEndDate.Add(self.endDateLabel, 0, wx.ALL | wx.CENTER, 5)
     sizerEndDate.Add(self.endcalendar, 0, wx.ALIGN_RIGHT | wx.CENTER, 5)
     fgs.AddMany([(self.queryTypeLabel), (self.comboBox1, 1, wx.EXPAND),
                  (self.queryIDLabel), (self.comboBox2, 1, wx.EXPAND),
                  (self.startDateLabel, 1, wx.EXPAND),
                  (self.startcalendar, 1, wx.EXPAND),
                  (self.endDateLabel, 1, wx.EXPAND),
                  (self.endcalendar, 1, wx.EXPAND)])
     #fgs.AddGrowableRow(2, 1)
     #fgs.AddGrowableCol(1, 1)
     hbox.Add(fgs, proportion=1, flag=wx.ALL | wx.EXPAND, border=15)
     okBtn = wx.Button(self, wx.ID_OK)
     vbox.Add(hbox, 0, wx.ALL | wx.CENTER, 5)
     vbox.Add(okBtn, 0, wx.ALL | wx.CENTER, 5)
     self.SetSizer(vbox)
     self.SetSizerAndFit(vbox)
     self.Centre()
Ejemplo n.º 5
0
    def on_row_selected(self, event):
        """
        Set the date pickers to match the start and end date of the row selected dates
        The date variable needs to be reset in order to get the start dates to stick
        :param event:
        :return:
        """
        self.spatial_plot.reset_highlighter()
        self.temporal_plot.clear_plot()
        date = wx.DateTime()
        start_date_string = self.table.get_selected_row()[3]
        if date.ParseFormat(start_date_string, "%Y-%m-%d") == -1:
            raise Exception("start_date_string is not in the right format")
        self._row_start_date = date
        self.start_date_picker.SetValue(date)
        self.start_date_object = date

        date = wx.DateTime()  # Need to reset the date

        end_date_string = self.table.get_selected_row()[4]
        if str(end_date_string) == "None":
            self.end_date_picker.SetValue(wx.DateTime_Now())
        elif date.ParseFormat(end_date_string, "%Y-%m-%d") == -1:
            raise Exception("end_date_string is not in the right format")
        else:
            self.end_date_picker.SetValue(date)
            self.end_date_object = date
        self._row_end_date = self.end_date_picker.GetValue()

        #  Plot Spatial
        self.plot_spatial(self.get_selected_id(),
                          self.table.get_selected_row()[1])
Ejemplo n.º 6
0
    def onAddMonitor(self, event):
        # add a default monitor to cfg_dict
        self.n_mons = self.n_mons + 1
        self.cfg_dict[0]['Monitors'] = self.n_mons
        self.cfg_dict.append({
            'mon_name':
            'Monitor%d' % self.n_mons,
            'sourcetype':
            1,
            'issdmonitor':
            False,
            'source':
            os.path.join(self.cfg.defaultDir, 'source.avi'),
            'fps_recording':
            1,
            'start_datetime':
            wx.DateTime_Now(),
            'track':
            False,
            'tracktype':
            0,
            'maskfile':
            os.path.join(self.cfg.defaultDir, 'mask.msk'),
            'datafolder':
            self.cfg.defaultDir
        })

        # add to cfg object
        self.cfg.dict_to_cfgObject(self.cfg_dict)

        # add to combobox
        self.mon_choice.Append('Monitor %d' % self.n_mons)
        self.mon_choice.SetSelection(self.n_mons - 1)  # combobox is 0-indexed
        self.update_cfgpanel(self.n_mons)
Ejemplo n.º 7
0
    def OnButtonClick(self, event):
        if self.radio12to24.GetValue():
            self.time24.SetValue(self.time12.GetValue())

        elif self.radio24to12.GetValue():
            self.time12.SetValue(self.time24.GetValue())

        elif self.radioWx.GetValue():
            now = wx.DateTime_Now()
            self.time12.SetValue(now)
            # (demonstrates that G/SetValue returns/takes a wx.DateTime)
            self.time24.SetValue(self.time12.GetValue(as_wxDateTime=True))

            # (demonstrates that G/SetValue returns/takes a wx.TimeSpan)
            self.spinless_ctrl.SetValue(
                self.time12.GetValue(as_wxTimeSpan=True))

        elif self.radioMx.GetValue():
            from mx import DateTime
            now = DateTime.now()
            self.time12.SetValue(now)

            # (demonstrates that G/SetValue returns/takes a DateTime)
            self.time24.SetValue(self.time12.GetValue(as_mxDateTime=True))

            # (demonstrates that G/SetValue returns/takes a DateTimeDelta)
            self.spinless_ctrl.SetValue(
                self.time12.GetValue(as_mxDateTimeDelta=True))
Ejemplo n.º 8
0
 def __init__(self, X, Y, width, height, cntrl):
     self.controller = wx.calendar.CalendarCtrl(
         cntrl.panel,
         -1,
         wx.DateTime_Now(), (X, Y),
         wx.Size(width, height),
         style=wx.calendar.CAL_SHOW_HOLIDAYS)
Ejemplo n.º 9
0
	def __init__(self, parent, ID, x):
		self.x = x
		wx.Panel.__init__(self, parent, -1, size=(280, wx.EXPAND))
		self.SetBackgroundColour('black')
		self.fonts = wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, 'Sans')
		cal = wx.calendar.CalendarCtrl(self, -1, wx.DateTime_Now(), pos = (0, 0), size=(280, 210), style=wx.calendar.CAL_SHOW_HOLIDAYS | wx.calendar.CAL_MONDAY_FIRST | wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION)
		cal.SetHeaderColours('blue', '#A49565')
		cal.SetHighlightColours('black', 'cyan')
		cal.SetFont(self.fonts)
		cal.SetBackgroundColour('black')
		self.cal = cal
		self.Bind(wx.calendar.EVT_CALENDAR, self.OnCalSelected, id=cal.GetId())
		self.basicText = wx.TextCtrl(self, -1, _("Two click to number and write name"), size=(270, 30), pos=(5,220))
		patch = sys_inf.DATA_PATH + 'Data/'
		self.list = []
		for i in os.listdir(patch):
			self.z = patch + i
			if os.path.isfile(self.z):
				pass
			else:
				self.list.append(self.z.split('/')[5])
		
		buttons = wx.Button(self, 2, _("Save"), size=(120,30), pos=(5, 290))
		buttons.SetForegroundColour('lightgray')
		buttons.Bind(wx.EVT_BUTTON, self.Sav, id=2)
		bu = wx.Button(self, 2, _("Exit"), size=(120,30), pos=(154, 290))
		bu.SetForegroundColour('lightgray')
		bu.Bind(wx.EVT_BUTTON, self.Ex, id=2)
Ejemplo n.º 10
0
    def month_changed(self, evt=None):
        """
        Link the calendars together so if one changes, they all change.

        TODO: Maybe wx.calendar.CAL_HITTEST_INCMONTH could be checked and
        the event skipped, rather than now where we undo the update after
        the event has gone through.
        """
        evt.Skip()
        cal_index = self.cal_ctrls.index(evt.GetEventObject())
        current_date = self.cal_ctrls[cal_index].GetDate()
        for i, cal in enumerate(self.cal_ctrls):
            # Current month is already updated, just need to shift the others
            if i != cal_index:
                new_date = self.shift_datetime(current_date, cal_index - i)
                cal.SetDate(new_date)
                cal.highlight_changed()

        # Back-up if we're not allowed to move into future months.
        if not self.allow_future:
            month = self.cal_ctrls[0].GetDate().GetMonth() + 1
            year = self.cal_ctrls[0].GetDate().GetYear()
            if (year, month) > (self.today.year, self.today.month):
                for i, cal in enumerate(self.cal_ctrls):
                    new_date = self.shift_datetime(wx.DateTime_Now(), -i)
                    cal.SetDate(new_date)
                    cal.highlight_changed()

        # Redraw the selected days.
        self.selected_list_changed()
Ejemplo n.º 11
0
    def __init__(self, parent, name='datetimectrl', use_now=False):
        self.name = name
        panel = self.panel = wx.Panel(parent)
        bgcol = wx.Colour(250, 250, 250)

        datestyle = wx.DP_DROPDOWN | wx.DP_SHOWCENTURY | wx.DP_ALLOWNONE

        self.datectrl = wx.DatePickerCtrl(panel,
                                          size=(120, -1),
                                          style=datestyle)
        self.timectrl = masked.TimeCtrl(panel,
                                        -1,
                                        name=name,
                                        limited=False,
                                        fmt24hr=True,
                                        oob_color=bgcol)
        timerheight = self.timectrl.GetSize().height
        spinner = wx.SpinButton(panel, -1, wx.DefaultPosition,
                                (-1, timerheight), wx.SP_VERTICAL)
        self.timectrl.BindSpinButton(spinner)
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(self.datectrl, 0, wx.ALIGN_CENTER)
        sizer.Add(self.timectrl, 0, wx.ALIGN_CENTER)
        sizer.Add(spinner, 0, wx.ALIGN_LEFT)
        panel.SetSizer(sizer)
        sizer.Fit(panel)
        if use_now:
            self.timectrl.SetValue(wx.DateTime_Now())
Ejemplo n.º 12
0
    def show_popup(self, event):
        def on_cal_changed(event):
            dt = event.GetDate()
            if is_date_conversion_supported():
                self.Parent.choose_item(dt.Format("%B ") + str(dt.Day))
            else:
                self.Parent.choose_item(dt.Format("%m.%d"))

        def on_cal(event):
            win.Destroy()

        win = wx.PopupTransientWindow(self, wx.NO_BORDER)

        now_date = date_to_mmdd(self.text.Value, return_formatted=False)

        if now_date is None:
            now_date = wx.DateTime_Now()

        style = 0

        if osutils.is_msw():
            style = wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION

        panel = wx.Panel(win)

        cal = wx.calendar.CalendarCtrl(panel,
                                       -1,
                                       now_date,
                                       pos=(1, 1),
                                       style=wx.RAISED_BORDER | style)

        panel.ClientSize = cal.Size + (1, 1)
        cal.Bind(wx.calendar.EVT_CALENDAR_SEL_CHANGED, on_cal_changed)
        cal.Bind(wx.calendar.EVT_CALENDAR, on_cal)
        size_combo = 0

        if not style & wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION:
            # hide the spin control
            for child in panel.Children:
                if isinstance(child, wx.SpinCtrl):
                    child.Hide()

                    # we will shorten ourselves by this amount
                    size_combo = child.Size[1] + 6

            # make combo fill up rest of space
            for child in panel.Children:
                if isinstance(child, wx.ComboBox):
                    child.Size = cal.Size[0], -1

        win.Size = panel.GetSize() - (0, size_combo)

        # Show the popup right below or above the button
        # depending on available screen space...
        btn = event.GetEventObject()
        pos = btn.ClientToScreen((btn.Size[0], 0))
        win.Position(pos, (-btn.Size[0], btn.Size[1]))

        win.Popup()
Ejemplo n.º 13
0
	def __set_properties(self):
		# begin wxGlade: pwxSubmitJob.__set_properties
		self.SetTitle("Job Submission - Nov 12, 2006 - Kamran Husain")
		self.combo_box_plc.SetSelection(0)
		self.radio_box_extract.SetSelection(3)
		self.radio_box_use_node.SetSelection(1)
		now = wx.DateTime_Now()
		self.spin_ctrl_hour.SetValue(now)
Ejemplo n.º 14
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))
Ejemplo n.º 15
0
 def SetDateControls(self, fgs, fgs1):
     self._start_date_chkbox=wx.CheckBox(self, id=wx.NewId(), 
                                          label='Start Date:',
                                          style=wx.ALIGN_RIGHT)
     fgs.Add(self._start_date_chkbox, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTRE_VERTICAL, 0)
     self._start_date=wx.calendar.CalendarCtrl(self, -1, wx.DateTime_Now(),
                                       style = wx.calendar.CAL_SUNDAY_FIRST
                                       | wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION)
     self._start_date.Disable()
     fgs.Add(self._start_date, 1, wx.ALIGN_LEFT, 5)
     self._end_date_chkbox=wx.CheckBox(self, id=wx.NewId(),
                                        label='End Date:',
                                        style=wx.ALIGN_RIGHT)
     fgs.Add(self._end_date_chkbox, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTRE_VERTICAL, 0)
     self._end_date=wx.calendar.CalendarCtrl(self, -1, wx.DateTime_Now(),
                                       style = wx.calendar.CAL_SUNDAY_FIRST
                                       | wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION)
     self._end_date.Disable()
     fgs.Add(self._end_date, 1, wx.ALIGN_LEFT, 5)
Ejemplo n.º 16
0
    def test_get_values(self):
        import wx
        site_url = "http://data.iutahepscor.org/LoganRiverWOF/cuahsi_1_1.asmx?WSDL"
        api = wateroneflow.WaterOneFlow(site_url)

        site_code = "LR_WaterLab_AA"
        variable = "BattVolt"
        start_date = wx.DateTime_Now() - 7 * wx.DateSpan_Day()
        end_date = wx.DateTime_Now()

        # Dates must be in YEAR-MONTH-DAY format
        start_date = start_date.FormatISODate()
        end_date = end_date.FormatISODate()

        data = api.getValuesObject(site_code=site_code,
                                   variable_code=variable,
                                   beginDate=start_date,
                                   endDate=end_date)
        self.assertIsInstance(data, object)
Ejemplo n.º 17
0
    def __init__(self, parent, columns=None):
        SimulationsPlotView.__init__(self, parent)

        if columns:
            self.table.set_columns(columns)

        self.data = {}  # Dictionary to hold the data respective to the row ID
        self.geometries = {}  # Holds the geometries respective to the row ID
        self.start_date_object = wx.DateTime_Now(
        ) - 1 * wx.DateSpan_Day()  # Default date is yesterday
        self.end_date_object = wx.DateTime_Now()  # Default date is today
        self._row_start_date = None
        self._row_end_date = None

        self.start_date_picker.SetValue(self.start_date_object)
        self.end_date_picker.SetValue(self.end_date_object)

        # Adding room for the x axis labels to be visible
        self.temporal_plot.add_padding_to_plot(bottom=0.15)
        self.spatial_plot.add_padding_to_plot(bottom=0.15)

        # Tool tips
        self.export_button.SetToolTip(
            wx.ToolTip("Export data of highlighted region"))

        # Pop up menu
        self.popup_menu = wx.Menu()
        export_menu = self.popup_menu.Append(1, "Export All")

        # Bindings
        self.refresh_button.Bind(wx.EVT_BUTTON, self.on_refresh)
        self.export_button.Bind(wx.EVT_BUTTON, self.on_export)
        self.table.Bind(wx.EVT_LIST_ITEM_SELECTED, self.on_row_selected)
        self.start_date_picker.Bind(wx.EVT_DATE_CHANGED,
                                    self.on_start_date_change)
        self.end_date_picker.Bind(wx.EVT_DATE_CHANGED, self.on_end_date_change)
        self.spatial_plot.canvas.mpl_connect('pick_event',
                                             self.on_pick_spatial)
        self.table.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK,
                        self.on_table_right_click)
        self.Bind(wx.EVT_MENU, self.on_export_menu, export_menu)
Ejemplo n.º 18
0
 def Today(self):
     today = datetime.date.today()
     if not self.today or self.today != today:
         # reset data to show 'current date only' events today
         Data.getMonths()
     self.today = today
     y, m, d = self.today.strftime("%Y %m %d").split()
     self.selday = (y, m, d)
     self.tdy.SetLabel("%s " % self.FormatDate(y, m, d))
     self.cal.SetDate(wx.DateTime_Now())
     self.showDay(self.selday[0], self.selday[1], self.selday[2])
     self.Focus('cal')
Ejemplo n.º 19
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))
Ejemplo n.º 20
0
    def OnKeyDown(self, event):
        if not self.hasFocus:
            event.Skip()
            return

        key_code = event.KeyCode()

        if key_code == wx.WXK_TAB:
            forward = not event.ShiftDown()
            ne = wx.NavigationKeyEvent()
            ne.SetDirection(forward)
            ne.SetCurrentFocus(self)
            ne.SetEventObject(self)
            self.GetParent().GetEventHandler().ProcessEvent(ne)
            event.Skip()
            return

        delta = None

        if key_code == wx.WXK_UP:
            delta = -7
        elif key_code == wx.WXK_DOWN:
            delta = 7
        elif key_code == wx.WXK_LEFT:
            delta = -1
        elif key_code == wx.WXK_RIGHT:
            delta = 1
        elif key_code == wx.WXK_HOME:
            curDate = wx.DateTimeFromDMY(int(self.cal_days[self.sel_key]),
                                         self.month - 1, self.year)
            newDate = wx.DateTime_Now()
            ts = newDate - curDate
            delta = ts.GetDays()

        if delta <> None:
            curDate = wx.DateTimeFromDMY(int(self.cal_days[self.sel_key]),
                                         self.month - 1, self.year)
            timeSpan = wx.TimeSpan_Days(delta)
            newDate = curDate + timeSpan

            if curDate.GetMonth() == newDate.GetMonth():
                self.set_day = newDate.GetDay()
                key = self.sel_key + delta
                self.SelectDay(key)
            else:
                self.month = newDate.GetMonth() + 1
                self.year = newDate.GetYear()
                self.set_day = newDate.GetDay()
                self.sel_key = None
                self.DoDrawing(wx.ClientDC(self))

        event.Skip()
Ejemplo n.º 21
0
    def __init__(self, parent):
        wx.Frame.__init__(self, parent=parent, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize,
                          style=wx.FRAME_FLOAT_ON_PARENT | wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER ^ wx.MAXIMIZE_BOX)
        panel = wx.Panel(self)
        today = wx.DateTime_Now()

        # Labels
        name_label = wx.StaticText(panel, label="Name: ")
        description_label = wx.StaticText(panel, label="Description: ")
        type_label = wx.StaticText(panel, label="Type: ")
        url_label = wx.StaticText(panel, label="URL: ")
        start_date_label = wx.StaticText(panel, label="Start Date: ")
        phone_label = wx.StaticText(panel, label="Phone: ")
        email_label = wx.StaticText(panel, label="Email: ")

        # Textboxes/Dropdown/etc
        self.name_textbox = wx.TextCtrl(panel)
        self.description_textbox = wx.TextCtrl(panel)
        self.type_combo = wx.ComboBox(panel, style=wx.CB_READONLY)
        self.url_textbox = wx.TextCtrl(panel)
        self.start_date_picker = wx.DatePickerCtrl(panel, id=wx.ID_ANY, dt=today)
        self.phone_textbox = wx.TextCtrl(panel)
        self.email_textbox = wx.TextCtrl(panel)
        self.accept_button = wx.Button(panel, label="Accept")
        self.cancel_button = wx.Button(panel, label="Cancel")

        # Sizer
        sizer = wx.GridBagSizer(5, 5)
        button_sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(name_label, pos=(1, 0), flag=wx.LEFT, border=15)
        sizer.Add(description_label, pos=(2, 0), flag=wx.LEFT, border=15)
        sizer.Add(type_label, pos=(3, 0), flag=wx.LEFT, border=15)
        sizer.Add(url_label, pos=(4, 0), flag=wx.LEFT, border=15)
        sizer.Add(start_date_label, pos=(5, 0), flag=wx.LEFT, border=15)
        sizer.Add(phone_label, pos=(6, 0), flag=wx.LEFT, border=15)
        sizer.Add(email_label, pos=(7, 0), flag=wx.LEFT, border=15)

        sizer.Add(self.name_textbox, pos=(1, 1), span=(1, 1), flag=wx.EXPAND | wx.RIGHT, border=10)
        sizer.Add(self.description_textbox, pos=(2, 1), span=(1, 1), flag=wx.EXPAND | wx.RIGHT, border=10)
        sizer.Add(self.type_combo, pos=(3, 1), span=(1, 1), flag=wx.EXPAND | wx.RIGHT, border=10)
        sizer.Add(self.url_textbox, pos=(4, 1), span=(1, 1), flag=wx.EXPAND | wx.RIGHT, border=10)
        sizer.Add(self.start_date_picker, pos=(5, 1), span=(1, 1), flag=wx.EXPAND | wx.RIGHT, border=10)
        sizer.Add(self.phone_textbox, pos=(6, 1), span=(1, 1), flag=wx.EXPAND | wx.RIGHT, border=10)
        sizer.Add(self.email_textbox, pos=(7, 1), span=(1, 1), flag=wx.EXPAND | wx.RIGHT, border=10)
        sizer.Add(button_sizer, pos=(8, 1), span=(1, 1), flag=wx.ALL | wx.EXPAND | wx.RIGHT, border=10)
        button_sizer.Add(self.accept_button, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL)
        button_sizer.Add(self.cancel_button, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL)

        panel.SetSizer(sizer)
        sizer.Fit(self)

        self.Show()
Ejemplo n.º 22
0
    def GetModalData(self, aItem):
        """ """
        aItem.Name = self.TextCtrlAlarmType.GetValue()
        tm = self.TimeCtrlAlarmTime.GetValue(as_wxDateTime=True)
        aTime = wx.DateTime_Now()
        aTime.SetHour(tm.GetHour())
        aTime.SetMinute(tm.GetMinute())
        aTime.SetSecond(tm.GetSecond())
        aItem.SetAlarmTime(aTime)

        aItem.SoundFile = self.TextCtrlAlarmFile.GetValue()

        aItem.AlarmOnce = not self.EveryDayBtn.GetValue()
Ejemplo n.º 23
0
    def OnSendEvent(self, event):
        e_obj = event.GetEventObject()
        if e_obj == self.evt_btn:
            # Send a EVT_MY_EVENT
            new_evt = MyEvent(self.GetId())
        else:
            # Send a EVT_MY_TIME_EVENT
            ctime = wx.DateTime_Now().FormatTime()
            new_evt = MyTimeEvent(self.GetId(), ctime)

        # Post the event to the event queue
        new_evt.SetEventObject(self)
        wx.PostEvent(self.panel, new_evt)
Ejemplo n.º 24
0
 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()
Ejemplo n.º 25
0
 def ClearField(self):
     controls = self.editSizer.GetChildren()
     for ctrl in controls:
         widget = ctrl.GetWindow()
         if isinstance(widget, wx.TextCtrl):
             widget.Clear()
         elif isinstance(widget, wx.DatePickerCtrl):
             widget.SetValue(wx.DateTime_Now())
         elif isinstance(widget, wx.CheckBox):
             widget.SetValue(False)
     self.txt_emp_id.SetFocus()
     self.refreshData(self.grid)
     self.SaveBtn.Enable(True)
     self.UpdateBtn.Enable(False)
Ejemplo n.º 26
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)
Ejemplo n.º 27
0
    def __init__(self, parent, log):
        self.log = log
        scroll.ScrolledPanel.__init__(self, parent, -1)
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.editList = []

        label = wx.StaticText(
            self, -1, """\
Here masked TextCtrls that have default values.  The states
control has a list of valid values, and the unsigned integer
has a legal range specified.
""")
        label.SetForegroundColour("Blue")
        requireValid = wx.CheckBox(self, -1, "Require Valid Value")
        self.Bind(wx.EVT_CHECKBOX,
                  self.onRequireValid,
                  id=requireValid.GetId())

        header = wx.BoxSizer(wx.HORIZONTAL)
        header.Add(label, 0, flag=wx.ALIGN_LEFT | wx.ALL, border=5)
        header.Add((75, 0))
        header.Add(requireValid, 0, flag=wx.ALIGN_LEFT | wx.ALL, border=10)

        grid = wx.FlexGridSizer(cols=5, vgap=10, hgap=10)
        self.labelGeneralTable(grid)

        controls = [
            #description        mask                    excl format     regexp                              range,list,initial
            ("U.S. State (2 char)", "AA", "", 'F!_', "[A-Z]{2}", '',
             masked.states, masked.states[0]),
            ("Integer (signed)", "#{6}", "", 'F-_', "", '', '', ' 0    '),
            ("Integer (unsigned)\n(1-399)", "######", "", 'F_', "", (1, 399),
             '', '1     '),
            ("Float (signed)", "#{6}.#{9}", "", 'F-_R', "", '', '',
             '000000.000000000'),
            ("Date (MDY) + Time", "##/##/#### ##:##:## AM",
             'BCDEFGHIJKLMNOQRSTUVWXYZ', 'DF!', "", '', '',
             wx.DateTime_Now().Format("%m/%d/%Y %I:%M:%S %p")),
        ]
        self.layoutGeneralTable(controls, grid)

        self.sizer.Add(header, 0, flag=wx.ALIGN_LEFT | wx.ALL, border=5)
        self.sizer.Add(grid, 0, flag=wx.ALIGN_LEFT | wx.ALL, border=5)

        self.SetSizer(self.sizer)
        self.SetAutoLayout(1)
        self.SetupScrolling()
Ejemplo n.º 28
0
    def OnTimer(self, evt):
        """ """
        now = wx.DateTime_Now()
        #log.debug("On Timer: " + now.Format("%H:%M:%S"))
        timeSpan = now.Subtract(self.LastClockTime)
        self.LastClockTime = now

        #Time rollback  or ajusted
        clkSpan = wx.TimeSpan(0, 0, int(self.ClockInterval * 2), 0)
        if timeSpan.IsNegative() or timeSpan.IsLongerThan(clkSpan):
            print "Time Revised"
            for item in self.AlamerList:
                item.AlarmReset()

        for item in self.AlamerList:
            if item.AlarmUp(now, self.ClockInterval):
                item.AlarmNotify(self)
Ejemplo n.º 29
0
    def DoDrawFace(self, dc, rect, timesz):
        """Draw the face of the watch
        @param dc: Device Context
        @param rect: face rect
        @param timesz: Size of time rect
        """
        cbrush = dc.GetBrush()

        # Create a GraphicsContext
        gc = dc.GetGraphicsContext()

        # Find the center of the rect
        center = (rect.x + (rect.width / 2), rect.y + (rect.height / 2))

        # Draw a circle for the face
        radius = rect.width / 2
        brush = gc.CreateRadialGradientBrush(center[0], center[1], center[0],
                                             center[1], radius * 1.25,
                                             wx.WHITE, wx.BLACK)
        gc.SetBrush(brush)
        pen = dc.GetPen()
        dc.SetPen(wx.Pen(wx.BLACK, 2))
        dc.DrawCircle(center[0], center[1], rect.width / 2)
        dc.SetPen(pen)

        # Draw a rectangle for the time display in the center
        # of the face.
        timerect = wx.Rect(width=timesz[0], height=timesz[1])
        timerect = timerect.CenterIn(rect)
        self.timerect = timerect  # save time rect
        x, y = timerect.x, timerect.y
        y2 = y + timerect.height
        brush = gc.CreateLinearGradientBrush(x, y * .9, x, y2, wx.BLUE,
                                             wx.WHITE)
        gc.SetBrush(brush)
        dc.DrawRectangleRect(timerect)

        # Draw the current time in the watch
        dt = wx.DateTime_Now()
        timestr = dt.FormatTime()
        dc.DrawLabel(timestr, timerect, wx.ALIGN_CENTER)

        # Restore the brush
        dc.SetBrush(cbrush)
Ejemplo n.º 30
0
    def __init__(self, parent, ID, PtID):
        wx.Panel.__init__(self, parent, ID)

        self.PtID = PtID
        self.toggler = 'Active'
        self.todoTitle = wx.StaticText(self, -1, self.toggler)
        titlefont = wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.BOLD)
        self.todoTitle.SetFont(titlefont)
        todo_columns = (('Date', 110), ('Description', 250), ('Priority', 55),
                        ('Category', 100), ('Memo', 200), ('Due Date', 85),
                        ('Completed', 0), ('ToDoNumber', 0))
        todo_items = todo_find(self.PtID)
        self.todo_list = EMR_utilities.buildCheckListCtrl(
            self, todo_columns, todo_items)

        lefttodo = wx.BoxSizer(wx.VERTICAL)
        righttodo = wx.BoxSizer(wx.VERTICAL)
        mainsizer = wx.BoxSizer(wx.HORIZONTAL)

        self.cal = wx.calendar.CalendarCtrl(self, -1, wx.DateTime_Now(),\
                             style = wx.calendar.CAL_SHOW_HOLIDAYS
                             | wx.calendar.CAL_SUNDAY_FIRST
                             | wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION)
        self.Bind(wx.calendar.EVT_CALENDAR,
                  self.OnCalSelected,
                  id=self.cal.GetId())

        buttons = (('Remove', self.OnRemove, lefttodo), ('Edit', self.OnEdit, lefttodo), \
            ('Complete', self.OnComplete, lefttodo), \
            ('Test', self.OnTest, lefttodo), ('Consult', self.OnConsult, lefttodo), \
            ('Toggle', self.OnToggle, lefttodo), ('Not Done', self.OnNotDone, lefttodo))
        for label, handler, sizer in buttons:
            EMR_utilities.buildOneButton(self, self, label, handler, sizer)

        self.addtodo = AddToDo(self, -1, self.PtID, self.todo_list)
        righttodo.Add(self.todoTitle, 0, wx.ALIGN_CENTER)
        righttodo.Add(self.todo_list, 1.5, wx.EXPAND | wx.ALL, 5)
        righttodo.Add(self.addtodo, 1, wx.EXPAND)
        righttodo.Add(self.cal, 1, wx.ALIGN_RIGHT | wx.ALL, 5)
        mainsizer.Add(lefttodo, 0, wx.ALL, 3)
        mainsizer.Add(righttodo, 1, wx.EXPAND | wx.ALL, 3)
        self.SetSizer(mainsizer)