I'm trying to embed multitouch events into my wxPython GUI, however i'm a bit lost as to the best approach.
Currently, I have a TUIO server which transmits the multitouch events to be captured. I then use the pytuio library to receive the multitouch events in a separate thread for my GUI. My GUI is composed of a wxFrame with multiple matplotlib panels and a single OpenGL panel.
The problem is that I have had to manually write code to determine how many fingers are being used, the locations and the touch type. I then send a custom event which can be received by my GUI.
This works fine for the matplotlib panels (albeit I have to provide a very small constant offset to the reported location of the fingers), but for the OpenGL panel the finger locations seem to be incorrect. This is a problem as the offset of the touch locations in the OpenGL panel is not even a constant, it seems to vary depending where on the panel the touch event occurs. So I cannot compensate for it.
I feel like there must be a more comprehensive multitouch library, which does all the hard work determining the number of fingers and touch type (tap, double tap, drag, release etc). And possibly would overcome my issue with the OpenGL panel. I have looked but I've not seen a library which can distinguish the touch type etc., they just seem to provide a list of the number of fingers and the locations.
The only comprehensive GUI library supporting:
Python
More than one OS
Multitouch
is Kivy. I was able to cobble together something which works for Windows 7 and higher and wxPython (by extracting the relevant part from Kivy for processing WM_TOUCH events), so in principle it could be done. But none of this would solve your specific problem.
Related
I want to visualize one or more STL file(s) using a vtk render viewport inside my application. I was able to get it all running with this example here: https://kitware.github.io/vtk-examples/site/Python/IO/ReadSTL/
My question is as follows: I have a mouse to control it and it is just unbelievable how bad default the controls of the camera are. It is almost impossible to get the model rotated intentionally or focus on a certain part. I am confused as I could not find any topic here or elsewhere discussing this. Normally I would read through other threads to find an answer, but there doesn't seem to be any. So, maybe you can point me to an approach or even certain functions of how I can change these settings, that would be really great! Basically I want to mimic the camera behavior of say, Paraview or a common CAD tool. Like zooming with mouse wheel, rotating with RMB and holding down the wheel to pan.
Some background on my project: I have written a python program and created a quite ok UI using tkinter. However, recently I was thinking of rewriting some basic parts of it and also upgrading everything visually and in terms of handling. So, I want to move to Qt widgets and, there shall be a VTK rendering viewport inside my application to show some of the stuff that can be interacted with.
I was able to find a solution in the tutorials. By explicitly defining the vtkInteractorStyle with
style = vtk.vtkInteractorStyleTrackballCamera()
The handling is just as I wanted it to be.
I've created a gameboy color emulator using C++ and am ready to start developing the frontend that will display the emulator's viewport, emit audio, and also display some debug information.
I'm looking into using Kivy to create the UI frontend and boost.python (which looks pretty promising) to interop between the C++ core and the python UI.
What I would like to have in my front end are:
A window to show the emulator graphics. More specifically something that let's me update a raw bitmap (i.e. raw pixel data) on each frame.
A window to display some debug information. More specifically I want a large scrollable text box to show the disassembled code and another one to show the memory.
A way to emit audio that's generated by the emulator. The core doesn't support audio yet so I'm not sure what it'll look like on the C++ side.
Accept keyboard input to control the game.
Will Kivy allow me to do all of this? I see that it has dependencies on glew and sdl2 which should take care of the graphics and audio requirements, right? Are there widgets that will let me create the disassembly and memory viewer?
A window to show the emulator graphics, update a raw bitmap on each frame
Not sure how exactly, but you have access to textures and to a huge part of OpenGL through Kivy and Python, so this could be doable.
A window to display some debug information, large scrollable text box
Use RecycleView and Label's core. There's an example for ListView, but since the new changes it's kind of broken. However, in a similar way it could be done for RecycleView
A way to emit audio that's generated by the emulator
Should work without problems if you can pass it to the provider. The only issue I see with built-in audio support in Kivy is pause and seek, because those afaik either aren't implemented (most probably) or are broken. However with Gstreamer it should work.
Accept keyboard input to control the game.
Keyboard and multitouch work out of the box with Kivy, you only need to (for keyboard) extend one method and (for touch) check for collisions with Widgets
Are there widgets that will let me create the disassembly and memory viewer?
No. At least none that I know will do that out of the box. If by disassembly you mean text, dump it into a widget that can handle text. Memory viewer however isn't there and you'll need to create your own widget. That's not hard if you work with Kivy at least for a while.
Kivy by default doesn't do 3D. There are "plugins" that can allow you such thing, but I don't see any that's still maintained so there's this thing. Also I see the code isn't C, but C++ so I'm not sure how to bind those together. Cython should be the rescue here ^^
Hi I am new to this whole coding thing I was suggested to use Python. The version I have now is 2.7. I need help with making a transparent window to the copacity of 100 so that you can actually see through it and I also want to know how to make a fairy thick, out line of a rectangle in the colour red.
Help me please :S Thanks!
Unfortunatelly, there is not such an easy thing as sa "trasnparent window" - althougmodern widnow managaers do have various opacity controls for the windows, those just affect the windows as a whole - and do not integrate at all with the program running "inside" the windows. There may even be, for some of them, a way to call functions to explicitly set up the opacity level of a given window, but I don't think it willbe possible for all of them.
That said, it is possible to get grab of the "root" window and draw directly on the screen - -bypassing the window manager. There are APIs for that at least on Windows and Linux (you have to mention in what operating system you need that working) - but it will amount to not a trivial research work, since this is not what is expected of a "well behaved app" - for which the GUI toolkits are written and documented. You will need to write xlib code in Linux, and directly call win32 api's on windows - both are possible from Python - as possible as under-documented.
And once you get to draw the rectangle, since you are bypassing the window manager, you willhave to care about every low-level detail of your app: mouse event handling, screen-redrawing (and notifying the system of drawing taking effect over other windows), and so on.
I'd like to hear the best means for displaying graphics that move on-screen as an overlay with Python. The intended initial platform is Linux. I've worked up some small demos using PyQt using frameless windows and looping and updating their location on screen. This works, but I have a feeling it is not the ideal solution.
The end result is an activity indicator that would show more objects swarming in an upward direction as activity increased. That would result in spawning perhaps a hundred windows in a go and that is why I think my PyQt demo is not optimal.
I'm open to any suggestions since this will be an open project and installing obscure modules is a non-issue.
There are examples for making transparent / unclickable windows in java and in javascript. Here are a couple of transparency related posts for QT.
I am working on embedded linux platform with limited system resources.
I want to do fullscreen slideshow with simple transistions (like slide in-out, fade in-out ).
I tried PyGtk+GTK+Cairo but its very slow, when I animate GTK image controls I get just two or three frames per second. But smplayer is playing video at good speed!
I did some little research and came to know about directfb, libggi, svgalib etc. and I don't know what library should be used.
Which library is the best for this kind of application? I would prefer to do this without stopping X.
I would try this first using just PyCairo, not using GTK controls at all.
However, if that does not give you the speed that you need, then you might want to try PyGame which gives you access to SDL including OpenGL backends. PyGame is very actively developed and used in building applications that include full screen animation so even if you are not writing a game, you will still likely find the best support by using PyGame.