Пример #1
0
    def __init__(self, parent, image, phoneprofile, origin):
        wx.Dialog.__init__(self,
                           parent,
                           -1,
                           "Image Preview",
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
                           | wx.SYSTEM_MENU | wx.MAXIMIZE_BOX
                           | wx.MINIMIZE_BOX)
        self.phoneprofile = phoneprofile
        self.image = image
        self.skip = False
        self.origin = origin
        self.target = ''

        self.vbsouter = wx.BoxSizer(wx.VERTICAL)
        self.SetupControls(self.vbsouter)
        self.OnTargetSelect(0)

        wx.EVT_BUTTON(
            self, wx.ID_HELP,
            lambda _: wx.GetApp().displayhelpid(helpids.ID_DLG_IMAGEPREVIEW))

        self.SetSizer(self.vbsouter)
        self.vbsouter.Fit(self)

        import guiwidgets
        guiwidgets.set_size("wallpaperpreview", self, 80, 1.0)
 def __init__(self, parent, image, filename, phoneprofile):
     wx.Dialog.__init__(self, parent, -1, "Image Preview", style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.SYSTEM_MENU|wx.MAXIMIZE_BOX|wx.MINIMIZE_BOX)
     self.phoneprofile=phoneprofile
     self.filename=filename
     self.image=image
     vbsouter=wx.BoxSizer(wx.VERTICAL)
     hbs=wx.BoxSizer(wx.HORIZONTAL)
     self.cropselect=ImageCropSelect(self, image)
     vbs=wx.BoxSizer(wx.VERTICAL)
     self.colourselect=wx.lib.colourselect.ColourSelect(self, wx.NewId(), "Background ...", (255,255,255))
     vbs.Add(self.colourselect, 0, wx.ALL|wx.EXPAND, 5)
     wx.lib.colourselect.EVT_COLOURSELECT(self, self.colourselect.GetId(), self.OnBackgroundColour)
     vbs.Add(wx.StaticText(self, -1, "Origin"), 0, wx.ALL, 5)
     self.originbox=wx.ListBox(self, size=(-1, 100))
     vbs.Add(self.originbox, 0, wx.ALL|wx.EXPAND, 5)
     vbs.Add(wx.StaticText(self, -1, "Target"), 0, wx.ALL, 5)
     self.targetbox=wx.ListBox(self, size=(-1,100))
     vbs.Add(self.targetbox, 0, wx.EXPAND|wx.ALL, 5)
     vbs.Add(wx.StaticText(self, -1, "Scale"), 0, wx.ALL, 5)
     for one,(s,_) in enumerate(self.SCALES):
         if s==1: break
     self.slider=wx.Slider(self, -1, one, 0, len(self.SCALES)-1, style=wx.HORIZONTAL|wx.SL_AUTOTICKS)
     wx.EVT_SCROLL(self, self.SetZoom)
     vbs.Add(self.slider, 0, wx.ALL|wx.EXPAND, 5)
     self.zoomlabel=wx.StaticText(self, -1, self.SCALES[one][1])
     vbs.Add(self.zoomlabel, 0, wx.ALL|wx.ALIGN_CENTRE_HORIZONTAL, 5)
     vbs.Add(wx.StaticText(self, -1, "Preview"), 0, wx.ALL, 5)
     self.imagepreview=ImagePreview(self)
     self.cropselect.SetPreviewWindow(self.imagepreview)
     vbs.Add(self.imagepreview, 0, wx.ALL, 5)
     hbs.Add(vbs, 0, wx.ALL, 5)
     hbs.Add(self.cropselect, 1, wx.ALL|wx.EXPAND, 5)
     vbsouter.Add(hbs, 1, wx.EXPAND|wx.ALL, 5)
     vbsouter.Add(wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL), 0, wx.EXPAND|wx.ALL, 5)
     vbsouter.Add(self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.HELP), 0, wx.ALIGN_CENTRE|wx.ALL, 5)
     wx.EVT_LISTBOX(self, self.originbox.GetId(), self.OnOriginSelect)
     wx.EVT_LISTBOX_DCLICK(self, self.originbox.GetId(), self.OnOriginSelect)
     wx.EVT_LISTBOX(self, self.targetbox.GetId(), self.OnTargetSelect)
     wx.EVT_LISTBOX_DCLICK(self, self.targetbox.GetId(), self.OnTargetSelect)
     wx.EVT_BUTTON(self, wx.ID_HELP, lambda _:
                   wx.GetApp().displayhelpid(helpids.ID_DLG_IMAGEPREVIEW))
     self.originbox.Set(phoneprofile.GetImageOrigins().keys())
     self.originbox.SetSelection(0)
     self.OnOriginSelect(None)
     self.SetSizer(vbsouter)
     vbsouter.Fit(self)
     import guiwidgets
     guiwidgets.set_size("wallpaperpreview", self, 80, 1.0)
 def __init__(self, parent, image, phoneprofile, origin):
     wx.Dialog.__init__(self, parent, -1, "Image Preview", style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.SYSTEM_MENU|wx.MAXIMIZE_BOX|wx.MINIMIZE_BOX)
     self.phoneprofile=phoneprofile
     self.image=image
     self.skip=False
     self.origin=origin
     self.target=''
     self.vbsouter=wx.BoxSizer(wx.VERTICAL)
     self.SetupControls(self.vbsouter)
     self.OnTargetSelect(0)
     wx.EVT_BUTTON(self, wx.ID_HELP, lambda _:
                   wx.GetApp().displayhelpid(helpids.ID_DLG_IMAGEPREVIEW))
     self.SetSizer(self.vbsouter)
     self.vbsouter.Fit(self)
     import guiwidgets
     guiwidgets.set_size("wallpaperpreview", self, 80, 1.0)
Пример #4
0
    def __init__(self, parent, id, title, col_labels, data={},
                 config_name=None,
                 style=wx.CAPTION|wx.MAXIMIZE_BOX| \
                 wx.SYSTEM_MENU|wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER):

        wx.Dialog.__init__(self, parent, id=id, title=title, style=style)
        
        self.__col_labels=col_labels
        self.__config_name=config_name
        self.itemDataMap={}
        # main boxsizer
        main_bs=wx.BoxSizer(wx.VERTICAL)
        # add custom controls here
        self.getcontrols(main_bs)
        # create a data preview list with supplied column labels
        self.__list=wx.ListView(self, wx.NewId())
        self.__image_list=wx.ImageList(16, 16)
        self.__ig_up=self.__image_list.Add(wx.ArtProvider_GetBitmap(wx.ART_GO_UP,
                                                             wx.ART_OTHER,
                                                             (16, 16)))
        self.__ig_dn=self.__image_list.Add(wx.ArtProvider_GetBitmap(wx.ART_GO_DOWN,
                                                             wx.ART_OTHER,
                                                             (16, 16)))
        self.__list.SetImageList(self.__image_list, wx.IMAGE_LIST_SMALL)
        li=wx.ListItem()
        li.m_mask=wx.LIST_MASK_TEXT | wx.LIST_MASK_IMAGE
        li.m_image=-1
        for i, d in enumerate(self.__col_labels):
            # insert a column with specified name and width
            li.m_text=d[1]
            self.__list.InsertColumnInfo(i, li)
            self.__list.SetColumnWidth(i, d[2])
        main_bs.Add(self.__list, 1, wx.EXPAND, 0)
        self.populate(data)
        # the Mixin sorter
        listmix.ColumnSorterMixin.__init__(self, len(col_labels))
        # now the buttons
        self.getpostcontrols(main_bs)
        # handle events
        # all done
        self.SetSizer(main_bs)
        self.SetAutoLayout(True)
        main_bs.Fit(self)
        # save my own size, if specified
        if config_name is not None:
            guiwidgets.set_size(config_name, self)
            wx.EVT_SIZE(self, self.__save_size)
 def __init__(self, mainwindow, frame, title="Schedule Auto Sync Settings", profile="Default Autosync", id=-1):
     t=title+" - "+profile
     wx.Dialog.__init__(self, frame, id, t,
                       style=wx.CAPTION|wx.SYSTEM_MENU|wx.DEFAULT_DIALOG_STYLE)
     self.mw=mainwindow
     self.profile=profile
     gs=wx.GridBagSizer(10, 10)
     gs.AddGrowableCol(1)
     gs.Add( wx.StaticText(self, -1, "Calender Type"), pos=(0,0), flag=wx.ALIGN_CENTER_VERTICAL)
     calendertype=('None',)
     for entry in self.mw.calenders:
         calendertype+=(entry[0], )
     self.caltype=wx.ComboBox(self, -1, calendertype[0], style=wx.CB_DROPDOWN|wx.CB_READONLY,choices=calendertype)
     gs.Add( self.caltype, pos=(0,1), flag=wx.ALIGN_CENTER_VERTICAL)
     gs.Add( wx.Button(self, self.ID_CALSETTINGS, "Calender Settings..."), pos=(0,2), flag=wx.ALIGN_CENTER_VERTICAL)
     gs.Add( wx.StaticText(self, -1, "Update when phone re-connected"), pos=(1,0), flag=wx.ALIGN_CENTER_VERTICAL)
     self.sync_on_connect=wx.CheckBox(self, wx.NewId(), "")
     gs.Add( self.sync_on_connect, pos=(1,1), flag=wx.ALIGN_CENTER_VERTICAL)
     gs.Add( wx.StaticText(self, -1, "Update Frequency (mins) 0=never"), pos=(2,0), flag=wx.ALIGN_CENTER_VERTICAL)
     self.sync_frequency=wx.lib.intctrl.IntCtrl(self, -1, value=0, min=0, max=1440)
     gs.Add( self.sync_frequency, pos=(2,1), flag=wx.ALIGN_CENTER_VERTICAL)
     bs=wx.BoxSizer(wx.VERTICAL)
     bs.Add(gs, 0, wx.EXPAND|wx.ALL, 10)
     bs.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 7)
     but=self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.HELP)
     bs.Add(but, 0, wx.CENTER|wx.ALL, 10)
     wx.EVT_BUTTON(self, wx.ID_HELP, self.OnHelp)
     wx.EVT_BUTTON(self, wx.ID_CANCEL, self.OnCancel)
     wx.EVT_BUTTON(self, wx.ID_OK, self.OnOK)
     wx.EVT_BUTTON(self, self.ID_CALSETTINGS, self.OnConfigCalender)
     wx.EVT_COMBOBOX(self, self.caltype.GetId(), self.OnCaltypeChange)
     self.settings=AutoSyncSettingsEntry()
     self.SetSizer(bs)
     self.SetAutoLayout(True)
     bs.Fit(self)
     self.getfromfs()
     self.auto_sync_timer_id = wx.NewId()
     self.auto_sync_timer = wx.Timer(self, self.auto_sync_timer_id)
     self.SetAutoSyncTimer()
     guiwidgets.set_size("AutoSyncSettingsDialog", self, screenpct=-1,  aspect=3.5)
     wx.EVT_CLOSE(self, self.OnClose)
 def __init__(self, parent, id, title, col_labels, data={},
              config_name=None,
              style=wx.CAPTION|wx.MAXIMIZE_BOX| \
              wx.SYSTEM_MENU|wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER):
     wx.Dialog.__init__(self, parent, id=id, title=title, style=style)
     self.__col_labels=col_labels
     self.__config_name=config_name
     self.itemDataMap={}
     main_bs=wx.BoxSizer(wx.VERTICAL)
     self.getcontrols(main_bs)
     self.__list=wx.ListView(self, wx.NewId())
     self.__image_list=wx.ImageList(16, 16)
     self.__ig_up=self.__image_list.Add(wx.ArtProvider_GetBitmap(wx.ART_GO_UP,
                                                          wx.ART_OTHER,
                                                          (16, 16)))
     self.__ig_dn=self.__image_list.Add(wx.ArtProvider_GetBitmap(wx.ART_GO_DOWN,
                                                          wx.ART_OTHER,
                                                          (16, 16)))
     self.__list.SetImageList(self.__image_list, wx.IMAGE_LIST_SMALL)
     li=wx.ListItem()
     li.m_mask=wx.LIST_MASK_TEXT | wx.LIST_MASK_IMAGE
     li.m_image=-1
     for i, d in enumerate(self.__col_labels):
         li.m_text=d[1]
         self.__list.InsertColumnInfo(i, li)
         self.__list.SetColumnWidth(i, d[2])
     main_bs.Add(self.__list, 1, wx.EXPAND, 0)
     self.populate(data)
     listmix.ColumnSorterMixin.__init__(self, len(col_labels))
     self.getpostcontrols(main_bs)
     self.SetSizer(main_bs)
     self.SetAutoLayout(True)
     main_bs.Fit(self)
     if config_name is not None:
         guiwidgets.set_size(config_name, self)
         wx.EVT_SIZE(self, self.__save_size)
	def SetUpdated(self, updater):

        self.updater=updater

        self.Refresh(True)

	def OnPaint(self, _):

        if self.updater is not None:

            self.bmp=self.updater()

            self.updater=None

        dc=wx.PaintDC(self)

        dc.DrawBitmap(self.bmp, 0, 0, False)


class  ImagePreviewDialog (wx.Dialog) :
	SCALES=[ (0.25, "1/4"),
             (0.5,  "1/2"),
             (1, "1"),
             (2, "2"),
             (4, "4")]
	    def __init__(self, parent, image, filename, phoneprofile):

        wx.Dialog.__init__(self, parent, -1, "Image Preview", style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.SYSTEM_MENU|wx.MAXIMIZE_BOX|wx.MINIMIZE_BOX)

        self.phoneprofile=phoneprofile

        self.filename=filename

        self.image=image

        vbsouter=wx.BoxSizer(wx.VERTICAL)

        hbs=wx.BoxSizer(wx.HORIZONTAL)

        self.cropselect=ImageCropSelect(self, image)

        vbs=wx.BoxSizer(wx.VERTICAL)

        self.colourselect=wx.lib.colourselect.ColourSelect(self, wx.NewId(), "Background ...", (255,255,255))

        vbs.Add(self.colourselect, 0, wx.ALL|wx.EXPAND, 5)

        wx.lib.colourselect.EVT_COLOURSELECT(self, self.colourselect.GetId(), self.OnBackgroundColour)

        vbs.Add(wx.StaticText(self, -1, "Origin"), 0, wx.ALL, 5)

        self.originbox=wx.ListBox(self, size=(-1, 100))

        vbs.Add(self.originbox, 0, wx.ALL|wx.EXPAND, 5)

        vbs.Add(wx.StaticText(self, -1, "Target"), 0, wx.ALL, 5)

        self.targetbox=wx.ListBox(self, size=(-1,100))

        vbs.Add(self.targetbox, 0, wx.EXPAND|wx.ALL, 5)

        vbs.Add(wx.StaticText(self, -1, "Scale"), 0, wx.ALL, 5)

        for one,(s,_) in enumerate(self.SCALES):

            if s==1: break

        self.slider=wx.Slider(self, -1, one, 0, len(self.SCALES)-1, style=wx.HORIZONTAL|wx.SL_AUTOTICKS)

        wx.EVT_SCROLL(self, self.SetZoom)

        vbs.Add(self.slider, 0, wx.ALL|wx.EXPAND, 5)

        self.zoomlabel=wx.StaticText(self, -1, self.SCALES[one][1])

        vbs.Add(self.zoomlabel, 0, wx.ALL|wx.ALIGN_CENTRE_HORIZONTAL, 5)

        vbs.Add(wx.StaticText(self, -1, "Preview"), 0, wx.ALL, 5)

        self.imagepreview=ImagePreview(self)

        self.cropselect.SetPreviewWindow(self.imagepreview)

        vbs.Add(self.imagepreview, 0, wx.ALL, 5)

        hbs.Add(vbs, 0, wx.ALL, 5)

        hbs.Add(self.cropselect, 1, wx.ALL|wx.EXPAND, 5)

        vbsouter.Add(hbs, 1, wx.EXPAND|wx.ALL, 5)

        vbsouter.Add(wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL), 0, wx.EXPAND|wx.ALL, 5)

        vbsouter.Add(self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.HELP), 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        wx.EVT_LISTBOX(self, self.originbox.GetId(), self.OnOriginSelect)

        wx.EVT_LISTBOX_DCLICK(self, self.originbox.GetId(), self.OnOriginSelect)

        wx.EVT_LISTBOX(self, self.targetbox.GetId(), self.OnTargetSelect)

        wx.EVT_LISTBOX_DCLICK(self, self.targetbox.GetId(), self.OnTargetSelect)

        wx.EVT_BUTTON(self, wx.ID_HELP, lambda _:
                      wx.GetApp().displayhelpid(helpids.ID_DLG_IMAGEPREVIEW))

        self.originbox.Set(phoneprofile.GetImageOrigins().keys())

        self.originbox.SetSelection(0)

        self.OnOriginSelect(None)

        self.SetSizer(vbsouter)

        vbsouter.Fit(self)

        import guiwidgets

        guiwidgets.set_size("wallpaperpreview", self, 80, 1.0)

	def ShowModal(self):

        res=wx.Dialog.ShowModal(self)

        import guiwidgets

        guiwidgets.save_size("wallpaperpreview", self.GetRect())

        return res

	def SetZoom(self, evt):

        self.cropselect.SetZoom(self.SCALES[evt.GetPosition()][0])

        self.zoomlabel.SetLabel(self.SCALES[evt.GetPosition()][1])

        return

	def OnBackgroundColour(self, evt):

        self.cropselect.setlbcolour(evt.GetValue())

	def OnOriginSelect(self, _):

        v=self.originbox.GetStringSelection()

        assert v is not None

        t=self.targetbox.GetStringSelection()

        self.targets=self.phoneprofile.GetTargetsForImageOrigin(v)

        keys=self.targets.keys()

        keys.sort()

        self.targetbox.Set(keys)

        if t in keys:

            self.targetbox.SetSelection(keys.index(t))

        else:

            self.targetbox.SetSelection(0)

        self.OnTargetSelect(None)

	def OnTargetSelect(self, _):

        v=self.targetbox.GetStringSelection()

        print "target is",v

        w,h=self.targets[v]['width'],self.targets[v]['height']

        self.imagepreview.SetSize( (w,h) )

        self.cropselect.setresultsize( (w, h) )

        sz=self.GetSizer()

        if sz is not None:

            sz.Layout()

            self.Refresh(True)

	def GetResultImage(self):

        return self.imagepreview.bmp.ConvertToImage()

	def GetResultParams(self):

        return self.targets[self.targetbox.GetStringSelection()]

	def GetResultOrigin(self):

        return self.originbox.GetStringSelection()


if __name__=='__main__':

    if __debug__:

        def profile(filename, command):

            import hotshot, hotshot.stats, os

            file=os.path.abspath(filename)

            profile=hotshot.Profile(file)

            profile.run(command)

            profile.close()

            del profile

            howmany=100

            stats=hotshot.stats.load(file)

            stats.strip_dirs()

            stats.sort_stats('time', 'calls')

            stats.print_stats(100)

            stats.sort_stats('cum', 'calls')

            stats.print_stats(100)

            stats.sort_stats('calls', 'time')

            stats.print_stats(100)

            sys.exit(0)

    class FakeProfile:

        def GetImageOrigins(self):

            return {"images": {'description': 'General images'},
                    "mms": {'description': 'Multimedia Messages'},
                    "camera": {'description': 'Camera images'}}

        def GetTargetsForImageOrigin(self, origin):

            return {"wallpaper": {'width': 100, 'height': 200, 'description': 'Display as wallpaper'},
                    "photoid": {'width': 100, 'height': 150, 'description': 'Display as photo id'},
                    "outsidelcd": {'width': 90, 'height': 80, 'description': 'Display on outside screen'}}

    def run():

        app=wx.PySimpleApp()

        dlg=ImagePreviewDialog(None, wx.Image("test.jpg"), "foobar.png", FakeProfile())

        dlg.ShowModal()

    if __debug__ and True:

        profile("wp.prof", "run()")

    run()


import fileview

if __name__=='__main__':

    if __debug__:

        def profile(filename, command):

            import hotshot, hotshot.stats, os

            file=os.path.abspath(filename)

            profile=hotshot.Profile(file)

            profile.run(command)

            profile.close()

            del profile

            howmany=100

            stats=hotshot.stats.load(file)

            stats.strip_dirs()

            stats.sort_stats('time', 'calls')

            stats.print_stats(100)

            stats.sort_stats('cum', 'calls')

            stats.print_stats(100)

            stats.sort_stats('calls', 'time')

            stats.print_stats(100)

            sys.exit(0)

    class FakeProfile:

        def GetImageOrigins(self):

            return {"images": {'description': 'General images'},
                    "mms": {'description': 'Multimedia Messages'},
                    "camera": {'description': 'Camera images'}}

        def GetTargetsForImageOrigin(self, origin):

            return {"wallpaper": {'width': 100, 'height': 200, 'description': 'Display as wallpaper'},
                    "photoid": {'width': 100, 'height': 150, 'description': 'Display as photo id'},
                    "outsidelcd": {'width': 90, 'height': 80, 'description': 'Display on outside screen'}}

    def run():

        app=wx.PySimpleApp()

        dlg=ImagePreviewDialog(None, wx.Image("test.jpg"), "foobar.png", FakeProfile())

        dlg.ShowModal()

    if __debug__ and True:

        profile("wp.prof", "run()")

    run()
	def _get_caltype(self):

        return self._data.get(self._caltype_key, 'None')

	def _set_caltype(self, v):

        self._set_or_del(self._caltype_key, v, [''])

	caltype=property(fget=_get_caltype, fset=_set_caltype)
	    def _get_calender_id(self):

        return self._data.get(self._calender_id_key, '')

	def _set_calender_id(self, v):

        self._set_or_del(self._calender_id_key, v, [''])

	calender_id=property(fget=_get_calender_id, fset=_set_calender_id)
	    def _get_sync_on_connect(self):

        return self._data.get(self._sync_on_connect_key, False)

	def _set_sync_on_connect(self, v):

        self._set_or_del(self._sync_on_connect_key, v, [''])

	sync_on_connect=property(fget=_get_sync_on_connect, fset=_set_sync_on_connect)
	    def _get_sync_frequency(self):

        return self._data.get(self._sync_frequency_key, 0)

	def _set_sync_frequency(self, v):

        self._set_or_del(self._sync_frequency_key, v, [''])

	sync_frequency=property(fget=_get_sync_frequency, fset=_set_sync_frequency)

