gpt4 book ai didi

python - PyGTK弃用警告 : What am I missing?

转载 作者:行者123 更新时间:2023-12-01 21:57:23 28 4
gpt4 key购买 nike

我的代码工作正常,但当我运行脚本时,我在终端中收到此警告。我错过了什么?

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 giventext.

Parameters: label #The text you want the GtkLabel to hold.

Returns: The newly created GtkButton widget.

Gtk.Button.new_with_label("Click Here")

关于python - PyGTK弃用警告 : What am I missing?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55816199/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com