#!/usr/bin/env python # example tooltip.py import pygtk pygtk.require('2.0') import gtk # Create an Arrow widget with the specified parameters # and pack it into a button def create_arrow_button(arrow_type, shadow_type): button = gtk.Button() arrow = gtk.Arrow(arrow_type, shadow_type) button.add(arrow) button.show() arrow.show() return button class Tooltips: def __init__(self): # Create a new window window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.set_title("Tooltips") # It’s a good idea to do this for all windows. window.connect("destroy", lambda w: gtk.main_quit()) # Sets the border width of the window. window.set_border_width(10) # Create a box to hold the arrows/buttons box = gtk.HBox(False, 0) box.set_border_width(2) window.add(box) # create a tooltips object self.tooltips = gtk.Tooltips() # Pack and show all our widgets box.show() button = create_arrow_button(gtk.ARROW_UP, gtk.SHADOW_IN) box.pack_start(button, False, False, 3) self.tooltips.set_tip(button, "上") button = create_arrow_button(gtk.ARROW_DOWN, gtk.SHADOW_OUT) box.pack_start(button, False, False, 3) self.tooltips.set_tip(button, "下") button = create_arrow_button(gtk.ARROW_LEFT, gtk.SHADOW_ETCHED_IN) box.pack_start(button, False, False, 3) self.tooltips.set_tip(button, "左") button = create_arrow_button(gtk.ARROW_RIGHT, gtk.SHADOW_ETCHED_OUT) box.pack_start(button, False, False, 3) self.tooltips.set_tip(button, "右") window.show() def main(): gtk.main() return 0 if __name__ == "__main__": tt = Tooltips() main()
?
?
tooltips.enable() 顯示工具條
tooltips.disable() 禁止工具條
tooltips.set_delay(delay) 設置延遲,以毫秒為單位
?
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
