当前位置: 首页>>代码示例>>Python>>正文


Python weechat.bar_item_new函数代码示例

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


在下文中一共展示了bar_item_new函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

def main():
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
        version = int(weechat.info_get("version_number", "")) or 0

        # unset unused setting from older versions of script
        if weechat.config_is_set_plugin("display_unit"):
            weechat.prnt("", "Option plugins.var.python.bandwidth.display_unit no longer used, removing.")
            weechat.config_unset_plugin("display_unit")

        # set default settings
        for option in SCRIPT_SETTINGS.iterkeys():
            if not weechat.config_is_set_plugin(option):
                weechat.config_set_plugin(option, SCRIPT_SETTINGS[option][0])
            if version >= 0x00030500:
                weechat.config_set_desc_plugin(option, SCRIPT_SETTINGS[option][1])

        # ensure sane refresh_rate setting
        if int(weechat.config_get_plugin("refresh_rate")) < 1:
            weechat.prnt(
                "",
                "{}Invalid value for option plugins.var.python.bandwidth.refresh_rate, setting to default of {}".format(
                    weechat.prefix("error"), SCRIPT_SETTINGS["refresh_rate"][0]
                ),
            )
            weechat.config_set_plugin("refresh_rate", SCRIPT_SETTINGS["refresh_rate"][0])

        # create the bandwidth monitor bar item
        weechat.bar_item_new("bandwidth", "bandwidth_item_cb", "")
        # update it every plugins.var.python.bandwidth.refresh_rate seconds
        weechat.hook_timer(int(weechat.config_get_plugin("refresh_rate")) * 1000, 0, 0, "bandwidth_timer_cb", "")
开发者ID:Shrews,项目名称:scripts,代码行数:30,代码来源:bandwidth.py

示例2: toggle_refresh

def toggle_refresh(pointer, name, value):
    option_name = name[len('plugins.var.python.' + SCRIPT_NAME + '.'):]      # get optionname

    # option was removed? remove bar_item from struct
    if not weechat.config_get_plugin(option_name):
        ptr_bar = weechat.bar_item_search(option_name)
        if ptr_bar:
            weechat.bar_item_remove(ptr_bar)
        return weechat.WEECHAT_RC_OK

    # check if option is new or changed
    if not weechat.bar_item_search(option_name):
        weechat.bar_item_new(option_name,'update_item',option_name)

    weechat.bar_item_update(option_name)
    return weechat.WEECHAT_RC_OK
开发者ID:alyptik,项目名称:scripts,代码行数:16,代码来源:text_item.py

示例3: main

def main():
    if not init(): return

    weechat.hook_command(SCRIPT_COMMAND,
                         SCRIPT_DESC,
                         "[cmd1 | cmd2]",
                         "   cmd1: comand1\n"
                         "   cmd2: command2\n",
                         "cmd1 example",
                         "bee_cmd", "")
    
    weechat.bar_item_new(bar_item, "bee_item_cb", "");
    weechat.bar_new(bar_name, "on", "0", "root", "", "top", "horizontal",
                    "vertical", "0", "0", "default", "default", "default", "0",
                    bar_item);
    return
开发者ID:frumiousbandersnatch,项目名称:weechat-scripts,代码行数:16,代码来源:bee.py

示例4: create_bar_items

def create_bar_items():
    ptr_infolist_option = weechat.infolist_get('option','','plugins.var.python.' + SCRIPT_NAME + '.*')

    if not ptr_infolist_option:
        return

    while weechat.infolist_next(ptr_infolist_option):
        option_full_name = weechat.infolist_string(ptr_infolist_option, 'full_name')
        option_name = option_full_name[len('plugins.var.python.' + SCRIPT_NAME + '.'):]      # get optionname

        if weechat.bar_item_search(option_name):
            weechat.bar_item_update(option_name)
        else:
            weechat.bar_item_new(option_name,'update_item',option_name)
        weechat.bar_item_update(option_name)

    weechat.infolist_free(ptr_infolist_option)
开发者ID:Adrian-Revk,项目名称:dotfiles,代码行数:17,代码来源:text_item.py

示例5: create_bar_items

def create_bar_items():
    ptr_infolist_option = weechat.infolist_get("option", "", "plugins.var.python." + SCRIPT_NAME + ".*")

    if not ptr_infolist_option:
        return

    while weechat.infolist_next(ptr_infolist_option):
        option_full_name = weechat.infolist_string(ptr_infolist_option, "full_name")
        option_name = option_full_name[len("plugins.var.python." + SCRIPT_NAME + ".") :]  # get optionname

        if weechat.bar_item_search(option_name):
            weechat.bar_item_update(option_name)
        else:
            weechat.bar_item_new(option_name, "update_item", option_name)
        weechat.bar_item_update(option_name)

    weechat.infolist_free(ptr_infolist_option)
