def __init__( self, iconName, iconSize, labels = None, buttonWidth = 200, buttonHeight = 38 ):
GObject.GObject.__init__( self )
self.connections = [ ]
self.iconName = iconName
self.iconSize = iconSize
self.showIcon = True
self.set_relief( Gtk.ReliefStyle.NONE )
self.set_size_request( buttonWidth, buttonHeight )
self.viewport = Gtk.Viewport()
self.Align1 = Gtk.Alignment.new( 0, 0.5, 1.0, 0 )
self.HBox1 = Gtk.HBox()
self.labelBox = Gtk.VBox( False, 2 )
self.buttonImage = Gtk.Image()
icon = self.getIcon( self.iconSize )
if icon:
self.buttonImage = icon
else:
#[ iW, iH ] = iconManager.getIconSize( self.iconSize )
self.buttonImage.set_size_request( self.iconSize, self.iconSize )
self.image_box = Gtk.HBox()
self.image_box.pack_start(self.buttonImage, False, False, 5)
self.image_box.show_all()
self.HBox1.pack_start( self.image_box, False, False, 0 )
if labels:
for label in labels:
if isinstance( label, str ):
self.addLabel( label )
elif isinstance( label, list ):
self.addLabel( label[0], label[1] )
self.labelBox.show()
self.HBox1.pack_start( self.labelBox , True, True, 0)
#add right icon for category
self.buttonIconRight = Gtk.Image()
iconfile = ICON_PATH + "arrow-right-line.png"
pixbuf = Pixbuf.new_from_file(iconfile)
pixbuf = pixbuf.scale_simple(6, 9, 2) #2 := BILINEAR
self.buttonIconRight.set_from_pixbuf(pixbuf)
#self.buttonIconRight.set_from_icon_name(ICON_PATH + "arrow-right-line.png", self.iconSize)
self.rightbox = Gtk.HBox()
self.rightbox.pack_start(self.buttonIconRight, False, False, 5)
self.HBox1.pack_start( self.rightbox, False, False, 0 )
self.HBox1.show()
self.Align1.add( self.HBox1 )
self.Align1.show()
self.add( self.Align1 )
self.connectSelf( "destroy", self.onDestroy )
self.connect( "released", self.onRelease )
# Reload icons when the theme changed
self.themeChangedHandlerId = iconManager.connect("changed", self.themeChanged )
评论列表
文章目录