11#!/usr/bin/env python3
2- """A simple example cmd2 application demonstrating many common features.
2+ """An example cmd2 application demonstrating many common features.
33
44Features demonstrated include all of the following:
55 1) Colorizing/stylizing output
151511) Shortcuts for commands
161612) Persistent bottom toolbar with realtime status updates
171713) Right prompt which displays contextual information
18+ 14) Using a background thread to update the bottom toolbar in an efficient manner
19+ 15) Using preloop() and postloop() hooks to start and stop a background thread
1820"""
1921
2022import datetime
@@ -109,8 +111,8 @@ def _update_toolbar_state(self) -> None:
109111 with self ._toolbar_lock :
110112 self ._toolbar_state ["now" ] = now
111113
112- # Sleep to yield CPU, polling 10 times a second
113- self ._stop_thread_event .wait (0.1 )
114+ # Sleep to yield CPU, polling 4 times a second
115+ self ._stop_thread_event .wait (0.25 )
114116
115117 def preloop (self ) -> None :
116118 """Hook method executed once when the cmdloop() method is called."""
@@ -136,7 +138,7 @@ def get_bottom_toolbar(self) -> AnyFormattedText:
136138 # If called outside a running app loop (e.g., in unit tests), get_app()
137139 # safely returns a dummy app with an 80-column fallback.
138140 cols = get_app ().output .get_size ().columns
139- padding_size = cols - len (left_text ) - len (now ) - 1
141+ padding_size = cols - len (left_text ) - len (now )
140142 if padding_size < 1 :
141143 padding_size = 1
142144 padding = " " * padding_size
0 commit comments