@@ -51,7 +51,7 @@ def __init__(self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.D
5151
5252 self .left_down = False
5353 self .selected = False
54- self .totp_cycle = 0
54+ self .totp_cycle = 30
5555 self .totp_period = 30
5656 self .code_masked = False
5757 self .timers_shown = True
@@ -68,7 +68,7 @@ def __init__(self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.D
6868 else :
6969 self .SetName ('entry_panel_X' )
7070 self .code_digits = 6
71- ## GetLogger().debug( "AEP init %s", self.GetName() )
71+ GetLogger ().debug ( "AEP init %s" , self .GetName () )
7272
7373 # Create panel child controls
7474
@@ -116,11 +116,11 @@ def __init__(self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.D
116116 12 )
117117
118118 self .totp_period = entry .GetPeriod () if self .entry != None else 30
119- self .timer_gauge = wx .Gauge (self , wx .ID_ANY , self .totp_period - 1 , size = wx .Size (40 , 8 ),
120- style = wx .GA_HORIZONTAL , name = 'timer_gauge' )
119+ self .totp_cycle = self .totp_period
120+ self .timer_gauge = wx .Gauge (self , wx .ID_ANY , self .totp_period - 1 , size = wx .Size (8 , 30 ),
121+ style = wx .GA_VERTICAL , name = 'timer_gauge' )
121122 self .timer_gauge .SetValue (self .totp_period - 1 )
122- self .timer_gauge .Fit ()
123- sizer .Add (self .timer_gauge , 0 , wx .RIGHT | wx .ALIGN_CENTER , 2 )
123+ sizer .Add (self .timer_gauge , 0 , wx .RIGHT | wx .ALIGN_CENTER , 16 )
124124
125125 # Create our context menu
126126 self .context_menu = wx .Menu ()
@@ -130,9 +130,7 @@ def __init__(self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.D
130130 self .Bind (wx .EVT_MENU , self .OnQrCodeImage , item )
131131
132132 self .UpdateContents ()
133-
134- if entry != None :
135- self .code = str (self .entry .GenerateNextCode ())
133+ self .UpdateTimerGauge ()
136134
137135 self .Bind (wx .EVT_WINDOW_CREATE , self .OnCreate )
138136 self .Bind (wx .EVT_TIMER , self .OnTimerTick )
@@ -151,7 +149,7 @@ def __init__(self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.D
151149 self .code_text .Bind (wx .EVT_CHAR , gp .OnKey )
152150 self .timer_gauge .Bind (wx .EVT_CHAR , gp .OnKey )
153151
154- ## GetLogger().debug( "AEP init done %s", self.GetName() )
152+ GetLogger ().debug ( "AEP init done %s" , self .GetName () )
155153
156154 def MouseBind (self , event_type , func ):
157155 """Bind a mouse event."""
@@ -168,8 +166,8 @@ def __cmp__(self, other):
168166 def OnCreate (self , event ):
169167 """Handle window creation."""
170168 self .Unbind (wx .EVT_WINDOW_CREATE )
171- ## GetLogger().debug( "AEP created" )
172- self .ChangeContents ()
169+ GetLogger ().debug ( "AEP created" )
170+ self .UpdateContents ()
173171
174172 def OnTimerTick (self , event ):
175173 """Update the timer countdown bar once per tick."""
@@ -252,8 +250,8 @@ def SetEntry(self, entry):
252250 self .code_digits = entry .GetDigits ()
253251 self .SetName ('entry_panel_{0:d}' .format (self .entry .GetGroup ()))
254252 self .code = str (self .entry .GenerateNextCode ())
255- ## GetLogger().debug( "AEP SE on %s", self.GetName() )
256- self .ChangeContents ()
253+ GetLogger ().debug ( "AEP SE on %s" , self .GetName () )
254+ self .UpdateContents ()
257255
258256 def GetSortIndex (self ):
259257 "Return the panel's sort index." ""
@@ -295,7 +293,7 @@ def GetLabelWidth(self):
295293
296294 def SizeLabels (self , label_width ):
297295 """Resize the labels to the given width to keep columns even."""
298- ## GetLogger().debug( "AEP SL new label width %d", label_width )
296+ GetLogger ().debug ( "AEP SL new label width %d" , label_width )
299297 self .label_width = label_width
300298
301299 s = self .label_panel .GetClientSize ()
@@ -307,7 +305,7 @@ def SizeLabels(self, label_width):
307305 def UpdateContents (self ):
308306 """Update the panel's displayed contents based on the current state and entry."""
309307 if self .entry != None :
310- ## GetLogger().debug( "AEP UC updating %s", self.GetName() )
308+ GetLogger ().debug ( "AEP UC updating %s" , self .GetName () )
311309 self .code_text .SetLabelText (self .GetCodeString (self .selected ))
312310 self .provider_text .SetLabelText (self .entry .GetProvider ())
313311 text_size = self .provider_text .GetTextExtent (self .entry .GetProvider ())
@@ -327,19 +325,10 @@ def UpdateContents(self):
327325 self .label_panel .SetClientSize (s )
328326 self .Fit ()
329327
330- ## GetLogger().debug( "AEP UC provider size: %s", unicode( self.provider_text.GetSize() ) )
331- ## GetLogger().debug( "AEP UC account size: %s", unicode( self.account_text.GetSize() ) )
332- ## GetLogger().debug( "AEP UC label width: %d", self.label_width )
333- ## GetLogger().debug( "AEP UC panel size: %s", unicode( self.GetSize() ) )
334-
335- def ChangeContents (self ):
336- """Handle a change in contents and signal the change to the frame."""
337- ## GetLogger().debug( "AEP CC" )
338- self .UpdateContents ()
339- gp = self .GetGrandParent ()
340- if gp != None :
341- ## GetLogger().debug( "AEP CC notifying frame" )
342- gp .UpdatePanelSize ()
328+ GetLogger ().debug ( "AEP UC provider size: %s" , unicode ( self .provider_text .GetSize () ) )
329+ GetLogger ().debug ( "AEP UC account size: %s" , unicode ( self .account_text .GetSize () ) )
330+ GetLogger ().debug ( "AEP UC label width: %d" , self .label_width )
331+ GetLogger ().debug ( "AEP UC panel size: %s" , unicode ( self .GetSize () ) )
343332
344333 def Select (self ):
345334 """Select this panel."""
@@ -366,7 +355,6 @@ def Deselect(self):
366355 def UpdateTimerGauge (self ):
367356 """Update the countdown bar and code based on the current time and cycle."""
368357 current_time = wx .GetUTCTime ()
369- ## GetLogger().debug( "AEP %s timer tick %d", self.GetName(), current_time ) # LOTS of debug output
370358 last_cycle = self .totp_cycle
371359 self .totp_cycle = current_time % self .totp_period
372360 # If we wrapped around the end of a cycle, update the code and reset the countdown timer gauge
0 commit comments