tooltip.py

来自「使用Pygtk写的几个例子」· Python 代码 · 共 44 行

PY
44
字号
#!/usr/bin/env python""" Simple example of creating a basic window and button.    Also adds a tooltip. """import gtkdef hello_cb(widget, main_window):    """ Callback function that prints a message and destroys the window """    print "Hello World"    main_window.destroy()def destroy_cb(widget, main_window):    """ Callback function to hide the main window and then terminate. """    main_window.hide()    gtk.main_quit()def main():    """ Sets up the application        Forms the widgets and connects callback functions to the signals """    window = gtk.Window( type=gtk.WINDOW_TOPLEVEL )    window.set_title("Hello World")    window.set_default_size(200, 200)    window.set_border_width(10)    window.connect("destroy", destroy_cb, window)    button = gtk.Button(label="Hello World")    window.add(button)    button.connect("clicked", hello_cb, window)    # setup tooltips and associate them with the button    tt = gtk.Tooltips()    tt.set_tip(button, 'Prints "Hello World"', None)    tt.enable()    # shows the window and any child objects (button in this example)    window.show_all()    gtk.main()# if we're being run normally then call the main functionif __name__ == '__main__':    main()

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?