请参阅下面的示例。
fread(fmtChunkId, sizeof(char), 4, fp);
if(memcmp(fmtChunkId, "WAVE", 4) != 0) {
cout << "Not WAVE format" << endl;
return 0;
}
如何将#!/usr/bin/env python3
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import Gio
import sys
class ApplicationWindow(Gtk.ApplicationWindow):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.set_title("Application")
self.set_default_size(200, 200)
grid = Gtk.Grid()
self.add(grid)
menubutton = Gtk.MenuButton()
grid.attach(menubutton, 0, 0, 1, 1)
label = Gtk.Label.new('AnyLabel')
grid.attach(label, 0, 1, 1, 1)
menumodel = Gio.Menu()
menubutton.set_menu_model(menumodel)
menumodel.append("New", "app.new")
menumodel.append("Quit", "app.quit")
menumodel.append("CLabel", "app.clabel")
class Application(Gtk.Application):
def do_activate(self):
window = ApplicationWindow(application=self)
window.show_all()
def do_startup(self):
Gtk.Application.do_startup(self)
new_action = Gio.SimpleAction.new("new", None)
new_action.connect("activate", self.new_callback)
self.add_action(new_action)
quit_action = Gio.SimpleAction.new("quit", None)
quit_action.connect("activate", self.quit_callback)
self.add_action(quit_action)
clabel_action = Gio.SimpleAction.new("clabel", None)
clabel_action.connect("activate", self.clabel_callback)
self.add_action(clabel_action)
def new_callback(self, action, parameter):
print("You clicked New")
def quit_callback(self, action, parameter):
print("You clicked Quit")
self.quit()
def clabel_callback(self, action, parameter):
"""How to change the label here"""
application = Application()
exit_status = application.run(sys.argv)
sys.exit(exit_status)
更改为label
类中的clabel_callback
方法?
Application
方法如何访问clabel_callback
并修改任何属性?
[off]注意无聊!它没有意识到有时代码值得千言万语
答案 0 :(得分:2)
您可能希望该操作成为ApplicationWindow的一部分,然后您将引用“win.clabel”。