Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Why not</p> <pre><code>image_log = gtk.Image() image_log.set_from_file("test.png") image_logb = gtk.Image() image_logb.set_from_file("test.png") self.out_button = gtk.Button() self.out_button.add(image_log) self.err_button = gtk.Button() self.err_button.add(image_logb) another_box.pack_start(self.out_button, False) another_box.pack_start(self.err_button, False) </code></pre> <p>It is only an extra 2 lines of code, and maybe more efficient than cloning/copying the first image object.</p> <p>That way you can treat <code>out_button</code> and <code>err_button</code> independently. But it should make sense to use the same <code>gtk.Image()</code> object for both buttons ... it is just an image.</p> <p><strong>Edit</strong> To avoid duplication (seems like <em>overkill</em> though) you could write a factory for gtk.Image() objects from the same image.</p> <pre><code>def gtkimage_factory(num_objs, image_file): i=0 imglist = [] while i&lt;num_objs: img_ob = gtk.Image() img_ob.set_from_file(image_file) imglist.append( img_ob ) i+=1 return imglist </code></pre> <p>Or something along those lines, you get the idea. But a factory seems like overkill unless you are producing <strong>loads</strong> of these things and need them independently parented in GTK. Then...</p> <pre><code>image_list = gtkimg_factory(2, "test.png") self.out_button = gtk.Button() self.out_button.add(image_list[0]) self.err_button = gtk.Button() self.err_button.add(image_list[1]) another_box.pack_start(self.out_button, False) another_box.pack_start(self.err_button, False) </code></pre> <p>Maybe it is something to do with GTK resource management?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload