Skip to content

Commit

Permalink
Merge branch 'category-tallies'
Browse files Browse the repository at this point in the history
  • Loading branch information
paulheider committed Dec 6, 2017
2 parents dee3bd3 + 6790347 commit 721ff1e
Show file tree
Hide file tree
Showing 2 changed files with 173 additions and 33 deletions.
111 changes: 109 additions & 2 deletions main.kv
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,44 @@ ScreenManagement:
root.manager.current = 'Four-Way Tracker'

<RootWidget>:
size_hint: 1,1

canvas.before:
Color:
## rgb(236,240,241)
rgba: [ .92549019607843137254 , .94117647058823529411 , .94509803921568627450 , 1 ]
Rectangle:
pos: self.pos
size: self.size

Button:
id: fac_bro_btn
text: 'a bro'
size_hint: 0.45,0.3
pos_hint: {'center_x': 0.25 , 'top': 0.95 }
on_press: self.parent.tap( 'fac_bro' )
font_size: min( ( self.height - 5 ) / 3 , ( self.width - 10 ) / 5 )
background_normal: ''
## rgb(46,204,113)
background_color: [ .18039215686274509803 , 0.8 , .44313725490196078431 , 1 ]
Button:
id: dec_fac_bro_btn
text: '-'
size_hint: 0.225,0.05
pos_hint: {'center_x': 0.125 , 'top': 0.95 }
on_press: self.parent.tap( 'dec_fac_bro' )
background_normal: ''
color: [ 0 , 0 , 0 , 1 ]
## rgb(241,196,15)
background_color: [ 0.94 , 0.77 , 0.06 , 1 ]
Button:
id: inc_fac_bro_btn
text: '+'
size_hint: 0.225,0.05
pos_hint: {'center_x': 0.375 , 'top': 0.95 }
on_press: self.parent.tap( 'inc_fac_bro' )
background_normal: ''
color: [ 0 , 0 , 0 , 1 ]
## rgb(155,89,182)
background_color: [ 0.61 , 0.35 , 0.71 , 1 ]
Label:
id: fac_bro_lbl
text: '(facilitator)'
Expand All @@ -84,6 +113,29 @@ ScreenManagement:
pos_hint: {'center_x': 0.75 , 'top': 0.95 }
on_press: self.parent.tap( 'fac_nd' )
font_size: min( ( self.height - 5 ) / 3 , ( self.width - 10 ) / 5 )
background_normal: ''
## rgb(46,204,113)
background_color: [ .18039215686274509803 , 0.8 , .44313725490196078431 , 1 ]
Button:
id: dec_fac_nd_btn
text: '-'
size_hint: 0.225,0.05
pos_hint: {'center_x': 0.625 , 'top': 0.95 }
on_press: self.parent.tap( 'dec_fac_nd' )
background_normal: ''
color: [ 0 , 0 , 0 , 1 ]
## rgb(241,196,15)
background_color: [ 0.94 , 0.77 , 0.06 , 1 ]
Button:
id: inc_fac_nd_btn
text: '+'
size_hint: 0.225,0.05
pos_hint: {'center_x': 0.875 , 'top': 0.95 }
on_press: self.parent.tap( 'inc_fac_nd' )
background_normal: ''
color: [ 0 , 0 , 0 , 1 ]
## rgb(155,89,182)
background_color: [ 0.61 , 0.35 , 0.71 , 1 ]
Label:
id: fac_nd_lbl
text: '(facilitator)'
Expand All @@ -107,19 +159,28 @@ ScreenManagement:
on_press: self.parent.press( self.text )
on_release: self.parent.release( self.text )
font_size: min( ( self.height - 10 ) / 2 , ( self.width - 10 ) / 3 )
background_normal: ''
## rgb(149,165,166)
background_color: [ .58431372549019607843 , .64705882352941176470 , .65098039215686274509 , 1 ]
Button:
text: 'pause'
size_hint: 0.45,0.2
pos_hint: {'center_x': 0.5 , 'center_y' : 0.5 }
on_press: self.parent.tap( 'pause' )
font_size: min( ( self.height - 10 ) / 2 , ( self.width - 10 ) / 3 )
background_normal: ''
## rgb(149,165,166)
background_color: [ .58431372549019607843 , .64705882352941176470 , .65098039215686274509 , 1 ]
Button:
text: 'clear'
size_hint: 0.1,0.1
pos_hint: {'center_x': 0.9 , 'center_y' : 0.5 }
on_press: self.parent.press( 'clear' )
on_release: self.parent.release( 'clear' )
font_size: min( ( self.height - 10 ) / 2 , ( self.width - 10 ) / 3 )
background_normal: ''
## rgb(149,165,166)
background_color: [ .58431372549019607843 , .64705882352941176470 , .65098039215686274509 , 1 ]

