def Draw(self): if self._DrawOnce == False: self.ClearCanvas() if is_wifi_connected_now(): self._Icons["online"].NewCoord(self._Coords["online"].x, self._Coords["online"].y) self._Icons["online"].Draw() self.SetLabels() for i in self._Labels: if i in self._Coords: self._Labels[i].NewCoord(self._Coords[i].x, self._Coords[i].y) self._Labels[i].Draw() self._Labels["key_and_pass"].NewCoord( 103, self._Coords["key_and_pass"].y) self._Labels["key_and_pass"].Draw() else: self._Icons["bg"].NewCoord(self._Coords["bg"].x, self._Coords["bg"].y) self._Icons["bg"].Draw() self._DrawOnce = True if self._HWND != None: self._HWND.fill((255, 255, 255)) self._HWND.blit( self._CanvasHWND, (self._PosX, self._PosY, self._Width, self._Height))
def SetLabels(self): if is_wifi_connected_now(): self._IP = get_wifi_ip() print("TinyCould : %s" % self._IP) try: if validators.ip_address.ipv4(self._IP) == False: self._IP = "xxx.xxx.xxx.xxx" except: print("ip error %s " % self._IP) self._IP = "xxx.xxx.xxx.xxx" else: self._IP = "xxx.xxx.xxx.xxx" labels = \ [["forssh","For ssh and scp:",self._ListFontObj,self._TextColor], ["ssh_addr","ssh cpi@%s" % self._IP, self._ListFontObj,self._URLColor], ["forwin", "For Windows network:", self._ListFontObj, self._TextColor], ["samba_games", "\\\\%s\games" % self._IP, self._ListFontObj,self._URLColor], ["samba_music", "\\\\%s\music" % self._IP, self._ListFontObj,self._URLColor], ["forID", "ID:", self._ListFontObj, self._TextColor], ["forKey", "Key:", self._ListFontObj, self._TextColor], ["key_and_pass", "cpi", self._ListFontObj, self._URLColor], ["for_airplay", "Airplay:", self._ListFontObj, self._TextColor], ["airplay_name","clockworkpi", self._ListFontObj, self._URLColor]] for i in labels: l = Label() l.SetCanvasHWND(self._CanvasHWND) l.Init(i[1], i[2]) l.SetColor(i[3]) self._Labels[i[0]] = l self.SetCoords() ##
def Draw(self): self.ClearCanvas() if is_wifi_connected_now() == False: self._Icons["needwifi_bg"].NewCoord(self._Width/2, self._Height/2) self._Icons["needwifi_bg"].Draw() return self._Icons["bg"].NewCoord(self._Width/2,self._Height/2-20) self._Icons["bg"].Draw() percent = self._Value if percent < 10: percent = 10 rect_ = midRect(self._Width/2,self._Height/2+33,170,17, Width,Height) aa_round_rect(self._CanvasHWND,rect_,MySkinManager.GiveColor('TitleBg'),5,0,MySkinManager.GiveColor('TitleBg')) rect2 = midRect(self._Width/2,self._Height/2+33,int(170*(percent/100.0)),17, Width,Height) rect2.left = rect_.left rect2.top = rect_.top aa_round_rect(self._CanvasHWND,rect2,MySkinManager.GiveColor('Front'),5,0,MySkinManager.GiveColor('Front')) rect3 = midRect(self._Width/2,self._Height/2+53,self._FileNameLabel._Width, self._FileNameLabel._Height,Width,Height) rect4 = midRect(self._Width/2,self._Height/2+70,self._SizeLabel._Width, self._SizeLabel._Height,Width,Height) self._FileNameLabel.NewCoord(rect3.left,rect3.top) self._SizeLabel.NewCoord(rect4.left, rect4.top) self._FileNameLabel.Draw() self._SizeLabel.Draw()
def ApplyGateWay(self, gateway): os.system("sudo ip route del 0/0") if gateway == "usb0": out = commands.getstatusoutput( "sudo ifconfig usb0 | grep inet | tr -s \" \"| cut -d \" \" -f3" ) if len(out[1]) > 7: if "error" not in out[1]: parts = out[1].split(".") if len(parts) == 4: ##IPv4 tp3 = int(parts[3]) tmp = tp3 if tp3 == 0: tmp = int(parts[3]) + 1 elif tp3 == 1: tmp = int(parts[3]) + 1 elif tp3 > 1: tmp = int(parts[3]) - 1 parts[3] = str(tmp) ipaddress = ".".join(parts) os.system("sudo route add default gw " + ipaddress) return True else: if is_wifi_connected_now(): os.system("sudo dhclient wlan0") return True else: self._Screen._MsgBox.SetText("Wi-Fi is not connected") self._Screen._MsgBox.Draw() self._Screen.SwapAndShow() return False return False
def Draw(self): if self._DrawOnce == False: self.ClearCanvas() if is_wifi_connected_now(): self._Icons["online"].NewCoord(self._Coords["online"].x, self._Coords["online"].y) self._Icons["online"].Draw() self.SetLabels() for i in self._Labels: if i in self._Coords: self._Labels[i].NewCoord( self._Coords[i].x, self._Coords[i].y) self._Labels[i].Draw() self._Labels["key_and_pass"].NewCoord( 103,self._Coords["key_and_pass"].y) self._Labels["key_and_pass"].Draw() else: self._Labels["for-usb-eth"].NewCoord(self._Coords["for-usb-eth"].x+55, self._Coords["for-usb-eth"].y) self._Labels["for-usb-eth"].Draw() self._Labels["usb-eth-addr"].NewCoord(self._Coords["usb-eth-addr"].x+55, self._Coords["usb-eth-addr"].y) self._Labels["usb-eth-addr"].Draw() self._Icons["bg"].NewCoord(self._Coords["bg"].x, self._Coords["bg"].y) self._Icons["bg"].Draw() self._DrawOnce = True if self._HWND != None: self._HWND.fill(MySkinManager.GiveColor('White')) self._HWND.blit(self._CanvasHWND,(self._PosX,self._PosY,self._Width, self._Height ) )
def Draw(self,title): self.ClearCanvas() title = MyLangManager.Tr(title) self._Title = title cur_time = datetime.now().strftime("%H:%M") time_text_font = MySkinManager.GiveFont("varela12") time_text_size = time_text_font.size(cur_time) title_text_size = MyLangManager.TrFont("varela16").size(title) self._CanvasHWND.blit(MyLangManager.TrFont("varela16").render(title,True,self._SkinManager.GiveColor("Text")),midRect(title_text_size[0]/2+self._LOffset, title_text_size[1]/2+(self._BarHeight-title_text_size[1])/2, title_text_size[0],title_text_size[1],Width,Height)) self._CanvasHWND.blit( time_text_font.render(cur_time,True,self._SkinManager.GiveColor("Text")),midRect(Width-time_text_size[0]/2-self._ROffset, time_text_size[1]/2+(self._BarHeight-time_text_size[1])/2, time_text_size[0],time_text_size[1],Width,Height)) start_x = Width-time_text_size[0]-self._ROffset-self._icon_width*3 # near by the time_text self._Icons["bluetooth"].NewCoord(start_x - self._icon_width,self._icon_height/2+(self._BarHeight-self._icon_height)/2) self._Icons["sound"].NewCoord(start_x, self._icon_height/2+(self._BarHeight-self._icon_height)/2) #self._Icons["wifi"].NewCoord(start_x+self._icon_width+5, self._icon_height/2+(self._BarHeight-self._icon_height)/2) self._Icons["battery"].NewCoord(start_x+self._icon_width+self._icon_width+8,self._icon_height/2+(self._BarHeight-self._icon_height)/2) if is_wifi_connected_now(): ge = self.GetWifiStrength(wifi_strength()) if ge > 0: self._Icons["wifistatus"]._IconIndex = ge self._Icons["wifistatus"].NewCoord(start_x+self._icon_width+5,self._icon_height/2+(self._BarHeight-self._icon_height)/2) self._Icons["wifistatus"].Draw() else: self._Icons["wifistatus"]._IconIndex = 0 self._Icons["wifistatus"].Draw() print("wifi strength error") else: 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() self._Icons["sound"].Draw() self._Icons["battery"].Draw() self._Icons["bluetooth"].Draw() pygame.draw.line(self._CanvasHWND,self._SkinManager.GiveColor("Line"),(0,self._BarHeight),(self._Width,self._BarHeight),self._BorderWidth) if self._HWND != None: self._HWND.blit(self._CanvasHWND,(self._PosX,self._PosY,self._Width,self._Height))
def OnKbdReturnBackCb(self): password_inputed = "".join(myvars.PasswordPage._Textarea._MyWords) if is_wifi_connected_now() == False: self.ConfigWireless(password_inputed) else: for i in range(0,10): if is_wifi_connected_now() == True: self.ShowBox(MyLangManager.Tr("Launching")) self._Daemon.Disconnect() self._Daemon.SetForcedDisconnect(True) self._Connecting = False else: break pygame.time.delay(100) if is_wifi_connected_now() == False: self.ConfigWireless(password_inputed) else: self.ShowBox(MyLangManager.Tr("Disconnect first"))
def KeyDown(self, event): if IsKeyMenuOrB(event.key): self.ReturnToUpLevelPage() self._Screen.Draw() self._Screen.SwapAndShow() if IsKeyStartOrA(event.key): if is_wifi_connected_now(): self.CurWeather() else: self._Screen.Draw() self._Screen._MsgBox.SetText("CheckWifiConnection") self._Screen._MsgBox.Draw() self._Screen.SwapAndShow()
def StartDownload(self,url,dst_dir): if is_wifi_connected_now() == False: return if validators.url(url) and os.path.isdir(dst_dir): self._URL = url self._DST_DIR = dst_dir else: self._Screen._MsgBox.SetText("Invaid") self._Screen._MsgBox.Draw() self._Screen.SwapAndShow() print("url or dst dir error") return self._Downloader = Download(url,dst_dir,None) self._Downloader.start() self._DownloaderTimer = gobject.timeout_add(100, self.GObjectUpdateProcessInterval)
def KeyDown(self,event): if IsKeyMenuOrB(event.key): self.ReturnToUpLevelPage() self._Screen.Draw() self._Screen.SwapAndShow() if event.key == CurKeys["X"]: if is_wifi_connected_now(): if self.CheckUpdate() == True: self._Screen.Draw() self._Screen.SwapAndShow() else: self._Screen.Draw() self._Screen._MsgBox.SetText("CheckingUpdateFailed") self._Screen._MsgBox.Draw() self._Screen.SwapAndShow() else: self._Screen.Draw() self._Screen._MsgBox.SetText("CheckWifiConnection") self._Screen._MsgBox.Draw() self._Screen.SwapAndShow()
def KeyDown(self, event): if event.key == CurKeys["Menu"] or event.key == CurKeys["A"]: self.ReturnToUpLevelPage() self._Screen.Draw() self._Screen.SwapAndShow() if event.key == CurKeys["X"]: if is_wifi_connected_now(): if self.CheckUpdate() == True: self._Screen.Draw() self._Screen.SwapAndShow() else: self._Screen.Draw() self._Screen._MsgBox.SetText("Checking update failed") self._Screen._MsgBox.Draw() self._Screen.SwapAndShow() else: self._Screen.Draw() self._Screen._MsgBox.SetText( "Please Check your Wi-Fi connection") self._Screen._MsgBox.Draw() self._Screen.SwapAndShow()
def Draw(self, title): self.ClearCanvas() self._Title = title cur_time = datetime.now().strftime("%H:%M") time_text_size = fonts["varela12"].size(cur_time) title_text_size = fonts["varela16"].size(title) self._CanvasHWND.blit( fonts["varela16"].render(title, True, self._TxtColor), midRect( title_text_size[0] / 2 + self._LOffset, title_text_size[1] / 2 + (self._BarHeight - title_text_size[1]) / 2, title_text_size[0], title_text_size[1], Width, Height)) self._CanvasHWND.blit( fonts["varela12"].render(cur_time, True, self._TxtColor), midRect( Width - time_text_size[0] / 2 - self._ROffset, time_text_size[1] / 2 + (self._BarHeight - time_text_size[1]) / 2, time_text_size[0], time_text_size[1], Width, Height)) start_x = Width - time_text_size[ 0] - self._ROffset - self._icon_width * 3 # near by the time_text self._Icons["sound"].NewCoord( start_x, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2) #self._Icons["wifi"].NewCoord(start_x+self._icon_width+5, self._icon_height/2+(self._BarHeight-self._icon_height)/2) self._Icons["battery"].NewCoord( start_x + self._icon_width + self._icon_width + 8, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2) if is_wifi_connected_now(): ge = self.GetWifiStrength(wifi_strength()) if ge > 0: self._Icons["wifistatus"]._IconIndex = ge self._Icons["wifistatus"].NewCoord( start_x + self._icon_width + 5, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2) self._Icons["wifistatus"].Draw() else: self._Icons["wifistatus"]._IconIndex = 0 self._Icons["wifistatus"].Draw() print("strength error") else: self._Icons["wifistatus"]._IconIndex = 0 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["sound"].Draw() self._Icons["battery"].Draw() pygame.draw.line(self._CanvasHWND, self._BottomLineColor, (0, self._BarHeight), (self._Width, self._BarHeight), self._BorderWidth) if self._HWND != None: self._HWND.blit( self._CanvasHWND, (self._PosX, self._PosY, self._Width, self._Height))
def Draw(self, title): self.ClearCanvas() title = MyLangManager.Tr(title) self._Title = title # get battery percentage, but not for music spectrum(GameShell RTA) RTA_title = "GameShell RTA" bat_pct = "" if title != RTA_title and title != MyLangManager.Tr(RTA_title): out = commands.getstatusoutput( "upower -i /org/freedesktop/UPower/devices/battery_axp20x_battery | grep percentage | tail -c 5" ) bat_pct = "".join(out[1]).strip() + " " cur_time = datetime.now().strftime("%H:%M") cur_time = bat_pct + cur_time time_text_font = MySkinManager.GiveFont("Eurostile12") time_text_size = time_text_font.size(cur_time) title_text_size = MyLangManager.TrFont("Eurostile16").size(title) self._CanvasHWND.blit( MyLangManager.TrFont("Eurostile16").render( title, True, self._SkinManager.GiveColor("Text")), midRect( title_text_size[0] / 2 + self._LOffset, title_text_size[1] / 2 + (self._BarHeight - title_text_size[1]) / 2, title_text_size[0], title_text_size[1], Width, Height)) self._CanvasHWND.blit( time_text_font.render(cur_time, True, self._SkinManager.GiveColor("Text")), midRect( Width - time_text_size[0] / 2 - self._ROffset, time_text_size[1] / 2 + (self._BarHeight - time_text_size[1]) / 2, time_text_size[0], time_text_size[1], Width, Height)) start_x = Width - time_text_size[ 0] - self._ROffset - self._icon_width * 3 # near by the time_text self._Icons["dlstatus"].NewCoord( start_x - self._icon_width * 2, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2) self._Icons["bluetooth"].NewCoord( start_x - self._icon_width, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2) self._Icons["sound"].NewCoord( start_x, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2) #self._Icons["wifi"].NewCoord(start_x+self._icon_width+5, self._icon_height/2+(self._BarHeight-self._icon_height)/2) self._Icons["battery"].NewCoord( start_x + self._icon_width + self._icon_width + 8, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2) if is_wifi_connected_now(): ge = self.GetWifiStrength(wifi_strength()) if ge > 0: self._Icons["wifistatus"]._IconIndex = ge self._Icons["wifistatus"].NewCoord( start_x + self._icon_width + 5, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2) self._Icons["wifistatus"].Draw() else: self._Icons["wifistatus"]._IconIndex = 0 self._Icons["wifistatus"].Draw() print("wifi strength error") else: 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() self._Icons["sound"].Draw() self._Icons["battery"].Draw() self._Icons["bluetooth"].Draw() #self._Icons["dlstatus"].Draw() pygame.draw.line(self._CanvasHWND, self._SkinManager.GiveColor("Line"), (0, self._BarHeight), (self._Width, self._BarHeight), self._BorderWidth) if self._HWND != None: self._HWND.blit( self._CanvasHWND, (self._PosX, self._PosY, self._Width, self._Height))
def OnKbdReturnBackCb(self): password_inputed = "".join(myvars.PasswordPage._Textarea._MyWords) if is_wifi_connected_now() == False: self.ConfigWireless(password_inputed)
def Draw(self, title): self.ClearCanvas() title = MyLangManager.Tr(title) # Couldn't see where to change this anywhere, so let's be super explicit if title == "GameShell": title = "PocketCHIP" self._Title = title title_text_size = MyLangManager.TrFont("varela16").size(title) self._CanvasHWND.blit( MyLangManager.TrFont("varela16").render( title, True, self._SkinManager.GiveColor("Text")), # x,y,width,height,canWidth,canHeight midRect( title_text_size[0] / 2 + self._LOffset, title_text_size[1] / 2 + (self._BarHeight - title_text_size[1]) / 2, title_text_size[0], title_text_size[1], Width, Height)) cur_time = datetime.now().strftime("%H:%M") time_text_font = MySkinManager.GiveFont("varela12") time_text_size = time_text_font.size(cur_time) self._CanvasHWND.blit( time_text_font.render(cur_time, True, self._SkinManager.GiveColor("Text")), # x,y,width,height,canWidth,canHeight midRect( Width - time_text_size[0] / 2 - self._ROffset, time_text_size[1] / 2 + (self._BarHeight - time_text_size[1]) / 2, time_text_size[0], time_text_size[1], Width, Height)) #### Debug: Output the battery value as text... # cur_batt = "Batt: %s, %s" % (str(BatteryAbstraction.AsPercentage()), str(BatteryAbstraction.IsCharging())) # batt_text_font = MySkinManager.GiveFont("varela12") # batt_text_size = batt_text_font.size(cur_batt) # self._CanvasHWND.blit(batt_text_font.render( # cur_batt, # True, # self._SkinManager.GiveColor("Text")), # # x,y,width,height,canWidth,canHeight # midRect( # # Width-batt_text_size[0]/2-self._ROffset, # 200, # batt_text_size[1]/2+(self._BarHeight-batt_text_size[1])/2, # batt_text_size[0], # batt_text_size[1], # Width, # Height # ) # ) start_x = Width - time_text_size[ 0] - self._ROffset - self._icon_width * 3 # near by the time_text self._Icons["bluetooth"].NewCoord( start_x - self._icon_width, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2) self._Icons["sound"].NewCoord( start_x, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2) #self._Icons["wifi"].NewCoord(start_x+self._icon_width+5, self._icon_height/2+(self._BarHeight-self._icon_height)/2) self._Icons["battery"].NewCoord( start_x + self._icon_width + self._icon_width + 8, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2) if is_wifi_connected_now(): ge = self.GetWifiStrength(wifi_strength()) if ge > 0: self._Icons["wifistatus"]._IconIndex = ge self._Icons["wifistatus"].NewCoord( start_x + self._icon_width + 5, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2) # self._Icons["wifistatus"].Draw() else: self._Icons["wifistatus"]._IconIndex = 0 # self._Icons["wifistatus"].Draw() print("wifi strength error") else: 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() # Draw the title bar icons self._Icons["wifistatus"].Draw() self._Icons["sound"].Draw() self._Icons["battery"].Draw() # self._Icons["bluetooth"].Draw() pygame.draw.line(self._CanvasHWND, self._SkinManager.GiveColor("Line"), (0, self._BarHeight), (self._Width, self._BarHeight), self._BorderWidth) if self._HWND != None: self._HWND.blit( self._CanvasHWND, (self._PosX, self._PosY, self._Width, self._Height))
def Init(self, screen): start_x = 0 self._CanvasHWND = pygame.Surface((self._Width, self._Height)) self._HWND = screen icon_wifi_status = MultiIconItem() icon_wifi_status._MyType = ICON_TYPES["STAT"] icon_wifi_status._ImageName = icon_base_path + "wifi.png" icon_wifi_status._Parent = self icon_wifi_status.Adjust( start_x + self._icon_width + 5, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2, self._icon_width, self._icon_height, 0) self._Icons["wifistatus"] = icon_wifi_status battery_charging = MultiIconItem() battery_charging._MyType = ICON_TYPES["STAT"] battery_charging._Parent = self battery_charging._ImageName = icon_base_path + "withcharging.png" battery_charging.Adjust( start_x + self._icon_width + self._icon_width + 8, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2, self._icon_width, self._icon_height, 0) self._Icons["battery_charging"] = battery_charging battery_discharging = MultiIconItem() battery_discharging._MyType = ICON_TYPES["STAT"] battery_discharging._Parent = self battery_discharging._ImageName = icon_base_path + "without_charging.png" battery_discharging.Adjust( start_x + self._icon_width + self._icon_width + 8, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2, self._icon_width, self._icon_height, 0) self._Icons["battery_discharging"] = battery_discharging battery_unknown = IconItem() battery_unknown._MyType = ICON_TYPES["STAT"] battery_unknown._Parent = self battery_unknown._ImageName = icon_base_path + "battery_unknown.png" battery_unknown.Adjust( start_x + self._icon_width + self._icon_width + 8, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2, self._icon_width, self._icon_height, 0) self._Icons["battery_unknown"] = battery_unknown self.CheckBatteryStat() sound_volume = MultiIconItem() sound_volume._MyType = ICON_TYPES["STAT"] sound_volume._Parent = self sound_volume._ImageName = icon_base_path + "soundvolume.png" sound_volume.Adjust( start_x + self._icon_width + self._icon_width + 8, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2, self._icon_width, self._icon_height, 0) self._Icons["soundvolume"] = sound_volume self.SyncSoundVolume() round_corners = MultiIconItem() round_corners._IconWidth = 10 round_corners._IconHeight = 10 round_corners._MyType = ICON_TYPES["STAT"] round_corners._Parent = self round_corners._ImgSurf = MyIconPool._Icons["roundcorners"] round_corners.Adjust(0, 0, 10, 10, 0) self._Icons["round_corners"] = round_corners if is_wifi_connected_now(): print("wifi is connected") print(wifi_strength())
def Init(self, screen): start_x = 0 self._CanvasHWND = pygame.Surface((self._Width, self._Height)) self._HWND = screen icon_wifi_status = MultiIconItem() icon_wifi_status._MyType = ICON_TYPES["STAT"] icon_wifi_status._ImageName = icon_base_path + "wifi.png" icon_wifi_status._Parent = self icon_wifi_status.Adjust( start_x + self._icon_width + 5, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2, self._icon_width, self._icon_height, 0) self._Icons["wifistatus"] = icon_wifi_status battery_charging = MultiIconItem() battery_charging._MyType = ICON_TYPES["STAT"] battery_charging._Parent = self battery_charging._ImageName = icon_base_path + "withcharging.png" battery_charging.Adjust( start_x + self._icon_width + self._icon_width + 8, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2, self._icon_width, self._icon_height, 0) self._Icons["battery_charging"] = battery_charging battery_discharging = MultiIconItem() battery_discharging._MyType = ICON_TYPES["STAT"] battery_discharging._Parent = self battery_discharging._ImageName = icon_base_path + "without_charging.png" battery_discharging.Adjust( start_x + self._icon_width + self._icon_width + 8, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2, self._icon_width, self._icon_height, 0) self._Icons["battery_discharging"] = battery_discharging battery_unknown = IconItem() battery_unknown._MyType = ICON_TYPES["STAT"] battery_unknown._Parent = self battery_unknown._ImageName = icon_base_path + "battery_unknown.png" battery_unknown.Adjust( start_x + self._icon_width + self._icon_width + 8, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2, self._icon_width, self._icon_height, 0) self._Icons["battery_unknown"] = battery_unknown self.CheckBatteryStat() sound_volume = MultiIconItem() sound_volume._MyType = ICON_TYPES["STAT"] sound_volume._Parent = self sound_volume._ImageName = icon_base_path + "soundvolume.png" sound_volume.Adjust( start_x + self._icon_width + self._icon_width + 8, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2, self._icon_width, self._icon_height, 0) self._Icons["soundvolume"] = sound_volume self.SyncSoundVolume() bluetooth = MultiIconItem() bluetooth._MyType = ICON_TYPES["STAT"] bluetooth._Parent = self bluetooth._ImageName = icon_base_path + "bluetooth.png" bluetooth.Adjust( start_x + self._icon_width + self._icon_width + 8, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2, self._icon_width, self._icon_height, 0) self._Icons["bluetooth"] = bluetooth self.CheckBluetooth() round_corners = MultiIconItem() round_corners._IconWidth = 10 round_corners._IconHeight = 10 round_corners._MyType = ICON_TYPES["STAT"] round_corners._Parent = self round_corners._ImgSurf = MyIconPool.GiveIconSurface("roundcorners") round_corners.Adjust(0, 0, 10, 10, 0) self._Icons["round_corners"] = round_corners dlstatus = MultiIconItem() dlstatus._MyType = ICON_TYPES["STAT"] dlstatus._Parent = self if FileExists(icon_base_path + "dlstatus18.png"): dlstatus._ImageName = icon_base_path + "dlstatus18.png" dlstatus.Adjust( start_x + self._icon_width + self._icon_width + 8, self._icon_height / 2 + (self._BarHeight - self._icon_height) / 2, self._icon_width, self._icon_height, 0) self._Icons["dlstatus"] = dlstatus self.UpdateDownloadStatus() if is_wifi_connected_now(): print("wifi is connected") print(wifi_strength()) else: out = commands.getstatusoutput( 'sudo rfkill list | grep yes | cut -d " " -f3') if out[1] == "yes": self._InAirPlaneMode = True else: self._InAirPlaneMode = False
def OnKbdReturnBackCb(self): password_inputed = "".join(myvars.PasswordPage._Textarea._MyWords) if is_wifi_connected_now() == False: self.ConfigWireless(password_inputed) else: self.ShowBox(MyLangManager.Tr("Disconnect first"))