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

View File

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

View File

@ -3,6 +3,7 @@
import pygame import pygame
import os import os
import sys import sys
import commands
from datetime import datetime from datetime import datetime
@ -46,6 +47,7 @@ class TitleBar:
_SkinManager = None _SkinManager = None
_InAirPlaneMode = False
def __init__(self): def __init__(self):
self._Icons = {} self._Icons = {}
@ -237,7 +239,13 @@ class TitleBar:
if is_wifi_connected_now(): if is_wifi_connected_now():
print("wifi is connected") print("wifi is connected")
print( wifi_strength()) 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): def ClearCanvas(self):
self._CanvasHWND.fill( self._SkinManager.GiveColor("TitleBg") ) self._CanvasHWND.fill( self._SkinManager.GiveColor("TitleBg") )
@ -293,7 +301,11 @@ class TitleBar:
self._Icons["wifistatus"].Draw() self._Icons["wifistatus"].Draw()
print("strength error") print("strength error")
else: 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"].NewCoord(start_x+self._icon_width+5,self._icon_height/2+(self._BarHeight-self._icon_height)/2)
self._Icons["wifistatus"].Draw() self._Icons["wifistatus"].Draw()