69 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Python
		
	
	
	
			
		
		
	
	
			69 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Python
		
	
	
	
| """
 | |
| 
 | |
| Anzeige von zwei frei definierbaren Werten
 | |
| 
 | |
| Layout
 | |
| +--------------------+
 | |
| |         1          |
 | |
| +--------------------+
 | |
| |         2          |
 | |
| +--------------------+
 | |
| 
 | |
| """
 | |
| 
 | |
| import cairo
 | |
| from .page import Page
 | |
| import nmea2000.boatdata
 | |
| 
 | |
| class TwoValues(Page):
 | |
| 
 | |
|     def __init__(self, pageno, cfg, appdata, boatdata, boatvalue1, boatvalue2):
 | |
|         super().__init__(pageno, cfg, appdata, boatdata)
 | |
|         self.ref1 = self.bd.getRef(boatvalue1)
 | |
|         self.ref2 = self.bd.getRef(boatvalue2)
 | |
|         #print(self.ref1.valname)
 | |
| 
 | |
|     def draw(self, ctx):
 | |
| 
 | |
|         # Seitenunterteilung
 | |
|         ctx.rectangle(0, 145, 400, 3)
 | |
|         ctx.fill()
 | |
| 
 | |
|         # Name
 | |
|         ctx.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD)
 | |
|         ctx.set_font_size(40) 
 | |
|         ctx.move_to(20, 80)
 | |
|         ctx.show_text(self.ref1.valname)
 | |
|         ctx.move_to(20, 190)
 | |
|         ctx.show_text(self.ref2.valname)
 | |
| 
 | |
|         # Einheit
 | |
|         ctx.set_font_size(24)
 | |
|         ctx.move_to(20, 130)
 | |
|         ctx.show_text(self.ref1.unit)
 | |
|         ctx.move_to(20, 240)
 | |
|         ctx.show_text(self.ref2.unit)
 | |
| 
 | |
|         # Meßwerte
 | |
|         if type(self.ref1) == nmea2000.boatdata.BoatValueGeo:
 | |
|             ctx.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD)
 | |
|             ctx.set_font_size(40)
 | |
|             ctx.move_to(140, 100)
 | |
|         else:
 | |
|             ctx.select_font_face("DSEG7 Classic")
 | |
|             ctx.set_font_size(84)
 | |
|             ctx.move_to(180, 130)
 | |
|         ctx.show_text(self.ref1.format())
 | |
| 
 | |
|         if type(self.ref2) == nmea2000.boatdata.BoatValueGeo:
 | |
|             ctx.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD)
 | |
|             ctx.set_font_size(40)
 | |
|             ctx.move_to(140, 210)
 | |
|         else:
 | |
|             ctx.select_font_face("DSEG7 Classic")
 | |
|             ctx.set_font_size(84)
 | |
|             ctx.move_to(180, 240)
 | |
|         ctx.show_text(self.ref2.format())
 | |
| 
 | |
|         ctx.stroke()
 |