-
Notifications
You must be signed in to change notification settings - Fork 0
Browser
Closing browser cleanly
Remember to delete all browser references for the browser to shut down cleanly. For an example see wxpython.py > MainFrame.OnClose().
Returns true if the browser can navigate backwards.
Returns true if the browser can navigate forwards.
Available only in CEF 1.
Clear the back/forward browsing history.
Closes the browser. If the window was created explicitily by you (not a popup) you still need to post WM_DESTROY message to the window.
Request that the browser close. The Javascript 'onbeforeunload' event will be fired. If |force_close| is false the event handler, if any, will be allowed to prompt the user and the user can optionally cancel the close.
If |force_close| is true the prompt will not be displayed and the close will proceed. Results in a call to LifespanHandler::DoClose() if the event handler allows the close or if |force_close| is true. See LifespanHandler::DoClose() documentation for additional usage information.
Available only in cefpython 1. Not yet implemented in cefpython 3.
Explicitly close the developer tools window if one exists for this browser instance.
Call javascript function asynchronously. This can also call object's methods, just pass "object.method" as funcName. Any valid javascript syntax is allowed as funcName, you could even pass an anonymous function here.
For a list of allowed types for mixed see JavascriptBindings.IsValueAllowed() (except function, method and instance).
Passing a python function here is not allowed, it is only possible through JavascriptCallback object.
Execute a string of JavaScript code in this frame. The sciptURL parameter is the URL where the script in question can be found, if any. The renderer may request this URL to show the developer the source of the error. The startLine parameter is the base line number to use for error reporting.
This function executes asynchronously so there is no way to get the returned value.
Calling javascript from native code synchronously is not possible in CEF 3. It is also not possible doing it synchronously the other way around ie. js->native.
Search for |searchText|. |searchID| can be custom, it is so that you can have multiple searches running simultaneously. |forward| indicates whether to search forward or backward within the page. |matchCase| indicates whether the search should be case-sensitive. |findNext| indicates whether this is the first request or a follow-up.
Get client callback by name.
Get client callbacks as a dictionary.
Returns the focused frame for the browser window. In CEF 1 this method should only be called on the UI thread.
Returns the frame with the specified name, or NULL if not found. In CEF 1 this method should only be called on the UI thread.
Available only in CEF 3.
Returns the frame with the specified identifier, or None if not found.
Get all frames. This is an internal CEF Python implementation that uses GetFrameNames() and GetFrame() methods to list through all frames. The main frame is not included in that list.
Available only in CEF 3. Not yet implemented.
Returns the number of frames that currently exist.
Available only in CEF 3. Not yet implemented.
Returns the identifiers of all existing frames.
Returns the names of all existing frames. This list does not include the main frame. In CEF 1 this method should only be called on the UI thread.
Available only in cefpython 1. Not yet implemented in CEF 3. Not supported on Linux.
Get the raw image data contained in the specified element without performing validation. The specified |width| and |height| dimensions must match the current element size. On Windows |buffer| must be width*height*4 bytes in size and represents a BGRA image with an upper-left origin. This method should only be called on the UI thread.
Returns PaintBuffer object.
Returns the JavascriptBindings object that was passed to cefpython.CreateBrowserSync().
Returns the main (top-level) frame for the browser window.
Not yet ported. Available only in CEF 3.
Get the NSTextInputContext implementation for enabling IME on Mac when window rendering is disabled.
Retrieve the CEF-internal (inner or outer) window handle of the browser that opened this browser. Will return None for non-popup windows. See GetWindowHandle() for an explanation of inner/outer window handles.
Get the most outer window handle.
Available only in CEF 1. This method is not available in CEF 3.
Get the size of the specified element. This method should only be called on the UI thread.
paintElementType is one of:
cefpython.PET_VIEW
cefpython.PET_POPUP
Returns tuple(width, height) or tuple(0, 0) if failed.
Get url of the main frame.
Get user data. See also SetUserData().
Returns an inner or outer window handle for the browser. If the browser was created using CreateBrowserSync() then this will return an inner CEF-internal window handle. If this is a popup browser created from javascript using window.open() and its WindowInfo has not been set in LifespanHandler.OnAfterCreated(), then it returns CEF-internal window handle which is the most outer window handle in this case.
Returns the globally unique identifier for this browser.
Get the current zoom level. The default zoom level is 0.0. In CEF 1 this method may only be called on the UI thread.
Navigate backwards.
Navigate forwards.
Available only in CEF 3. Not yet implemented.
Performs any additional actions after NSTextInputClient handles the event.
Available only in CEF 3. Not yet implemented.
Handles a keyDown event prior to passing it through the NSTextInputClient
machinery.
Returns true if a document has been loaded in the browser.
Available only in CEF 1.
Hide the currently visible popup, if any.
Available only in cefpython 1. Not yet implemented in cefpython 3.
Invalidate the |dirtyRect| region of the view. This method is only used when window rendering is disabled and will result in a call to HandlePaint().
dirtyRect is a list: [x, y, width, height].
Whether in fullscreen mode, see ToggleFullscreen().
This function is Windows-only.
Available only in CEF 3. Not yet implemented.
Returns true if the browser is currently loading.
Available only in CEF 3.
Returns true if mouse cursor change is disabled.
Returns true if the window is a popup window.
Available only in CEF 1.
Returns true if a popup is currently visible. In CEF 1 this method should only be called on the UI thread.
Returns true if window rendering is disabled.
Load url in the main frame.
This is an alias for the LoadUrl method.
Available only in CEF 3.
Send a notification to the browser that the screen info has changed. The
browser will then call RenderHandler.GetScreenInfo() to update the
screen information with the new values. This simulates moving the webview
window from one display to another, or changing the properties of the
current display. This method is only used when window rendering is
disabled.
Call this method before destroying a contained browser window. This method
performs any internal cleanup that may be needed before the browser window
is destroyed. See LifespanHandler::DoClose() documentation for
additional usage information.
Reload the current page.
Reload the current page ignoring any cached data.
These arguments and description apply for CEF 1 only. In CEF 3 this
function has a different number of arguments, see the next function
listed on this wiki page.
Sending keyboard input using this function is not trivial, it is
recommended to use one of SendKeys libraries available on Windows:
- http://code.google.com/p/pywinauto/source/browse/pywinauto/SendKeysCtypes.py
- http://code.google.com/p/sendkeys-ctypes/
- https://github.com/zvodd/sendkeys-py-si
- https://bitbucket.org/orutherfurd/sendkeys/overview
Send a key event to the browser.
keyType may be one of:
cefpython.KEYTYPE_KEYUP
cefpython.KEYTYPE_KEYDOWN
cefpython.KEYTYPE_CHAR
keyInfo on Windows is a tuple(int key, BOOL sysChar, BOOL imeChar).
keyInfo on Mac is a tuple(int keyCode, int character, int characterNoModifiers).
keyInfo on Linux is a tuple(int key).
key in keyInfo is a VirtualKey.
modifiers parameter is a VirtualKey.
These arguments and description apply for CEF 3 only. In CEF 1 this
function has a different number of arguments, see the previous
function listed on this wiki page.
KeyEvent is a dictionary, see KeyboardHandler.OnPreKeyEvent()
for a description of the available keys.
SendMouseClickEvent(int x, int y, int mouseButtonType, bool mouseUp, int clickCount, int modifiers=0) (void)
Send a mouse click event to the browser. The |x| and |y| coordinates are relative to the upper-left corner of the view.
mouseButtonType may be one of:
cefpython.MOUSEBUTTON_LEFT
cefpython.MOUSEBUTTON_MIDDLE
cefpython.MOUSEBUTTON_RIGHT
modifiers may be:
enum cef_event_flags_t {
EVENTFLAG_NONE = 0,
EVENTFLAG_CAPS_LOCK_ON = 1 << 0,
EVENTFLAG_SHIFT_DOWN = 1 << 1,
EVENTFLAG_CONTROL_DOWN = 1 << 2,
EVENTFLAG_ALT_DOWN = 1 << 3,
EVENTFLAG_LEFT_MOUSE_BUTTON = 1 << 4,
EVENTFLAG_MIDDLE_MOUSE_BUTTON = 1 << 5,
EVENTFLAG_RIGHT_MOUSE_BUTTON = 1 << 6,
// Mac OS-X command key.
EVENTFLAG_COMMAND_DOWN = 1 << 7,
EVENTFLAG_NUM_LOCK_ON = 1 << 8,
EVENTFLAG_IS_KEY_PAD = 1 << 9,
EVENTFLAG_IS_LEFT = 1 << 10,
EVENTFLAG_IS_RIGHT = 1 << 11,
Send a mouse move event to the browser. The |x| and |y| coordinates are relative to the upper-left corner of the view.
Send a mouse wheel event to the browser. The |x| and |y| coordinates are relative to the upper-left corner of the view. The |deltaX| and |deltaY| values represent the movement delta in the X and Y directions respectively. In order to scroll inside select popups with window rendering disabled RenderHandler.GetScreenPoint() should be implemented properly.
Send a focus event to the browser.
Send a capture lost event to the browser.
Set client callback.
Set client handler object (class instance), its members will be inspected. Private methods that are not meant to be callbacks should have their names prepended with an underscore.
Set focus for the browser window. If |enable| is true focus will be set to the window. Otherwise, focus will be removed.
Available only in CEF 3.
Set whether mouse cursor change is disabled.
Available only in cefpython 1. Not yet implemented in cefpython 3.
Set the size of the specified element. This method is only used when window rendering is disabled (off-screen browser). This function is asynchronous, after a call to SetSize() the RenderHandler.OnPaint() event might still have the old size, you would have to ignore it and wait for the next one RenderHandler.OnPaint() event.
See GetSize() for possible values of paintElementType.
Set user data. Use this function to keep data associated with this browser. See also GetUserData().
Change the zoom level to the specified value. Specify 0.0 to reset the zoom level. If called on the UI thread the change will be applied immediately. Otherwise, the change will be applied asynchronously on the UI thread.
Open developer tools in a popup window.
Available only in CEF 3.
Download the file at |url| using DownloadHandler.
Stop loading the page.
Cancel all searches that are currently going on.
Switch between fullscreen mode / windowed mode. To check whether in fullscreen mode call IsFullscreen().
This function is Windows-only.
Notify the browser that the widget has been resized. The browser will first call RenderHandler::GetViewRect to get the new size and then call RenderHandler::OnPaint asynchronously with the updated regions.
This method is only used when window rendering is disabled.
Available only in CEF 3.
Notify the browser that it has been hidden or shown. Layouting and RenderHandler::OnPaint notification will stop when the browser is hidden. This method is only used when window rendering is disabled.