class  AutoSyncSettingsDialog (wx.Dialog) :
	ID_CALSETTINGS=wx.NewId()
	    def __init__(self, mainwindow, frame, title="Schedule Auto Sync Settings", profile="Default Autosync", id=-1):

        t=title+" - "+profile

        wx.Dialog.__init__(self, frame, id, t,
                          style=wx.CAPTION|wx.SYSTEM_MENU|wx.DEFAULT_DIALOG_STYLE)

        self.mw=mainwindow

        self.profile=profile

        gs=wx.GridBagSizer(10, 10)

        gs.AddGrowableCol(1)

        gs.Add( wx.StaticText(self, -1, "Calender Type"), pos=(0,0), flag=wx.ALIGN_CENTER_VERTICAL)

        calendertype=('None',)

        for entry in self.mw.calenders:

            calendertype+=(entry[0], )

        self.caltype=wx.ComboBox(self, -1, calendertype[0], style=wx.CB_DROPDOWN|wx.CB_READONLY,choices=calendertype)

        gs.Add( self.caltype, pos=(0,1), flag=wx.ALIGN_CENTER_VERTICAL)

        gs.Add( wx.Button(self, self.ID_CALSETTINGS, "Calender Settings..."), pos=(0,2), flag=wx.ALIGN_CENTER_VERTICAL)

        gs.Add( wx.StaticText(self, -1, "Update when phone re-connected"), pos=(1,0), flag=wx.ALIGN_CENTER_VERTICAL)

        self.sync_on_connect=wx.CheckBox(self, wx.NewId(), "")

        gs.Add( self.sync_on_connect, pos=(1,1), flag=wx.ALIGN_CENTER_VERTICAL)

        gs.Add( wx.StaticText(self, -1, "Update Frequency (mins) 0=never"), pos=(2,0), flag=wx.ALIGN_CENTER_VERTICAL)

        self.sync_frequency=wx.lib.intctrl.IntCtrl(self, -1, value=0, min=0, max=1440)

        gs.Add( self.sync_frequency, pos=(2,1), flag=wx.ALIGN_CENTER_VERTICAL)

        bs=wx.BoxSizer(wx.VERTICAL)

        bs.Add(gs, 0, wx.EXPAND|wx.ALL, 10)

        bs.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 7)

        but=self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.HELP)

        bs.Add(but, 0, wx.CENTER|wx.ALL, 10)

        wx.EVT_BUTTON(self, wx.ID_HELP, self.OnHelp)

        wx.EVT_BUTTON(self, wx.ID_CANCEL, self.OnCancel)

        wx.EVT_BUTTON(self, wx.ID_OK, self.OnOK)

        wx.EVT_BUTTON(self, self.ID_CALSETTINGS, self.OnConfigCalender)

        wx.EVT_COMBOBOX(self, self.caltype.GetId(), self.OnCaltypeChange)

        self.settings=AutoSyncSettingsEntry()

        self.SetSizer(bs)

        self.SetAutoLayout(True)

        bs.Fit(self)

        self.getfromfs()

        self.auto_sync_timer_id = wx.NewId()

        self.auto_sync_timer = wx.Timer(self, self.auto_sync_timer_id)

        self.SetAutoSyncTimer()

        guiwidgets.set_size("AutoSyncSettingsDialog", self, screenpct=-1,  aspect=3.5)

        wx.EVT_CLOSE(self, self.OnClose)

	def OnCaltypeChange(self, _):

        if self.settings.caltype!=self.caltype.GetValue():

            self.OnConfigCalender()

        return

	def OnConfigCalender(self, _=None):

        old_folder=self.settings.calender_id

        for entry in self.mw.calenders:

            if entry[0]==self.caltype.GetValue():

                if self.settings.caltype!=self.caltype.GetValue():

                    self.settings.calender_id=''    

                filter={}

                for setting in _filter_keys:

                    if self.settings._data.has_key(setting) and self.settings._data[setting]!=None:

                        if setting=="categories":

                            filter[setting]=self.settings._data[setting].split("||")

                        else:

                            filter[setting]=self.settings._data[setting]

                res, temp=entry[1](self.mw, self.settings.calender_id, filter)

                if res==wx.ID_OK:

                    self.settings.calender_id=temp[0]

                    for setting in _filter_keys:

                        if(temp[1].has_key(setting) and temp[1][setting]!=None):

                            if setting=="categories":

                                cat_str=""

                                for cat in temp[1][setting]:

                                    if len(cat_str):

                                        cat_str=cat_str+"||"+cat

                                    else:

                                        cat_str=cat

                                self.settings._data[setting]=cat_str

                            else:

                                self.settings._data[setting]=temp[1][setting]

                        else:

                            if self.settings._data.has_key(setting):

                                del self.settings._data[setting]

                    self.settings.caltype=self.caltype.GetValue()

                else: 

                    self.caltype.SetValue(self.settings.caltype)

                    self.settings.calender_id=old_folder

                return

        return

	def OnCancel(self, _):

        self.saveSize()

        self.EndModal(wx.ID_CANCEL)

        return

	def OnOK(self, _):

        self.saveSize()

        self.EndModal(wx.ID_OK)

        return

	def OnHelp(self, _):

        return

	def OnClose(self, evt):

        self.saveSize()

        self.EndModal(wx.ID_CANCEL)

        return

	def _save_to_db(self):

        db_rr={}

        self.settings.caltype=self.caltype.GetValue()

        self.settings.sync_on_connect=self.sync_on_connect.GetValue()

        self.settings.sync_frequency=self.sync_frequency.GetValue()

        self.settings.id=self.profile

        db_rr[self.settings.id]=AutoSyncSettingsobject(self.settings)

        database.ensurerecordtype(db_rr, autosyncsettingsobjectfactory)

        self.mw.tree.GetActivePhone().GetDatabase().savemajordict(_data_key, db_rr)

	def getfromfs(self):

        self.settings=_getsettings(self.mw, self.profile)

        self.caltype.SetValue(self.settings.caltype)

        self.sync_on_connect.SetValue(int(self.settings.sync_on_connect))

        self.sync_frequency.SetValue(int(self.settings.sync_frequency))

        return

	def IsConfigured(self):

        return self.settings.caltype!='None'

	def updatevariables(self):

        self.mw.auto_save_dict=self.settings

	def ShowModal(self):

        self.getfromfs()

        ec=wx.Dialog.ShowModal(self)

        if ec==wx.ID_OK:

            self._save_to_db()

            self.updatevariables()

            self.SetAutoSyncTimer()

        return ec

	def saveSize(self):

        guiwidgets.save_size("AutoSyncSettingsDialog", self.GetRect())

	def SetAutoSyncTimer(self):

        self.auto_sync_timer.Stop()

        oneShot = True

        timeout=self.settings.sync_frequency*60000 

        if timeout:

            self.auto_sync_timer.Start(timeout, oneShot)

            self.Bind(wx.EVT_TIMER, self.OnTimer, self.auto_sync_timer)

	def OnTimer(self, event):

        self.mw.log("Auto Sync: Timed update")

        SyncSchedule(self.mw).sync(self.mw, silent=1)

        self.SetAutoSyncTimer()
