mattn / go-gtk

Go binding for GTK
http://mattn.github.com/go-gtk
BSD 3-Clause "New" or "Revised" License
2.12k stars 247 forks source link

How to get the label in glade #413

Closed rookiefront closed 4 years ago

rookiefront commented 4 years ago

gtk2 go1.4 go-gtk last

func main() {
    //初始化
    gtk.Init(&os.Args)
    builder := gtk.NewBuilder()
    builder.AddFromFile("./1.3.ui")

    //获取glade 上面的控件
    obj := builder.GetObject("window1")
    window := gtk.WidgetFromObject(obj)
    window.Show()

    window.Connect("destroy", gtk.MainQuit)

    gtk.Label

    callback.Init(builder)
    gtk.Main()
}
<?xml version="1.0"?>
<interface>
  <requires lib="gtk+" version="2.16"/>
  <!-- interface-naming-policy project-wide -->
  <object class="GtkWindow" id="window1">
    <property name="width_request">480</property>
    <property name="height_request">320</property>
    <property name="extension_events">cursor</property>
    <property name="title" translatable="yes">studyseo&#x95EE;&#x7B54;</property>
    <property name="window_position">center-on-parent</property>
    <property name="default_width">480</property>
    <property name="default_height">320</property>
    <property name="type_hint">dialog</property>
    <child>
      <object class="GtkFixed" id="fixed1">
        <property name="visible">True</property>
        <child>
          <object class="GtkButton" id="button2">
            <property name="label" translatable="yes">B2</property>
            <property name="width_request">100</property>
            <property name="height_request">80</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
          </object>
          <packing>
            <property name="x">159</property>
            <property name="y">143</property>
          </packing>
        </child>
      </object>
    </child>
  </object>
</interface>
mattn commented 4 years ago

Can you try _exmaple/builder ?

rookiefront commented 4 years ago

I need this control now Label image

I need tag label and set it

I'm sorry I didn't find him in the example.

The API doesn't seem to provide either

Thank you for your reply