Uranium
Application Framework
Loading...
Searching...
No Matches
UM.Qt.Duration.Duration Class Reference

Public Member Functions

None __init__ (self, Optional[int] duration=None, parent=None)
 days (self)
 hours (self)
 minutes (self)
 seconds (self)
 valid (self)
 isTotalDurationZero (self)
None setDuration (self, int duration)
 getDisplayString (self, display_format=DurationFormat.Format.Short)
 __int__ (self)

Static Public Attributes

 durationChanged = pyqtSignal()

Protected Attributes

int _days = -1
int _hours = -1
int _minutes = -1
int _seconds = -1

Detailed Description

A class representing a time duration.

This is primarily used as a value type to QML so we can report things
like "How long will this print take" without needing a bunch of logic
in the QML.

Constructor & Destructor Documentation

◆ __init__()

None UM.Qt.Duration.Duration.__init__ ( self,
Optional[int] duration = None,
parent = None )
Create a duration object.

:param duration: The duration in seconds. If this is None (the default), an invalid Duration object will be created.
:param parent: The QObject parent.

Member Function Documentation

◆ __int__()

UM.Qt.Duration.Duration.__int__ ( self)
Get an integer representation of this duration.

The integer contains the number of seconds in the duration. Convert it
back to a Duration instance by providing the number of seconds to the
constructor.

◆ getDisplayString()

UM.Qt.Duration.Duration.getDisplayString ( self,
display_format = DurationFormat.Format.Short )
Get a string representation of this object that can be used to display
in interfaces.

This is not called toString() primarily because that conflicts with
JavaScript's toString().
:return: A human-readable string representation of this duration.

◆ setDuration()

None UM.Qt.Duration.Duration.setDuration ( self,
int duration )
Set the duration in seconds.

This will convert the given amount of seconds into an amount of days, hours, minutes and seconds.
Note that this is mostly a workaround for issues with PyQt, as a value type this class should not
really have a setter.

The documentation for this class was generated from the following file:
  • UM/Qt/Duration.py