本文整理汇总了Python中gui.MainWindow.set_battery_bar方法的典型用法代码示例。如果您正苦于以下问题:Python MainWindow.set_battery_bar方法的具体用法?Python MainWindow.set_battery_bar怎么用?Python MainWindow.set_battery_bar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gui.MainWindow
的用法示例。
在下文中一共展示了MainWindow.set_battery_bar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from gui import MainWindow [as 别名]
# 或者: from gui.MainWindow import set_battery_bar [as 别名]
#.........这里部分代码省略.........
for data in self.client_thread.get_queue("source"):
uuid = data["uuid"]
if uuid == "00000000-0000-0000-0000-000000000000":
continue
self.sources[uuid] = data
update = True
if update is True:
self.main_window.update_sources_table(self.sources)
return True
def queue_handler_networks(self):
#ssid
for data in self.client_thread.get_queue("ssid"):
self.networks.add_ssid_data(data)
#bssid
bssids = {}
for data in self.client_thread.get_queue("bssid"):
mac = data["bssid"]
self.networks.add_bssid_data(data)
if mac in self.main_window.signal_graphs and "signal_dbm" not in self.client_thread.client.capabilities["bssidsrc"]:
self.main_window.signal_graphs[mac].add_value(None, None, data["signal_dbm"])
bssids[mac] = True
#bssidsrc
for data in self.client_thread.get_queue("bssidsrc"):
if "signal_dbm" not in data or data["uuid"] not in self.sources:
continue
mac = data["bssid"]
if mac in self.main_window.signal_graphs:
self.main_window.signal_graphs[mac].add_value(self.sources[data["uuid"]], data, data["signal_dbm"])
if len(self.networks.notify_add_queue) > 0:
self.networks.start_queue()
if len(self.networks.notify_add_queue) > 500:
self.networks.disable_refresh()
self.main_window.networks_queue_progress()
self.main_window.update_statusbar()
return True
def quit(self):
self.client_thread.stop()
self.config_handler.write()
self.networks.save(self.networks_file)
def get_battery_capacity(self):
filename = "/proc/acpi/battery/%s/state" % self.battery
if not os.path.isfile(filename):
return False
f = open(filename)
for line in f.readlines():
if line.startswith("remaining capacity:"):
current = line.split(":")[1].strip()
current = int(current.split()[0])
return round(100.0 / self.battery_max * current, 1)
return False
def update_battery_bar(self):
battery = self.get_battery_capacity()
self.main_window.set_battery_bar(battery)
return True
def add_network_to_map(self, mac):
network = self.networks.get_network(mac)
try:
crypt = self.crypt_cache[network["cryptset"]]
except KeyError:
crypt = decode_cryptset(network["cryptset"], True)
self.crypt_cache[network["cryptset"]] = crypt
if "WPA" in crypt:
color = "red"
elif "WEP" in crypt:
color = "orange"
else:
color = "green"
ssid = network["ssid"]
if ssid == "":
ssid = "<no ssid>"
evils = (("&", "&"),("<", "<"),(">", ">"))
for evil, good in evils:
ssid = ssid.replace(evil, good)
time_format = "%d.%m.%Y %H:%M:%S"
text = self.marker_text % (crypt, mac, network["manuf"],
network["type"], network["channel"],
time.strftime(time_format, time.localtime(network["firsttime"])),
time.strftime(time_format, time.localtime(network["lasttime"]))
)
text = text.replace("&", "&")
self.map.add_marker(mac, color, network["lat"], network["lon"])