WPF Image Viewer
import zip
import wpf
import wpf_icon as icon
global app, index, img, zf, ix, mx, ls
def setMenuBar():
app.add_ezmenubar(
[[ 'File', 'Exit', on_exit, icon.GetExitImage() ],
[ 'Help', 'About', on_about ]]
)
def setStatusBar():
global index, prevImg, nextImg
index = wpf.WpfChoice(handler = on_index, width=64)
prevImg = wpf.WpfButton(text="<", handler = on_prev, width=32)
nextImg = wpf.WpfButton(text=">", handler = on_next, width=32)
app.set_ezstatusbar( [ index, prevImg, nextImg ] )
def setContent():
global img
img = wpf.WpfImage(imagefile='D:/Lenna.png', stretch='uniformfill')
img.set_filedrop(on_drop)
hbox = [[ img ]]
app.set_ezcontent( [[ hbox, 0 ]] )
def on_about(sender,event):
wpf.WpfAlertDialog("About ImageViewer", "Information" )
def on_exit(sender,event):
app.Close()
def new_page(page):
global index, img, zf, ix, ls
ix = page
index.set_selected_index(ix)
img.set_image(wpf.GetImageSource(wpf.ByteArray(zf.read(ls[ix]))))
img.scroll_top()
def on_drop(files):
global index, zf, mx, ls
app.set_title(files[0])
zf = zip.PyUnZip(files[0])
ls = zf.list()
mx = len(ls)
for i in range(mx): index.add_item(str(i))
new_page(0)
def on_index(sender,event):
new_page( index.get_selected_index() )
def on_prev(sender,event):
if ix > 0: new_page(ix - 1)
def on_next(sender,event):
if ix < mx-1: new_page(ix + 1)
if __name__ == "__main__":
app = wpf.Win("Image Viewer 0.1",320,240)
app.set_icon(icon.GetExitImageSource())
setMenuBar()
setContent()
setStatusBar()
app.run()
댓글 없음:
댓글 쓰기