def __init__(self, mainwindow, parent):
     global thewallpapermanager
     thewallpapermanager=self
     self.mainwindow=mainwindow
     self.usewidth=10
     self.useheight=10
     wx.FileSystem_AddHandler(BPFSHandler(self))
     self._data={'wallpaper-index': {}}
     self.updateprofilevariables(self.mainwindow.phoneprofile)
     self.organizemenu=wx.Menu()
     guiwidgets.FileView.__init__(self, mainwindow, parent, "wallpaper-watermark")
     self.wildcard="Image files|*.bmp;*.jpg;*.jpeg;*.png;*.gif;*.pnm;*.tiff;*.ico;*.bci;*.bit"
     self.organizeinfo={}
     last_mode=mainwindow.config.Read('imageorganizedby',
                                      self.organizetypes[0])
     for k in self.organizetypes:
         id=wx.NewId()
         self.organizemenu.AppendRadioItem(id, k)
         wx.EVT_MENU(self, id, self.OrganizeChange)
         self.organizeinfo[id]=getattr(self, "organizeby_"+k.replace(" ",""))
         if k==last_mode:
             self.organizemenu.Check(id, True)
     self.modified=False
     wx.EVT_IDLE(self, self.OnIdle)
     pubsub.subscribe(self.OnListRequest, pubsub.REQUEST_WALLPAPERS)
     pubsub.subscribe(self.OnPhoneModelChanged, pubsub.PHONE_MODEL_CHANGED)
     self._raw_image=self._shift_down=False
     wx.EVT_KEY_DOWN(self.aggdisp, self._OnKey)
     wx.EVT_KEY_UP(self.aggdisp, self._OnKey)
Beispiel #2
0
    def __init__(self, root, id, parent):
        BaseNotebook.__init__(self, parent, id, style=_style)
        self.root = root
        if WHICHNB == 2 and wx.VERSION >= (3, ):
            self.SetArtProvider(aui.AuiGenericTabArt())
        if WHICHNB != 2 or wx.VERSION >= (3, ):
            if __main__.USE_DOC_ICONS:
                self.AssignImageList(__main__.IMGLIST2)
        else:
            self.imagelist = __main__.IMGLIST3

        #for some reason, the notebook needs the next line...the text control
        #doesn't.
        self.Bind(wx.EVT_KEY_DOWN, self.root.OnKeyPressed)
        self.Bind(pch, self.OnPageChanged)
        self.Bind(wx.EVT_SET_FOCUS, self.GotFocus)

        self.SetDropTarget(__main__.FileDropTarget(self.root))
        self.calling = 0
        self.other_focus = 0
        self.fr = None
        self.cs = 0
        self.Bind(aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnClose)
        self.Bind(aui.EVT_AUINOTEBOOK_BEGIN_DRAG, self.OnBeginDrag)
        self.Bind(aui.EVT_AUINOTEBOOK_DRAG_DONE, self.OnDragDone)
        pubsub.subscribe('document.selected', self.updateChecks)
Beispiel #3
0
 def __init__(self):
     pubsub.subscribe('DISPLAY', self.output)
     self.worker_thread = None
     self.running = False
     self.buffer = ''
     self._buffer_lock = threading.Lock()
     self.is_dirty = True
 def __init__(self, parent, pos):
     global widgets_list
     pb_editor.DirtyUIBase.__init__(self, parent)
     self.static_box=wx.StaticBox(self, -1, "Category")
     hs=wx.StaticBoxSizer(self.static_box, wx.HORIZONTAL)
     self.categories=[]
     self.category=wx.ListBox(self, -1, choices=self.categories)
     pubsub.subscribe(self.OnUpdateCategories, pubsub.ALL_CATEGORIES)
     pubsub.publish(pubsub.REQUEST_CATEGORIES)
     vbs=wx.BoxSizer(wx.VERTICAL)
     vbs.Add(wx.StaticText(self, -1, 'Master Category'), 0,
             wx.TOP|wx.LEFT, 5)
     vbs.Add(self.category, 1, wx.EXPAND|wx.ALL, 5)
     hs.Add(vbs, 1, wx.EXPAND|wx.ALL, 5)
     vbs=wx.BoxSizer(wx.VERTICAL)
     self.but=wx.Button(self, wx.NewId(), "Manage Categories:")
     add_btn=wx.Button(self, -1, 'Add ->')
     del_btn=wx.Button(self, -1, '<- Remove')
     vbs.Add(self.but, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
     vbs.Add(add_btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
     vbs.Add(del_btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
     hs.Add(vbs, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
     wx.EVT_BUTTON(self, add_btn.GetId(), self.OnAddCategory)
     wx.EVT_BUTTON(self, del_btn.GetId(), self.OnDelCategory)
     vbs=wx.BoxSizer(wx.VERTICAL)
     vbs.Add(wx.StaticText(self, -1, 'Selected Category:'), 0,
             wx.TOP|wx.LEFT, 5)
     self._my_category=wx.ListBox(self, -1)
     vbs.Add(self._my_category, 1, wx.EXPAND|wx.ALL, 5)
     hs.Add(vbs, 1, wx.EXPAND|wx.ALL, 5)
     wx.EVT_BUTTON(self, self.but.GetId(), self.OnManageCategories)
     self.SetSizer(hs)
     hs.Fit(self)
 def __init__(self, mainwindow, parent):
     global widgets_list
     super(TodoWidget, self).__init__(parent, -1)
     self._main_window=mainwindow
     self._data=self._data_map={}
     vbs=wx.BoxSizer(wx.VERTICAL)
     hbs=wx.BoxSizer(wx.HORIZONTAL)
     self._item_list=wx.ListBox(self, wx.NewId(),
                                 style=wx.LB_SINGLE|wx.LB_HSCROLL|wx.LB_NEEDED_SB)
     hbs.Add(self._item_list, 1, wx.EXPAND|wx.BOTTOM, border=5)
     scrolled_panel=scrolled.ScrolledPanel(self, -1)
     vbs1=wx.BoxSizer(wx.VERTICAL)
     self._items=(
         (GeneralEditor, 0, None),
         (cal_editor.CategoryEditor, 1, 'category'),
         (pb_editor.MemoEditor, 1, 'memo')
         )
     self._w=[]
     for n in self._items:
         w=n[0](scrolled_panel, -1)
         vbs1.Add(w, n[1], wx.EXPAND|wx.ALL, 5)
         self._w.append(w)
         if n[2]:
             widgets_list.append((w.static_box, n[2]))
     scrolled_panel.SetSizer(vbs1)
     scrolled_panel.SetAutoLayout(True)
     vbs1.Fit(scrolled_panel)
     scrolled_panel.SetupScrolling()
     hbs.Add(scrolled_panel, 3, wx.EXPAND|wx.ALL, border=5)
     self._general_editor_w=self._w[0]
     self._cat_editor_w=self._w[1]
     self._memo_editor_w=self._w[2]
     hbs1=wx.BoxSizer(wx.HORIZONTAL)
     self._save_btn=wx.Button(self, wx.NewId(), "Save")
     self._revert_btn=wx.Button(self, wx.NewId(), "Revert")
     help_btn=wx.Button(self, wx.ID_HELP, "Help")
     hbs1.Add(self._save_btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
     hbs1.Add(help_btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
     hbs1.Add(self._revert_btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
     vbs.Add(hbs, 1, wx.EXPAND|wx.ALL, 5)
     vbs.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5)
     vbs.Add(hbs1, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
     self.SetSizer(vbs)
     self.SetAutoLayout(True)
     vbs.Fit(self)
     wx.EVT_LISTBOX(self, self._item_list.GetId(), self._OnListBoxItem)
     wx.EVT_BUTTON(self, self._save_btn.GetId(), self._OnSave)
     wx.EVT_BUTTON(self, self._revert_btn.GetId(), self._OnRevert)
     wx.EVT_BUTTON(self, wx.ID_HELP,
                   lambda _: wx.GetApp().displayhelpid(helpids.ID_TAB_TODO))
     for w in self._w:
         pb_editor.EVT_DIRTY_UI(self, w.GetId(), self.OnMakeDirty)
     self._populate()
     self.ignoredirty=False
     self.setdirty(False)
     today.bind_notification_event(self.OnTodaySelection,
                                   today.Today_Group_Todo)
     today.bind_request_event(self.OnTodayRequest)
     field_color.reload_color_info(self, widgets_list)
     pubsub.subscribe(self.OnPhoneChanged, pubsub.PHONE_MODEL_CHANGED)
Beispiel #6
0
    def __init__(self, master=None):
        tk.Frame.__init__(self, master)
        self.path = os.path.split(sys.argv[0])[0]
        self.data_dir = os.path.join(self.path, DATADIR)
        self.cfg = config.Load(os.path.join(self.data_dir, CONFIG))
        self.grid(sticky=tk.NSEW)
        self.idle_calls = 0
        self.charts = []
        self.focus_chart = None
        self.q = multiprocessing.Queue(maxsize=QUEUE_SIZE)
        self.status_q = multiprocessing.Queue(0)
        self.next_color = 0
        self.running = 1
        self.proc = None
        self.state = App.SETUP
        self.parent_conn, self.child_conn = multiprocessing.Pipe()
        self.man_span = 0
        self.scaling = config.ScaleInfo()
        self.spans = [0] * SPAN_MAX  # map range slider to range value
        self.time_diff = time.time() - utils.timer()  # see module docstring
        top = self.winfo_toplevel()
        top.geometry(self.cfg.geometry)
        try:
            top.wm_iconbitmap('electroscope.ico')
        except:
            pass
        top.rowconfigure(0, weight=1)
        top.columnconfigure(0, weight=1)
        self.scale_min = (SAMPLESCALE_MIN, 0, FREQSCALE_MIN)
        self.scale_max = (SAMPLESCALE_MAX, 0, FREQSCALE_MAX)
        self.plot_sizes = [SAMPLESCALE_MAX, 0, FREQSCALE_MAX]

        # the layout is 3 rows:
        self.rowconfigure(0, weight=1)
        self.rowconfigure(1, weight=1000)
        self.rowconfigure(2, weight=1)
        # row 1 is constructed as 2 columns, with all the expansion
        # assigned to the graphs
        self.columnconfigure(0, weight=1000)
        self.columnconfigure(1, weight=1)

        # construct the widgets - note that these member functions know where
        # they belong in the grid, so they are sensitive to grid layout changes
        self.create_menu(self)
        self.create_controls(self)
        self.create_graphs(self)
        self.create_button_row(self)

        # connect event handlers
        top.protocol("WM_DELETE_WINDOW", self.on_quit)
        pubsub.subscribe('status', self.set_status)
        pubsub.subscribe('focus2', self.on_focus)

        # start a process to receive and buffer data
        self.start_source(self.cfg.sources)

        self.on_timer()
        # start the code that processes and displays the data
        self.after_idle(self.on_plot_type)
        self.after_idle(self.read_queue)
Beispiel #7
0
    def __init__(self):
        self._worker_thread = None
        self._running = False
        self._board_data = ''
        self._move_history = ''
        self._board_data_lock = threading.Lock()

        pubsub.subscribe('DISPLAY', self._update_board_data)
Beispiel #8
0
 def event_stream():
     # instantiate pubsub
     pubsub = red.pubsub()
     # subscribe to tweet_stream channel
     pubsub.subscribe('tweet_stream')
     # initiate server-sent events on messages pushed to channel
     for message in pubsub.listen():
         yield 'data: %s\n\n' % message['data']
Beispiel #9
0
 def _handle_mfeeder_conn(self):
     print "Feeder connected."
     self._fprocessor = FeedProcessor(self._config['display_width'],
                                      self._config['display_height'],
                                      self._config['upside_down'])
     self._fprocessor.set_fixation_detector(DispersionDetector())
     self._fprocessor.set_output_method(self._mfeeder.send_data)
     pubsub.subscribe('data', self._fprocessor.process)
     self._etf.start_tracking()
Beispiel #10
0
    def __init__(self, model):
        self.model = model
        self.worker_thread = None
        self.running = False
        self.is_dirty = True
        self.event_queue = []
        self._event_queue_lock = threading.Lock()

        pubsub.subscribe('PLAYER_INPUT', self.receive_events)
        pubsub.subscribe('QUIT', self.on_quit)
Beispiel #11
0
 def __init__(self, mainwindow, parent, media_root, id=-1):
     self.mainwindow=mainwindow
     self._data={self.database_key: {}}
     fileview.FileView.__init__(self, mainwindow, parent, media_root, "ringtone-watermark")
     self.wildcard="Audio files|*.wav;*.mid;*.qcp;*.mp3;*.pmd;*.wma|Midi files|*.mid|Purevoice files|*.qcp|MP3 files|*.mp3|WMA files|*.wma|PMD/CMX files|*.pmd|All files|*.*"
     self.thedir=self.mainwindow.ringerpath
     self.modified=False
     pubsub.subscribe(self.OnListRequest, pubsub.REQUEST_RINGTONES)
     pubsub.subscribe(self.OnDictRequest, pubsub.REQUEST_RINGTONE_INDEX)
     self._raw_media=self._shift_down=False
 def __init__(self, mainwindow, parent, media_root, id=-1):
     self.mainwindow=mainwindow
     self._data={self.database_key: {}}
     fileview.FileView.__init__(self, mainwindow, parent, media_root, "ringtone-watermark")
     self.wildcard="Audio files|*.wav;*.mid;*.qcp;*.mp3;*.pmd|Midi files|*.mid|Purevoice files|*.qcp|MP3 files|*.mp3|PMD/CMX files|*.pmd|All files|*.*"
     self.thedir=self.mainwindow.ringerpath
     self.modified=False
     pubsub.subscribe(self.OnListRequest, pubsub.REQUEST_RINGTONES)
     pubsub.subscribe(self.OnDictRequest, pubsub.REQUEST_RINGTONE_INDEX)
     self._raw_media=self._shift_down=False
 def __init__(self, mainwindow, parent, id=-1):
     self.mainwindow=mainwindow
     wx.SplitterWindow.__init__(self, parent, id, style=wx.SP_BORDER|wx.SP_LIVE_UPDATE)
     self.tree=FileSystemDirectoryView(mainwindow, self, wx.NewId(), style=(wx.TR_DEFAULT_STYLE|wx.TR_NO_LINES)&~wx.TR_TWIST_BUTTONS)
     self.list=FileSystemFileView(mainwindow, self, wx.NewId())
     pos=mainwindow.config.ReadInt("filesystemsplitterpos", 200)
     self.SplitVertically(self.tree, self.list, pos)
     self.SetMinimumPaneSize(20)
     wx.EVT_SPLITTER_SASH_POS_CHANGED(self, id, self.OnSplitterPosChanged)
     pubsub.subscribe(self.OnPhoneModelChanged, pubsub.PHONE_MODEL_CHANGED)
Beispiel #14
0
def print_keys_thread():
    sub_key = pubsub.subscribe("CVKeyStroke")
    sub_cmd = pubsub.subscribe("CVWinCmd")
    msg_cmd = ''
    while msg_cmd != 'quit':
        key_chr = listen_default(sub_key, timeout=.1)  # type: np.ndarray
        if key_chr is not None:
            print("key pressed: " + str(key_chr))
        msg_cmd = listen_default(sub_cmd, block=False, empty='')
    pubsub.publish("CVWinCmd", 'quit')
 def __init__(self, parent):
     super(FolderPage, self).__init__(parent, -1)
     self._data=self._data_map=self._name_map={}
     self.canned_data=sms.CannedMsgEntry()
     hbs=wx.BoxSizer(wx.HORIZONTAL)
     scrolled_panel=scrolled.ScrolledPanel(self, -1)
     vbs0=wx.BoxSizer(wx.VERTICAL)
     self._item_list=wx.TreeCtrl(scrolled_panel, wx.NewId(),
                                 style=wx.TR_MULTIPLE|wx.TR_HAS_BUTTONS)
     vbs0.Add(self._item_list, 1, wx.EXPAND|wx.ALL, 5)
     self._root=self._item_list.AddRoot('SMS')
     self._nodes={}
     for s in sms.SMSEntry.Valid_Folders:
         self._nodes[s]=self._item_list.AppendItem(self._root, s)
     canned_node=self._item_list.AppendItem(self._root, 'Canned')
     self._item_list.AppendItem(canned_node, 'Built-In')
     self._item_list.AppendItem(canned_node, 'User')
     scrolled_panel.SetSizer(vbs0)
     scrolled_panel.SetAutoLayout(True)
     vbs0.Fit(scrolled_panel)
     scrolled_panel.SetupScrolling()
     hbs.Add(scrolled_panel, 1, wx.EXPAND|wx.BOTTOM, border=5)
     vbs1=wx.BoxSizer(wx.VERTICAL)
     self._item_info=SMSInfo(self)
     vbs1.Add(self._item_info, 0, wx.EXPAND|wx.ALL, 5)
     self._item_text=pb_editor.MemoEditor(self, -1)
     vbs1.Add(self._item_text, 1, wx.EXPAND|wx.ALL, 5)
     self.canned_list=gizmos.EditableListBox(self, -1, 'Canned Messages')
     vbs1.Add(self.canned_list, 1, wx.EXPAND|wx.ALL, 5)
     vbs1.Show(self.canned_list, False)
     self.builtin_canned_list=wx.ListBox(self, -1)
     vbs1.Add(self.builtin_canned_list, 1, wx.EXPAND|wx.ALL, 5)
     vbs1.Show(self.builtin_canned_list, False)
     self.save_btn=wx.Button(self, wx.NewId(), 'Save')
     vbs1.Add(self.save_btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
     vbs1.Show(self.save_btn, False)
     self.info_bs=vbs1
     hbs.Add(vbs1, 3, wx.EXPAND|wx.ALL, border=5)
     self._bgmenu=wx.Menu()
     context_menu_data=(
         ('Expand All', self._OnExpandAll),
         ('Collapse All', self._OnCollapseAll))
     for e in context_menu_data:
         id=wx.NewId()
         self._bgmenu.Append(id, e[0])
         wx.EVT_MENU(self, id, e[1])
     self.SetSizer(hbs)
     self.SetAutoLayout(True)
     hbs.Fit(self)
     wx.EVT_TREE_SEL_CHANGED(self, self._item_list.GetId(),
                             self._OnSelChanged)
     pubsub.subscribe(self._OnPBLookup, pubsub.RESPONSE_PB_LOOKUP)
     wx.EVT_RIGHT_UP(self._item_list, self._OnRightClick)
     self._populate()
     self._OnExpandAll(None)
Beispiel #16
0
    def __init__(self, mainwindow, parent, stats):
        super(SMSList, self).__init__(parent, -1)
        self._main_window = mainwindow
        self._stats = stats
        self.nodes = {}
        self.nodes_keys = {}
        self._display_filter = "All"
        self._name_map = {}
        self._data_map = {}

        # main box sizer
        vbs = wx.BoxSizer(wx.VERTICAL)
        # data date adjuster
        hbs = wx.BoxSizer(wx.HORIZONTAL)
        static_bs = wx.StaticBoxSizer(
            wx.StaticBox(self, -1, 'Historical Data Status:'), wx.VERTICAL)
        self.historical_data_label = wx.StaticText(self, -1, 'Current Data')
        static_bs.Add(self.historical_data_label, 1, wx.EXPAND | wx.ALL, 5)
        hbs.Add(static_bs, 1, wx.EXPAND | wx.ALL, 5)
        vbs.Add(hbs, 0, wx.EXPAND | wx.ALL, 5)
        # main list
        hbmessage = wx.BoxSizer(wx.HORIZONTAL)
        column_info = []
        column_info.append(("From", 105, False))
        column_info.append(("To", 120, False))
        column_info.append(("Date", 180, False))
        self._item_list = guiwidgets.BitPimListCtrl(self, column_info)
        self._item_list.ResetView(self.nodes, self.nodes_keys)
        vbs0 = wx.BoxSizer(wx.VERTICAL)
        vbs0.Add(self._item_list, 1, wx.EXPAND | wx.ALL, 5)
        vbs0.Add(
            wx.StaticText(self, -1,
                          '  Note: Click column headings to sort data'), 0,
            wx.ALIGN_CENTRE | wx.BOTTOM, 10)
        hbmessage.Add(vbs0, 1, wx.EXPAND | wx.ALL, 5)
        vbs1 = wx.BoxSizer(wx.VERTICAL)
        self._item_info = SMSInfo(self)
        vbs1.Add(self._item_info, 0, wx.EXPAND | wx.ALL, 5)
        self._item_text = pb_editor.MemoEditor(self, -1)
        vbs1.Add(self._item_text, 1, wx.EXPAND | wx.ALL, 5)
        hbmessage.Add(vbs1, 0, wx.EXPAND | wx.ALL, 5)
        hbmessage.SetItemMinSize(1, (350, 20))
        vbs.Add(hbmessage, 1, wx.EXPAND | wx.ALL, 5)
        wx.EVT_LIST_ITEM_SELECTED(self, self._item_list.GetId(),
                                  self._OnSelChanged)
        pubsub.subscribe(self._OnPBLookup, pubsub.RESPONSE_PB_LOOKUP)
        # register for Today selection
        self.today_data = None
        today.bind_notification_event(self.OnTodaySelection,
                                      today.Today_Group_IncomingSMS)
        # all done
        self.SetSizer(vbs)
        self.SetAutoLayout(True)
        vbs.Fit(self)
Beispiel #17
0
    def start(self):
        info('controller', 'start')
        try:
            self.senderProcess.start()
            self.signerProcess.start()
            self.receiverProcess.start()
        except Exception as ex:
            error('controller', 'start error: '+str(ex))
            self.senderProcess.terminate()
            self.signerProcess.terminate()
            self.receiverProcess.terminate()

            self.senderProcess.join()
            self.signerProcess.join()
            self.receiverProcess.join()
            return
        else:
            self.running = True

        # Wait for the processes to start.
        time.sleep(3)

        # Subscribe to admin and sensor data.
        info('controller', 'subscribe to admin and sensor data')
        subscribe(self.handle_admin, channel='admin')
        subscribe(self.handle, channel='sensor')

        # Start processing messages.
        info('controller', 'processing messages!')
        while self.running:
            # Check to make sure the signer is not finished with a return
            # message for the broker.
            if self.signPipe.poll():
                msg = self.signPipe.recv()
                info('controller', 'signer data: '+str(msg))

                # Send message if not a Kit message, those go to admin.
                if msg.get_topic() != 'KIT':
                    self.sendPipe.send(msg)
                # Handle Kit messages by sending to admin after encryption.
                else:
                    info('controller', 'admin message: '+str(msg))
                    data = self.signer.encrypt(msg)
                    info('controller', 'admin message: '+str(data))
                    publish_raw(data, channel='admin')

            # Check if the reciever has any data waiting and process.
            if self.receivePipe.poll():
                msg = self.receivePipe.recv()
                info('controller', 'receiver data: '+str(msg))
                self.handle(msg)

            get_message()
            time.sleep(0.001)
 def __init__(self, mainwindow, parent):
     self._sections=[]
     super(TodayWidget, self).__init__(parent, self)
     self._main_window=mainwindow
     self._sections=[SectionHeader(s) for s in self._section_names]
     for i,group in enumerate(self._item_names):
         for name in group:
             w=GroupWidget(self, name)
             self._sections[i].Add(w)
     self.UpdateItems()
     BaseEvent.bind(self.OnNewData)
     pubsub.subscribe(self._OnMidnight, pubsub.MIDNIGHT)
Beispiel #19
0
 def __init__(self, mainwindow, parent, id=-1):
     # the listbox and textbox in a splitter
     self.mainwindow=mainwindow
     wx.SplitterWindow.__init__(self, parent, id, style=wx.SP_LIVE_UPDATE)
     self.tree=FileSystemDirectoryView(mainwindow, self, wx.NewId(), style=(wx.TR_DEFAULT_STYLE|wx.TR_NO_LINES)&~wx.TR_TWIST_BUTTONS)
     self.list=FileSystemFileView(mainwindow, self, wx.NewId())
     self.sash_pos=mainwindow.config.ReadInt("filesystemsplitterpos", 200)
     self.update_sash=False
     self.SplitVertically(self.tree, self.list, self.sash_pos)
     self.SetMinimumPaneSize(20)
     wx.EVT_SPLITTER_SASH_POS_CHANGED(self, id, self.OnSplitterPosChanged)
     pubsub.subscribe(self.OnPhoneModelChanged, pubsub.PHONE_MODEL_CHANGED)
 def __init__(self, mainwindow, parent):
     super(CallHistoryWidget, self).__init__(parent, -1)
     self._main_window=mainwindow
     self._data={}
     self._node_dict={}
     self._name_map={}
     self._by_mode=self._by_type
     self._display_func=(self._display_by_type, self._display_by_date,
                          self._display_by_number)
     vbs=wx.BoxSizer(wx.VERTICAL)
     hbs=wx.BoxSizer(wx.HORIZONTAL)
     self.read_only=False
     self.historical_date=None
     static_bs=wx.StaticBoxSizer(wx.StaticBox(self, -1,
                                              'Historical Data Status:'),
                                 wx.VERTICAL)
     self.historical_data_label=wx.StaticText(self, -1, 'Current Data')
     static_bs.Add(self.historical_data_label, 1, wx.EXPAND|wx.ALL, 5)
     hbs.Add(static_bs, 1, wx.EXPAND|wx.ALL, 5)
     vbs.Add(hbs, 0, wx.EXPAND|wx.ALL, 5)
     self._item_list=wx.TreeCtrl(self, wx.NewId(),
                                 style=wx.TR_MULTIPLE|wx.TR_HAS_BUTTONS)
     vbs.Add(self._item_list, 1, wx.EXPAND|wx.ALL, 5)
     self._root=self._item_list.AddRoot('Call History')
     self._nodes={}
     organize_menu=wx.Menu()
     organize_menu_data=(
         ('Type', self._OnOrganizedByType),
         ('Date', self._OnOrganizedByDate),
         ('Number', self._OnOrganizedByNumber))
     for e in organize_menu_data:
         id=wx.NewId()
         organize_menu.AppendRadioItem(id, e[0])
         wx.EVT_MENU(self, id, e[1])
     context_menu_data=(
         ('Expand All', self._OnExpandAll),
         ('Collapse All', self._OnCollapseAll))
     self._bgmenu=wx.Menu()
     self._bgmenu.AppendMenu(wx.NewId(), 'Organize Items by', organize_menu)
     for e in context_menu_data:
         id=wx.NewId()
         self._bgmenu.Append(id, e[0])
         wx.EVT_MENU(self, id, e[1])
     pubsub.subscribe(self._OnPBLookup, pubsub.RESPONSE_PB_LOOKUP)
     wx.EVT_RIGHT_UP(self._item_list, self._OnRightClick)
     self.SetSizer(vbs)
     self.SetAutoLayout(True)
     vbs.Fit(self)
     self.SetupScrolling()
     self._populate()
 def __init__(self, mainwindow, parent, media_root):
     global thewallpapermanager
     thewallpapermanager=self
     self.mainwindow=mainwindow
     self.usewidth=10
     self.useheight=10
     wx.FileSystem_AddHandler(BPFSHandler(self))
     self._data={self.database_key: {}}
     fileview.FileView.__init__(self, mainwindow, parent, media_root, "wallpaper-watermark")
     self.thedir=self.mainwindow.wallpaperpath
     self.wildcard="Image files|*.bmp;*.jpg;*.jpeg;*.png;*.gif;*.pnm;*.tiff;*.ico;*.bci;*.bit"
     self.modified=False
     pubsub.subscribe(self.OnListRequest, pubsub.REQUEST_WALLPAPERS)
     self._raw_image=self._shift_down=False
Beispiel #22
0
    def __init__(self, mainwindow, parent, stats):
        super(SMSList, self).__init__(parent, -1)
        self._main_window=mainwindow
        self._stats=stats
        self.nodes={}
        self.nodes_keys={}
        self._display_filter="All"
        self._name_map={}
        self._data_map={}

        # main box sizer
        vbs=wx.BoxSizer(wx.VERTICAL)
        # data date adjuster
        hbs=wx.BoxSizer(wx.HORIZONTAL)
        static_bs=wx.StaticBoxSizer(wx.StaticBox(self, -1, 'Historical Data Status:'),
                                    wx.VERTICAL)
        self.historical_data_label=wx.StaticText(self, -1, 'Current Data')
        static_bs.Add(self.historical_data_label, 1, wx.EXPAND|wx.ALL, 5)
        hbs.Add(static_bs, 1, wx.EXPAND|wx.ALL, 5)
        vbs.Add(hbs, 0, wx.EXPAND|wx.ALL, 5)
        # main list
        hbmessage=wx.BoxSizer(wx.HORIZONTAL)
        column_info=[]
        column_info.append(("From", 105, False))
        column_info.append(("To", 120, False))
        column_info.append(("Date", 180, False))
        self._item_list=guiwidgets.BitPimListCtrl(self, column_info)
        self._item_list.ResetView(self.nodes, self.nodes_keys)
        vbs0=wx.BoxSizer(wx.VERTICAL)
        vbs0.Add(self._item_list, 1, wx.EXPAND|wx.ALL, 5)
        vbs0.Add(wx.StaticText(self, -1, '  Note: Click column headings to sort data'), 0, wx.ALIGN_CENTRE|wx.BOTTOM, 10)
        hbmessage.Add(vbs0, 1, wx.EXPAND|wx.ALL, 5)
        vbs1=wx.BoxSizer(wx.VERTICAL)
        self._item_info=SMSInfo(self)
        vbs1.Add(self._item_info, 0, wx.EXPAND|wx.ALL, 5)
        self._item_text=pb_editor.MemoEditor(self, -1)
        vbs1.Add(self._item_text, 1, wx.EXPAND|wx.ALL, 5)
        hbmessage.Add(vbs1, 0, wx.EXPAND|wx.ALL, 5)
        hbmessage.SetItemMinSize(1, (350, 20))
        vbs.Add(hbmessage, 1, wx.EXPAND|wx.ALL, 5)
        wx.EVT_LIST_ITEM_SELECTED(self, self._item_list.GetId(), self._OnSelChanged)
        pubsub.subscribe(self._OnPBLookup, pubsub.RESPONSE_PB_LOOKUP)
        # register for Today selection
        self.today_data=None
        today.bind_notification_event(self.OnTodaySelection,
                                      today.Today_Group_IncomingSMS)
        # all done
        self.SetSizer(vbs)
        self.SetAutoLayout(True)
        vbs.Fit(self)
Beispiel #23
0
 def __init__(self, mainwindow, parent):
     self._sections = []
     super(TodayWidget, self).__init__(parent, self)
     self._main_window = mainwindow
     # sections & items info
     self._sections = [SectionHeader(s) for s in self._section_names]
     for i, group in enumerate(self._item_names):
         for name in group:
             w = GroupWidget(self, name)
             self._sections[i].Add(w)
     # all done
     # populate data
     self.UpdateItems()
     # register for pubsub events
     BaseEvent.bind(self.OnNewData)
     pubsub.subscribe(self._OnMidnight, pubsub.MIDNIGHT)
Beispiel #24
0
 def loop(self):
     """Continually gets frames from the video publisher, runs callbacks on them, and listens to commands."""
     t = pub_cam_thread(self.cam_id, self.request_size, self.high_speed,
                        self.fps_limit)
     sub_cam = pubsub.subscribe("CVCams." + str(self.cam_id) + ".Vid")
     sub_owner = pubsub.subscribe("CVCamHandlers." + str(self.cam_id) +
                                  ".Cmd")
     msg_owner = ''
     while msg_owner != 'quit':
         frame = listen_default(sub_cam, timeout=.1)  # type: np.ndarray
         if frame is not None:
             frame = frame[0]
             for c in self.callbacks:
                 c(frame, self.cam_id)
         msg_owner = listen_default(sub_owner, block=False, empty='')
     pubsub.publish("CVCams." + str(self.cam_id) + ".Cmd", 'quit')
     t.join()
Beispiel #25
0
 def test_unsubscribe(self):
     sub = pubsub.subscribe('test')
     pubsub.publish('test', 'hello world 1')
     sub.unsubscribe()
     pubsub.publish('test', 'hello world 2')
     msgs = list(sub.listen(block=False))
     self.assertEqual(len(msgs), 1)
     self.assertEqual(msgs[0]['data'], 'hello world 1')
 def __init__(self, mainwindow, parent):
     super(CallHistoryWidget, self).__init__(parent, -1)
     self._main_window=mainwindow
     self.call_history_tree_nodes={}
     self._parent=parent
     self.read_only=False
     self.historical_date=None
     self._data={}
     self._name_map={}
     pubsub.subscribe(self._OnPBLookup, pubsub.RESPONSE_PB_LOOKUP)
     self.list_widget=CallHistoryList(self._main_window, self._parent, self)
     vbs=wx.BoxSizer(wx.VERTICAL)
     hbs=wx.BoxSizer(wx.HORIZONTAL)
     static_bs=wx.StaticBoxSizer(wx.StaticBox(self, -1,
                                              'Historical Data Status:'),
                                 wx.VERTICAL)
     self.historical_data_label=wx.StaticText(self, -1, 'Current Data')
     static_bs.Add(self.historical_data_label, 1, wx.EXPAND|wx.ALL, 5)
     hbs.Add(static_bs, 1, wx.EXPAND|wx.ALL, 5)
     vbs.Add(hbs, 0, wx.EXPAND|wx.ALL, 5)
     self.total_calls=wx.StaticText(self, -1, '  Total Calls: 0')
     self.total_in=wx.StaticText(self, -1, '  Incoming Calls: 0')
     self.total_out=wx.StaticText(self, -1, '  Outgoing Calls: 0')
     self.total_missed=wx.StaticText(self, -1, '  Missed Calls: 0')
     self.total_data=wx.StaticText(self, -1, '  Data Calls: 0')
     self.duration_all=wx.StaticText(self, -1, '  Total Duration(h:m:s): 0')
     self.duration_in=wx.StaticText(self, -1, '  Incoming Duration(h:m:s): 0')
     self.duration_out=wx.StaticText(self, -1, '  Outgoing Duration(h:m:s): 0')
     self.duration_data=wx.StaticText(self, -1, '  Data Duration(h:m:s): 0')
     vbs.Add(wx.StaticText(self, -1, ''), 0, wx.ALIGN_LEFT|wx.ALL, 2)
     vbs.Add(self.total_calls, 0, wx.ALIGN_LEFT|wx.ALL, 2)
     vbs.Add(self.total_in, 0, wx.ALIGN_LEFT|wx.ALL, 2)
     vbs.Add(self.total_out, 0, wx.ALIGN_LEFT|wx.ALL, 2)
     vbs.Add(self.total_missed, 0, wx.ALIGN_LEFT|wx.ALL, 2)
     vbs.Add(self.total_data, 0, wx.ALIGN_LEFT|wx.ALL, 2)
     vbs.Add(wx.StaticText(self, -1, ''), 0, wx.ALIGN_LEFT|wx.ALL, 2)
     vbs.Add(self.duration_all, 0, wx.ALIGN_LEFT|wx.ALL, 2)
     vbs.Add(self.duration_in, 0, wx.ALIGN_LEFT|wx.ALL, 2)
     vbs.Add(self.duration_out, 0, wx.ALIGN_LEFT|wx.ALL, 2)
     vbs.Add(self.duration_data, 0, wx.ALIGN_LEFT|wx.ALL, 2)
     self.SetSizer(vbs)
     self.SetAutoLayout(True)
     vbs.Fit(self)
     self.SetupScrolling()
     self.SetBackgroundColour(wx.WHITE)
     self._populate()
Beispiel #27
0
def publish_event(event_t, data=None, extra_channels=None, wait=None):
    event = Event(event_t, data)
    pubsub.publish("shoebot", event)
    for channel_name in extra_channels or []:
        pubsub.publish(channel_name, event)
    if wait is not None:
        channel = pubsub.subscribe(wait)
        channel.listen(wait)
Beispiel #28
0
def frame_handler_loop(cam_id,  # type: Union[int, str]
                       frame_handler,  # type: Callable[[np.ndarray, int], Any]
                       request_size=(1280, 720),  # type: Tuple[int, int]
                       high_speed=False,  # type: bool
                       fps_limit=240  # type: float
                       ):
    t = pub_cam_thread(cam_id, request_size, high_speed, fps_limit)
    sub_cam = pubsub.subscribe("CVCams." + str(cam_id) + ".Vid")
    sub_owner = pubsub.subscribe("CVCamHandlers." + str(cam_id) + ".Cmd")
    msg_owner = ''
    while msg_owner != 'quit':
        frame = listen_default(sub_cam, timeout=.1)  # type: np.ndarray
        if frame is not None:
            frame = frame[0]
            frame_handler(frame, cam_id)
        msg_owner = listen_default(sub_owner, block=False, empty='')
    pubsub.publish("CVCams." + str(cam_id) + ".Cmd", 'quit')
    t.join()
 def __init__(self, mainwindow, parent):
     super(MediaWidget, self).__init__(parent, -1)
     self._main_window=mainwindow
     self.call_history_tree_nodes={}
     self._parent=parent
     self.vbs=wx.BoxSizer(wx.VERTICAL)
     self.vbs.Add(wx.StaticText(self, -1, 'Media summary'), 0, wx.ALIGN_LEFT|wx.ALL, 2)
     self.SetSizer(self.vbs)
     self.SetAutoLayout(True)
     self.vbs.Fit(self)
     self.ringernodes={}
     self.wallpapernodes={}
     self.widget_to_save=None
     self.origin_to_save=""
     self.SetBackgroundColour(wx.WHITE)
     self.ringerwidget=ringers.RingerView(self._main_window, parent, self)
     self.wallpaperwidget=wallpaper.WallpaperView(self._main_window, parent, self)
     pubsub.subscribe(self.OnPhoneModelChanged, pubsub.PHONE_MODEL_CHANGED)
Beispiel #30
0
 def loop(self):
     sub_cmd = pubsub.subscribe("CVWinCmd")
     msg_cmd = ''
     while msg_cmd != 'quit':
         self.update_window_frames()
         self.handle_keys(cv2.waitKey(1))
         msg_cmd = listen_default(sub_cmd, block=False, empty='')
     pubsub.publish("CVWinCmd", 'quit')
     self.__stop_all_cams()
 def __init__(self, mainwindow, parent, id=-1):
     """constructor
     @type  mainwindow: gui.MainWindow
     @param mainwindow: Used to get configuration data (such as directory to save/load data.
     @param parent:     Widget acting as parent for this one
     @param id:         id
     """
     self.mainwindow=mainwindow
     self.entrycache={}
     self.entries={}
     self.repeating=[]  # nb this is stored unsorted
     self._data={} # the underlying data
     calendarcontrol.Calendar.__init__(self, parent, rows=5, id=id)
     self.dialog=calendarentryeditor.Editor(self)
     pubsub.subscribe(self.OnMediaNameChanged, pubsub.MEDIA_NAME_CHANGED)
     today.bind_notification_event(self.OnTodayItem,
                                   today.Today_Group_Calendar)
     today.bind_request_event(self.OnTodayRequest)
     pubsub.subscribe(self.OnTodayButton, pubsub.MIDNIGHT)
 def __init__(self, mainwindow, parent, id=-1):
     self.mainwindow=mainwindow
     self._data={'ringtone-index': {}}
     self.updateprofilevariables(self.mainwindow.phoneprofile)
     self.organizemenu=wx.Menu()
     fileview.FileView.__init__(self, mainwindow, parent, "ringtone-watermark")
     self.wildcard="Audio files|*.wav;*.mid;*.qcp;*.mp3;*.pmd|Midi files|*.mid|Purevoice files|*.qcp|MP3 files|*.mp3|PMD/CMX files|*.pmd|All files|*.*"
     self.organizeinfo={}
     for k in self.organizetypes:
         id=wx.NewId()
         self.organizemenu.AppendRadioItem(id, k)
         wx.EVT_MENU(self, id, self.OrganizeChange)
         self.organizeinfo[id]=getattr(self, "organizeby_"+k.replace(" ",""))
     self.modified=False
     wx.EVT_IDLE(self, self.OnIdle)
     pubsub.subscribe(self.OnListRequest, pubsub.REQUEST_RINGTONES)
     pubsub.subscribe(self.OnDictRequest, pubsub.REQUEST_RINGTONE_INDEX)
     self._raw_media=self._shift_down=False
     wx.EVT_KEY_DOWN(self.aggdisp, self._OnKey)
     wx.EVT_KEY_UP(self.aggdisp, self._OnKey)
Beispiel #33
0
    def __init__(self, mainwindow, parent, media_root):
        global thewallpapermanager
        thewallpapermanager = self
        self.mainwindow = mainwindow
        self.usewidth = 10
        self.useheight = 10
        self._dummy_image_filename = guihelper.getresourcefile('wallpaper.png')
        wx.FileSystem_AddHandler(BPFSHandler(self))
        self._data = {self.database_key: {}}
        fileview.FileView.__init__(self, mainwindow, parent, media_root,
                                   "wallpaper-watermark")
        self.thedir = self.mainwindow.wallpaperpath
        self.wildcard="Image files|*.bmp;*.jpg;*.jpeg;*.png;*.gif;*.pnm;*.tiff;*.ico;*.bci;*.bit"\
                       "|Video files|*.3g2|All files|*.*"

        ##        self.bgmenu.Insert(1,guihelper.ID_FV_PASTE, "Paste")
        ##        wx.EVT_MENU(self.bgmenu, guihelper.ID_FV_PASTE, self.OnPaste)

        self.modified = False
        pubsub.subscribe(self.OnListRequest, pubsub.REQUEST_WALLPAPERS)
        self._raw_image = self._shift_down = False
Beispiel #34
0
    def __init__(self, mainwindow, parent, media_root):
        global thewallpapermanager
        thewallpapermanager=self
        self.mainwindow=mainwindow
        self.usewidth=10
        self.useheight=10
        self._dummy_image_filename=guihelper.getresourcefile('wallpaper.png')
        wx.FileSystem_AddHandler(BPFSHandler(self))
        self._data={self.database_key: {}}
        fileview.FileView.__init__(self, mainwindow, parent, media_root, "wallpaper-watermark")
        self.thedir=self.mainwindow.wallpaperpath
        self.wildcard="Image files|*.bmp;*.jpg;*.jpeg;*.png;*.gif;*.pnm;*.tiff;*.ico;*.bci;*.bit"\
                       "|Video files|*.3g2|All files|*.*"


##        self.bgmenu.Insert(1,guihelper.ID_FV_PASTE, "Paste")
##        wx.EVT_MENU(self.bgmenu, guihelper.ID_FV_PASTE, self.OnPaste)

        self.modified=False
        pubsub.subscribe(self.OnListRequest, pubsub.REQUEST_WALLPAPERS)
        self._raw_image=self._shift_down=False
Beispiel #35
0
def register(start_recording=None, start_playback=None, stop=None):
    if start_recording:
        pubsub.subscribe(start_recording, pubsub.DR_RECORD)
    if start_playback:
        pubsub.subscribe(start_playback, pubsub.DR_PLAY)
    if stop:
        pubsub.subscribe(stop, pubsub.DR_STOP)
Beispiel #36
0
def register(start_recording=None, start_playback=None, stop=None):
    if start_recording:
        pubsub.subscribe(start_recording, pubsub.DR_RECORD)
    if start_playback:
        pubsub.subscribe(start_playback, pubsub.DR_PLAY)
    if stop:
        pubsub.subscribe(stop, pubsub.DR_STOP)
Beispiel #37
0
    def __init__(self, parent, pos):
        global widgets_list

        pb_editor.DirtyUIBase.__init__(self, parent)
        self.static_box = wx.StaticBox(self, -1, "Category")
        hs = wx.StaticBoxSizer(self.static_box, wx.HORIZONTAL)

        self.categories = []
        self.category = wx.ListBox(self, -1, choices=self.categories)
        pubsub.subscribe(self.OnUpdateCategories, pubsub.ALL_CATEGORIES)
        pubsub.publish(pubsub.REQUEST_CATEGORIES)
        # a boxsizer for the master category list
        vbs = wx.BoxSizer(wx.VERTICAL)
        vbs.Add(wx.StaticText(self, -1, 'Master Category'), 0,
                wx.TOP | wx.LEFT, 5)
        vbs.Add(self.category, 1, wx.EXPAND | wx.ALL, 5)
        hs.Add(vbs, 1, wx.EXPAND | wx.ALL, 5)
        # a boxsizer for the buttons
        vbs = wx.BoxSizer(wx.VERTICAL)
        self.but = wx.Button(self, wx.NewId(), "Manage Categories:")
        add_btn = wx.Button(self, -1, 'Add ->')
        del_btn = wx.Button(self, -1, '<- Remove')
        vbs.Add(self.but, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        vbs.Add(add_btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        vbs.Add(del_btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        hs.Add(vbs, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        wx.EVT_BUTTON(self, add_btn.GetId(), self.OnAddCategory)
        wx.EVT_BUTTON(self, del_btn.GetId(), self.OnDelCategory)
        # box sizer for the selected category
        vbs = wx.BoxSizer(wx.VERTICAL)
        vbs.Add(wx.StaticText(self, -1, 'Selected Category:'), 0,
                wx.TOP | wx.LEFT, 5)
        self._my_category = wx.ListBox(self, -1)
        vbs.Add(self._my_category, 1, wx.EXPAND | wx.ALL, 5)
        hs.Add(vbs, 1, wx.EXPAND | wx.ALL, 5)
        wx.EVT_BUTTON(self, self.but.GetId(), self.OnManageCategories)

        self.SetSizer(hs)
        hs.Fit(self)
Beispiel #38
0
    def subscribe(self):
        subscribe(self.updateRelation, "newGraphPair.gui")
        subscribe(self.updateRelation, "newNodeSelect.gui")

        # Updating on newRelation seems redundant, but is required
        # when the relation is changed by another method than the radio buttons,
        # e.g. using shortcut keys
        subscribe(self.updateRelation, "newRelation.gui")
Beispiel #39
0
def pub_cam_loop(
        cam_id,  # type: Union[int, str]
        request_size=(1280, 720),  # type: Tuple[int, int]
        high_speed=False,  # type: bool
        fps_limit=240  # type: float
):  # type: (...)->bool
    """Publishes whichever camera you select to CVCams.<cam_id>.Vid
    You can send a quit command 'quit' to CVCams.<cam_id>.Cmd
    Status information, such as failure to open, will be posted to CVCams.<cam_id>.Status


    :param high_speed: Selects mjpeg transferring, which most cameras seem to support, so speed isn't limited
    :param fps_limit: Limits the frames per second.
    :param cam_id: An integer representing which webcam to use, or a string representing a video file.
    :param request_size: A tuple with width, then height, to request the video size.
    :return: True if loop ended normally, False if it failed somehow.
    """
    sub = pubsub.subscribe("CVCams." + str(cam_id) + ".Cmd")
    msg = ''
    cam = cv2.VideoCapture(cam_id)
    # cam.set(cv2.CAP_PROP_CONVERT_RGB, 0)
    frame_counter = 0

    if high_speed:
        cam.set(cv2.CAP_PROP_FOURCC, cv2.CAP_OPENCV_MJPEG)

    cam.set(cv2.CAP_PROP_FRAME_WIDTH, request_size[0])
    cam.set(cv2.CAP_PROP_FRAME_HEIGHT, request_size[1])

    if not cam.isOpened():
        pubsub.publish("CVCams." + str(cam_id) + ".Status", "failed")
        return False
    now = time.time()
    while msg != 'quit':
        time.sleep(1. / (fps_limit - (time.time() - now)))
        now = time.time()
        (ret, frame) = cam.read()  # type: Tuple[bool, np.ndarray ]
        if ret is False or not isinstance(frame, np.ndarray):
            cam.release()
            pubsub.publish("CVCams." + str(cam_id) + ".Status", "failed")
            return False
        if cam.get(cv2.CAP_PROP_FRAME_COUNT) > 0:
            frame_counter += 1
            if frame_counter >= cam.get(cv2.CAP_PROP_FRAME_COUNT):
                frame_counter = 0
                cam = cv2.VideoCapture(cam_id)
        pubsub.publish("CVCams." + str(cam_id) + ".Vid", (frame, ))
        msg = listen_default(sub, block=False, empty='')

    cam.release()
    return True
Beispiel #40
0
 def subscribe(self):
     subscribe(self.updateRelation, "newGraphPair.gui")                
     subscribe(self.updateRelation, "newNodeSelect.gui")
     
     # Updating on newRelation seems redundant, but is required
     # when the relation is changed by another method than the radio buttons,
     # e.g. using shortcut keys
     subscribe(self.updateRelation, "newRelation.gui")
Beispiel #41
0
 def __init__(self, mainwindow, parent):
     super(MediaWidget, self).__init__(parent, -1)
     self._main_window = mainwindow
     self.call_history_tree_nodes = {}
     self._parent = parent
     # main box sizer
     self.vbs = wx.BoxSizer(wx.VERTICAL)
     # main stats display
     self.vbs.Add(wx.StaticText(self, -1, 'Media summary'), 0,
                  wx.ALIGN_LEFT | wx.ALL, 2)
     # all done
     self.SetSizer(self.vbs)
     self.SetAutoLayout(True)
     self.vbs.Fit(self)
     self.ringernodes = {}
     self.wallpapernodes = {}
     self.widget_to_save = None
     self.origin_to_save = ""
     self.SetBackgroundColour(wx.WHITE)
     self.ringerwidget = ringers.RingerView(self._main_window, parent, self)
     self.wallpaperwidget = wallpaper.WallpaperView(self._main_window,
                                                    parent, self)
     pubsub.subscribe(self.OnPhoneModelChanged, pubsub.PHONE_MODEL_CHANGED)
Beispiel #42
0
def publish_event(event_t, data=None, extra_channels=None, wait=None):
    """
    Publish an event ot any subscribers.

    :param event_t:  event type
    :param data:     event data
    :param extra_channels:
    :param wait:
    :return:
    """
    event = Event(event_t, data)
    pubsub.publish("shoebot", event)
    for channel_name in extra_channels or []:
        pubsub.publish(channel_name, event)
    if wait is not None:
        channel = pubsub.subscribe(wait)
        channel.listen(wait)
Beispiel #43
0
def publish_event(event_t, data=None, extra_channels=None, wait=None):
    """
    Publish an event ot any subscribers.

    :param event_t:  event type
    :param data:     event data
    :param extra_channels:
    :param wait:
    :return:
    """
    event = Event(event_t, data)
    pubsub.publish("shoebot", event)
    for channel_name in extra_channels or []:
        pubsub.publish(channel_name, event)
    if wait is not None:
        channel = pubsub.subscribe(wait)
        channel.listen(wait)
 def __init__(self, parent):
     self.parent=parent
     today.TodayWidget.__init__(self, self, self.parent)
     pubsub.subscribe(self.OnPhoneChanged, pubsub.PHONE_MODEL_CHANGED)
        for k in self.organizetypes:

            id=wx.NewId()

            self.organizemenu.AppendRadioItem(id, k)

            wx.EVT_MENU(self, id, self.OrganizeChange)

            self.organizeinfo[id]=getattr(self, "organizeby_"+k.replace(" ",""))

        self.modified=False

        wx.EVT_IDLE(self, self.OnIdle)

        pubsub.subscribe(self.OnListRequest, pubsub.REQUEST_RINGTONES)

        pubsub.subscribe(self.OnDictRequest, pubsub.REQUEST_RINGTONE_INDEX)

        self._raw_media=self._shift_down=False

        wx.EVT_KEY_DOWN(self.aggdisp, self._OnKey)

        wx.EVT_KEY_UP(self.aggdisp, self._OnKey)

	def updateprofilevariables(self, profile):

        self.maxlen=profile.MAX_RINGTONE_BASENAME_LENGTH

        self.filenamechars=profile.RINGTONE_FILENAME_CHARS
            self.organizemenu.AppendRadioItem(id, k)

            wx.EVT_MENU(self, id, self.OrganizeChange)

            self.organizeinfo[id]=getattr(self, "organizeby_"+k.replace(" ",""))

            if k==last_mode:

                self.organizemenu.Check(id, True)

        self.modified=False

        wx.EVT_IDLE(self, self.OnIdle)

        pubsub.subscribe(self.OnListRequest, pubsub.REQUEST_WALLPAPERS)

        pubsub.subscribe(self.OnPhoneModelChanged, pubsub.PHONE_MODEL_CHANGED)

        self._raw_image=self._shift_down=False

        wx.EVT_KEY_DOWN(self.aggdisp, self._OnKey)

        wx.EVT_KEY_UP(self.aggdisp, self._OnKey)

	def OnPhoneModelChanged(self, msg):

        phonemodule=msg.data

        self.updateprofilevariables(phonemodule.Profile)
Beispiel #47
0
"""
The pubsub library enables communication between the GUI parts of shoebot
and the commandline shell.
"""

import collections
import pubsub

# Only the 'shoebot' channel is used
channel = pubsub.subscribe("shoebot")


def namedtuple_with_defaults(typename, field_names, default_values=()):
    T = collections.namedtuple(typename, field_names)
    T.__new__.__defaults__ = (None,) * len(T._fields)
    if isinstance(default_values, collections.Mapping):
        prototype = T(**default_values)
    else:
        prototype = T(*default_values)
    T.__new__.__defaults__ = tuple(prototype)
    return T


Event = namedtuple = namedtuple_with_defaults("Event", "type data", dict(data=None))

QUIT_EVENT = "quit"
SOURCE_CHANGED_EVENT = "source-changed"
VARIABLE_UPDATED_EVENT = "variable-updated"
SET_WINDOW_TITLE = "set-window-title"
REDRAW = "redraw"
	def Set(self, data):

        self.ignore_dirty=True

        if data is None:

            for n in self._fields:

                n[self._w_index].Enable(False)

        else:

            for n in self._fields:

                w=n[self._w_index]

                w.Enable(True)

                w.SetValue(getattr(data, n[self._dict_key_index]))

        self.ignore_dirty=self.dirty=False

	def Get(self, data):

        self.ignore_dirty=self.dirty=False

        if data is None:

            return

        for n in self._fields:

            w=n[self._w_index]

            v=w.GetValue()

            setattr(data, n[self._dict_key_index], v)


class  TodoWidget (wx.Panel) :
	color_field_name='todo'
	    def __init__(self, mainwindow, parent):

        global widgets_list

        super(TodoWidget, self).__init__(parent, -1)

        self._main_window=mainwindow

        self._data=self._data_map={}

        vbs=wx.BoxSizer(wx.VERTICAL)

        hbs=wx.BoxSizer(wx.HORIZONTAL)

        self._item_list=wx.ListBox(self, wx.NewId(),
                                    style=wx.LB_SINGLE|wx.LB_HSCROLL|wx.LB_NEEDED_SB)

        hbs.Add(self._item_list, 1, wx.EXPAND|wx.BOTTOM, border=5)

        scrolled_panel=scrolled.ScrolledPanel(self, -1)

        vbs1=wx.BoxSizer(wx.VERTICAL)

        self._items=(
            (GeneralEditor, 0, None),
            (cal_editor.CategoryEditor, 1, 'category'),
            (pb_editor.MemoEditor, 1, 'memo')
            )

        self._w=[]

        for n in self._items:

            w=n[0](scrolled_panel, -1)

            vbs1.Add(w, n[1], wx.EXPAND|wx.ALL, 5)

            self._w.append(w)

            if n[2]:

                widgets_list.append((w.static_box, n[2]))

        scrolled_panel.SetSizer(vbs1)

        scrolled_panel.SetAutoLayout(True)

        vbs1.Fit(scrolled_panel)

        scrolled_panel.SetupScrolling()

        hbs.Add(scrolled_panel, 3, wx.EXPAND|wx.ALL, border=5)

        self._general_editor_w=self._w[0]

        self._cat_editor_w=self._w[1]

        self._memo_editor_w=self._w[2]

        hbs1=wx.BoxSizer(wx.HORIZONTAL)

        self._save_btn=wx.Button(self, wx.NewId(), "Save")

        self._revert_btn=wx.Button(self, wx.NewId(), "Revert")

        help_btn=wx.Button(self, wx.ID_HELP, "Help")

        hbs1.Add(self._save_btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        hbs1.Add(help_btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        hbs1.Add(self._revert_btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

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

        vbs.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5)

        vbs.Add(hbs1, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        self.SetSizer(vbs)

        self.SetAutoLayout(True)

        vbs.Fit(self)

        wx.EVT_LISTBOX(self, self._item_list.GetId(), self._OnListBoxItem)

        wx.EVT_BUTTON(self, self._save_btn.GetId(), self._OnSave)

        wx.EVT_BUTTON(self, self._revert_btn.GetId(), self._OnRevert)

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

        for w in self._w:

            pb_editor.EVT_DIRTY_UI(self, w.GetId(), self.OnMakeDirty)

        self._populate()

        self.ignoredirty=False

        self.setdirty(False)

        today.bind_notification_event(self.OnTodaySelection,
                                      today.Today_Group_Todo)

        today.bind_request_event(self.OnTodayRequest)

        field_color.reload_color_info(self, widgets_list)

        pubsub.subscribe(self.OnPhoneChanged, pubsub.PHONE_MODEL_CHANGED)

	def OnPhoneChanged(self, _):

        field_color.reload_color_info(self, widgets_list)

        self.Refresh()

	def _clear(self):

        self._item_list.Clear()

        self._clear_each()

	def _clear_each(self):

        for w in self._w:

            w.Set(None)

            w.Enable(False)

        self.Refresh()

	def _publish_today_events(self):

        now=datetime.datetime.now()

        _today='%04d%02d%02d'%(now.year, now.month, now.day)

        keys=self._data.keys()

        keys.sort()

        today_event=today.TodayTodoEvent()

        for k in keys:

            if self._data[k].is_active() and \
               (not self._data[k].due_date or \
                self._data[k].due_date<=_today):

                today_event.append(self._data[k].summary,
                                   { 'key': k,
                                     'index': self._data_map[k] })

        today_event.broadcast()

	def _publish_thisweek_events(self):

        now=datetime.datetime.now()

        _today='%04d%02d%02d'%(now.year, now.month, now.day)

        s=now+datetime.timedelta(7-now.isoweekday()%7)

        _sun='%04d%02d%02d'%(s.year, s.month, s.day)

        keys=self._data.keys()

        keys.sort()

        today_event=today.ThisWeekTodoEvent()

        dow_flg=[False]*7

        for k in keys:

            due_date=self._data[k].due_date

            if due_date>_today and due_date<_sun:

                dt=datetime.datetime(int(due_date[:4]), int(due_date[4:6]),
                                         int(due_date[6:8]))

                _dow=dt.isoweekday()%7

                if dow_flg[_dow]:

                    _name=today.dow_initials[-1]+'   '+self._data[k].summary

                else:

                    dow_flg[_dow]=True

                    _name=today.dow_initials[_dow]+' - '+self._data[k].summary

                today_event.append(_name, { 'key': k,
                                            'index': self._data_map[k] })

        today_event.broadcast()

	def OnTodayRequest(self, _):

        self._publish_today_events()

        self._publish_thisweek_events()

	def OnTodaySelection(self, evt):

        if evt.data:

            self._item_list.SetSelection(evt.data.get('index', wx.NOT_FOUND))

            self._populate_each(evt.data.get('key', None))

	def _populate(self):

        self._clear()

        self._data_map={}

        keys=self._data.keys()

        keys.sort()

        for k in keys:

            n=self._data[k]

            i=self._item_list.Append(n.summary)

            self._item_list.SetClientData(i, k)

            self._data_map[k]=i

        self._publish_today_events()

        self._publish_thisweek_events()

	def _populate_each(self, k):

        if k is None:

            self._clear_each()

            return

        self.ignoredirty=True

        for w in self._w:

            w.Enable(True)

        entry=self._data[k]

        self._general_editor_w.Set(entry)

        self._cat_editor_w.Set(entry.categories)

        self._memo_editor_w.Set({ 'memo': entry.note })

        self.ignoredirty=False

        self.setdirty(False)

	def OnMakeDirty(self, _=None):

        """A public function you can call that will set the dirty flag"""

        if self.dirty or self.ignoredirty or not self.IsShown():

            return

        self.setdirty(True)

	def setdirty(self, val):

        """Set the dirty flag"""

        if self.ignoredirty:

            return

        self.dirty=val

        self._item_list.Enable(not self.dirty)

        self._save_btn.Enable(self.dirty)

        self._revert_btn.Enable(self.dirty)

	def OnAdd(self, _):

        if self.dirty:

            return

        m=TodoEntry()

        m.summary='New Task'

        self._data[m.id]=m

        self._populate()

        self._save_to_db(self._data)

        self._item_list.Select(self._data_map[m.id])

        self._populate_each(m.id)

	def OnDelete(self, _):

        sel_idx=self._item_list.GetSelection()

        if sel_idx is None or sel_idx==-1:

            return

        self.ignoredirty=True

        k=self._item_list.GetClientData(sel_idx)

        self._item_list.Delete(sel_idx)

        self._clear_each()

        del self._data[k]

        del self._data_map[k]

        self._save_to_db(self._data)

        self.ignoredirty=False

        self.setdirty(False)

	def getdata(self,dict,want=None):

        dict['todo']=copy.deepcopy(self._data)

        return dict

	def populate(self, dict):

        self._data=dict.get('todo', {})

        self._populate()

	def _save_to_db(self, todo_dict):

        db_rr={}

        for k, e in todo_dict.items():

            db_rr[k]=TodoDataObject(e)

        database.ensurerecordtype(db_rr, todoobjectfactory)

        self._main_window.database.savemajordict('todo', db_rr)

        self._publish_today_events()

        self._publish_thisweek_events()

	def populatefs(self, dict):

        self._save_to_db(dict.get('todo', {}))

        return dict

	def getfromfs(self, result):

        todo_dict=self._main_window.database.\
                   getmajordictvalues('todo',todoobjectfactory)

        r={}

        for k,e in todo_dict.items():

            ce=TodoEntry()

            ce.set_db_dict(e)

            r[ce.id]=ce

        result.update({ 'todo': r })

        return result

	def _OnListBoxItem(self, evt):

        self._populate_each(self._item_list.GetClientData(evt.GetInt()))

        self.Refresh()

	def _OnSave(self, evt):

        self.ignoredirty=True

        sel_idx=self._item_list.GetSelection()

        k=self._item_list.GetClientData(sel_idx)

        entry=self._data[k]

        self._general_editor_w.Get(entry)

        entry.note=self._memo_editor_w.Get().get('memo', None)

        entry.categories=self._cat_editor_w.Get()

        entry.check_completion()

        self._general_editor_w.Set(entry)

        self._item_list.SetString(sel_idx, entry.summary)

        self._save_to_db(self._data)

        self.ignoredirty=False

        self.setdirty(False)

	def _OnRevert(self, evt):

        self.ignoredirty=True

        sel_idx=self._item_list.GetSelection()

        k=self._item_list.GetClientData(sel_idx)

        self._populate_each(k)

        self.ignoredirty=False

        self.setdirty(False)
 def _bind(func):
     pubsub.subscribe(func, pubsub.NEW_DATA_AVAILABLE)
	def summary(self, name=None):

        s=self.datetime

        if s:

            s=s[4:6]+'/'+s[6:8]+' '+s[9:11]+':'+s[11:13]+' '

        else:

            s='**/** **:** '

        if name:

            s+=name

        elif self.name:

            s+=self.name

        else:

            s+=phonenumber.format(self.number)

        return s

	def _get_date_str(self):

        s=self.datetime

        if not len(s):

            return '****-**-**'

        else:

            return s[:4]+'-'+s[4:6]+'-'+s[6:8]

	date_str=property(fget=_get_date_str)

class  CallHistoryWidget (scrolled.ScrolledPanel) :
	_data_key='call_history'
	    _by_type=0
	    _by_date=1
	    _by_number=2
	    def __init__(self, mainwindow, parent):

        super(CallHistoryWidget, self).__init__(parent, -1)

        self._main_window=mainwindow

        self._data={}

        self._node_dict={}

        self._name_map={}

        self._by_mode=self._by_type

        self._display_func=(self._display_by_type, self._display_by_date,
                             self._display_by_number)

        vbs=wx.BoxSizer(wx.VERTICAL)

        hbs=wx.BoxSizer(wx.HORIZONTAL)

        self.read_only=False

        self.historical_date=None

        static_bs=wx.StaticBoxSizer(wx.StaticBox(self, -1,
                                                 'Historical Data Status:'),
                                    wx.VERTICAL)

        self.historical_data_label=wx.StaticText(self, -1, 'Current Data')

        static_bs.Add(self.historical_data_label, 1, wx.EXPAND|wx.ALL, 5)

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

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

        self._item_list=wx.TreeCtrl(self, wx.NewId(),
                                    style=wx.TR_MULTIPLE|wx.TR_HAS_BUTTONS)

        vbs.Add(self._item_list, 1, wx.EXPAND|wx.ALL, 5)

        self._root=self._item_list.AddRoot('Call History')

        self._nodes={}

        organize_menu=wx.Menu()

        organize_menu_data=(
            ('Type', self._OnOrganizedByType),
            ('Date', self._OnOrganizedByDate),
            ('Number', self._OnOrganizedByNumber))

        for e in organize_menu_data:

            id=wx.NewId()

            organize_menu.AppendRadioItem(id, e[0])

            wx.EVT_MENU(self, id, e[1])

        context_menu_data=(
            ('Expand All', self._OnExpandAll),
            ('Collapse All', self._OnCollapseAll))

        self._bgmenu=wx.Menu()

        self._bgmenu.AppendMenu(wx.NewId(), 'Organize Items by', organize_menu)

        for e in context_menu_data:

            id=wx.NewId()

            self._bgmenu.Append(id, e[0])

            wx.EVT_MENU(self, id, e[1])

        pubsub.subscribe(self._OnPBLookup, pubsub.RESPONSE_PB_LOOKUP)

        wx.EVT_RIGHT_UP(self._item_list, self._OnRightClick)

        self.SetSizer(vbs)

        self.SetAutoLayout(True)

        vbs.Fit(self)

        self.SetupScrolling()

        self._populate()

	def _OnPBLookup(self, msg):

        d=msg.data

        k=d.get('item', None)

        name=d.get('name', None)

        if k is None:

            return

        self._name_map[k]=name

	def _OnRightClick(self, evt):

        self._item_list.PopupMenu(self._bgmenu, evt.GetPosition())

	def _OnOrganizedByType(self, evt):

        evt.GetEventObject().Check(evt.GetId(), True)

        if self._by_mode!=self._by_type:

            self._by_mode=self._by_type

            self._display_func[self._by_type]()

            self._expand_all()

	def _OnOrganizedByDate(self, evt):

        evt.GetEventObject().Check(evt.GetId(), True)

        if self._by_mode!=self._by_date:

            self._by_mode=self._by_date

            self._display_func[self._by_date]()

            self._expand_all()

	def _OnOrganizedByNumber(self, evt):

        evt.GetEventObject().Check(evt.GetId(), True)

        if self._by_mode!=self._by_number:

            self._by_mode=self._by_number

            self._display_func[self._by_number]()

            self._expand_all()

	def _expand_all(self, sel_id=None):

        if sel_id is None:

            sel_id=self._root

        self._item_list.Expand(sel_id)

        id, cookie=self._item_list.GetFirstChild(sel_id)

        while id.IsOk():

            self._item_list.Expand(id)

            id, cookie=self._item_list.GetNextChild(sel_id, cookie)

	def _OnExpandAll(self, _):

        sel_ids=self._item_list.GetSelections()

        if not sel_ids:

            sel_ids=[self._root]

        for sel_id in sel_ids:

            if not sel_id.IsOk():

                sel_id=self._root

            self._expand_all(sel_id)

	def _OnCollapseAll(self, _):

        sel_ids=self._item_list.GetSelections()

        if not sel_ids:

            sel_ids=[self._root]

        for sel_id in sel_ids:

            if not sel_id.IsOk():

                sel_id=self._root

            self._item_list.Collapse(sel_id)

            id, cookie=self._item_list.GetFirstChild(sel_id)

            while id.IsOk():

                self._item_list.Collapse(id)

                id, cookie=self._item_list.GetNextChild(sel_id, cookie)

	def _clear(self):

        self._item_list.Collapse(self._root)

        for k,e in self._nodes.items():

            self._item_list.DeleteChildren(e)

	def _display_by_date(self):

        self._item_list.CollapseAndReset(self._root)

        self._nodes={}

        date_list=[]

        for k,e in self._data.items():

            if e.date_str not in date_list:

                date_list.append(e.date_str)

        date_list.sort()

        for s in date_list:

            self._nodes[s]=self._item_list.AppendItem(self._root, s)

        for k,e in self._data.items():

            i=self._item_list.AppendItem(self._nodes[e.date_str],
                                          e.get_repr(self._name_map.get(e.number, None)))

            self._item_list.SetItemPyData(i, k)

	def _display_by_number(self):

        self._item_list.CollapseAndReset(self._root)

        self._nodes={}

        number_list=[]

        for k,e in self._data.items():

            s=phonenumber.format(e.number)

            if s not in number_list:

                number_list.append(s)

        number_list.sort()

        for s in number_list:

            self._nodes[s]=self._item_list.AppendItem(self._root, s)

        for k,e in self._data.items():

            i=self._item_list.AppendItem(self._nodes[phonenumber.format(e.number)],
                                          e.get_repr(self._name_map.get(e.number, None)))

            self._item_list.SetItemPyData(i, k)

	def _display_by_type(self):

        self._item_list.CollapseAndReset(self._root)

        self._nodes={}

        for s in CallHistoryEntry.Valid_Folders:

            self._nodes[s]=self._item_list.AppendItem(self._root, s)

        node_dict={}

        for k,e in self._data.items():

            node_dict[e.get_repr(self._name_map.get(e.number, None))]=k

        keys=node_dict.keys()

        keys.sort()

        for k in keys:

            data_key=node_dict[k]

            n=self._data[data_key]

            i=self._item_list.AppendItem(self._nodes[n.folder], k)

            self._item_list.SetItemPyData(i, data_key)

	def _publish_today_data(self):

        keys=[(x.datetime, k) for k,x in self._data.items()]

        keys.sort()

        keys.reverse()

        today_event=today.TodayIncomingCallsEvent()

        today_event.names=[self._data[k].summary(self._name_map.get(self._data[k].number, None))\
                                    for _,k in keys \
                                    if self._data[k].folder==CallHistoryEntry.Folder_Incoming]

        today_event.broadcast()

        today_event=today.TodayMissedCallsEvent()

        today_event.names=[self._data[k].summary(self._name_map.get(self._data[k].number, None))\
                                    for _,k in keys \
                                    if self._data[k].folder==CallHistoryEntry.Folder_Missed]

        today_event.broadcast()

	def _populate(self):

        self._clear()

        self._node_dict={}

        for k,e in self._data.items():

            if e.name:

                if not self._name_map.has_key(e.number):

                    self._name_map[e.number]=e.name

            else:

                if not self._name_map.has_key(e.number):

                    pubsub.publish(pubsub.REQUEST_PB_LOOKUP,
                                   { 'item': e.number } )

        self._display_func[self._by_mode]()

        self._OnExpandAll(None)

        self._publish_today_data()

	def OnDelete(self, _):

        if self.read_only:

            return

        sels_idx=self._item_list.GetSelections()

        if not sels_idx:

            return

        for sel_idx in sels_idx:

            if not sel_idx.Ok():

                continue

            k=self._item_list.GetPyData(sel_idx)

            if k is None:

                continue

            self._item_list.Delete(sel_idx)

            del self._data[k]

        self._save_to_db(self._data)

	def getdata(self, dict, want=None):

        dict[self._data_key]=copy.deepcopy(self._data)

	def populate(self, dict, force=False):

        if self.read_only and not force:

            return

        self._data=dict.get(self._data_key, {})

        self._populate()

	def _save_to_db(self, dict):

        if self.read_only:

            return

        db_rr={}

        for k,e in dict.items():

            db_rr[k]=CallHistoryDataobject(e)

        database.ensurerecordtype(db_rr, callhistoryobjectfactory)

        self._main_window.database.savemajordict(self._data_key, db_rr)

	def populatefs(self, dict):

        if self.read_only:

            wx.MessageBox('You are viewing historical data which cannot be changed or saved',
                             'Cannot Save Call History Data',
                             style=wx.OK|wx.ICON_ERROR)

        else:

            self._save_to_db(dict.get(self._data_key, {}))

        return dict

	def getfromfs(self, result, timestamp=None):

        dict=self._main_window.database.\
                   getmajordictvalues(self._data_key,
                                      callhistoryobjectfactory,
                                      at_time=timestamp)

        r={}

        for k,e in dict.items():

            ce=CallHistoryEntry()

            ce.set_db_dict(e)

            r[ce.id]=ce

        result.update({ self._data_key: r})

        return result

	def merge(self, dict):

        if self.read_only:

            wx.MessageBox('You are viewing historical data which cannot be changed or saved',
                             'Cannot Save Call History Data',
                             style=wx.OK|wx.ICON_ERROR)

            return

        d=dict.get(self._data_key, {})

        l=[e for k,e in self._data.items()]

        for k,e in d.items():

            if e not in l:

                self._data[e.id]=e

        self._save_to_db(self._data)

        self._populate()

	def OnHistoricalData(self):

        """Display current or historical data"""

        if self.read_only:

            current_choice=guiwidgets.HistoricalDataDialog.Historical_Data

        else:

            current_choice=guiwidgets.HistoricalDataDialog.Current_Data

        dlg=guiwidgets.HistoricalDataDialog(self,
                                            current_choice=current_choice,
                                            historical_date=self.historical_date,
                                            historical_events=\
                                            self._main_window.database.getchangescount(self._data_key))

        if dlg.ShowModal()==wx.ID_OK:

            self._main_window.OnBusyStart()

            current_choice, self.historical_date=dlg.GetValue()

            r={}

            if current_choice==guiwidgets.HistoricalDataDialog.Current_Data:

                self.read_only=False

                msg_str='Current Data'

                self.getfromfs(r)

            else:

                self.read_only=True

                msg_str='Historical Data as of %s'%\
                         str(wx.DateTimeFromTimeT(self.historical_date))

                self.getfromfs(r, self.historical_date)

            self.populate(r, True)

            self.historical_data_label.SetLabel(msg_str)

            self._main_window.OnBusyEnd()

        dlg.Destroy()

	def get_selected_data(self):

        res={}

        for sel_idx in self._item_list.GetSelections():

            k=self._item_list.GetPyData(sel_idx)

            if k:

                res[k]=self._data[k]

        return res

	def get_data(self):

        return self._data
Beispiel #51
0
 def __init__(self, parent):
     self.parent=parent
     today.TodayWidget.__init__(self, self, self.parent)
     pubsub.subscribe(self.OnPhoneChanged, pubsub.PHONE_MODEL_CHANGED)
Beispiel #52
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)
Beispiel #53
0
"""
The pubsub library enables communication between the GUI parts of shoebot
and the commandline shell.
"""

import collections
import pubsub

# Only the 'shoebot' channel is used
channel = pubsub.subscribe("shoebot")


def namedtuple_with_defaults(typename, field_names, default_values=()):
    T = collections.namedtuple(typename, field_names)
    T.__new__.__defaults__ = (None, ) * len(T._fields)
    if isinstance(default_values, collections.Mapping):
        prototype = T(**default_values)
    else:
        prototype = T(*default_values)
    T.__new__.__defaults__ = tuple(prototype)
    return T


Event = namedtuple = namedtuple_with_defaults("Event", "type data",
                                              dict(data=None))

QUIT_EVENT = "quit"
SOURCE_CHANGED_EVENT = "source-changed"
VARIABLE_UPDATED_EVENT = "variable-updated"
SET_WINDOW_TITLE = "set-window-title"
REDRAW = "redraw"
 def ShowModal(self):
     pubsub.subscribe(self.OnRingtoneUpdates, pubsub.ALL_RINGTONES)
     wx.CallAfter(pubsub.publish, pubsub.REQUEST_RINGTONES) # make the call once we are onscreen
     return wx.Dialog.ShowModal(self)
Beispiel #55
0
 def __init__(self, mainwindow, parent):
     wx.Panel.__init__(self, parent, -1)
     self._main_window = mainwindow
     self._data = {}
     self._data_map = {}
     # main box sizer
     vbs = wx.BoxSizer(wx.VERTICAL)
     # horizontal sizer for the listbox and tabs
     hbs = wx.BoxSizer(wx.HORIZONTAL)
     # the list box
     self._item_list = wx.ListBox(self,
                                  wx.NewId(),
                                  style=wx.LB_SINGLE | wx.LB_HSCROLL
                                  | wx.LB_NEEDED_SB)
     hbs.Add(self._item_list, 1, wx.EXPAND | wx.BOTTOM, border=5)
     # the detailed info pane
     vbs1 = wx.BoxSizer(wx.VERTICAL)
     self._items = ((GeneralEditor, 0, None), (cal_editor.CategoryEditor, 1,
                                               'category'),
                    (pb_editor.MemoEditor, 1, 'memo'))
     self._w = []
     for n in self._items:
         w = n[0](self, -1)
         vbs1.Add(w, n[1], wx.EXPAND | wx.ALL, 5)
         self._w.append(w)
         if n[2]:
             widgets_list.append((w.static_box, n[2]))
     hbs.Add(vbs1, 3, wx.EXPAND | wx.ALL, border=5)
     self._general_editor_w = self._w[0]
     self._cat_editor_w = self._w[1]
     self._memo_editor_w = self._w[2]
     # the bottom buttons
     hbs1 = wx.BoxSizer(wx.HORIZONTAL)
     self._save_btn = wx.Button(self, wx.ID_SAVE)
     self._revert_btn = wx.Button(self, wx.ID_REVERT_TO_SAVED)
     help_btn = wx.Button(self, wx.ID_HELP)
     hbs1.Add(self._save_btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
     hbs1.Add(help_btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
     hbs1.Add(self._revert_btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
     # all done
     vbs.Add(hbs, 1, wx.EXPAND | wx.ALL, 5)
     vbs.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)
     vbs.Add(hbs1, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
     self.SetSizer(vbs)
     self.SetAutoLayout(True)
     vbs.Fit(self)
     # event handlers
     wx.EVT_LISTBOX(self, self._item_list.GetId(), self._OnListBoxItem)
     wx.EVT_BUTTON(self, self._save_btn.GetId(), self._OnSave)
     wx.EVT_BUTTON(self, self._revert_btn.GetId(), self._OnRevert)
     wx.EVT_BUTTON(self, wx.ID_HELP,
                   lambda _: wx.GetApp().displayhelpid(helpids.ID_TAB_MEMO))
     # DIRTY UI Event handlers
     for w in self._w:
         pb_editor.EVT_DIRTY_UI(self, w.GetId(), self.OnMakeDirty)
     # populate data
     self._populate()
     # turn on dirty flag
     self.ignoredirty = False
     self.setdirty(False)
     # register for Today selection
     today.bind_notification_event(self.OnTodaySelection,
                                   today.Today_Group_Memo)
     # color code editable labels
     field_color.reload_color_info(self, widgets_list)
     pubsub.subscribe(self.OnPhoneChanged, pubsub.PHONE_MODEL_CHANGED)
def bind_request_event(evt_handler):
    pubsub.subscribe(evt_handler, pubsub.REQUEST_TODAY_DATA)
Beispiel #57
0
 def __init__(self, parent, id, caption, categories, style=wx.DEFAULT_DIALOG_STYLE):
     wx.Dialog.__init__(self, parent, id,
                        title=caption, style=style)
     # the main box sizer
     bs=wx.BoxSizer(wx.VERTICAL)
     # the flex grid sizers for the editable items
     main_fgs=wx.FlexGridSizer(0, 1, 0, 0)
     fgs=wx.FlexGridSizer(3, 2, 0, 5)
     fgs1=wx.FlexGridSizer(0, 1, 0, 0)
     fgs2=wx.FlexGridSizer(0, 2, 0, 5)
     # set the date options
     self.SetDateControls(fgs, fgs1)
     # new repeat to single events option
     self._rpt_chkbox=wx.CheckBox(self, id=wx.NewId(), label='Repeat Events:',
                                   style=wx.ALIGN_RIGHT)
     self._rpt_chkbox.Disable()
     fgs.Add(self._rpt_chkbox, 0, wx.ALIGN_RIGHT|wx.TOP|wx.BOTTOM, 5)
     self._rpt_chkbox_text=wx.StaticText(self, -1, 'Import as multi-single events.')
     fgs.Add(self._rpt_chkbox_text, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTRE, 0)
     self._rpt_chkbox_text.Disable()
     # alarm option
     choices=('Disable All Alarms', 'Use Alarm Settings From Calender', 
              'Set Alarm On All Events') 
     self.__alarm_setting = wx.RadioBox(self, id=wx.NewId(),
                                        label="Select Alarm Settings For Imported Events",
                                        choices=choices,
                                        majorDimension=1,
                                        size=(280,-1))
     fgs1.Add(self.__alarm_setting, 0, wx.ALIGN_CENTRE|wx.TOP|wx.BOTTOM, 5)
     #alarm vibrate
     self.__vibrate=wx.CheckBox(self, id=wx.NewId(), label='Alarm Vibrate:',
                                style=wx.ALIGN_RIGHT)
     fgs2.Add(self.__vibrate, 0, wx.ALIGN_RIGHT|wx.TOP|wx.BOTTOM, 5)
     self.__vibrate_text=wx.StaticText(self, -1, 'Enable vibrate for alarms.')
     fgs2.Add(self.__vibrate_text, 0, wx.ALIGN_LEFT|wx.TOP|wx.BOTTOM, 5)
     # alarm settings
     self.__ringtone_text=wx.StaticText(self, -1, 'Alarm Ringtone:')
     fgs2.Add(self.__ringtone_text, 0, wx.ALIGN_RIGHT|wx.TOP|wx.BOTTOM, 5)
     self.__ringtone=wx.ComboBox(self, id=wx.NewId(),
                                 style=wx.CB_DROPDOWN|wx.CB_READONLY,
                                 choices=[self.unnamed], size=(160,-1))
     fgs2.Add(self.__ringtone, 0, wx.ALIGN_LEFT|wx.TOP|wx.BOTTOM, 2)
     # alarm value
     self.__alarm_value_text=wx.StaticText(self, -1, 'Alert before (mins):')
     fgs2.Add(self.__alarm_value_text, 0, wx.ALIGN_RIGHT|wx.TOP|wx.BOTTOM, 5)
     self.__alarm_value=wx.lib.intctrl.IntCtrl(self, id=wx.NewId(), size=(50,-1), 
                                            value=0, min=0, max=1000)
     fgs2.Add( self.__alarm_value, 0, wx.ALIGN_LEFT|wx.TOP|wx.BOTTOM, 2)
     # category option
     self.__cat_chkbox=wx.CheckBox(self, id=wx.NewId(), label='Categories:',
                                   style=wx.ALIGN_RIGHT)
     fgs2.Add(self.__cat_chkbox, 0, wx.ALIGN_RIGHT|wx.TOP|wx.BOTTOM, 5)
     for i,c in enumerate(categories):
         if not len(c):
             categories[i]='<None>'
     self.__cats=wx.CheckListBox(self, choices=categories, size=(160, 50))
     self.__cats.Disable()
     fgs2.Add(self.__cats, 0, wx.ALIGN_LEFT, 0)
     main_fgs.Add(fgs, 1, wx.EXPAND|wx.ALL, 0)
     main_fgs.Add(fgs1, 1, wx.EXPAND|wx.ALL, 0)
     main_fgs.Add(fgs2, 1, wx.EXPAND|wx.ALL, 0)
     bs.Add(main_fgs, 1, wx.EXPAND|wx.ALL, 5)
     # the buttons
     bs.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5)
     bs.Add(self.CreateButtonSizer(wx.OK|wx.CANCEL), 0, wx.ALIGN_CENTRE|wx.ALL, 5)
     # event handles
     wx.EVT_CHECKBOX(self, self._start_date_chkbox.GetId(), self.OnCheckBox)
     wx.EVT_CHECKBOX(self, self._end_date_chkbox.GetId(), self.OnCheckBox)
     wx.EVT_CHECKBOX(self, self.__cat_chkbox.GetId(), self.OnCheckBox)
     wx.EVT_RADIOBOX(self, self.__alarm_setting.GetId(), self.OnAlarmSetting)
     # Listen to changes in ringtones list
     pubsub.subscribe(self.OnRingtoneUpdates, pubsub.ALL_RINGTONES)
     # all done
     self.SetSizer(bs)
     self.SetAutoLayout(True)
     bs.Fit(self)
Beispiel #58
0
 def attach(self, topic, listener):
     pubsub.subscribe(listener, topic)