Piggy wallet: simplify

This commit is contained in:
Thomas Farstrike
2025-05-31 22:11:24 +02:00
parent c482c69eef
commit 0219da2995
2 changed files with 8 additions and 26 deletions
@@ -117,36 +117,16 @@ class SettingsScreen():
setting["cont"].remove_flag(lv.obj.FLAG.HIDDEN)
def radio_event_handler(self, event):
code = event.get_code()
if code != lv.EVENT.CLICKED:
return
targetblob = event.get_target()
#target = self.radio_container
#obj = e.get_target()
target = lv.obj(targetblob)
#pos = lvobj.get_pos() #
if target == self.radio_container:
print("it's the container")
return # Ignore clicks on the container itself
else:
print("it's not the container")
old_cb = self.radio_container.get_child(self.active_radio_index)
old_cb.remove_state(lv.STATE.CHECKED)
#target.add_state(lv.STATE.CHECKED)
# 19 = lv.STATE.HOVERED, lv.STATE.CHECKED and lv.STATE.FOCUSED
radio_index = -1
for childnr in range(2):
self.active_radio_index = -1
for childnr in range(self.radio_container.get_child_count()):
child = self.radio_container.get_child(childnr)
state = child.get_state()
print(f"state: {state}")
if state != lv.STATE.DEFAULT:
print("found checked child!")
radio_index = childnr
print(f"radio_container child's state: {state}")
if state != lv.STATE.DEFAULT: # State can be something like 19 = lv.STATE.HOVERED & lv.STATE.CHECKED & lv.STATE.FOCUSED
self.active_radio_index = childnr
break
else:
print("skipping child...")
#self.active_radio_index = self.radio_container.get_child_by_id(target)
self.active_radio_index = radio_index
print(f"active_radio_index is now {self.active_radio_index}")
def create_radio_button(self, parent, text, index):
@@ -230,6 +230,7 @@ class LNBitsWallet(Wallet):
"X-Api-Key": self.lnbits_readkey,
}
try:
print(f"Fetching balance with GET to {walleturl}")
response = requests.get(walleturl, timeout=10, headers=headers)
except Exception as e:
print("fetch_balance: get request failed:", e)
@@ -253,6 +254,7 @@ class LNBitsWallet(Wallet):
"X-Api-Key": self.lnbits_readkey,
}
try:
print(f"Fetching payments with GET to {paymentsurl}")
response = requests.get(paymentsurl, timeout=10, headers=headers)
except Exception as e:
print("fetch_payments: get request failed:", e)
@@ -418,7 +420,7 @@ class NWCWallet(Wallet):
#cleartext_content='{"params":{"limit": 4 },"method":"list_transactions"}'
)
self.private_key.sign_event(dm) # sign also does encryption if it's a encrypted dm
print("\n\nPublishing DM to fetch payments...\n\n")
print("Publishing DM to fetch payments...")
self.relay_manager.publish_event(dm)
def parse_nwc_url(self, nwc_url):