MCPcopy Create free account
hub / github.com/cztomczak/cefpython / MainFrame

Class MainFrame

examples/tkinter_.py:69–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67 cef.Shutdown()
68
69class MainFrame(tk.Frame):
70
71 def __init__(self, root):
72 self.browser_frame = None
73 self.navigation_bar = None
74 self.root = root
75
76 # Root
77 root.geometry("900x640")
78 tk.Grid.rowconfigure(root, 0, weight=1)
79 tk.Grid.columnconfigure(root, 0, weight=1)
80
81 # MainFrame
82 tk.Frame.__init__(self, root)
83 self.master.title("Tkinter example")
84 self.master.protocol("WM_DELETE_WINDOW", self.on_close)
85 self.master.bind("<Configure>", self.on_root_configure)
86 self.setup_icon()
87 self.bind("<Configure>", self.on_configure)
88 self.bind("<FocusIn>", self.on_focus_in)
89 self.bind("<FocusOut>", self.on_focus_out)
90
91 # NavigationBar
92 self.navigation_bar = NavigationBar(self)
93 self.navigation_bar.grid(row=0, column=0,
94 sticky=(tk.N + tk.S + tk.E + tk.W))
95 tk.Grid.rowconfigure(self, 0, weight=0)
96 tk.Grid.columnconfigure(self, 0, weight=0)
97
98 # BrowserFrame
99 self.browser_frame = BrowserFrame(self, self.navigation_bar)
100 self.browser_frame.grid(row=1, column=0,
101 sticky=(tk.N + tk.S + tk.E + tk.W))
102 tk.Grid.rowconfigure(self, 1, weight=1)
103 tk.Grid.columnconfigure(self, 0, weight=1)
104
105 # Pack MainFrame
106 self.pack(fill=tk.BOTH, expand=tk.YES)
107
108 def on_root_configure(self, _):
109 logger.debug("MainFrame.on_root_configure")
110 if self.browser_frame:
111 self.browser_frame.on_root_configure()
112
113 def on_configure(self, event):
114 logger.debug("MainFrame.on_configure")
115 if self.browser_frame:
116 width = event.width
117 height = event.height
118 if self.navigation_bar:
119 height = height - self.navigation_bar.winfo_height()
120 self.browser_frame.on_mainframe_configure(width, height)
121
122 def on_focus_in(self, _):
123 logger.debug("MainFrame.on_focus_in")
124
125 def on_focus_out(self, _):
126 logger.debug("MainFrame.on_focus_out")

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected