pyqt5 (x11) make window stay on bottom - python

This has been solved in the comments by ekhumero, thank you ;)
I need to have my window stay on bottom.
There is the windowOnTop flag, as dicussed here (here using pyqt4, but it's an well enough example), but is there a way to achieve the exact opposite?
I'm using Linux (Manjaro) with X11, so I'll accept X11 specific answers too, if they work with pyqt5, cross plattform compatibillity is no concern.

Related

Scroll python function help in Vim

I am learning to use vim as an IDE for Python and followed this tutorial to setup my .vimrc file. My setup is working fine.
Here, vim shows me the help for np.random.randint, but I could not figure out how to scroll through the displayed help and read about the other parameters. This feature is introduced by YouCompleMe (as far as I understand), so possible solution might be to change some configuration for it.
Since, I am new to this, I am not even sure what this feature is called (auto complete does not seem to be the right name for displaying help) and therefore was not able to find help on web-searching.
Any help will be appreciated, thanks.
YouCompleteMe uses the Jedi library for Python. If you want to install Jedi alongside YCM, this answer has some advice on how to do so.
In any case, the extra docstring information is opened in a preview window, so you should be able to switch to it in normal mode (ctrl-w w) and scroll like a regular Vim window.
If the buffer disappears when you exit insert mode, here's some sample solutions:
If you're okay with enabling mouse controls, add set mouse=a to your VIMRC, and then you can click between the buffers while typing and even scroll using your mouse wheel or trackpad.
Remove let g:ycm_autoclose_preview_window_after_completion=1 from your VIMRC, since that will remove the preview window when you enter normal mode. Then, switch to the window normally.
Change the default preview height. Just be aware that this might be annoying if you have limited screen space.

How Can i open a subwindow with pygame?

I need to make a sub window using The pygame package, I want to do two type of subwindow, the first fixed in of the window and the second type completely independent of the window.
While approaching this problem, be aware that two windows is pretty much impossible for Pygame, since it is dependent on SDL and SDL is limited to 1 screen.
Maayyybbe, you could run two different programs that have different windows and can interact with each other via some networking you set up. But at this point, you'd probably be better off coding in something else.
Making a sort of subwindow is doable by splitting up your screen, and to use parts of it for one thing, and others for something else. For example, you can blit images to this separate "window" that have totally different things going on than the stuff outside of it.
Also, please google before posting a question, a quick google search revealed Pygame with Multiple Windows, which answers half of your question.

Best Qt Widget to use for properties window... in PySide?

This question is the exact same as this one except that I'm looking for such a widget to be used in PySide. Anyone knows some code out there that provide easy-to-reuse property editor widget?
There is the proposal of using QTreeView or QTableView to build such a widget that is an option with PySide, but this is not a straight forward solution...
I don't know if you would be OK with this, but if you are happy to add the whole of pyqtgraph as a dependency, then you might want to try using pyqtgraph's ParameterTree.
There is a pretty comprehensive set of examples, just install pyqtgraph and then run:
import pyqtgraph.examples
pyqtgraph.examples.run()
Launch the ParameterTree example!

Is there a way to create transparent windows with Tkinter?

I'm trying, ultimately, to create "oddly-shaped windows" with Python using the Tkinter module. But for now I will settle for being able to make the background transparent while keeping child widgets fully-visible.
I'm aware this is done with wxPython and some other modules, but I'm inquiring as to the limits of Tkinter.
Can Tkinter create a clear Canvas or Frame? Can it pack UI elements without a canvas or frame? Can individual UI elements be transparent?
Can it pass mouse-click locations back to the system for processing any windows below it in the Z stack?
The option root.attributes('-alpha', 0.1) can be used to make a transparent window
from Tkinter import *
root = Tk()
root.attributes('-alpha', 0.3)
root.mainloop()
However in this case even the widgets on the root will inherit the transparency.
Update for Linux (Tested on Ubuntu)
The above code does not work on Linux machines. Here's an update that works on Linux.
from tkinter import Tk # or(from Tkinter import Tk) on Python 2.x
root = Tk()
root.wait_visibility(root)
root.wm_attributes('-alpha',0.3)
root.mainloop()
Not sure if this works on Windows.
Summary as of late 2019:
As of TCL/TK version 8.6, the alpha, fullscreen and topmost window attributes work on ALL platforms (Windows, Mac and Linux):
https://www.tcl.tk/man/tcl8.6/TkCmd/wm.htm#M9
Previous versions of the manual noted that there PREVIOUSLY WERE platform differences (only some platforms supported those 3 attributes). But as long as you use the latest TCL/TK, you're guaranteed that all of those attributes will work on ALL platforms!
There are still platform quirks on LINUX, since each window attribute feature relies on the operating system's underlying window manager (on Mac and Windows they're always capable, but on Linux there are tons of different window managers/compositors, and NOT all support transparent windows, etc). It says that in case transparency is not supported, the alpha property will stay at 1.0 if you try to read it again later. However the page also notes that on Linux (X11), the attributes are updated asynchronously which means that you can't trust the value you read (if you change alpha and then immediately try to read it, you'll still read the old value, so you can't use that method to check if alpha was successfully changed on Linux).
As for the other answers saying that you first need to use root.wait_visibility(root) on Linux to make sure the window is visible on screen before setting the alpha attribute... I don't know, since I don't have a Linux machine to check. But I heavily doubt that it's needed anymore, since the official manual says that alpha is supported and says nothing about that command being necessary. Either way, it doesn't hurt to add the wait_visibility trick too... It is simply a command that runs a very brief event loop that waits until the actual window has appeared on the user's screen. So it's probably still a good idea to add that command before all of your attribute-setting. Especially since it's proven to help the alpha work on Linux on old TCL/TK versions! PS: You don't need the (root) argument, and should type root.wait_visibility() instead, which means "wait for self (root in this case since we called the command on the root object)".
Update:
Daniel in the comments below has let me know that root.wait_visibility() is still necessary on Ubuntu 19.10. Although he didn't specify his Python, TCL/TK or TkInter versions so maybe they're outdated on his system. Either way, sounds like it's a safer bet to always include that command for backwards compatibility!

GUI-embeddable Python drawing widget with anti-aliasing

I am writing a small diagram drawing application (similar to Graphviz in spirit), and need a GUI library that would allow me to embed a canvas capable of drawing anti-aliased lines and text. I want to have a text editor in one half of the window to edit the diagram code and a (perhaps live) preview pane in the other.
Right now I have the text editor in a tkinter window and the rendered diagram in a separate pygame one. This technically works, but it's messy (e.g. having two event loops), and in general I would much prefer having both parts in one window. I have searched for ways of integrating the two, but haven't been able to find anything cross-platform, and pygame explicitly suggests not trying to do it.
An alternative would be to have pygame export the image into a file and load it back into tkinter, but tkinter can read only GIF/PPM without PIL (and I use Python 3, which PIL doesn't support) and pygame can't write GIF/PPM. I could backport to Python 2, since it's a tiny app, but even then, having a large extra library for a simple image conversion doesn't seem right, and the round-trip to a file will probably be too slow for live preview (not to mention ugly).
Finally, a simple tkinter canvas is almost what I want, except it can't draw anti-aliased lines, and for a program whose main purpose is to draw line figures, that is not acceptable.
I'm using Python 3 so libraries that support it are preferred, but if there's no way to do that whatsoever Python 2 libs are Ok as well. The library needs to be cross-platform, and of course, the fewer external packages are required, the better.
If you don't mind the way GTK looks, pygtk has an option for antialising in their canvas widget (see this) and is considered by many to be as powerful as Tkinter, though it is not included in standard Python installs.
Also, it's Python 3.x compatible, which can't be said of most non-standard library modules and packages.
Screwing around with Tkinter+pygame is silly. I would use wxPython. In fact, I've done a diagramming widget using wxPython, and it has anti-aliasing:
Unfortunately it was for work, so I can't distribute the code.
The wxPython classes you want to look at for anti-aliasing are wx.GCDC and/or wx.GraphicsContext.
After a thorough search I ended up using PyQt4. It does fit all my requirements (Python 3, cross-platform, anti-aliasing), and now that I've gotten through the basics, it's also quite intuitive and easy to use.
Posting this as an answer to my own question and accepting it for future reference.

Categories

Resources