disable user selection in qlistwidget - pyqt4

I have an ordinary qlistwidget in pyqt4. I sometimes want to prevent the user from making a selection, but still want to set the selection programmatically. So setting the selection mode to noselection won't work. Is there a way in which I can prevent the user from making a selection?
Thanks for your help!

I would install an event filter on the widget to catch and discard mouse events.

Related

Hide window (pywinauto)

import pywinauto
from pywinauto.application import Application
PATH = 'c:/Users/User/PycharmProjects/InviterChannel/Telegram/Telegram.exe'
app = Application().start(PATH)
app.Telegram.ClickInput(coords=(330, 530)) # This is what the user should not see
Is it possible to hide the window while continuing to click in it?
How to do it?
The task is to hide from the user what the algorithm does (keyboard input, mouse clicks, etc.)
Both .click_input() and .type_keys() methods require active window.
There is only workaround for keyboard input that is sometimes possible for minimized window (after app.Telegram.minimize()):
.send_keys() and .send_keystrokes() (the difference may appear for some special keys that may work or may not).
I haven't heard about similar possibilities for mouse actions. Maybe app.Telegram.move_window(x=-1000, y=-1000) would help. The window will have negative coordinates. It will be in focus, but invisible to user. So usual .click_input() and .type_keys() should work, but these actions may bother a user. So you'll have to remember mouse cursor (by win32api.GetCursorPos()) and get it back by win32api.SetCursorPos(...) quickly. Also need to switch focus back to previous active window.
P.S. I'm in doubt moving Telegram window would work, because it's not movable by hands as far as I remember. They made some defense against this probably. :)

PyQt: How do you clear focus on startup?

When I start up my PyQt GUI, the focus immediately goes to the text box.
I want there to be no focus on any of the buttons at the start of the program, especially not the text box.
Is there a way to remove the focus entirely or at least move the focus to a button or something?
Thanks
clearFocus() seems to work after a certain amount of delay after the window is visible. I also used setFocus() on the QMainWindow and then the textedit field lost focus.
Create a button with dimensions 0 wide by 0 high.
Set it as the default button and also early in the tab order before the other controlls that except focus; but note that it will be triggered if the user presses ENTER in some edit controls.
Call self.ui.yourbutton.setFocus() if desired for example after restore from minimized

QWidget / X11: Prevent window from beeing activated/focussed by mouse clicks

I would like to develop a system-wide onscreen keyboard in Qt/QML. Injecting key-events via xlib works fine.
My problem now: If a keyboard-button is clicked, the window with the selected input field will lose the focus. In consequence, the key event will not be delivered to the previously selected input field.
So does anybody know how to prevent a QWidget from beeing activated/focussed by mouse-clicks? Every hint is welcome and a code examples would be great!
Thank you very much in advance,
Frime

WinRT XAML - how to fix higlight issues?

When I'm testing my app on a mouse-driven device, I'm seeing a couple of odd highlight issues that I would like to try and resolve.
The first occurs when I call up the app bar, hover the mouse over a button (at which point the button goes grey) and then press Escape to dismiss the app bar. If I then call up the app bar again, the button has stayed grey, even if the mouse isn't over it, and remains in that state until I move the mouse over it and then away again.
I can't immediately see a property of the button that I can reset to clear that state when the app bar gets dismissed.
The other oddity I'm seeing is that sometimes the first item in the list on the page will get a box drawn around it:
This seems to happen when the app bar is being dismissed. I'm guessing that this is because the item is in a particular state that causes the box to appear but I'm not sure what state or how to clear it. The box does not appear during normal use of my app.
Thanks for any clarification or solutions you can provide.
I found a simple way to workaround this issue. In the code for Clicked/Tapped set Visibility of the button:
CreateNewDatabase.Visibility = Visibility.Collapsed;
CreateNewDatabase.Visibility = Visibility.Visible;
It will reset button state to Normal.
Hope this helps!
So, the issue is that the VisualState for the Button is being set to PointedOver, and then not being unset (because your mouse isn't leaving the bounds of the control and therefore triggering a PointerExited event). What this means is that you'll have to manually set the VisualState of the Button if you want it to change in this manner. You could do it on AppBar's Closed event. Basically, do a recursive check of all Children of the Content property of the AppBar using the VisualTreeHelper. Check to see if the Child is a Button. If it is, set its VisualState using VisualStateManager.GoToState().
I've also figured out what was causing the black box around the button - it is to indicate that the button has Focus.
The rather strange thing is that I'm not really sure why that specific button is getting focus or how a user is supposed to give focus to a button without it just randomly happening so, until I figure that out, I've decided to comment out the Focus state support from the Visual Manager XAML used in the default GridView item style.

Dismiss spinner control popup if you don't want an item in android

I have an android spinner which I call via the performClick method to show a list of items (the actual control is hidden from the user and is called from a checkbox, too complex to explain why I have done it this way).
If I do not want an item in the list, how can I dismiss the popup by clicking on the black area?
Does this make sense? :/
Edit: Sorry, forgot to mention that the users will not be able to operate the bottom buttons (device is going to be galaxy tab) as they will be covered up with protective layer due as they will be outdoors.
usually such a control is dismissed using the back key in the android applications. So I would suggest that you find a way to do it the same way on your control.
'Esc' button should do the same job..

Resources