Last active
August 29, 2015 14:12
-
-
Save jason-s/3502be21ad4b9ebe3abc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from enaml.layout.api import ( | |
hbox, vbox, align, spacer, | |
) | |
from enaml.widgets.api import ( | |
MainWindow, PushButton, ImageView, Container | |
) | |
import enaml | |
import os | |
def openResource(path, mode='r'): | |
dirname = '.' | |
return open(os.path.join(dirname,path), mode=mode) | |
def loadImage(filename): | |
with openResource(filename, 'rb') as f: | |
data = f.read() | |
return enaml.image.Image(data=data) | |
def loadIcon(filename): | |
image = loadImage(filename) | |
return enaml.icon.Icon(images=[enaml.icon.IconImage(image=image)]) | |
ICONS = { | |
'tr-A' : loadIcon('tr-a.png'), | |
'tr-B' : loadIcon('tr-b.png'), | |
'tr-C' : loadIcon('tr-c.png'), | |
} | |
enamldef Main(MainWindow): main: | |
Container: | |
constraints << [ | |
vbox( | |
hbox(btnTrA, btnTrB, btnTrC, spacer), | |
spacer | |
), | |
] | |
PushButton: btnTrA: | |
icon = ICONS['tr-A'] | |
clicked :: | |
print "A" | |
PushButton: btnTrB: | |
icon = ICONS['tr-B'] | |
clicked :: | |
print "B" | |
PushButton: btnTrC: | |
icon = ICONS['tr-C'] | |
clicked :: | |
print "C" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment