wxPython on KDE 4.2: popping window on top of the screen and hiding back - linux

I want my window to be invisible most of the time, but get to top of
the screen on hotkey and hide again if the user switches to another
application.
In my hotkey handler I use
self.Show()
self.Raise()
self.Iconize(False)
and in my activate message handler
self.Hide()
self.Iconize(True)
but the window pops up on top of the screen, but remains deactivated:
it's title bar colour is a inactive one, and it flashes in the taskbar
as a window requiring my attention and it doesn't get EVT_ACTIVATE. I
tried to add self.SetFocus, but no effect.
And if I use
self.Show()
self.SetFocus()
in hotkey handler and in my activate message handler
self.Hide()
and it works okay if I deactivate my window by clicking to another
window, but if I press Alt-Tab and then invoke my window with a hotkey
it doesn't appear on top of the screen but just flashes in the
taskbar. Also I made an ability to hide it by pressing a button on it,
and if I hide it this way, it also doesn't show correctly afterwards
as in the case with Alt-Tab

you have to use a window manager to activate windows. I'm using wmctrl for that purpose (cannot find the same func. through kwin's dbus for kde).

Related

How to propagate the parent's click event in Pyside2 as if I have clicked the button directly while hovering over it?

How to propagate the parent's click event in Pyside2 as if I have clicked the button directly while hovering over it?
This is a very peculiar problem, and I haven't been able to find even a question like this.
A button is positioned on the main UI window. When clicked, it hides the parent window, and spawns another window at that position. I need it to work with a single click, for example, I want to press the button, and not release the mouse immediately, but hover over a certain part of the newly spawned window and then release it.
This works perfectly fine if I click the button directly , but the problem is I need to click the button from the main UI window.
I am doing it by sending "mousePressEvent" from the main UI window to the child widget's "mousePressEvent", like this:
def mousePressEvent(self, event): #parent mouse press event
#----
#----
self.FocusedButton.mousePressEvent(event) # child widget
When I activate the button from the mainUI window, the window is immediately hidden and the new window is spawned. However, since I haven't performed mouse release yet, I am stuck into the parent's mouse press event loop. The mouse doesn't invoke paint event and doesn't register mouseMoveEvent until I release the click because the mainUI window is hidden and mouse tracking doesn't work any more.
I have tried setting the flags of the window in every way, (QtCore.Qt.WA_TransparentForMouseEvents,True ) for example, but none of it worked.
The main UI window inherits from "QtWidgets.QWidget" and does not have the clicked method.

how to disappear a button after clicking on it in tkinter?

consider the following code:
from tkinter import *
root=Tk()
root.geometry('700x700')
frame=Frame(root)
frame.pack(fill=BOTH,expand=True)
def opencanvas():
canvas=Canvas(frame,bg='red')
canvas.place(x=50,y=50,height=300,width=300)
button2=Button(frame,text='exit',command=canvas.place_forget)
button2.place(x=5,y=10)
button1=Button(frame,text='open',command=opencanvas)
button1.place(x=5,y=10)
mainloop()
this program opens a frame in a tkinter window and a 'open' button in the frame.when pressing 'open',a canvas opens and a button named 'exit' appears in frame at the same place of the open button.exit button hides canvas.
when clicking the 'exit' button,i want to disappear the 'exit' button automatically after performing its operation(ie,hiding canvas). what should i do to work this?
I want to insert some commands inside opencanvas() which disappears the button2 right after it pressed.
nb: the two buttons should place at same place and have same dimensions.
Use button1.place_forget() or .grid_forget() or .pack_forget() depending on which geometry manager you use. If you use these, then the button is hidden. To get the button back use .place() etc...
If you want to, you could use button1.destroy() but this deletes the button permanently, and if you have to make that button again, you have to initialise from start.
Use button.place_forget() for your code to hide the button and then, button1.place(x=5,y=10) to show your button
I found the answer for my question.It can be done by using lambda inside button command as follows.
button2=Button(frame,text='exit',command=lambda:[canvas.place_forget(),button2.place_forget()])
lambda function executes the commands one by one.

Finding what window the user is focused on in Xfce

when I play osu! on Linux the option to "confine mouse cursor to osu! window" does not work. This means that my mouse cursor will move to my other monitor when I am playing. This is an issue because if I accidentaly click one of my mouse buttons it will tab me out of osu! and I will fail the map.
I wanted to make a python script to check if the user is focused on the osu! window, and if they are, it would confine the cursor to that window, but I have no idea how I would check what window the user is focused on.

Coded UI Test Builder not recognizing buttons on the pop-up window

When I click the crosshairs icon on the Coded UI Test Builder and drag it over to the pop-up window buttons (Run and Cancel), it is unable to locate and find the Properties of them on the pop-up window.
Does any one know how I can know the properties of the Run button on the pop-up window?
That window appears to be a Java window, which is not supported by Coded UI.
You may be able to extend your tests to interact with the Window:
https://blogs.msdn.microsoft.com/gautamg/2010/01/05/1-introduction-to-coded-ui-test-extensibility/
Alternatively, if you can detect if the window is present, you may be able to emulate the keypresses required to dismiss/approve the window (e.g Enter, or Tab + Enter). Or, if the window's location is predictable, emulate a click at the desired location.

Hide mainform only and keep it in taskbar

I have a main form being the parent of x number of ToolWindows. I would like to hide the main form but keep it in the taskbar.
When I set the main form's Visible = false, it hides and keeps the ToolWindows visible, so far all good. But the icon in the taskbar disappears too.
I want to hide the main form, keep the ToolWindows visible AND keep the Taskbar icon so I can bring the main form back again.
By default, Application.MainFormOnTaskbr is set to true, which means the MainForm owns the Taskbar button. When a window is on the Taskbar, it is not possible to show/hide the window without affecting its Taskbar button accordingly. You have three choices:
Set Application.MainFormOnTaskbar to false, so the Application window owns the Taskbar button instead of the MainForm. Not advisible on Vista+, as ShowMainFormOnTaskbar was introduced to address UI issues in Vista onwards.
Create another window that has its own Taskbar button. You can use a similar technique that TApplication uses for its window.
Don't hide the MainForm, thus its Taskbar button will not hide. Move the MainForm offscreen, or resize it, so the user cannot see it but Windows still can.

Resources