-
Notifications
You must be signed in to change notification settings - Fork 64
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
Tkinter? #43
Comments
Definitely want to give that a try at least. I'm not entirely sure how to cover mouse, keyboard and window events, but I'm guessing tkinter should be able to provide most of those? Worst case missing events can be emulated somehow. I guess starting with a simple Tk window with a frame covering the entire window is a good idea. Then later make a widget that can be mixed with other UI elements (making one for PyQt5 and PySide2 as well). It would probably require a bit of investment in your pyopengltk project. I see One very important thing to resolve is setting a package license on github and in There is a 1000% percent chance we will get questions about this if not resolved 😄 |
I manage to get moderngl context and basic rendering working on windows at least. There's of course a lot more work needed to make this into a proper window, but a good sign this idea is doable.
|
That was fast! I had been thinking to eliminate all the ctypes code and just use the winfo_id and winfo_screen to hook up the window with one of your contexts. It sounds like you already got it working, so I am happy I asked. I don't have access to mac but would be happy to do some testing on windows and linux (although it might take me some time to get up to speed). |
The tkinter window is located here: You can test the window by running:
.. or any other of the examples. Currently window resizing, minimize and maximize works. The only way to close the window currently is clicking the window close button. I'll probably see if I can add some more event support later today. I have access to win10, linux and OS X. |
@jonwright This might be done pretty fast as an experimental window. See if you can fix the license issue because I don't want to deal with emails about this 😄 |
The way moderngl works in 5.x : We do have an experimental glcontext package : https://github.com/moderngl/glcontext .. but I'm not sure if the plan is to support context creation and default framebuffer creation (that is not headless) in that one. It's a very odd use case. |
I think the first version of the tk window is actually done now. Currently only tested on windows. I'll test it out tomorrow in linux. What has been implemented:
Missing features:
I created these issues in : https://github.com/jonwright/pyopengltk |
moderngl-window 1.5.0 is now on PyPI with the new experimental tkinter window. For the optional dependencies for tk window:
.. and you can run examples using the tk window like this (pyglet window will be the default if # The basic animated logo example
python examples/moderngl_logo.py --window tk
# Other parameters ..
python examples/moderngl_logo.py --window tk --cursor no --resizable no
# more fun .. (mouse + AWSD / QE)
python examples/cube_model.py --window tk --fullscreen We'll see how that works out on linux... and possibly OS X in the future. Don't think it should be that hard to do some minor tweaks in pyopengltk to conver the missing stuff. The pyglet code base can also be a great reference for this. They do everything with ctypes. https://github.com/pyglet/pyglet I can look into darwin support some time in the near future. |
Released moderngl-window I'm not sure what the difference between these versions are, but at least it works. I assume some bug was fixed. |
Works on Ubuntu Eoan Ermine (AMD Vega) ⭐
Missing darwin support. Currently working on that. (Half way done) |
Most of this is now resolved. We are still missing OS X support in pyopengltk. More info here : jonwright/pyopengltk#4 |
Looks good to me. I managed to see some moderngl test windows. Eventually there may be enhancements needed for the context types etc, but those issues are in pyopengltk, I think. You could close this issue I guess? |
Yup. I guess we can close this. moderngl-window provides a single interface to multiple window libraries so user can just switch the window type when on OS X. (Configuration option or enviroment variable). |
@jonwright Also, thanks a lot for suggesting a window for tikinter. I think a lot of people will be happy. Adding separate widgets is the next step (existing task #42 ) so users can easily combine these with UI elements. |
I have some (rough) code at https://github.com/jonwright/pyopengltk which makes an OpenGL context for tkinter. You can summarise it as creating empty Tk.frame, and then using the window information (winfo_id/winfo_screen) for some ctypes calls.
Would you be interested to try to get a Tk backend working here?
The text was updated successfully, but these errors were encountered: