PYQT Display stops displaying changes periodically, fixes when changing element - python

I am having a small issue with PYQT that I cannot seem to find an answer for. I have made several apps using PYQT that do a multitude of functions but they all seem to have this one similar issue. When I leave my machine (windows 10) idle for a bit (not moving mouse/keyboard), the display will appear to 'freeze' but it is not actual frozen, just the display. The way to fix this is to change ANY element (increase spinbox value, minimize/maximize screen, etc).
This is particularly a problem with a video app I am working on where a camera is displaying video and suddenly it looks like the app is frozen until I 'fix' it. I am not sure if its a PYQT thing or perhaps windows itself. I will post relevant code below:
I can post more as needed but this is how I start my app:
app = QtWidgets.QApplication(sys.argv)
window = Ui()
widget = QtWidgets.QStackedWidget()
widget.addWidget(window)
widget.showMaximized()
app.exec_()
window.stop_threads()
cv2.destroyAllWindows()

Related

Kivy window size for mobile

I am coding kivy app on PC. At the end, I will convert it to .apk on my android phone (redmi note 9 pro). Which window size should I choose? It will be easier to code with this specific window size (add buttons and text on specific place).
And how to do it. Because I heard that using window.size is not good/not working.
Thanks
It's usually a better idea not to code for a specific window size, but to code the gui in such a way that regardless of the window size it tries to do something sensible. For instance, your app might have a navigation bar at the top that is always 40dp high, then the rest of the app is taken up by something else that grows to fill all the available space.
You can code the whole gui to a fixed size if you want of course, but it probably isn't the best solution.

app is showing widget at the wrong size when executed on another computer

I have a bit of mistery here regarding the rendering of a PyQt4 app on two different computers. I have check a number of internet sites and even this one Overlapping controls in Windows XP and I haven't found the solution.
The problem is as follow. The app written in python27 and pyqt4 and is run on two identical laptops running Windows 10 with additional screen connected of the same resolutions, one was used to develop the app and the second is used simply to run a copy of the app. All the necessary python packages are installed in order to run the app:
The app contains a tabwidget set in main window grid-layout and share it with a qtextedit at the bottom.
On the second laptop the first and second tab of the tabwidget are displaying wrongly the widgets it contains such as this way:
On the development laptop it is displayed this way:
Changing the window size does not solve the problem. So where could the problem be? Idea are welcome !!!!
Note 1: the 1st and 2nd tab of the tabwidget are not setup with a layout but individual object such as group box are setup with a layout.
Note 2: There is a third tab that is dynamically filled by the app with custom widgets on a vertical layout. This tab do not exhibit any shrinking/overlap/oversized issues. Could this be the solution, and why?
Regards.
finally I found out what was the problem. One of the laptop had its screen set to 150% scaling and apparently Qt4 doesn't handle it well. So to make it right the screnn scaling should be 100%.
One thing to notice though is that the scaling used by Qt4 is the one used at startup and is ignoring the session settings. In other words and in my case, my interface was wrongly displayed and changing the scaling to 100% and restarting the application didn't help. However changing the scaling to 100%, restarting Windows10 and starting the application was not causing any problem. Even changing the scaling after the restart didn't cause any problems since only the value at startup time is considered.
I guess this item can now be closed.

Tkinter GUI buttons become invisible after creating app using Py2App

I built a small GUI using Tkinter. The GUI features, among some other elements, three buttons. These buttons serve to open a dystem dialog and select certain data-files etc. One of the three buttons is a 'Go' button that runs the underlying data-processing.
When running the .py script the GUI works fine. However, after creating a developer app in alias mode using Py2App the buttons have become invisible! They're still there and usable, but invisible until interacted with.
How can I prevent this from happening?
I was stuck in your exact situation for quite some time. When I ran my tkinter script, it worked perfectly and all the buttons showed up, but once I packaged it, the buttons stopped showing up (They were still there but you couldn't see them). After a long time of trying random things, I found out how to make the buttons and their text show up again. Simply resize the window. Even a difference of 1 or 2 pixels does the trick. I have not yet found a way to PREVENT this issue, but at least this makes the app look right.
Please reply if you figure out a solution to prevent this!
Good Luck!

How to write a handler for window move event in Kivy?

I'd like to write a handler for the event after the window is moved in Windows / Linux.
I need such a function to reset the behaviour of my app because dragging of the window will stop/pause all Clock.schedules and after the window is released the animation with the schedule is not starting properly.
The wrong behaviour during window move is no problem but afterwards the app should restart correctly.
Something simillar to this code for window resize:
class DemoApp(App):
def build(self):
def win_cb(window, width, height):
print 'resizing'
Window.bind(on_resize=win_cb)
Is there something like on_move? I haven't seen anything like that in the api-documentation
No, there is no way to get the current window position in Kivy. It may be possible by directly utilizing the window backend (i.e. pygame) but this is not cross-platform compatible and is quite hacky.
However, you're definitely having some other problem here. Animations and Clock schedules both work fine for me while moving and resizing the window. You might want to post another question asking why your schedules are getting screwed up, because this is not expected behavior.

Putting Webkit onto the Nautilus desktop (on Ubuntu Maverick) with PyGTK

I can get what I think is the Nautilus desktop window by using this code:
screen = wnck.screen_get_default()
while gtk.events_pending():
gtk.main_iteration()
for window in screen.get_windows():
if window.get_name() == 'x-nautilus-desktop':
xid = window.get_xid()
wrapped_window = gtk.gdk.window_foreign_new(xid)
but when I try to do wrapped_window.add() I get the error that the Window Object does not have the add method.
I know this can be done since someone already has a youtube video demoing the effect at http://www.youtube.com/watch?v=NOlIfhXQX9g but I can't figure out how to get the background window and put a widget on it.
Anyone know how to do it?
You're mixing up gtk.Window and gtk.gdk.Window. They are not the same. The former is a toplevel desktop window and functions as a container for GTK widgets; the latter is an abstraction of an area of the screen which can be drawn on top of, and is not a container.
You can't get an application's GTK widgets using libwnck. How to achieve the effect you want I don't know, but I think you need to look more into extending the window manager, since that is what manages the desktop.

Categories

Resources