# Path: janus_event_PushButton.py
# class event_PushButton( QPushButton ) :
# 
# 
# 	#-----------------------------------------------------------------------
# 	# DEFINE THE INITIALIZATION FUNCTION.
# 	#-----------------------------------------------------------------------
# 
# 	def __init__( self, owner, fnc, lab='' ) :
# 
# 
# 		# Inherit all attributes of an instance of "QPushButton".
# 
# 		super( event_PushButton, self ).__init__( lab )
# 
# 
# 		# Store the user-provided instance of the initializing object.
# 
# 		self.owner = owner
# 
# 
# 		# Store the string indicating the function of this button.
# 
# 		self.fnc = fnc
# 
# 
# 	#-----------------------------------------------------------------------
# 	# (RE)DEFINE THE FUNCTION FOR RESPONDING TO MOUSE CLICKS.
# 	#-----------------------------------------------------------------------
# 
# 	def mousePressEvent( self, event ) :
# 
# 
# 		# Deligate the handling of the mouse-click event to
# 		# "self.owner", providing it with the details of the event and
# 		# also the string identifying the function of this button.
# 
# 		self.owner.user_event( event, self.fnc )
# 
# 
# 	#-----------------------------------------------------------------------
# 	# (RE)DEFINE THE FUNCTION FOR RESPONDING TO KEY PRESSES.
# 	#-----------------------------------------------------------------------
# 
# 	def keyPressEvent( self, event ) :
# 
# 
# 		# If the "Enter" or "Return" key was pressed, interpret this as
# 		# an event and deligate handling thereof to "self.owner".
# 
# 		if ( ( event.key( ) == Qt.Key_Enter  ) or
# 		     ( event.key( ) == Qt.Key_Return )    ) :
# 
# 			self.owner.user_event( event, self.fnc )
# 
# Path: janus_time.py
# def calc_time_val( time ) :
# 
# 	# If this function has been called on "None" or an empty string, simply
# 	# return "None".
# 
# 	if ( ( time is None ) or ( time == '' ) ) :
# 		return None
# 
# 	# If "time" is a "datetime" epoch or a string, compute the elapsed time
# 	# of "time" since "1970-01-01/00:00:00.000".  Otherwise, assume that
# 	# "time" is a numerical quantity, and return "time" recast as a "float"
# 	# rounded to three decimal places (to "standardize" it).
# 
# 	if ( ( type( time ) == datetime ) or 
# 	     ( type( time ) == str      )    ) :
# 
# 		# Attempt to standardize the "datetime" epoch "time".  If this
# 		# fails, abort (returning "None").
# 
# 		time_epc = calc_time_epc( time )
# 
# 		if ( time_epc is None ) :
# 			return None
# 
# 		# Create a "datetime" object for "1970-01-01/00:00:00.000".
# 
# 		unix_epc = datetime( 1970, 1, 1, 0, 0, 0, 0 )
# 
# 		# Return the number of seconds elased from "unix_epc" to
# 		# "time_epc" rounded to the thrid decimal place.
# 
# 		return round( float( 
# 		                 ( time_epc - unix_epc ).total_seconds( ) ), 3 )
# 
# 	else :
# 
# 		# Assume that "time" is a numerical quantity, and attempt to
# 		# return it recast as a "float" rounded to three decimal places.
# 		# If this fails, return "None" instead.
# 
# 		try :
# 			return round( float( time ), 3 )
# 		except :
# 			return None


from PyQt4.QtGui import QDialog, QGridLayout, QLabel, QProgressBar
from janus_event_PushButton import event_PushButton
from janus_time import calc_time_val

		# Make this a non-modal dialog (i.e., allow the user to still
		# interact with the main application window).

		self.setModal( False )

		# Set the title of this dialog window.

		self.setWindowTitle( 'Progress' )

		# Give this widget a grid layout, "self.grd".

		self.grd = QGridLayout( )

		self.grd.setContentsMargins( 6, 6, 6, 6 )

		self.setLayout( self.grd )

		# Initialize the progress bar and set its minimum, maximum, and
		# initial values.

		self.bar = QProgressBar( )

		self.bar.setMinimum( calc_time_val( time_strt ) )
		self.bar.setMaximum( calc_time_val( time_stop ) )

		self.bar.setValue( self.bar.minimum( ) )

		# Initialize the event button.


