python - PyGTKDeprecationWarning:我错过了什么?
问题描述
我的代码工作得很好,但是当我运行脚本时,我在终端中收到了这个警告。我错过了什么?
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.按钮:
类:new_with_label(标签)
使用包含给定文本的 GtkLabel 子项创建 GtkButton 小部件。
参数: label #你希望 GtkLabel 保存的文本。
返回: 新创建的 GtkButton 小部件。
Gtk.Button.new_with_label("Click Here")
推荐阅读
- python - 在直通表中批量创建的最佳方法是什么?
- keycloak - Keycloak 10 在作为服务运行时部分启动
- javascript - 如何检查数组输入字段是否以jquery中的特定字符串开头
- excel - 从一个用户表单到另一个用户表单
- powershell - 将 Powershell 输出放入批处理脚本中的变量中
- kubernetes - Kubernetes 将 YAML 转换为 JSON 时出错:yaml:第 30 行:找不到预期的“:”
- flutter - 如何在flutter中将具有文档ID的自定义对象设置为firestore中的集合?
- python - 使用 Python 在图像上生成带有受控参数的文本
- php - 第二次从套接字写入和读取
- openmdao - 因子的含义正是在组中找到的单数/单数条目