开发者ID:weechatter,项目名称:weechat-scripts,代码行数:17,代码来源:text_item.py

示例6: hook_timer

def hook_timer():
    global hooks
    hooks["timer"] = weechat.hook_timer(int(OPTIONS["refresh"]) * 1000, 0, 0, 'item_update', '')
    hooks["bar_item"] = weechat.bar_item_new(SCRIPT_NAME, 'show_item','')

    if hooks["timer"] == 0:
        weechat.prnt('',"%s: can't enable %s, hook failed" % (weechat.prefix("error"), SCRIPT_NAME))
        weechat.bar_item_remove(hooks["bar_item"])
        hooks["bar_item"] = ""
        return 0
    weechat.bar_item_update(SCRIPT_NAME)
    return 1
开发者ID:norrs,项目名称:weechat-plugins,代码行数:12,代码来源:logsize.py

示例7: toggle_refresh

            weechat.config_set_plugin(option, value[0])
            OPTIONS[option] = value[0]
        else:
            OPTIONS[option] = weechat.config_get_plugin(option)
        weechat.config_set_desc_plugin(option, '%s (default: "%s")' % (value[1], value[0]))

def toggle_refresh(pointer, name, value):
    global OPTIONS
    option = name[len('plugins.var.python.' + SCRIPT_NAME + '.'):]        # get optionname
    OPTIONS[option] = value                                               # save new value
    return weechat.WEECHAT_RC_OK

# ================================[ main ]===============================
if __name__ == "__main__":
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', ''):
        version = weechat.info_get("version_number", "") or 0

        # get weechat version (0.3.6) and store it
        if int(version) >= 0x00030600:
            # init options from your script
            init_options()
            # create a hook for your options
            weechat.hook_config( 'plugins.var.python.' + SCRIPT_NAME + '.*', 'toggle_refresh', '' )
            # create a new bar item (for scripts running on weechat >= 0.4.2 see script API for additional arguments)
            bar_item = weechat.bar_item_new(SCRIPT_NAME, 'bar_item_cb','')
            # create a hook with signal "buffer_switch" for your item
            weechat.hook_signal("buffer_switch","update_cb","")
        else:
            weechat.prnt("","%s%s %s" % (weechat.prefix("error"),SCRIPT_NAME,": needs version 0.3.6 or higher"))
            weechat.command("","/wait 1ms /python unload %s" % SCRIPT_NAME)
开发者ID:FiXato,项目名称:weechat-scripts,代码行数:30,代码来源:skeleton.py

示例8: it

    # Show the command line when needed, hide it (and update vi_buffer since
    # we'd be looking for keystrokes instead) otherwise.
    if cmd_text != '':
        weechat.command('', "/bar show vi_cmd")
        weechat.bar_item_update("cmd_text")
    else:
        weechat.command('', "/bar hide vi_cmd")
        if is_printing(signal_data, pressed_keys):
            vi_buffer += signal_data
        pressed_keys += signal_data
        # Check for any matching bound keys.
        weechat.hook_timer(1, 0, 1, "pressed_keys_check", '')
        last_time = time.time()
        # Clear the buffers after some time.
        weechat.hook_timer(1000, 0, 1, "clear_vi_buffers", "check_time")
    weechat.bar_item_update("vi_buffer")
    return weechat.WEECHAT_RC_OK


weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
                 SCRIPT_DESC, '', '')

weechat.bar_item_new("mode_indicator", "mode_indicator_cb", '')
weechat.bar_item_new("cmd_text", "cmd_text_cb", '')
weechat.bar_item_new("vi_buffer", "vi_buffer_cb", '')
vi_cmd = weechat.bar_new("vi_cmd", "off", "0", "root", '', "bottom",
                         "vertical", "vertical", "0", "0", "default",
                         "default", "default", "0", "cmd_text")
weechat.hook_signal("key_pressed", "key_pressed_cb", '')

开发者ID:jnbek,项目名称:_weechat,代码行数:29,代码来源:vimode.py

示例9: cb_hats

# Bar items.
# ----------

def cb_hats(data, item, window):
    buf = weechat.current_buffer()
    plugin = weechat.buffer_get_string(buf, "localvar_plugin")
    if plugin == "irc":
        server = weechat.buffer_get_string(buf, "localvar_server")
        channel = weechat.buffer_get_string(buf, "localvar_channel")
        nick = weechat.buffer_get_string(buf, "localvar_nick")
        nicks = weechat.infolist_get("irc_nick", "", "{},{},{}".format(
            server, channel, nick))
        weechat.infolist_next(nicks)
        hats = weechat.infolist_string(nicks, "prefixes")
        weechat.infolist_free(nicks)
        return hats.replace(" ", "")
    return ""


# Main script.
# ============

if __name__ == "__main__":
    weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
                     SCRIPT_LICENSE, SCRIPT_DESC, "", "")
    # Create bar items and setup hooks.
    weechat.bar_item_new("hats", "cb_hats", "")
    weechat.hook_print("", "irc_mode", "", 0, "cb_irc_mode", "")
    weechat.hook_signal("buffer_switch", "cb_buffer_switch", "")
开发者ID:DarkDefender,项目名称:scripts,代码行数:29,代码来源:hatwidget.py

示例10: return

    return (tm.tm_hour*3600+tm.tm_min*60+tm.tm_sec)/1000.0 
    

def kiloseconds_cmd(data, buffer, args):
    """Callback for /ks command"""
    weechat.command(buffer,"The current time is " + str(getKiloseconds()) + " ks")
    return weechat.WEECHAT_RC_OK

def kiloseconds_cb(data, buffer, args):
    """Callback for the bar item"""
    return "%06.3f" % getKiloseconds()

def kiloseconds_update(data,cals):
    """Update the bar item"""
    weechat.bar_item_update('kiloseconds')
    return weechat.WEECHAT_RC_OK

if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
                    SCRIPT_DESC, '', ''):

    weechat.hook_command(SCRIPT_COMMAND,
                         "Display current time in kiloseconds",
                         "",
                         "Add 'kiloseconds' to any bar to have it show the time in kiloseconds.",
                         "",
                         "kiloseconds_cmd", "")

    weechat.bar_item_new('kiloseconds', 'kiloseconds_cb', '')
    weechat.hook_timer(1000,1,0,'kiloseconds_update','')

开发者ID:GunioRobot,项目名称:Kiloseconds,代码行数:29,代码来源:kiloseconds.py

示例11: config_changed

def config_changed(data, option, value):
    init_config()
    return w.WEECHAT_RC_OK

def tc_action_cb():
    global tc_options
    if tc_options['warn_command']:
        if tc_options['warn_command'] == '$bell':
            f = open('/dev/tty', 'w')
            f.write('\a')
            f.close()
        else:
            os.system(tc_options['warn_command'])
    return w.WEECHAT_RC_OK

if __name__ == "__main__" and import_ok:
    if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
                  SCRIPT_LICENSE, SCRIPT_DESC,
                  "", ""):
        version = w.info_get("version_number", "") or 0
        init_config() # read configuration
        tc_bar_item_update() # update status bar display

        w.hook_signal('input_text_changed', 'tc_bar_item_update', '')
        w.hook_signal('input_text_cursor_moved','tc_bar_item_update','')
        w.hook_command_run('/input move_previous_char','command_run_cb','')
        w.hook_command_run('/input delete_previous_char','command_run_cb','')
        w.hook_signal('buffer_switch','tc_bar_item_update','')
        w.hook_config('plugins.var.python.' + SCRIPT_NAME + ".*", "config_changed", "")
        w.bar_item_new('tc', 'tc_bar_item', '')
开发者ID:MatthewCox,项目名称:dotfiles,代码行数:30,代码来源:typing_counter.py

示例12: ircrypt_config_init

	ircrypt_config_init()
	ircrypt_config_read()
	ircrypt_check_binary()
	weechat.hook_modifier('irc_in_privmsg',  'ircrypt_decrypt_hook', '')
	weechat.hook_modifier('irc_out_privmsg', 'ircrypt_encrypt_hook', '')

	weechat.hook_command('ircrypt', 'Commands to manage IRCrypt options and execute IRCrypt commands',
			'[list]'
			'| set-key [-server <server>] <target> <key> '
			'| remove-key [-server <server>] <target> '
			'| set-cipher [-server <server>] <target> <cipher> '
			'| remove-cipher [-server <server>] <target> '
			'| plain [-server <server>] [-channel <channel>] <message>',
			SCRIPT_HELP_TEXT,
			'list || set-key %(irc_channel)|%(nicks)|-server %(irc_servers) %- '
			'|| remove-key %(irc_channel)|%(nicks)|-server %(irc_servers) %- '
			'|| set-cipher %(irc_channel)|-server %(irc_servers) %- '
			'|| remove-cipher |%(irc_channel)|-server %(irc_servers) %- '
			'|| plain |-channel %(irc_channel)|-server %(irc_servers) %-',
			'ircrypt_command', '')
	weechat.bar_item_new('ircrypt', 'ircrypt_encryption_statusbar', '')
	weechat.hook_signal('ircrypt_buffer_opened', 'update_encryption_status', '')


