This question already has answers here:
In PyQt, what is the best way to share data between the main window and a thread
(1 answer)
Background thread with QThread in PyQt
(7 answers)
Example of the right way to use QThread in PyQt?
(3 answers)
Closed 3 months ago.
I wat to make an small python GUI in order to monitor the status of some services, to simplify it I want to see a green circle when the service is running and a red one when it is not
I have this piece of code to load a pixmap into a QLabel
self.m2w_state = QLabel(self)
running_icon = QPixmap('green.png')
self.m2w_state.setPixmap(running_icon)
self.m2w_state.resize(running_icon.width(), running_icon.height())
self.m2w_state.move(40, 50)
But now I'm trying to change this during execution from green to red. I tried in the same thread and the GUI got stuck, so I tried using a different thread, but an error appears saying that I cannot change the property from a different thread
How is the way to do that?
Related
This question already has answers here:
Can I detect if a window is partly hidden?
(2 answers)
How to determine if any part of the window is visible to Screen?
(1 answer)
How to get only the visible part of a window (Windows, gdi32, user32, etc)
(2 answers)
Closed 8 months ago.
I want to get a window's clip box so I can detect if the whole window is displayed.
package: win32gui
I know that IsWindowVisible() from the Windows API will return true if a window is NOT minimized, but it won't detect if the window is hidden behind other windows.
I also know that in C++, I could use GetWindowDC(); GetClipBox(); ReleaseDC(); to get a RECT struct with the coordinates of the smallest bounding rectangle of the window (I got this from another post on StackOverflow, but I haven't tested it).
In Python, I can use:
# That just returns a window by the title
handle = getWindowByTitle("Skype") # "Skype" is just an example
winDC = win32gui.GetWindowDC(handle)
# this function doesn't seem to exist/be implemented in win32gui
win32gui.GetClipBox(winDC, '''This also needs a RECT struct''')
win32gui.ReleaseDC(winDC)
How can I use GetClipBox() in Python? Or, is there any other way to check it?
I would like to not use any other package, because I want my app to have as few dependencies as possible.
I have also heard of ctypes, but I have never used them. I am not sure how it works, and/or if it can help here.
This question already has answers here:
Simple button click connection to python function
(1 answer)
several questions about QML and PySide2
(1 answer)
How to connect Python and QML with PySide2?
(1 answer)
Closed 2 years ago.
I am completely new to QML and PySide2. I am working on a desktop application where I want to make the UI using QML and connect it with PySide2. I saw some onlne documentation but was not able to find much about it. For an example, if I am creating a simple button using QML how can I access the button in PySide2.
This question already has answers here:
Load whole *ui file in an frame/widget of another *.ui file
(1 answer)
PyQt: How to switch widgets in QStackedWidget
(5 answers)
Creating a custom widget in PyQT5
(2 answers)
Closed 3 years ago.
I am making a simple app and was wondering what the standard is for multiple windows when using Qt Designer and python.
I need to be able to have functional back and next buttons which will take me to the previous screen like in simple .exe installers.
I do not want to use the tab widget.
I have tried using the stacked widget but when using layouts on my first screen it gets inserted into the grid layout.
This question already has an answer here:
PyQt : Linking buttons to functions in my program
(1 answer)
Closed 6 years ago.
So I have this GUI that has 2 empty text spots to fill and a "Run" button
I want to make it that the 2 empty text spots go to values in the program and the run button will run the python "Main" program ..
How can i do that ?
You need to have a look at the documentation for PyQt signals and slots. Normally, when you install PyQt you also install some great examples. Walk through the code and it will teach you a lot (search your filesystem for "qtdemo" or standarddialogs.py).
New-style signals and slots
Old-style signals and slots
Here's a snippet from standarddialogs.py:
self.saveFileNameButton = QPushButton("QFileDialog.get&SaveFileName()")
...
self.saveFileNameButton.clicked.connect(self.setSaveFileName)
...
def setSaveFileName(self):
This question already has an answer here:
PyGObject and glade send window to the front
(1 answer)
Closed 8 years ago.
I am currently building an application with python 2.7 with Gtk3+.
I want to open a window on top of another window. If the second window is visible, the parent one should not be clickable.
So the behaviour should be the same like opening a dialog window.
What is the best way to achieve this?
You need to use the property window.set_transient_for(parent_window)
This post may help you if you are using glade.