本文整理汇总了Python中pubsub.subscribe函数的典型用法代码示例。如果您正苦于以下问题:Python subscribe函数的具体用法?Python subscribe怎么用?Python subscribe使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了subscribe函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
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)
示例2: __init__
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)
示例3: __init__
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)
示例4: _handle_mfeeder_conn
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()
示例5: __init__
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
示例6: __init__
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)
示例7: __init__
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)
示例8: __init__
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)
示例9: __init__
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)
示例10: __init__
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
示例11: __init__
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()
示例12: test_unsubscribe
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')
示例13: __init__
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()
示例14: __init__
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)
示例15: __init__
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)