mirror of
				https://github.com/KevinMidboe/termForecast.git
				synced 2025-10-29 18:00:17 +00:00 
			
		
		
		
	Moved all runnning scripts to single folder
This commit is contained in:
		
							
								
								
									
										40
									
								
								termWeather/loadingAnimation.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										40
									
								
								termWeather/loadingAnimation.py
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,40 @@ | ||||
| #!/usr/bin/env python3.6 | ||||
| # -*- coding: utf-8 -*- | ||||
| # @Author: KevinMidboe | ||||
| # @Date:   2017-07-30 13:53:38 | ||||
| # @Last Modified by:   KevinMidboe | ||||
| # @Last Modified time: 2017-07-30 13:53:46 | ||||
|  | ||||
| import itertools | ||||
| from threading import Thread | ||||
| from time import sleep | ||||
| from sys import stdout | ||||
|  | ||||
| class LoadingAnimation(object): | ||||
| 	def __init__(self): | ||||
| 		self.done = False | ||||
|  | ||||
| 	def start(self): | ||||
| 		t = Thread(target=self.animate) | ||||
| 		t.start() | ||||
|  | ||||
| 	def animate(self): | ||||
| 	    for c in itertools.cycle(['|', '/', '-', '\\']): | ||||
| 	        if self.done: | ||||
| 	            break | ||||
| 	        stdout.write('\rFetching ' + c) | ||||
| 	        stdout.flush() | ||||
| 	        sleep(0.1) | ||||
|  | ||||
| 	def stop(self): | ||||
| 		self.done = True | ||||
|  | ||||
| def main(): | ||||
| 	loadingAnimation = LoadingAnimation() | ||||
| 	loadingAnimation.start() | ||||
| 	sleep(2) | ||||
| 	loadingAnimation.stop() | ||||
| 	stdout.write('\rTemp          \n') | ||||
| 	 | ||||
| if __name__ == '__main__': | ||||
| 	main() | ||||
		Reference in New Issue
	
	Block a user