# Path: janus_event_PushButton.py
# class event_PushButton( QPushButton ) :
# 
# 
# 	#-----------------------------------------------------------------------
# 	# DEFINE THE INITIALIZATION FUNCTION.
# 	#-----------------------------------------------------------------------
# 
# 	def __init__( self, owner, fnc, lab='' ) :
# 
# 
# 		# Inherit all attributes of an instance of "QPushButton".
# 
# 		super( event_PushButton, self ).__init__( lab )
# 
# 
# 		# Store the user-provided instance of the initializing object.
# 
# 		self.owner = owner
# 
# 
# 		# Store the string indicating the function of this button.
# 
# 		self.fnc = fnc
# 
# 
# 	#-----------------------------------------------------------------------
# 	# (RE)DEFINE THE FUNCTION FOR RESPONDING TO MOUSE CLICKS.
# 	#-----------------------------------------------------------------------
# 
# 	def mousePressEvent( self, event ) :
# 
# 
# 		# Deligate the handling of the mouse-click event to
# 		# "self.owner", providing it with the details of the event and
# 		# also the string identifying the function of this button.
# 
# 		self.owner.user_event( event, self.fnc )
# 
# 
# 	#-----------------------------------------------------------------------
# 	# (RE)DEFINE THE FUNCTION FOR RESPONDING TO KEY PRESSES.
# 	#-----------------------------------------------------------------------
# 
# 	def keyPressEvent( self, event ) :
# 
# 
# 		# If the "Enter" or "Return" key was pressed, interpret this as
# 		# an event and deligate handling thereof to "self.owner".
# 
# 		if ( ( event.key( ) == Qt.Key_Enter  ) or
# 		     ( event.key( ) == Qt.Key_Return )    ) :
# 
# 			self.owner.user_event( event, self.fnc )
# 
# Path: janus_time.py
# def calc_time_val( time ) :
# 
# 	# If this function has been called on "None" or an empty string, simply
# 	# return "None".
# 
# 	if ( ( time is None ) or ( time == '' ) ) :
# 		return None
# 
# 	# If "time" is a "datetime" epoch or a string, compute the elapsed time
# 	# of "time" since "1970-01-01/00:00:00.000".  Otherwise, assume that
# 	# "time" is a numerical quantity, and return "time" recast as a "float"
# 	# rounded to three decimal places (to "standardize" it).
# 
# 	if ( ( type( time ) == datetime ) or 
# 	     ( type( time ) == str      )    ) :
# 
# 		# Attempt to standardize the "datetime" epoch "time".  If this
# 		# fails, abort (returning "None").
# 
# 		time_epc = calc_time_epc( time )
# 
# 		if ( time_epc is None ) :
# 			return None
# 
# 		# Create a "datetime" object for "1970-01-01/00:00:00.000".
# 
# 		unix_epc = datetime( 1970, 1, 1, 0, 0, 0, 0 )
# 
# 		# Return the number of seconds elased from "unix_epc" to
# 		# "time_epc" rounded to the thrid decimal place.
# 
# 		return round( float( 
# 		                 ( time_epc - unix_epc ).total_seconds( ) ), 3 )
# 
# 	else :
# 
# 		# Assume that "time" is a numerical quantity, and attempt to
# 		# return it recast as a "float" rounded to three decimal places.
# 		# If this fails, return "None" instead.
# 
# 		try :
# 			return round( float( time ), 3 )
# 		except :
# 			return None


# Path: janus_dialog_auto_prog.py
from PyQt4.QtGui import QDialog, QGridLayout, QLabel, QProgressBar
from janus_event_PushButton import event_PushButton
from janus_time import calc_time_val


		# Make this a non-modal dialog (i.e., allow the user to still
		# interact with the main application window).

		self.setModal( False )

		# Set the title of this dialog window.

		self.setWindowTitle( 'Progress' )

		# Give this widget a grid layout, "self.grd".

		self.grd = QGridLayout( )

		self.grd.setContentsMargins( 6, 6, 6, 6 )

		self.setLayout( self.grd )

		# Initialize the progress bar and set its minimum, maximum, and
		# initial values.

		self.bar = QProgressBar( )

		self.bar.setMinimum( calc_time_val( time_strt ) )
		self.bar.setMaximum( calc_time_val( time_stop ) )

		self.bar.setValue( self.bar.minimum( ) )

		# Initialize the event button.


		self.btn_exit = event_PushButton( self, 'exit', 'Close' )