how to use glyphicon

430 views
Skip to first unread message

mcamel

unread,
Dec 24, 2014, 8:04:48 AM12/24/14
to web...@googlegroups.com
Hi all,

I've realized web2py uses 'app/static/images/glyphicons-halflings.png' (and the white version) in a CSS way.

For example, the edit button on a grid is rendered to something like:
<span class="icon pen icon-pencil glyphicon glyphicon-arrow-pencil"></span>

I want to use those icons that way, so i'm begging to write things like:
SPAN(_class="icon ok icon-ok glyphicon glyphicon-ok")

It seems to work also simply with:
SPAN(_class="icon-ok")

or the following if you have black background:
SPAN(_class="icon-white icon-ok")

What are the proper combinations of classes?. Should we write the large one, or evry class has its own purpose?.


Just in case it helps, i've wrote this to find quickly a certain icon:

def icons():
    classes    
= ['glass','music','search','envelope','heart','star','star-empty','user','film','th-large','th','th-list','ok','remove','zoom-in','zoom-out','off','signal','cog','trash','home','file','time','road','download-alt','download','upload','inbox','play-circle','repeat','refresh','list-alt','lock','flag','headphones','volume-off','volume-down','volume-up','qrcode','barcode','tag','tags','book','bookmark','print','camera','font','bold','italic','text-height','text-width','align-left','align-center','align-right','align-justify','list','indent-left','indent-right','facetime-video','picture','pencil','map-marker','adjust','tint','edit','share','check','move','step-backward','fast-backward','backward','play','pause','stop','forward','fast-forward','step-forward','eject','chevron-left','chevron-right','plus-sign','minus-sign','remove-sign','ok-sign','question-sign','info-sign','screenshot','remove-circle','ok-circle','ban-circle','arrow-left','arrow-right','arrow-up','arrow-down','share-alt','resize-full','resize-small','plus','minus','asterisk','exclamation-sign','gift','leaf','fire','eye-open','eye-close','warning-sign','plane','calendar','random','comment','magnet','chevron-up','chevron-down','retweet','shopping-cart','folder-close','folder-open','resize-vertical','resize-horizontal','hdd','bullhorn','bell','certificate','thumbs-up','thumbs-down','hand-right','hand-left','hand-up','hand-down','circle-arrow-right','circle-arrow-left','circle-arrow-up','circle-arrow-down','globe','wrench','tasks','filter','briefcase','fullscreen']
   
    icon      
= "icon %(c)s icon-%(c)s glyphicon glyphicon-%(c)s"
    icon_white
= "icon-white %(c)s icon-%(c)s glyphicon glyphicon-%(c)s"
   
    trs        
= [TR(TD(SPAN(_class=icon % locals(), _style='background-color:white'),
                        SPAN
(_class=icon_white % locals(), _style='background-color:black'),
                        SPAN
(' %(c)s' % locals(), _style='background-color:white'))) for c in classes]
   
   
return dict(html=TABLE(trs))

Regards! 

Massimo Di Pierro

unread,
Dec 24, 2014, 8:43:00 AM12/24/14
to web...@googlegroups.com
:-)
Reply all
Reply to author
Forward
0 new messages