Hello! Does anyone know if it's possible to keep the last frame at the end of a video when using QMediaPlayer? The current behavior is to display a black screen right after EndOfMedia has been reached, which is very unpleasant for my application purposes :/ I know some "hacks" that make use of the positionChanged signal, but I wonder if there is a clean solution to this?
19 October 2023
Ссылка
click to show
click to show
qtpip 0.1 released!
A simple command line tool to get commercial wheels for Qt License holders
https://www.qt.io/blog/qtpip-qtforpython-installer
Cristián 🥑pa: no, it's not possible.
Is it an answer to my question? I don't know what "pa" is referring to
id 1460231460Is it an answer to my question? I don't know what "pa" is referring to
I'm replying to the user 'pa' that sent a message after your question.
What is the pythonic way to create a notify signal for a Property when I use the @Property decorator?
Markus BauerWhat is the pythonic way to create a notify signal for a Property when I use the @Property decorator?
I’d say declare the signal with in the class definition with propertyNameChanged = Signal(parameter_type) and explicitly emit it in the property setter, if the new value differs from the old. That's plain and obvious when reading the code, and IDEs do find the signal usage.
Now, there's a clash between Qt's name convention for change signals (using camelCase, like valueChanged), and Python, using snake_case, for example value_changed.
PEP8 and related style guildes aren't set in stone, so I’d say, take the choice with the highest consistency
That's what I am doing now:
runFilter_changed = Signal(name="runFilterChanged")
@Property(bool, notify=runFilter_changed)
and than I have
@runFilter.setter
def runFilter(self, val):
print( val )
self._runFilter = val
self.runFilter_changed.emit()
But this doesn't feel pythonic
I tried with @Property(bool, notify=Signal(name="runFilterChanged")) but so I can't emit it anymore
Markus BauerThat's what I am doing now:
runFilter_changed = Signal(name="runFilterChanged")
@Property(bool, notify=runFilter_changed)
and than I have
@runFilter.setter
def runFilter(self, val):
print( val )
self._runFilter = val
self.runFilter_changed.emit()
But thi
Ссылка
click to show
click to show
Notify signals typically carry the new value, like https://doc.qt.io/qt-6/qlineedit.html#textChanged, so I’d include that. Otherwise the receiver has to go lengths retrieving the new value, if they want to do something with it.
Also, you probably shouldn't mix both styles and produce camelCase_snake_case. That's neither Qt's naming scheme nor Pythonic according to PEP8 style. Either have run_filter and run_filter_changed, or runFilter and runFilterChanged.
And yeah, the last doesn't assign it to a Python variable, so it gets garbage collected immediately, and may cause RuntimeErrors later.
So more like this?
runFilterChanged = Signal(bool, name="runFilterChanged")
@Property(bool, notify=runFilterChanged)
def runFilter(self):
return self._runFilter
@runFilter.setter
def runFilter(self, val):
self._runFilter = val
self.runFilterChanged.emit(val)
Markus BauerAre you sure it will be garbage collected? As you assign it to the notify, it should stick
I did not find it in the sources tbh
I'm relatively sure that doing only @Property(bool, notify=Signal(name="runFilterChanged")) will cause the Signal() instance (the PyObject wrapping the underlying C++ object) to get GC'ed, but I'm not 100% on that. If you pass something to a Qt function, it will not keep a reference to the PyObject, but only the wrapped object. If there's no reference to the wrapper in Python code, the GC will eat it.