Button:
id: nf_bro_btn
Expand All @@ -128,6 +189,29 @@ ScreenManagement:
pos_hint: {'center_x': 0.25 , 'top': 0.35 }
on_press: self.parent.tap( 'nf_bro' )
font_size: min( ( self.height - 5 ) / 3 , ( self.width - 10 ) / 5 )
background_normal: ''
## rgb(46,204,113)
background_color: [ .18039215686274509803 , 0.8 , .44313725490196078431 , 1 ]
Button:
id: dec_nf_bro_btn
text: '-'
size_hint: 0.225,0.05
pos_hint: {'center_x': 0.125 , 'center_y': 0.075 }
on_press: self.parent.tap( 'dec_nf_bro' )
background_normal: ''
color: [ 0 , 0 , 0 , 1 ]
## rgb(241,196,15)
background_color: [ 0.94 , 0.77 , 0.06 , 1 ]
Button:
id: inc_nf_bro_btn
text: '+'
size_hint: 0.225,0.05
pos_hint: {'center_x': 0.375 , 'center_y': 0.075 }
on_press: self.parent.tap( 'inc_nf_bro' )
background_normal: ''
color: [ 0 , 0 , 0 , 1 ]
## rgb(155,89,182)
background_color: [ 0.61 , 0.35 , 0.71 , 1 ]
Label:
id: nf_bro_lbl
text: '(non-facilitator)'
Expand All @@ -149,6 +233,29 @@ ScreenManagement:
pos_hint: {'center_x': 0.75 , 'top': 0.35 }
on_press: self.parent.tap( 'nf_nd' )
font_size: min( ( self.height - 5 ) / 3 , ( self.width - 10 ) / 5 )
background_normal: ''
## rgb(46,204,113)
background_color: [ .18039215686274509803 , 0.8 , .44313725490196078431 , 1 ]
Button:
id: dec_nf_nd_btn
text: '-'
size_hint: 0.225,0.05
pos_hint: {'center_x': 0.625 , 'center_y': 0.075 }
on_press: self.parent.tap( 'dec_nf_nd' )
background_normal: ''
color: [ 0 , 0 , 0 , 1 ]
## rgb(241,196,15)
background_color: [ 0.94 , 0.77 , 0.06 , 1 ]
Button:
id: inc_nf_nd_btn
text: '+'
size_hint: 0.225,0.05
pos_hint: {'center_x': 0.875 , 'center_y': 0.075 }
on_press: self.parent.tap( 'inc_nf_nd' )
background_normal: ''
color: [ 0 , 0 , 0 , 1 ]
## rgb(155,89,182)
background_color: [ 0.61 , 0.35 , 0.71 , 1 ]
Label:
id: nf_nd_lbl
text: '(non-facilitator)'
Expand Down
95 changes: 64 additions & 31 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
from kivy.properties import ObjectProperty

class StopWatch(EventDispatcher):
__members = 0

def get_member_count(self):
return self.__members

def get_running(self):
return self.__start_time != 0
Expand Down Expand Up @@ -72,17 +76,24 @@ def reset(self):
self.__offset = 0
self.__start_time = 0
self.__running = False


def dec(self):
if( self.__members > 0 ):
self.__members -= 1

def inc(self):
self.__members += 1

def __init__(self):
self.__offset = 0
self.__start_time = 0
self.__running = False


def __repr__(self):
hours, remainder = divmod( int( self.get_elapsed() ) , 3600 )
minutes, seconds = divmod( remainder , 60 )
return '{:02d}:{:02d}:{:02d}'.format( hours , minutes , seconds )
return '{:02d}:{:02d}:{:02d} ({})'.format( hours , minutes , seconds ,
self.__members )

from kivy.clock import Clock
from functools import partial
Expand All @@ -91,7 +102,7 @@ class ScreenManagement( ScreenManager ):
pass

class AboutScreen(Screen):
__version__ = '17.49.1'
__version__ = '17.49.2'

