Commits

squeaky committed 0e35844

jbrowser

Comments (0)

Files changed (2)

pystacia/compat.py

     dist = platform.dist
 
 
-try:
-    from webbrowser import open as gui_open
-except ImportError:
-    #TODO: implement
-    gui_open = lambda x: None
-
-
 # detect PyPy
 import sys
 pypy = '__pypy__' in sys.builtin_module_names
 
 # detect Jython
 jython = sys.platform.startswith('java')
+
+if jython:
+    from pystacia.jbrowser import open as gui_open
+else:
+    from webbrowser import open as gui_open

pystacia/jbrowser.py

+from java.awt.image import BufferedImage
+from java.io import File
+from java.net import URL
+from javax.imageio import ImageIO
+from javax.swing import JLabel, JFrame, ImageIcon
+
+
+def open(path):
+    label = JLabel(ImageIcon(ImageIO.read(File(URL(path).getFile()))))
+    frame = JFrame()
+    frame.getContentPane().add(label)
+    frame.pack()
+    frame.setLocation(200, 200)
+    frame.setVisible(True)