如何访问 Gtk+ 3 / Glade / Python 3 项目中的小部件属性
How to access to widgets properties in a Gtk+ 3 / Glade / Python 3 project
我用的是经典码example:
from gi.repository import Gtk
class Handler():
def onDeleteWindow(self, *args):
Gtk.main_quit(*args)
def on_button1_clicked(self, button):
print("Hello World!")
builder = Gtk.Builder()
builder.add_from_file("D:/temp/test1.glade")
builder.connect_signals(Handler())
window = builder.get_object("window1")
window.show_all()
Gtk.main()
一切正常。但是:
- 如何在事件中更改小部件 属性。就像单击它时更改 button1 标签一样。主要是因为事件发生在看不到 window ?
的 Handler 中
- Where/how 以获得关于小部件的所有 Python/Gtk 信息,例如小部件属性名称(即:GtkButton 的标签 属性 是什么?)?
Where/how to have all the Python/Gtk informations about widgets, like widgets properties names?
https://lazka.github.io/pgi-docs/#Gtk-3.0
How to change a widget property in event. Like change the button1 label on click on it.
button.set_label()
https://lazka.github.io/pgi-docs/#Gtk-3.0/classes/Button.html#Gtk.Button.set_label
我用的是经典码example:
from gi.repository import Gtk
class Handler():
def onDeleteWindow(self, *args):
Gtk.main_quit(*args)
def on_button1_clicked(self, button):
print("Hello World!")
builder = Gtk.Builder()
builder.add_from_file("D:/temp/test1.glade")
builder.connect_signals(Handler())
window = builder.get_object("window1")
window.show_all()
Gtk.main()
一切正常。但是:
- 如何在事件中更改小部件 属性。就像单击它时更改 button1 标签一样。主要是因为事件发生在看不到 window ? 的 Handler 中
- Where/how 以获得关于小部件的所有 Python/Gtk 信息,例如小部件属性名称(即:GtkButton 的标签 属性 是什么?)?
Where/how to have all the Python/Gtk informations about widgets, like widgets properties names?
https://lazka.github.io/pgi-docs/#Gtk-3.0
How to change a widget property in event. Like change the button1 label on click on it.
button.set_label()
https://lazka.github.io/pgi-docs/#Gtk-3.0/classes/Button.html#Gtk.Button.set_label