def load_location_task_update(self):
        """
        Handle geo location task update event.
        """
        try:
            #retrieving data from dataset and converting it to string
            getLocation = self.location_data_queue.get(False)
            getLocationPostal = str(self.postal_code)
            getLocationAddr = str(self.address_data[0:1])
            getLocationAddr = getLocationAddr.replace(" ", "+")
            #open the url in the tkinter gui
            if getLocation is not None:
                self.browser_frame.browser.StopLoad()
                self.browser_frame.browser.LoadUrl(
                    cef.GetNavigateUrl(
                        "https://www.google.com/maps/search/?api=1&map_action=map&query="
                        + getLocationAddr + "+" + getLocationPostal +
                        "&zoom=18"))

                self.browser_frame.on_mainframe_configure(
                    self.winfo_width(), self.winfo_height())

            #error msg if google map didnt read
            else:
                self.browser_frame.browser.LoadUrl(
                    cef.GetDataUrl(
                        "<html><body><p>Unable to locate from the google map. Please try again later.</p></body></html>"
                    ))

        except Queue.Empty:
            self.after(100, self.load_location_task_update)
Ejemplo n.º 2
0
def main():
    cef.Initialize()
    browser = cef.CreateBrowserSync(url=cef.GetDataUrl(g_htmlcode),
                                    window_title="Javascript Errors")
    browser.SetClientHandler(DisplayHandler())
    cef.MessageLoop()
    cef.Shutdown()
    def load(self, *args, **kwargs):
        """
        Handle on load event for this GUI.

        :param args: List of args pass from the previous frame.
        :param kwargs: Dictionary of args pass from the previous frame.
        """
        if "back_button_frame" in kwargs:
            self.back_button_frame = kwargs["back_button_frame"]

        if "address_data" in kwargs:
            self.address_data = kwargs["address_data"]

        if "postal_code" in kwargs:
            self.postal_code = kwargs["postal_code"]

        if "company_name" in kwargs:
            self.company_name = kwargs["company_name"]

        self.company_label.configure(text=self.company_name)

        self.browser_frame.browser.LoadUrl(
            cef.GetDataUrl(
                "<html><body><p>Loading Google Map... Please wait!</p></body></html>"
            ))

        Task.Task(self.load_location_task_run,
                  self.location_data_queue).start()

        self.after(100, self.load_location_task_update)
Ejemplo n.º 4
0
def main():
    sys.excepthook = cef.ExceptHook
    cef.Initialize()
    browser = cef.CreateBrowserSync(url=cef.GetDataUrl(html))
    browser.SetClientHandler(RequestHandler())
    cef.MessageLoop()
    del browser
    cef.Shutdown()
 def embed_browser(self):
     window_info = cef.WindowInfo()
     rect = [0, 0, self.winfo_width(), self.winfo_height()]
     window_info.SetAsChild(self.get_window_handle(), rect)
     self.browser = cef.CreateBrowserSync(
         window_info,
         url=cef.GetDataUrl(
             "<html><body><p>Loading Google Map... Please wait!</p></body></html>"
         ))
     assert self.browser
     self.message_loop_work()
Ejemplo n.º 6
0
def main(frame):
    with codecs.open("joystick.html", "r", encoding="utf-8") as file:
        global html_code
        html_code = file.read()
    sys.excepthook = cef.ExceptHook
    window_info = cef.WindowInfo(frame.winfo_id())
    window_info.SetAsChild(frame.winfo_id(), [0, 0, 1200, 900])
    cef.Initialize()
    browser = cef.CreateBrowserSync(window_info, url=cef.GetDataUrl(html_code))
    browser.SetClientHandler(LoadHandler())
    setBindings(browser)
    cef.MessageLoop()
Ejemplo n.º 7
0
def main():
    cef.Initialize()
    browser = cef.CreateBrowserSync(url=cef.GetDataUrl(g_htmlcode),
                                    window_title="Javascript Bindings")
    browser.SetClientHandler(LoadHandler())
    bindings = cef.JavascriptBindings()
    bindings.SetFunction("py_function", py_function)
    bindings.SetFunction("py_callback", py_callback)
    browser.SetJavascriptBindings(bindings)
    cef.MessageLoop()
    del browser
    cef.Shutdown()
Ejemplo n.º 8
0
def main_cef(frame):
    print("main")
    print(len(data_set) - 1)
    global w, h
    sys.excepthook = cef.ExceptHook
    window_info = cef.WindowInfo(frame.winfo_id())
    window_info.SetAsChild(frame.winfo_id(), [0, 0, w, h])
    cef.Initialize()
    browser = cef.CreateBrowserSync(window_info, url=cef.GetDataUrl(html_code))
    browser.SetClientHandler(LoadHandler())
    setBindings(browser)
    cef.MessageLoop()
    print("end thread")
Ejemplo n.º 9
0
def main():
    settings = {"debug": False, "context_menu": {"enabled": False}}
    cef.Initialize(settings=settings)
    browser = cef.CreateBrowserSync(url=cef.GetDataUrl(html_code),
                                    window_title="Despachador Bellaco")
    browser.SetClientHandler(LifespanHandler())
    bindings = cef.JavascriptBindings()

    pyjs = PythonJS(
    )  # Crea el objeto con los procesos iniciales e inicia el despachador
    # Une las funciones de python a javascript
    bindings.SetFunction("py_despachador", pyjs.py_despachador)

    browser.SetJavascriptBindings(bindings)
    cef.MessageLoop()
    del browser
    cef.Shutdown()
Ejemplo n.º 10
0
def create_browser(url=None,
                   title="Pytigon",
                   parent_win=None,
                   x=200,
                   y=200,
                   width=1024,
                   height=768):

    info = cef.WindowInfo()
    if parent_win:
        info.SetAsChild(parent_win.Handle, [x, y, x + width, y + height])
    else:
        info.SetAsChild(0, [x, y, x + width, y + height])

    browser = cef.CreateBrowserSync(window_info=info,
                                    url=cef.GetDataUrl(LOADER),
                                    window_title=title)

    if platform.system() == "Windows":
        window_handle = browser.GetOuterWindowHandle()
        insert_after_handle = 0
        SWP_NOMOVE = 0x0002
        ctypes.windll.user32.SetWindowPos(window_handle, insert_after_handle,
                                          0, 0, 900, 640, SWP_NOMOVE)

    client_handler = ClientHandler()

    browser.SetClientHandler(client_handler)

    if url:
        while True:
            test = exists(url)
            if test:
                break
            else:
                print("wait")
                time.sleep(1)

        browser.LoadUrl(url)

    return browser, client_handler
Ejemplo n.º 11
0
def main():
    cef.Initialize()
    window_info = cef.WindowInfo()
    parent_handle = 0
    # This call has effect only on Mac and Linux.
    # All rect coordinates are applied including X and Y parameters.
    window_info.SetAsChild(parent_handle, [0, 0, 1720, 1440])

    browser = cef.CreateBrowserSync(
        url=cef.GetDataUrl(open('cube.html', 'r').read()),
        window_info=window_info,
        window_title="Javascript Bindings",
        settings={
            'universal_access_from_file_urls_allowed': True,
            'file_access_from_file_urls_allowed': True
        })

    if platform.system() == "Windows":
        window_handle = browser.GetOuterWindowHandle()
        insert_after_handle = 0
        # X and Y parameters are ignored by setting the SWP_NOMOVE flag
        SWP_NOMOVE = 0x0002
        # noinspection PyUnresolvedReferences
        ctypes.windll.user32.SetWindowPos(window_handle, insert_after_handle,
                                          0, 0, 1720, 1440, SWP_NOMOVE)

    browser.SetClientHandler(LoadHandler())

    bindings = cef.JavascriptBindings()
    bindings.SetFunction("get_puzzle", get_puzzle)
    bindings.SetFunction("load_patterns", load_patterns)
    bindings.SetFunction("translate_c", translate)
    browser.SetJavascriptBindings(bindings)

    cef.MessageLoop()
    del browser
    cef.Shutdown()
Ejemplo n.º 12
0
        js_code_completed();
    }
    window.onload = function() {
        print("window.onload() ok");
        onload_helper();
    }
    </script>
</head>
<body>
    <!-- FrameSourceVisitor hash = 747ef3e6011b6a61e6b3c6e54bdd2dee -->
    <h1>Main test</h1>
    <div id="console"></div>
</body>
</html>
"""
g_datauri = cef.GetDataUrl(g_datauri_data)


class MainTest_IsolatedTest(unittest.TestCase):
    def test_main(self):
        """Main entry point. All the code must run inside one
        single test, otherwise strange things happen."""

        print("")
        print("CEF Python {ver}".format(ver=cef.__version__))
        print("Python {ver}".format(ver=sys.version[:6]))

        # Test initialization of CEF
        settings = {
            "debug": False,
            "log_severity": cef.LOGSEVERITY_ERROR,