Пример #9
0
    def __init__(self, parent):
        global widgets_list
        wx.Dialog.__init__(self,
                           parent,
                           -1,
                           'Calendar Entry Editor',
                           wx.DefaultPosition,
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
        # the parent is the BPCalenda widget, save it
        self.cw = parent  # also the BPCalendar object
        # Tracking of the entries in the listbox.  Each entry is a dict. Entries are just the
        # entries in a random order.  entrymap maps from the order in the listbox to a
        # specific entry
        self.entries = []
        self.entrymap = []
        self._current_entry = None

        # Dirty tracking.  We restrict what the user can do while editting an
        # entry to only be able to edit that entry.  'dirty' gets fired when
        # they make any updates.  Annoyingly, controls generate change events
        # when they are updated programmatically as well as by user interaction.
        # ignoredirty is set when we are programmatically updating controls
        self.dirty = None
        self.ignoredirty = True

        # overall container
        vbs = wx.BoxSizer(wx.VERTICAL)

        self._prev_btn = wx.BitmapButton(self,
                                         wx.NewId(),
                                         wx.ArtProvider.GetBitmap(
                                             guihelper.ART_ARROW_LEFT),
                                         name="Previous Day")
        self._next_btn = wx.BitmapButton(self,
                                         wx.NewId(),
                                         wx.ArtProvider.GetBitmap(
                                             guihelper.ART_ARROW_RIGHT),
                                         name="Next Day")
        self.title = wx.StaticText(self,
                                   -1,
                                   "Date here",
                                   style=wx.ALIGN_CENTRE | wx.ST_NO_AUTORESIZE)

        # top row container
        hbs1 = wx.BoxSizer(wx.HORIZONTAL)
        hbs1.Add(self._prev_btn, 0, wx.EXPAND)
        hbs1.Add(self.title, 1, wx.EXPAND)
        hbs1.Add(self._next_btn, 0, wx.EXPAND)
        vbs.Add(hbs1, 0, wx.TOP | wx.EXPAND, 10)

        # list box and two buttons below
        self.listbox = wx.ListBox(self,
                                  wx.NewId(),
                                  style=wx.LB_SINGLE | wx.LB_HSCROLL
                                  | wx.LB_NEEDED_SB)
        self._add_btn = wx.Button(self, wx.ID_NEW)
        hbs2 = wx.BoxSizer(wx.HORIZONTAL)
        hbs2.Add(self._add_btn,
                 1,
                 wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT,
                 border=5)

        # sizer for listbox
        lbs = wx.BoxSizer(wx.VERTICAL)
        lbs.Add(self.listbox, 1, wx.EXPAND | wx.BOTTOM, border=5)
        lbs.Add(hbs2, 0, wx.EXPAND)

        # right hand bit with all fields
        self._nb = wx.Notebook(self, -1)
        self._widgets = []
        for i, (name, key, klass, color_name) in enumerate(self._items):
            if name in ('Ringtones', 'Wallpapers'):
                self._widgets.append(klass(self._nb, parent, False))
            else:
                self._widgets.append(klass(self._nb, parent))
            self._nb.AddPage(self._widgets[i], name)
            if color_name:
                widgets_list.append((self._widgets[i].static_box, color_name))

        # buttons below fields
        self._delete_btn = wx.Button(self, wx.ID_DELETE)
        self._revert_btn = wx.Button(self, wx.ID_REVERT_TO_SAVED)
        self._save_btn = wx.Button(self, wx.ID_SAVE)

        hbs4 = wx.BoxSizer(wx.HORIZONTAL)
        hbs4.Add(self._delete_btn, 1, wx.ALIGN_CENTRE | wx.LEFT, border=10)
        hbs4.Add(self._revert_btn,
                 1,
                 wx.ALIGN_CENTRE | wx.LEFT | wx.RIGHT,
                 border=10)
        hbs4.Add(self._save_btn, 1, wx.ALIGN_CENTRE | wx.RIGHT, border=10)

        # fields and buttons together
        vbs2 = wx.BoxSizer(wx.VERTICAL)
        vbs2.Add(self._nb, 1, wx.EXPAND | wx.BOTTOM, border=5)
        vbs2.Add(hbs4, 0, wx.EXPAND | wx.ALIGN_CENTRE)

        # container for everything below title row
        hbs3 = wx.BoxSizer(wx.HORIZONTAL)
        hbs3.Add(lbs, 1, wx.EXPAND | wx.ALL, 5)
        hbs3.Add(vbs2, 2, wx.EXPAND | wx.ALL, 5)
        vbs.Add(hbs3, 1, wx.EXPAND)
        # the standard buttons
        vbs.Add(wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL), 0,
                wx.EXPAND | wx.ALL, 5)
        vbs.Add(self.CreateButtonSizer(wx.OK | wx.CANCEL | wx.HELP), 0,
                wx.ALIGN_CENTRE | wx.ALL, 5)

        self.SetSizer(vbs)
        self.SetAutoLayout(True)
        vbs.Fit(self)
        # delete is disabled until an item is selected
        self._delete_btn.Enable(False)

        wx.EVT_LISTBOX(self, self.listbox.GetId(), self.OnListBoxItem)
        wx.EVT_LISTBOX_DCLICK(self, self.listbox.GetId(), self.OnListBoxItem)
        wx.EVT_BUTTON(self, wx.ID_SAVE, self.OnSaveButton)
        wx.EVT_BUTTON(self, wx.ID_REVERT_TO_SAVED, self.OnRevertButton)
        wx.EVT_BUTTON(self, wx.ID_NEW, self.OnNewButton)
        wx.EVT_BUTTON(self, wx.ID_DELETE, self.OnDeleteButton)
        wx.EVT_BUTTON(self, self._prev_btn.GetId(), self.OnPrevDayButton)
        wx.EVT_BUTTON(self, self._next_btn.GetId(), self.OnNextDayButton)
        # callbacks for the standard buttons
        wx.EVT_BUTTON(self, wx.ID_OK, self.OnOk)
        wx.EVT_BUTTON(self, wx.ID_CANCEL, self.OnCancel)
        wx.EVT_BUTTON(
            self, wx.ID_HELP, lambda _: wx.GetApp().displayhelpid(
                helpids.ID_EDITING_CALENDAR_EVENTS))
        # DIRTY UI Event handlers
        for w in self._widgets:
            pb_editor.EVT_DIRTY_UI(self, w.GetId(), self.OnMakeDirty)
        self.ignoredirty = False
        self.setdirty(False)
        guiwidgets.set_size("CalendarEntryEditor", self, 52, 1.0)
        field_color.reload_color_info(self, widgets_list)
        pubsub.subscribe(self.OnPhoneChanged, pubsub.PHONE_MODEL_CHANGED)
Пример #10
0
    def __init__(self,
                 mainwindow,
                 frame,
                 title="Auto Calendar Import Settings",
                 profile="Default Autosync",
                 id=-1):
        t = title + " - " + profile
        wx.Dialog.__init__(self,
                           frame,
                           id,
                           t,
                           style=wx.CAPTION | wx.SYSTEM_MENU
                           | wx.DEFAULT_DIALOG_STYLE)
        self.mw = mainwindow
        self.profile = profile

        gs = wx.GridBagSizer(10, 10)
        gs.AddGrowableCol(1)

        # calender type
        gs.Add(wx.StaticText(self, -1, "Calender Type"),
               pos=(0, 0),
               flag=wx.ALIGN_CENTER_VERTICAL)
        # get a list of the possible calender types supported
        calendertype = ('None', )
        # build a list of calender types for the user to select from
        for entry in self.mw.calenders:
            calendertype += (entry[0], )

        self.caltype = wx.ComboBox(self,
                                   -1,
                                   calendertype[0],
                                   style=wx.CB_DROPDOWN | wx.CB_READONLY,
                                   choices=calendertype)
        gs.Add(self.caltype, pos=(0, 1), flag=wx.ALIGN_CENTER_VERTICAL)
        gs.Add(wx.Button(self, self.ID_CALSETTINGS, "Calender Settings..."),
               pos=(0, 2),
               flag=wx.ALIGN_CENTER_VERTICAL)

        # on connect
        gs.Add(wx.StaticText(self, -1, "Update when phone re-connected"),
               pos=(1, 0),
               flag=wx.ALIGN_CENTER_VERTICAL)
        self.sync_on_connect = wx.CheckBox(self, wx.NewId(), "")
        gs.Add(self.sync_on_connect, pos=(1, 1), flag=wx.ALIGN_CENTER_VERTICAL)

        # frequency
        gs.Add(wx.StaticText(self, -1, "Update Frequency (mins) 0=never"),
               pos=(2, 0),
               flag=wx.ALIGN_CENTER_VERTICAL)
        self.sync_frequency = wx.lib.intctrl.IntCtrl(self,
                                                     -1,
                                                     value=0,
                                                     min=0,
                                                     max=1440)
        gs.Add(self.sync_frequency, pos=(2, 1), flag=wx.ALIGN_CENTER_VERTICAL)

        # crud at the bottom
        bs = wx.BoxSizer(wx.VERTICAL)
        bs.Add(gs, 0, wx.EXPAND | wx.ALL, 10)
        bs.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 7)

        but = self.CreateButtonSizer(wx.OK | wx.CANCEL | wx.HELP)
        bs.Add(but, 0, wx.CENTER | wx.ALL, 10)

        wx.EVT_BUTTON(self, wx.ID_HELP, self.OnHelp)
        wx.EVT_BUTTON(self, wx.ID_CANCEL, self.OnCancel)
        wx.EVT_BUTTON(self, wx.ID_OK, self.OnOK)
        wx.EVT_BUTTON(self, self.ID_CALSETTINGS, self.OnConfigCalender)
        wx.EVT_COMBOBOX(self, self.caltype.GetId(), self.OnCaltypeChange)

        self.settings = AutoSyncSettingsEntry()

        self.SetSizer(bs)
        self.SetAutoLayout(True)
        bs.Fit(self)
        # read initial values from database
        self.getfromfs()
        self.auto_sync_timer_id = wx.NewId()
        self.auto_sync_timer = wx.Timer(self, self.auto_sync_timer_id)
        # start the timer
        self.SetAutoSyncTimer()

        # Retrieve saved settings... (we only care about position)
        guiwidgets.set_size("AutoSyncSettingsDialog",
                            self,
                            screenpct=-1,
                            aspect=3.5)

        wx.EVT_CLOSE(self, self.OnClose)
Пример #11
0
    def __init__(self, parent):
        global widgets_list
        wx.Dialog.__init__(self, parent, -1, 'Calendar Entry Editor',
                           wx.DefaultPosition,
                           style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
        # the parent is the BPCalenda widget, save it
        self.cw=parent  # also the BPCalendar object
        # Tracking of the entries in the listbox.  Each entry is a dict. Entries are just the
        # entries in a random order.  entrymap maps from the order in the listbox to a
        # specific entry
        self.entries=[]
        self.entrymap=[]
        self._current_entry=None

        # Dirty tracking.  We restrict what the user can do while editting an
        # entry to only be able to edit that entry.  'dirty' gets fired when
        # they make any updates.  Annoyingly, controls generate change events
        # when they are updated programmatically as well as by user interaction.
        # ignoredirty is set when we are programmatically updating controls
        self.dirty=None
        self.ignoredirty=True
        
        # overall container
        vbs=wx.BoxSizer(wx.VERTICAL)
        
        self._prev_btn=wx.BitmapButton(self, wx.NewId(), wx.ArtProvider.GetBitmap(guihelper.ART_ARROW_LEFT), name="Previous Day")
        self._next_btn=wx.BitmapButton(self, wx.NewId(), wx.ArtProvider.GetBitmap(guihelper.ART_ARROW_RIGHT), name="Next Day")
        self.title=wx.StaticText(self, -1, "Date here", style=wx.ALIGN_CENTRE|wx.ST_NO_AUTORESIZE)

        # top row container 
        hbs1=wx.BoxSizer(wx.HORIZONTAL)
        hbs1.Add(self._prev_btn, 0, wx.EXPAND)
        hbs1.Add(self.title, 1, wx.EXPAND)
        hbs1.Add(self._next_btn, 0, wx.EXPAND)
        vbs.Add(hbs1, 0, wx.TOP|wx.EXPAND, 10)

        # list box and two buttons below
        self.listbox=wx.ListBox(self, wx.NewId(), style=wx.LB_SINGLE|wx.LB_HSCROLL|wx.LB_NEEDED_SB)
        self._add_btn=wx.Button(self, wx.ID_NEW)
        hbs2=wx.BoxSizer(wx.HORIZONTAL)
        hbs2.Add(self._add_btn, 1, wx.ALIGN_CENTER|wx.LEFT|wx.RIGHT, border=5)
        
        # sizer for listbox
        lbs=wx.BoxSizer(wx.VERTICAL)
        lbs.Add(self.listbox, 1, wx.EXPAND|wx.BOTTOM, border=5)
        lbs.Add(hbs2, 0, wx.EXPAND)

        # right hand bit with all fields
        self._nb=wx.Notebook(self, -1)
        self._widgets=[]
        for i, (name, key, klass, color_name) in enumerate(self._items):
            if name in ('Ringtones', 'Wallpapers'):
                self._widgets.append(klass(self._nb, parent, False))
            else:
                self._widgets.append(klass(self._nb, parent))
            self._nb.AddPage(self._widgets[i], name)
            if color_name:
                widgets_list.append((self._widgets[i].static_box, color_name))
            
        # buttons below fields
        self._delete_btn=wx.Button(self, wx.ID_DELETE)
        self._revert_btn=wx.Button(self, wx.ID_REVERT_TO_SAVED)
        self._save_btn=wx.Button(self, wx.ID_SAVE)

        hbs4=wx.BoxSizer(wx.HORIZONTAL)
        hbs4.Add(self._delete_btn, 1, wx.ALIGN_CENTRE|wx.LEFT, border=10)
        hbs4.Add(self._revert_btn, 1, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT, border=10)
        hbs4.Add(self._save_btn, 1, wx.ALIGN_CENTRE|wx.RIGHT, border=10)

        # fields and buttons together
        vbs2=wx.BoxSizer(wx.VERTICAL)
        vbs2.Add(self._nb, 1, wx.EXPAND|wx.BOTTOM, border=5)
        vbs2.Add(hbs4, 0, wx.EXPAND|wx.ALIGN_CENTRE)

        # container for everything below title row
        hbs3=wx.BoxSizer(wx.HORIZONTAL)
        hbs3.Add(lbs, 1, wx.EXPAND|wx.ALL, 5)
        hbs3.Add(vbs2, 2, wx.EXPAND|wx.ALL, 5)
        vbs.Add(hbs3, 1, wx.EXPAND)
        # the standard buttons
        vbs.Add(wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL), 0, wx.EXPAND|wx.ALL, 5)
        vbs.Add(self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.HELP), 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        self.SetSizer(vbs)
        self.SetAutoLayout(True)
        vbs.Fit(self)
        # delete is disabled until an item is selected
        self._delete_btn.Enable(False)

        wx.EVT_LISTBOX(self, self.listbox.GetId(), self.OnListBoxItem)
        wx.EVT_LISTBOX_DCLICK(self, self.listbox.GetId(), self.OnListBoxItem)
        wx.EVT_BUTTON(self, wx.ID_SAVE, self.OnSaveButton)
        wx.EVT_BUTTON(self, wx.ID_REVERT_TO_SAVED, self.OnRevertButton)
        wx.EVT_BUTTON(self, wx.ID_NEW, self.OnNewButton)
        wx.EVT_BUTTON(self, wx.ID_DELETE, self.OnDeleteButton)
        wx.EVT_BUTTON(self, self._prev_btn.GetId(), self.OnPrevDayButton)
        wx.EVT_BUTTON(self, self._next_btn.GetId(), self.OnNextDayButton)
        # callbacks for the standard buttons
        wx.EVT_BUTTON(self, wx.ID_OK, self.OnOk)
        wx.EVT_BUTTON(self, wx.ID_CANCEL, self.OnCancel)
        wx.EVT_BUTTON(self, wx.ID_HELP, lambda _: wx.GetApp().displayhelpid(helpids.ID_EDITING_CALENDAR_EVENTS))
        # DIRTY UI Event handlers
        for w in self._widgets:
            pb_editor.EVT_DIRTY_UI(self, w.GetId(), self.OnMakeDirty)
        self.ignoredirty=False
        self.setdirty(False)
        guiwidgets.set_size("CalendarEntryEditor", self, 52, 1.0)
        field_color.reload_color_info(self, widgets_list)
        pubsub.subscribe(self.OnPhoneChanged, pubsub.PHONE_MODEL_CHANGED)
 def __init__(self, parent):
     global widgets_list
     wx.Dialog.__init__(self, parent, -1, 'Calendar Entry Editor',
                        wx.DefaultPosition,
                        style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
     self.cw=parent  # also the BPCalendar object
     self.entries=[]
     self.entrymap=[]
     self._current_entry=None
     self.dirty=None
     self.ignoredirty=True
     vbs=wx.BoxSizer(wx.VERTICAL)
     self._prev_btn=wx.BitmapButton(self, self.ID_PREV, wx.ArtProvider.GetBitmap(guihelper.ART_ARROW_LEFT), name="Previous Day")
     self._next_btn=wx.BitmapButton(self, self.ID_NEXT, wx.ArtProvider.GetBitmap(guihelper.ART_ARROW_RIGHT), name="Next Day")
     self.title=wx.StaticText(self, -1, "Date here", style=wx.ALIGN_CENTRE|wx.ST_NO_AUTORESIZE)
     hbs1=wx.BoxSizer(wx.HORIZONTAL)
     hbs1.Add(self._prev_btn, 0, wx.EXPAND)
     hbs1.Add(self.title, 1, wx.EXPAND)
     hbs1.Add(self._next_btn, 0, wx.EXPAND)
     vbs.Add(hbs1, 0, wx.TOP|wx.EXPAND, 10)
     self.listbox=wx.ListBox(self, self.ID_LISTBOX, style=wx.LB_SINGLE|wx.LB_HSCROLL|wx.LB_NEEDED_SB)
     self._add_btn=wx.Button(self, self.ID_ADD, "New")
     hbs2=wx.BoxSizer(wx.HORIZONTAL)
     hbs2.Add(self._add_btn, 1, wx.ALIGN_CENTER|wx.LEFT|wx.RIGHT, border=5)
     lbs=wx.BoxSizer(wx.VERTICAL)
     lbs.Add(self.listbox, 1, wx.EXPAND|wx.BOTTOM, border=5)
     lbs.Add(hbs2, 0, wx.EXPAND)
     self._nb=wx.Notebook(self, -1)
     self._widgets=[]
     for i, (name, key, klass, color_name) in enumerate(self._items):
         if name in ('Ringtones', 'Wallpapers'):
             self._widgets.append(klass(self._nb, parent, False))
         else:
             self._widgets.append(klass(self._nb, parent))
         self._nb.AddPage(self._widgets[i], name)
         if color_name:
             widgets_list.append((self._widgets[i].static_box, color_name))
     self._delete_btn=wx.Button(self, self.ID_DELETE, "Delete")
     self._revert_btn=wx.Button(self, self.ID_REVERT, "Revert")
     self._save_btn=wx.Button(self, self.ID_SAVE, "Save")
     hbs4=wx.BoxSizer(wx.HORIZONTAL)
     hbs4.Add(self._delete_btn, 1, wx.ALIGN_CENTRE|wx.LEFT, border=10)
     hbs4.Add(self._revert_btn, 1, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT, border=10)
     hbs4.Add(self._save_btn, 1, wx.ALIGN_CENTRE|wx.RIGHT, border=10)
     vbs2=wx.BoxSizer(wx.VERTICAL)
     vbs2.Add(self._nb, 1, wx.EXPAND|wx.BOTTOM, border=5)
     vbs2.Add(hbs4, 0, wx.EXPAND|wx.ALIGN_CENTRE)
     hbs3=wx.BoxSizer(wx.HORIZONTAL)
     hbs3.Add(lbs, 1, wx.EXPAND|wx.ALL, 5)
     hbs3.Add(vbs2, 2, wx.EXPAND|wx.ALL, 5)
     vbs.Add(hbs3, 1, wx.EXPAND)
     vbs.Add(wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL), 0, wx.EXPAND|wx.ALL, 5)
     vbs.Add(self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.HELP), 0, wx.ALIGN_CENTRE|wx.ALL, 5)
     self.SetSizer(vbs)
     self.SetAutoLayout(True)
     vbs.Fit(self)
     self._delete_btn.Enable(False)
     wx.EVT_LISTBOX(self, self.ID_LISTBOX, self.OnListBoxItem)
     wx.EVT_LISTBOX_DCLICK(self, self.ID_LISTBOX, self.OnListBoxItem)
     wx.EVT_BUTTON(self, self.ID_SAVE, self.OnSaveButton)
     wx.EVT_BUTTON(self, self.ID_REVERT, self.OnRevertButton)
     wx.EVT_BUTTON(self, self.ID_ADD, self.OnNewButton)
     wx.EVT_BUTTON(self, self.ID_DELETE, self.OnDeleteButton)
     wx.EVT_BUTTON(self, self.ID_PREV, self.OnPrevDayButton)
     wx.EVT_BUTTON(self, self.ID_NEXT, self.OnNextDayButton)
     wx.EVT_BUTTON(self, wx.ID_OK, self.OnOk)
     wx.EVT_BUTTON(self, wx.ID_CANCEL, self.OnCancel)
     wx.EVT_BUTTON(self, wx.ID_HELP, lambda _: wx.GetApp().displayhelpid(helpids.ID_EDITING_CALENDAR_EVENTS))
     for w in self._widgets:
         pb_editor.EVT_DIRTY_UI(self, w.GetId(), self.OnMakeDirty)
     self.ignoredirty=False
     self.setdirty(False)
     guiwidgets.set_size("CalendarEntryEditor", self, 50, 1.5)
     field_color.reload_color_info(self, widgets_list)
     pubsub.subscribe(self.OnPhoneChanged, pubsub.PHONE_MODEL_CHANGED)