Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update kivy example #573

Merged
merged 6 commits into from
Feb 14, 2021
Merged

update kivy example #573

merged 6 commits into from
Feb 14, 2021

Conversation

hoba87
Copy link
Contributor

@hoba87 hoba87 commented May 15, 2020

I've updated the kivy example to be working for me on Windows 10. I have removed the pygtk depedency, because it seems to be not necessary (at least for me on Win10).

@cztomczak
Copy link
Owner

Your code breaks features on Linux. Use conditional statements instead for Windows. Provide version information on Kivy, Python and CEF Python that you have tested with.

@hoba87
Copy link
Contributor Author

hoba87 commented May 18, 2020

The code should be working as before on Linux.
I've tested on Windows 10 with python 3.6.5, kivy 1.11.1 and cefpython 66, where everything seems working, except the issue described here: #574.
On MacOS 10.14.6 I've also tested with python 3.7.4, kivy 1.11.1 and cefpython 66, however there is also an issue with keyboard support.

@cztomczak
Copy link
Owner

What if you add such code for Mac.

if sys.platform == 'darwin':
        # On MacOS, the NSApplication created in the cefpython initialization
        # will be hidden if windowless is specified. In order for SDL to receive
        # propper input events and for the application to show up in the
        # command-tab list, the application must be made "regular".
        AppKit.NSApplication.sharedApplication().setActivationPolicy_(
            AppKit.NSApplicationActivationPolicyRegular)

Does it resolve keyboard issue? It's from the pysdl2.py example. See also usage of MACOS_TRANSLATION_TABLE and get_native_key() in that example.

@cztomczak
Copy link
Owner

You don't use GTK APIs on Mac, so no need to import Gtk for that OS. Just keep the single if import for Linux.

@hoba87
Copy link
Contributor Author

hoba87 commented May 18, 2020

The code from pysdl2.py doesn't help, while the pysdl2.py works with and without the code line. The issue with the kivy example is that the key is forwarded to cef only very rarely. So it is not completely impossible to type something, however it gets only about every 20th to 30th key event.

If I remove the import Gtk, the example is crashing with exit code 132 (interrupted by signal 4: SIGILL).

@cztomczak
Copy link
Owner

On Mac try setting the external_message_pump option to True. See:

"external_message_pump": False, # See Issue #246

@hoba87
Copy link
Contributor Author

hoba87 commented May 18, 2020

For MacOS the keyboard is also working now

@cztomczak
Copy link
Owner

The external_message_pump option should be set only for Mac. It's buggy on other OSes.

@hoba87
Copy link
Contributor Author

hoba87 commented May 19, 2020

Ok, it is activated now only for MacOS

@tariksetia
Copy link

@hoba87, I tried your version and I getting following error. Could you please help me fix this?

INFO   ] [Logger      ] Record log in /Users/tarik.setia/.kivy/logs/kivy_21-01-14_16.txt
[INFO   ] [Kivy        ] v2.0.0
[INFO   ] [Kivy        ] Installed at "/Users/tarik.setia/opt/miniconda3/envs/nyc/lib/python3.7/site-packages/kivy/__init__.py"
[INFO   ] [Python      ] v3.7.8 | packaged by conda-forge | (default, Jul 23 2020, 03:39:37) 
[Clang 10.0.0 ]
[INFO   ] [Python      ] Interpreter at "/Users/tarik.setia/opt/miniconda3/envs/nyc/bin/python"
[INFO   ] [Factory     ] 186 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_imageio, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
[INFO   ] [Window      ] Provider: sdl2
[WARNING] Both Window.minimum_width and Window.minimum_height must be bigger than 0 for the size restriction to take effect.
[INFO   ] [GL          ] Using the "OpenGL ES 2" graphics system
[INFO   ] [GL          ] Backend used <sdl2>
[INFO   ] [GL          ] OpenGL version <b'2.1 ATI-3.10.18'>
[INFO   ] [GL          ] OpenGL vendor <b'ATI Technologies Inc.'>
[INFO   ] [GL          ] OpenGL renderer <b'AMD Radeon Pro 5300M OpenGL Engine'>
[INFO   ] [GL          ] OpenGL parsed version: 2, 1
[INFO   ] [GL          ] Shading version <b'1.20'>
[INFO   ] [GL          ] Texture max size <16384>
[INFO   ] [GL          ] Texture max units <16>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
 Traceback (most recent call last):
   File "kivy_.py", line 991, in <module>
     CefBrowserApp().run()
   File "/Users/tarik.setia/opt/miniconda3/envs/nyc/lib/python3.7/site-packages/kivy/app.py", line 949, in run
     self._run_prepare()
   File "/Users/tarik.setia/opt/miniconda3/envs/nyc/lib/python3.7/site-packages/kivy/app.py", line 919, in _run_prepare
     root = self.build()
   File "kivy_.py", line 981, in build
     self.layout = BrowserLayout()
   File "kivy_.py", line 47, in __init__
     self.browser_widget = CefBrowser(id="browser")
   File "kivy_.py", line 78, in __init__
     super(CefBrowser, self).__init__(**kwargs)
   File "/Users/tarik.setia/opt/miniconda3/envs/nyc/lib/python3.7/site-packages/kivy/uix/widget.py", line 350, in __init__
     super(Widget, self).__init__(**kwargs)
   File "_event.pyx", line 245, in kivy._event.EventDispatcher.__init__
 TypeError: object.__init__() takes exactly one argument (the instance to initialize)

@cztomczak cztomczak merged commit 8e36e82 into cztomczak:master Feb 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants