Gtk.AccelLabel
Gtk.AccelLabel是GtkLabel的子类,不同的是,它能在文本的右方显示快捷键助记符,常用来在Gtk.Menu中
继承关系
Methods
方法修饰词 | 方法名及参数 |
---|---|
static | new (string) |
get_accel () | |
get_accel_widget () | |
get_accel_width () | |
refetch () | |
set_accel (accelerator_key, accelerator_mods) | |
set_accel_closure (accel_closure) | |
set_accel_widget (accel_widget) |
Virtual Methods
Properties
Name | Type | Flags | Short Description |
---|---|---|---|
accel-closure | GObject.Closure | r/w/en | The closure to be monitored for accelerator changes |
accel-widget | Gtk.Widget | r/w/en | The widget to be monitored for accelerator changes |
例子
代码:
#!/usr/bin/env python3
# Created by xiaosanyu at 16/7/14
# section 102
#
# author: xiaosanyu
# website: yuxiaosan.tk \
# http://blog.csdn.net/a87b01c14
# created: 16/7/14
TITLE = "AccelLabel"
DESCRIPTION = """
The Gtk.AccelLabel widget is a subclass of Gtk.Label that also displays
an accelerator key on the right of the label text,
e.g. “Ctl+S”. It is commonly used in menus to show the keyboard short-cuts for commands.
"""
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk, Gio, GLib
class AccelLabelWindow(Gtk.Window):
def __init__(self, *args, **kwargs):
Gtk.Window.__init__(self, title="AccelLabel Example")
self.set_size_request(200, 200)
label = Gtk.AccelLabel.new("Accel Label")
label.set_accel(Gdk.KEY_A, Gdk.ModifierType.CONTROL_MASK)
self.add(label)
@staticmethod
def click(button):
print("click button")
def main():
win = AccelLabelWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
if __name__ == "__main__":
main()