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

Class MainFrame

examples/wxpython.py:88–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86
87
88class MainFrame(wx.Frame):
89
90 def __init__(self):
91 self.browser = None
92
93 # Must ignore X11 errors like 'BadWindow' and others by
94 # installing X11 error handlers. This must be done after
95 # wx was intialized.
96 if LINUX:
97 cef.WindowUtils.InstallX11ErrorHandlers()
98
99 global g_count_windows
100 g_count_windows += 1
101
102 if WINDOWS:
103 # noinspection PyUnresolvedReferences, PyArgumentList
104 print("[wxpython.py] System DPI settings: %s"
105 % str(cef.DpiAware.GetSystemDpi()))
106 if hasattr(wx, "GetDisplayPPI"):
107 print("[wxpython.py] wx.GetDisplayPPI = %s" % wx.GetDisplayPPI())
108 print("[wxpython.py] wx.GetDisplaySize = %s" % wx.GetDisplaySize())
109
110 print("[wxpython.py] MainFrame declared size: %s"
111 % str((WIDTH, HEIGHT)))
112 size = scale_window_size_for_high_dpi(WIDTH, HEIGHT)
113 print("[wxpython.py] MainFrame DPI scaled size: %s" % str(size))
114
115 wx.Frame.__init__(self, parent=None, id=wx.ID_ANY,
116 title='wxPython example', size=size)
117 # wxPython will set a smaller size when it is bigger
118 # than desktop size.
119 print("[wxpython.py] MainFrame actual size: %s" % self.GetSize())
120
121 self.setup_icon()
122 self.create_menu()
123 self.Bind(wx.EVT_CLOSE, self.OnClose)
124
125 # Set wx.WANTS_CHARS style for the keyboard to work.
126 # This style also needs to be set for all parent controls.
127 self.browser_panel = wx.Panel(self, style=wx.WANTS_CHARS)
128 self.browser_panel.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus)
129 self.browser_panel.Bind(wx.EVT_SIZE, self.OnSize)
130
131 if MAC:
132 # Make the content view for the window have a layer.
133 # This will make all sub-views have layers. This is
134 # necessary to ensure correct layer ordering of all
135 # child views and their layers. This fixes Window
136 # glitchiness during initial loading on Mac (Issue #371).
137 NSApp.windows()[0].contentView().setWantsLayer_(True)
138
139 if LINUX:
140 # On Linux must show before embedding browser, so that handle
141 # is available (Issue #347).
142 self.Show()
143 # In wxPython 3.0 and wxPython 4.0 on Linux handle is
144 # still not yet available, so must delay embedding browser
145 # (Issue #349).

Callers 1

initializeMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected