PyGTKDeprecationWarning:我错过了什么?
PyGTKDeprecationWarning: What am I missing?
我的代码工作正常,但是当我 运行 脚本时,我在终端中收到此警告。我错过了什么?
abc.py:10: PyGTKDeprecationWarning: Using positional arguments with the GObject constructor has been deprecated. Please specify keyword(s) for "label" or use a class specific constructor. See: https://wiki.gnome.org/PyGObject/InitializerDeprecations
actor_act = Gtk.Button("Click Here")
脚本名称:abc.py
实际代码:
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
def actor(button):
print('Simple Button')
boxy = Gtk.Window(title="Hello")
boxy.set_default_size(500,500)
actor_act = Gtk.Button("Click Here")
boxy.add(actor_act)
actor_act.connect("clicked", actor)
boxy.connect("destroy", Gtk.main_quit)
boxy.show_all()
Gtk.main()
Gtk.Button:
class: new_with_label (label)
Creates a GtkButton widget with a GtkLabel child containing the given
text.
Parameters: label #The text you want the GtkLabel to hold.
Returns: The newly created GtkButton widget.
Gtk.Button.new_with_label("Click Here")
我的代码工作正常,但是当我 运行 脚本时,我在终端中收到此警告。我错过了什么?
abc.py:10: PyGTKDeprecationWarning: Using positional arguments with the GObject constructor has been deprecated. Please specify keyword(s) for "label" or use a class specific constructor. See: https://wiki.gnome.org/PyGObject/InitializerDeprecations
actor_act = Gtk.Button("Click Here")
脚本名称:abc.py
实际代码:
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
def actor(button):
print('Simple Button')
boxy = Gtk.Window(title="Hello")
boxy.set_default_size(500,500)
actor_act = Gtk.Button("Click Here")
boxy.add(actor_act)
actor_act.connect("clicked", actor)
boxy.connect("destroy", Gtk.main_quit)
boxy.show_all()
Gtk.main()
Gtk.Button:
class: new_with_label (label)
Creates a GtkButton widget with a GtkLabel child containing the given text.
Parameters: label #The text you want the GtkLabel to hold.
Returns: The newly created GtkButton widget.
Gtk.Button.new_with_label("Click Here")