TitleBar show airplane mode icon

This commit is contained in:
cuu 2018-07-01 21:34:26 +08:00
parent 89bfa9d92f
commit d56de234c2
3 changed files with 20 additions and 11 deletions

View File

@ -88,8 +88,6 @@ class AirplanePage(Page):
_DrawOnce = False
_Scroller = None
_InAirPlaneMode = False
def __init__(self):
Page.__init__(self)
@ -143,22 +141,20 @@ class AirplanePage(Page):
self._Scrolled += dis
def ToggleMode(self):
print("ToggleMode")
out = commands.getstatusoutput('rfkill list | grep yes | cut -d " " -f3')
print out
if out[1] == "yes":
self._InAirPlaneMode = True
self._Screen._MsgBox.SetText("Turning On")
self._Screen._MsgBox.Draw()
commands.getstatusoutput("rfkill unblock all")
self._Screen._TitleBar._InAirPlaneMode = False
else:
self._InAirPlaneMode = False
self._Screen._MsgBox.SetText("Turning Off")
self._Screen._MsgBox.Draw()
commands.getstatusoutput("rfkill block all")
self._Screen._TitleBar._InAirPlaneMode = True
def OnLoadCb(self):
self._Scrolled = 0
@ -166,9 +162,9 @@ class AirplanePage(Page):
self._DrawOnce = False
out = commands.getstatusoutput('rfkill list | grep yes | cut -d " " -f3')
if out[1] == "yes":
self._InAirPlaneMode = True
self._Screen._TitleBar._InAirPlaneMode = True
else:
self._InAirPlaneMode = False
self._Screen._TitleBar._InAirPlaneMode = False
def OnReturnBackCb(self):

View File

@ -136,6 +136,7 @@ class MainScreen(object):
_IconFont = fonts["varela15"]
_SkinManager = None
def __init__(self):
self._Pages = []
self._MyPageStack = PageStack()

View File

@ -3,6 +3,7 @@
import pygame
import os
import sys
import commands
from datetime import datetime
@ -46,6 +47,7 @@ class TitleBar:
_SkinManager = None
_InAirPlaneMode = False
def __init__(self):
self._Icons = {}
@ -237,7 +239,13 @@ class TitleBar:
if is_wifi_connected_now():
print("wifi is connected")
print( wifi_strength())
else:
out = commands.getstatusoutput('rfkill list | grep yes | cut -d " " -f3')
if out[1] == "yes":
self._InAirPlaneMode = True
else:
self._InAirPlaneMode = False
def ClearCanvas(self):
self._CanvasHWND.fill( self._SkinManager.GiveColor("TitleBg") )
@ -293,7 +301,11 @@ class TitleBar:
self._Icons["wifistatus"].Draw()
print("strength error")
else:
self._Icons["wifistatus"]._IconIndex = 0
if self._InAirPlaneMode == False:
self._Icons["wifistatus"]._IconIndex = 0
else:
self._Icons["wifistatus"]._IconIndex = 5 ## airplane mode icon
self._Icons["wifistatus"].NewCoord(start_x+self._icon_width+5,self._icon_height/2+(self._BarHeight-self._icon_height)/2)
self._Icons["wifistatus"].Draw()