File: view.py

package info (click to toggle)
python-gtk 0.5.3-2
  • links: PTS
  • area: main
  • in suites: slink
  • size: 1,604 kB
  • ctags: 4,295
  • sloc: ansic: 19,390; python: 8,220; makefile: 91; sh: 26
file content (52 lines) | stat: -rwxr-xr-x 1,092 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python

from Gtkinter import *
import GdkImlib

def close(win, _event=None):
	win.hide()
	win.destroy()

def resize(win, event):
	im = win.get_data('user_data')
	# note that render must be called once before each call to make_pixmap
	im.render(event.width, event.height)
	pix = win.children()[0]
	win.remove(pix)
	pix = im.make_pixmap()
	pix.show()
	win.add(pix)

def open_img(_b):
        file = fs.get_filename()
	try:
		im = GdkImlib.Image(file)
	except RuntimeError: return
	win = GtkWindow()
	win.connect('destroy', close)
	win.connect('delete_event', close)
	win.connect('configure_event', resize)
	win.set_title(file)
	win.set_data('user_data', im)
	im.render()
	pix = im.make_pixmap()
	pix.show()
	win.add(pix)
	win.show()

fs = GtkFileSelection()
fs.set_title('Image Viewer')
fs.connect('destroy', mainquit)
fs.connect('delete_event', mainquit)

label = fs.ok_button.children()[0]
label.set('View')
fs.ok_button.connect('clicked', open_img)

label = fs.cancel_button.children()[0]
label.set('Quit')
fs.cancel_button.connect('clicked', mainquit)

fs.show()

mainloop()