Wrapped entry box changed callback in try/except to handle ValueError
This commit is contained in:
		
					parent
					
						
							
								6328b97265
							
						
					
				
			
			
				commit
				
					
						f646f99d02
					
				
			
		
					 1 changed files with 16 additions and 3 deletions
				
			
		|  | @ -1,5 +1,6 @@ | |||
| # -*- coding: utf-8 -*- | ||||
| 
 | ||||
| # Copyright 2021 Alexander Rowsell. Licenced under MPLv2.0 | ||||
| # This Source Code Form is subject to the terms of the Mozilla Public | ||||
| # License, v. 2.0. If a copy of the MPL was not distributed with this | ||||
| # file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||||
|  | @ -69,7 +70,11 @@ class spirographs: | |||
|         self.updatePlot() | ||||
| 
 | ||||
|     def bigRadiusEntry_changed_cb(self, widget): | ||||
|         self.bigRadius = float(widget.get_text()) | ||||
|         try: | ||||
|             self.bigRadius = float(widget.get_text()) | ||||
|         except ValueError: | ||||
|             print("Couldn't get a float for R, ignoring...\n") | ||||
|             return | ||||
|         self.bigRadiusAdjustment.set_value(self.bigRadius) | ||||
| 
 | ||||
|     def smallRadiusAdjustment_value_changed_cb(self, widget): | ||||
|  | @ -79,7 +84,11 @@ class spirographs: | |||
|         self.updatePlot() | ||||
| 
 | ||||
|     def smallRadiusEntry_changed_cb(self, widget): | ||||
|         self.smallRadius = float(widget.get_text()) | ||||
|         try: | ||||
|             self.smallRadius = float(widget.get_text()) | ||||
|         except ValueError: | ||||
|             print("Couldn't get a float for r, ignoring...\n") | ||||
|             return | ||||
|         self.smallRadiusAdjustment.set_value(self.smallRadius) | ||||
| 
 | ||||
|     def distanceAdjustment_value_changed_cb(self, widget): | ||||
|  | @ -89,7 +98,11 @@ class spirographs: | |||
|         self.updatePlot() | ||||
| 
 | ||||
|     def distanceEntry_changed_cb(self, widget): | ||||
|         self.distance = float(widget.get_text()) | ||||
|         try: | ||||
|             self.distance = float(widget.get_text()) | ||||
|         except ValueError: | ||||
|             print("Couldn't get a float for d, ignoring...\n") | ||||
|             return | ||||
|         self.distanceAdjustment.set_value(self.distance) | ||||
| 
 | ||||
|     def recalcPoints(self): | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue