-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowser.py
More file actions
46 lines (37 loc) · 1.56 KB
/
browser.py
File metadata and controls
46 lines (37 loc) · 1.56 KB
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
import tkinter as tk
from tkinter import ttk
import jpype
from jpype import javax, java
class JavaBrowserFrame(tk.Frame):
def __init__(self, root):
super().__init__(root)
self.root = root
self.pack_propagate(0)
self.create_widgets()
def create_widgets(self):
# TODO: Implement the Libraries functionality
label = ttk.Label(self, text="This is the Shell Frame")
label.pack()
# Create the Java browser component
self.browser = jpype.JClass('javax.swing.JEditorPane')()
# Set the URL to load
self.browser.setPage(java.net.URL("http://google.com"))
# Create a Swing component to embed the browser
jframe = jpype.JClass('javax.swing.JFrame')()
jframe.add(self.browser)
jframe.setSize(800, 600)
jframe.setVisible(True)
# Get the native component and embed it in the Tkinter frame
native_component = jpype.awt.Component.getComponent(self.browser)
native_window_id = jpype.awt.Component.getNativeWindowID(native_component)
embed_window_id = str(native_window_id)
embed_window = tk.Frame(self, width=800, height=600)
embed_window.pack()
embed_window.winfo_id()
jpype.java.awt.Frame.getFrames()[0].dispose()
jpype.attachThreadToJVM()
jpype.attachThreadToJVM().getAwtView().setParentWindowID(embed_window_id)
back_button = ttk.Button(self, text="Back", command=self.back_button_click)
back_button.pack()
def back_button_click(self):
self.callback()