Display program time / cyclus time in custom gui, how to example

More
02 Jan 2019 21:23 - 02 Jan 2019 21:24 #123356 by Grotius
Hi,

This tiny doc is for the python coded gui's / user interfaces :

dependencies : import time

in init section :
self.start = False
self.start_time = 0
self.end_time = 0

behind start button :
self.start = True
self.start_time = time.time()

behind stop button :
self.start = False
self.end_time = time.time()

in periodic section :
if self.start == True:
self.widgets.program_time.set_text('%.2f' %(float(time.time() - self.start_time)/60) )
if not self.start == True:
self.widgets.program_time.set_text('%.2f' %(float(self.end_time - self.start_time)/60) )

The result is a output text of 2 decimal's, this is fabricated with '%.2f' %
3f will output 3 decimal's and so on.



Displaying current loaded file :

Add a label, for example label "program_name"
In python add a line, i did this in periodic section :

self.widgets.program_name.set_text("program :" + self.s.file)

And it will display your current loaded program, this is very handy.
Attachments:
Last edit: 02 Jan 2019 21:24 by Grotius.

Please Log in or Create an account to join the conversation.

More
03 Jan 2019 00:38 - 03 Jan 2019 00:39 #123379 by BigJohnT
There is a time component that does this for any GUI.

JT
Last edit: 03 Jan 2019 00:39 by BigJohnT.

Please Log in or Create an account to join the conversation.

Moderators: HansU
Time to create page: 0.106 seconds
Powered by Kunena Forum