• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python pubsub.publish函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pubsub.publish函数的典型用法代码示例。如果您正苦于以下问题:Python publish函数的具体用法?Python publish怎么用?Python publish使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了publish函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:joliebig,项目名称:featurehouse_fstmerge_examples,代码行数:33,代码来源:calendarentryeditor.py


示例2: do_load_base64

    def do_load_base64(self, line):
        """
        load filename=(file)
        load base64=(base64 encoded)
        """

        cookie = self.cookie
        executor = self.bot._executor

        def source_good():
            self.print_response(status=RESPONSE_CODE_OK, cookie=cookie)
            executor.clear_callbacks()

        def source_bad(tb):
            if called_good:
                # good and bad callbacks shouldn't both be called
                raise ValueError('Good AND Bad callbacks called !')
            # TODO - get simple_trace_back of exception to send back
            self.print_response(status=RESPONSE_REVERTED, keep=True, cookie=cookie)
            self.print_response(tb.replace('\n', '\\n'), cookie=cookie)
            executor.clear_callbacks()

        called_good = False
        source = str(base64.b64decode(line))
        # Test compile
        pubsub.publish("shoebot", SOURCE_CHANGED_EVENT)
        executor.load_edited_source(source, good_cb=source_good, bad_cb=source_bad)
开发者ID:arvindmeena01,项目名称:shoebot,代码行数:27,代码来源:shell.py


示例3: record_to_file

def record_to_file(file_name, append=False):
    "start a data recording session into the specified file"
    global DR_On, _the_recorder
    if DR_On and _the_recorder:
        _the_recorder.stop()
    _rec=DR_Rec_File(file_name, append)
    _rec.start()
    pubsub.publish(pubsub.DR_RECORD, data=_rec)
开发者ID:SJLC,项目名称:portage-overlay,代码行数:8,代码来源:data_recording.py


示例4: playback_from_file

def playback_from_file(file_name):
    "start a playback session from the specified file"
    global DR_Play, _the_player
    if DR_Play and _the_player:
        _the_player.stop()
    _player=DR_Read_File(file_name)
    _player.start()
    pubsub.publish(pubsub.DR_PLAY, data=_player)
开发者ID:SJLC,项目名称:portage-overlay,代码行数:8,代码来源:data_recording.py


示例5: stop

def stop():
    "stop a recording and/or playback session"
    global DR_Play, DR_On, _the_recorder, _the_player
    if DR_On and _the_recorder:
        _the_recorder.stop()
    if DR_Play and _the_player:
        _the_player.stop()
    pubsub.publish(pubsub.DR_STOP)
开发者ID:SJLC,项目名称:portage-overlay,代码行数:8,代码来源:data_recording.py


示例6: 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')
开发者ID:nehz,项目名称:pubsub,代码行数:8,代码来源:tests.py


示例7: handle_data

def handle_data(protocol, data, address):
    proto = protocol()
    try:
        event = proto.read(data)
    except (ValueError, TypeError):
        log.exception("Error decoding event from %s", address)
        return
    else:
        pubsub.publish("events", event)
开发者ID:agentultra,项目名称:dmon,代码行数:9,代码来源:server.py


示例8: handle_accept

    def handle_accept(self):
        conn, addr = self.accept()

        # Drop existing connection.
        if self._handler is not None:
            self._handler.handle_close()

        self._handler = MonkeyHandler(conn)
        pubsub.publish('conn', addr, self._handler)
开发者ID:leethree,项目名称:attentive-ui,代码行数:9,代码来源:network.py


示例9: do_window_close

    def do_window_close(self, widget,data=None):
        pubsub.publish("shoebot", "quit")

        if self.has_server:
            self.sock.close()

        self.hide_variables_window()

        self.destroy()
        self.window_open = False
开发者ID:arvindmeena01,项目名称:shoebot,代码行数:10,代码来源:gtk_window.py


示例10: _populate

 def _populate(self):
     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.list_widget.populate()
     self.CalculateStats()
     self._publish_today_data()
开发者ID:joliebig,项目名称:featurehouse_fstmerge_examples,代码行数:12,代码来源:call_history.py


示例11: _populate

 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()
开发者ID:joliebig,项目名称:featurehouse_fstmerge_examples,代码行数:14,代码来源:call_history.py


示例12: publish_event

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)
开发者ID:shoebot,项目名称:shoebot,代码行数:17,代码来源:events.py


示例13: OnRename

 def OnRename(self, _=None):
     items=self.GetSelectedItems()
     if len(items)!=1:
            return
     old_name=items[0].name
     dlg=wx.TextEntryDialog(self, "Enter a new name:", "Item Rename",
                            old_name)
     if dlg.ShowModal()==wx.ID_OK:
         new_name=dlg.GetValue()
         if len(new_name) and new_name!=old_name:
             old_name=items[0].name
             new_name=self.get_media_name_from_filename(new_name)
             items[0].RenameInIndex(new_name)
             pubsub.publish(pubsub.MEDIA_NAME_CHANGED,
                            data={ pubsub.media_change_type: self.media_notification_type,
                                   pubsub.media_old_name: old_name,
                                   pubsub.media_new_name: new_name })
     dlg.Destroy()
开发者ID:joliebig,项目名称:featurehouse_fstmerge_examples,代码行数:18,代码来源:fileview.py


示例14: populate

 def populate(self):
     self.nodes={}
     self.nodes_keys={}
     index=0
     for k,e in self._stats._data.items():
         if len(e._from) and not self._name_map.has_key(e._from):
             pubsub.publish(pubsub.REQUEST_PB_LOOKUP,
                            { 'item': e._from } )
         if len(e._to) and not self._name_map.has_key(e._to):
             pubsub.publish(pubsub.REQUEST_PB_LOOKUP,
                            { 'item': e._to } )
         if len(e.callback) and not self._name_map.has_key(e.callback):
             pubsub.publish(pubsub.REQUEST_PB_LOOKUP,
                            { 'item': e.callback } )
         if e.folder==self._display_filter:
             col=self._item_list.GetColumn(0)
             col.SetMask(wx.LIST_MASK_TEXT)
             if e.folder==sms.SMSEntry.Folder_Inbox:
                 col.SetText("From")
                 name=e._from
             else:
                 col.SetText("To")
                 name=e._to
             self._item_list.SetColumn(0, col)
             if name!=None and name!="":
                 temp=self._name_map.get(name, None)
                 if temp !=None:
                     name=temp
             self.nodes[index]=(name, e.get_date_time_str(), e.subject)
             self.nodes_keys[index]=k
             self._data_map[k]=index
             index+=1
     self._item_list.ResetView(self.nodes, self.nodes_keys)
     self.publish_today_data()
开发者ID:joliebig,项目名称:featurehouse_fstmerge_examples,代码行数:34,代码来源:sms_tab.py


示例15: populate

 def populate(self):
     self.nodes={}
     self.nodes_keys={}
     index=0
     for k,e in self._stats._data.items():
         if len(e._from) and not self._name_map.has_key(e._from):
             pubsub.publish(pubsub.REQUEST_PB_LOOKUP,
                            { 'item': e._from } )
         if len(e._to) and not self._name_map.has_key(e._to):
             pubsub.publish(pubsub.REQUEST_PB_LOOKUP,
                            { 'item': e._to } )
         if len(e.callback) and not self._name_map.has_key(e.callback):
             pubsub.publish(pubsub.REQUEST_PB_LOOKUP,
                            { 'item': e.callback } )
         if self._display_filter=='All' or e.folder==self._display_filter:
             _from=self._me_name if e.folder in (e.Folder_Sent, e.Folder_Saved) \
                    else self._number2name(e._from)
             _to=self._me_name if e.folder==e.Folder_Inbox \
                  else self._number2name(e._to)
             self.nodes[index]=(_from, _to, e.get_date_time_str())
             self.nodes_keys[index]=k
             self._data_map[k]=index
             index+=1
     self._item_list.ResetView(self.nodes, self.nodes_keys)
     self.publish_today_data()
开发者ID:SJLC,项目名称:portage-overlay,代码行数:25,代码来源:sms_tab.py


示例16: widget_changed

 def widget_changed(self, widget, v):
     ''' Called when a slider is adjusted. '''
     # set the appropriate bot var
     if v.type is NUMBER:
         self.bot._namespace[v.name] = widget.get_value()
         self.bot._vars[v.name].value = widget.get_value()  ## Not sure if this is how to do this - stu
         pubsub.publish("shoebot", EVENT_VARIABLE_UPDATED) # pretty dumb for now
     elif v.type is BOOLEAN:
         self.bot._namespace[v.name] = widget.get_active()
         self.bot._vars[v.name].value = widget.get_active()  ## Not sure if this is how to do this - stu
         pubsub.publish("shoebot", EVENT_VARIABLE_UPDATED) # pretty dumb for now
     elif v.type is TEXT:
         self.bot._namespace[v.name] = widget.get_text()
         self.bot._vars[v.name].value = widget.get_text()  ## Not sure if this is how to do this - stu
         pubsub.publish("shoebot", EVENT_VARIABLE_UPDATED) # pretty dumb for now