def version( self , *args ):
return self.__version__
Expand Down Expand Up @@ -138,40 +149,46 @@ def save_to_disk( self , *args ):
now_time = datetime.datetime.now()
now_stamp = now_time.strftime( "%Y-%m-%d %H:%M:%S" )
now_filesafe = now_time.strftime( "%Y-%m-%d_%H%M%S" )
filename = 'youdonebro_{}.csv'.format( now_filesafe )
save_file = os.path.join( App.get_running_app().user_data_dir ,
'data' ,
'youdonebro_{}.csv'.format( now_filesafe ) )
filename )
with open( save_file , 'w' ) as fp:
fp.write( '{}\t{}\t{}\t{}\t{}\n'.format( 'Timestamp' ,
'Status' ,
'Gender' ,
'RawTime' ,
'PercentageTime' ) )
fp.write( '{}\t{}\t{}\t{}\t{}\t{}\n'.format( 'Timestamp' ,
'Status' ,
'Gender' ,
'RawTime' ,
'PercentageTime' ,
'Members' ) )
##
fp.write( '{}\t{}\t{}\t{}\t{}\n'.format( now_stamp ,
'facilitator' ,
'a bro' ,
self.ids[ 'fac_bro_time' ].text ,
self.ids[ 'fac_bro_pct' ].text ) )
fp.write( '{}\t{}\t{}\t{}\t{}\t{}\n'.format( now_stamp ,
'facilitator' ,
'a bro' ,
self.ids[ 'fac_bro_time' ].text ,
self.ids[ 'fac_bro_pct' ].text ,
self.fac_bro_watch.get_member_count() ) )
#
fp.write( '{}\t{}\t{}\t{}\t{}\n'.format( now_stamp ,
'facilitator' ,
'not a bro' ,
self.ids[ 'fac_nd_time' ].text ,
self.ids[ 'fac_nd_pct' ].text ) )
fp.write( '{}\t{}\t{}\t{}\t{}\t{}\n'.format( now_stamp ,
'facilitator' ,
'not a bro' ,
self.ids[ 'fac_nd_time' ].text ,
self.ids[ 'fac_nd_pct' ].text ,
self.fac_nd_watch.get_member_count() ) )
#
fp.write( '{}\t{}\t{}\t{}\t{}\n'.format( now_stamp ,
'non-facilitator' ,
'a bro' ,
self.ids[ 'nf_bro_time' ].text ,
self.ids[ 'nf_bro_pct' ].text ) )
fp.write( '{}\t{}\t{}\t{}\t{}\t{}\n'.format( now_stamp ,
'non-facilitator' ,
'a bro' ,
self.ids[ 'nf_bro_time' ].text ,
self.ids[ 'nf_bro_pct' ].text ,
self.nf_bro_watch.get_member_count() ) )
#
fp.write( '{}\t{}\t{}\t{}\t{}\n'.format( now_stamp ,
'non-facilitator' ,
'not a bro' ,
self.ids[ 'nf_nd_time' ].text ,
self.ids[ 'nf_nd_pct' ].text ) )
self.save_popup.content.text = save_file
fp.write( '{}\t{}\t{}\t{}\t{}\t{}\n'.format( now_stamp ,
'non-facilitator' ,
'not a bro' ,
self.ids[ 'nf_nd_time' ].text ,
self.ids[ 'nf_nd_pct' ].text ,
self.nf_nd_watch.get_member_count() ) )
self.save_popup.content.text = filename
self.save_popup.open()

def press(self, button):
Expand Down Expand Up @@ -200,6 +217,10 @@ def tap(self, button):
self.fac_nd_watch.stop()
self.nf_bro_watch.stop()
self.nf_nd_watch.stop()
elif( button == 'dec_fac_bro' ):
self.fac_bro_watch.dec()
elif( button == 'inc_fac_bro' ):
self.fac_bro_watch.inc()
elif( button == 'fac_bro' ):
if( self.fac_bro_watch.get_running() ):
self.fac_bro_watch.stop()
Expand All @@ -208,6 +229,10 @@ def tap(self, button):
self.fac_nd_watch.stop()
self.nf_bro_watch.stop()
self.nf_nd_watch.stop()
elif( button == 'dec_fac_nd' ):
self.fac_nd_watch.dec()
elif( button == 'inc_fac_nd' ):
self.fac_nd_watch.inc()
elif( button == 'fac_nd' ):
if( self.fac_nd_watch.get_running() ):
self.fac_nd_watch.stop()
Expand All @@ -216,6 +241,10 @@ def tap(self, button):
self.fac_nd_watch.start()
self.nf_bro_watch.stop()
self.nf_nd_watch.stop()
elif( button == 'dec_nf_bro' ):
self.nf_bro_watch.dec()
elif( button == 'inc_nf_bro' ):
self.nf_bro_watch.inc()
elif( button == 'nf_bro' ):
if( self.nf_bro_watch.get_running() ):
self.nf_bro_watch.stop()
Expand All @@ -224,6 +253,10 @@ def tap(self, button):
self.fac_nd_watch.stop()
self.nf_bro_watch.start()
self.nf_nd_watch.stop()
elif( button == 'dec_nf_nd' ):
self.nf_nd_watch.dec()
elif( button == 'inc_nf_nd' ):
self.nf_nd_watch.inc()
elif( button == 'nf_nd' ):
if( self.nf_nd_watch.get_running() ):
self.nf_nd_watch.stop()
Expand Down

0 comments on commit 721ff1e

Please sign in to comment.