def ircrypt_unload_script():
	'''Hook to ensure the configuration is properly written to disk when the
	script is unloaded.
	'''
	ircrypt_config_write()
	return weechat.WEECHAT_RC_OK
开发者ID:petvoigt,项目名称:ircrypt-weechat,代码行数:30,代码来源:ircrypt.py

示例13: SearchList

        servers = SearchList()
        for token in slack_api_token.split(','):
            servers.append(SlackServer(token))
        channels = Meta('channels', servers)
        users = Meta('users', servers)


        w.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "config_changed_cb", "")
        w.hook_timer(10, 0, 0, "async_queue_cb", "")
        w.hook_timer(6000, 0, 0, "slack_connection_persistence_cb", "")

        ### attach to the weechat hooks we need
        w.hook_timer(1000, 0, 0, "typing_update_cb", "")
        w.hook_timer(1000, 0, 0, "buffer_list_update_cb", "")
        w.hook_timer(1000, 0, 0, "hotlist_cache_update_cb", "")
        w.hook_timer(1000 * 3, 0, 0, "slack_never_away_cb", "")
        w.hook_timer(1000 * 60* 29, 0, 0, "slack_never_away_cb", "")
        w.hook_signal('buffer_closing', "buffer_closing_cb", "")
        w.hook_signal('buffer_switch', "buffer_switch_cb", "")
        w.hook_signal('window_switch', "buffer_switch_cb", "")
        w.hook_signal('input_text_changed', "typing_notification_cb", "")
        w.hook_command('slack','Plugin to allow typing notification and sync of read markers for slack.com', 'stuff', 'stuff2', '|'.join(cmds.keys()), 'slack_command_cb', '')
        w.hook_command('me','', 'stuff', 'stuff2', '', 'me_command_cb', '')
#        w.hook_command('me', 'me_command_cb', '')
        w.hook_command_run('/join', 'join_command_cb', '')
        w.hook_command_run('/part', 'part_command_cb', '')
        w.hook_command_run('/leave', 'part_command_cb', '')
        w.bar_item_new('slack_typing_notice', 'typing_bar_item_cb', '')
        ### END attach to the weechat hooks we need

开发者ID:ishigoemon,项目名称:wee-slack,代码行数:29,代码来源:wee_slack.py

示例14: open

    loadproc = open("/proc/loadavg")
    load_data = loadproc.read().split(" ")
    loadproc.close()
    config_items = weechat.config_get_plugin("items")
    first_load = load_data[0]
    second_load = load_data[1]
    third_load = load_data[2]
    if config_items == "1":
        return load_data[0]
    if config_items == "5":
        return load_data[1]
    if config_items == "15":
        return load_data[2]
    if config_items == "all":
        return "%s %s %s" % (load_data[0], load_data[1], load_data[2])


def load_timer(*args):
    weechat.bar_item_update("load")
    return weechat.WEECHAT_RC_OK


if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):

    for option, default_value in settings.iteritems():
        if not weechat.config_is_set_plugin(option):
            weechat.config_set_plugin(option, default_value)
    weechat.bar_item_new("load", "load_item", "")
    weechat.bar_item_update("load")
    weechat.hook_timer(1000 * 20, 0, 0, "load_timer", "")
开发者ID:fbesser,项目名称:weechat_scripts,代码行数:30,代码来源:load_avg.py

示例15: int

 VERSION = weechat.info_get("version_number", "")
 if int(VERSION) < 0x01000000:
     print_warning("Please upgrade to WeeChat ≥ 1.0.0. Previous versions" " are not supported.")
 # Set up script options.
 for option, value in vimode_settings.items():
     if weechat.config_is_set_plugin(option):
         vimode_settings[option] = weechat.config_get_plugin(option)
     else:
         weechat.config_set_plugin(option, value[0])
         vimode_settings[option] = value[0]
     weechat.config_set_desc_plugin(option, '%s (default: "%s")' % (value[1], value[0]))
 # Warn the user about possible problems if necessary.
 if not weechat.config_string_to_boolean(vimode_settings["no_warn"]):
     check_warnings()
 # Create bar items and setup hooks.
 weechat.bar_item_new("mode_indicator", "cb_mode_indicator", "")
 weechat.bar_item_new("cmd_text", "cb_cmd_text", "")
 weechat.bar_item_new("vi_buffer", "cb_vi_buffer", "")
 weechat.bar_item_new("line_numbers", "cb_line_numbers", "")
 weechat.bar_new(
     "vi_cmd",
     "off",
     "0",
     "root",
     "",
     "bottom",
     "vertical",
     "vertical",
     "0",
     "0",
     "default",
开发者ID:tarruda,项目名称:dot-files,代码行数:31,代码来源:vimode.py


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