开发者ID:arvindmeena01,项目名称:shoebot,代码行数:15,代码来源:var_window.py


示例17: _populate

 def _populate(self):
     self._clear()
     self._data_map={}
     keys=[(x.datetime, k) for k,x in self._data.items()]
     keys.sort()
     for (_,k) in keys:
         n=self._data[k]
         i=self._item_list.AppendItem(self._nodes[n.folder], n.subject)
         self._item_list.SetItemPyData(i, k)
         self._data_map[k]=i
         if len(n._from) and not self._name_map.has_key(n._from):
             pubsub.publish(pubsub.REQUEST_PB_LOOKUP,
                            { 'item': n._from } )
         if len(n._to) and not self._name_map.has_key(n._to):
             pubsub.publish(pubsub.REQUEST_PB_LOOKUP,
                            { 'item': n._to } )
         if len(n.callback) and not self._name_map.has_key(n.callback):
             pubsub.publish(pubsub.REQUEST_PB_LOOKUP,
                            { 'item': n.callback } )
     self.canned_list.SetStrings(
         self.canned_data.user_list)
     self.builtin_canned_list.Set(self.canned_data.builtin_list)
开发者ID:joliebig,项目名称:featurehouse_fstmerge_examples,代码行数:22,代码来源:sms_tab.py


示例18: OnListRequest

	def OnListRequest(self, msg=None):

        l=[self._data['wallpaper-index'][x]['name'] \
           for x in self._data['wallpaper-index']\
               if self._data['wallpaper-index'][x].get('origin', None)!='video' ]

        l.sort()

        pubsub.publish(pubsub.ALL_WALLPAPERS, l)

	def OnIdle(self, _):

        "Save out changed data"

        if self.modified:

            self.modified=False

            self.populatefs(self._data)

            self.OnListRequest()

	def _OnKey(self, evt):

        self._shift_down=evt.ShiftDown()

        evt.Skip()

	def OnAdd(self, evt=None):

        self._raw_image=self._shift_down

        super(WallpaperView, self).OnAdd(evt)

        self._shift_down=False

	def OrganizeChange(self, evt):

        self.mainwindow.config.Write('imageorganizedby',
                                     evt.GetEventObject().GetLabel(evt.GetId()))

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

        self.OnRefresh()

	def GetSections(self):

        items=[DisplayItem(self, key, self.mainwindow.wallpaperpath) for key in self._data['wallpaper-index']]

        items=[item for item in items if os.path.exists(item.filename)]

        self.sections=[]

        if len(items)==0:

            return self.sections

        for i in range(len(self.organizetypes)):

            item=self.organizemenu.FindItemByPosition(i)

            if self.organizemenu.IsChecked(item.GetId()):

                for sectionlabel, items in self.organizeinfo[item.GetId()](items):

                    sh=aggregatedisplay.SectionHeader(sectionlabel)

                    sh.itemsize=(self.usewidth+120, self.useheight+DisplayItem.PADDING*2)

                    for item in items:

                        item.thumbnailsize=self.usewidth, self.useheight

                    items=[(item.name.lower(), item) for item in items]

                    items.sort()

                    items=[item for name,item in items]

                    self.sections.append( (sh, items) )

                return [sh for sh,items in self.sections]

        assert False, "Can't get here"

	def GetItemSize(self, sectionnumber, sectionheader):

        return sectionheader.itemsize

	def GetItemsFromSection(self, sectionnumber, sectionheader):

        return self.sections[sectionnumber][1]

	def organizeby_ImageType(self, items):

        types={}

        for item in items:

            t=item.fileinfo.format
#.........这里部分代码省略.........
开发者ID:joliebig,项目名称:featurehouse_fstmerge_examples,代码行数:101,代码来源:wallpaper.py


示例19: broadcast

 def broadcast(self):
     pubsub.publish(pubsub.NEW_DATA_AVAILABLE, data=self)
开发者ID:joliebig,项目名称:featurehouse_fstmerge_examples,代码行数:2,代码来源:today.py


示例20: OnHyperlinkLeft

 def OnHyperlinkLeft(self, evt):
     if self.tab_index:
         pubsub.publish(pubsub.REQUEST_TAB_CHANGED,
                        data=self.tab_index)
开发者ID:joliebig,项目名称:featurehouse_fstmerge_examples,代码行数:4,代码来源:today.py



注:本文中的pubsub.publish函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pubsub.subscribe函数代码示例发布时间:2022-05-25
下一篇:
Python pubnub_tornado.PubNubTornado类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap