mirror of
https://github.com/pdxlocations/contact.git
synced 2026-08-06 17:03:08 +02:00
Add dialog confirmation when traceroute sent
This commit is contained in:
@@ -4,6 +4,7 @@ import globals
|
||||
from utilities.utils import get_name_from_number, get_channels
|
||||
from settings import settings
|
||||
from message_handlers.tx_handler import send_message, send_traceroute
|
||||
import ui.dialog
|
||||
|
||||
def add_notification(channel_number):
|
||||
handle_notification(channel_number, add=True)
|
||||
@@ -327,6 +328,9 @@ def main_ui(stdscr):
|
||||
# Check for Ctrl + t
|
||||
elif char == 20:
|
||||
send_traceroute()
|
||||
curses.curs_set(0) # Hide cursor
|
||||
ui.dialog.dialog(stdscr, "Traceroute Sent", "Results will appear in messages window")
|
||||
curses.curs_set(1) # Show cursor again
|
||||
|
||||
elif char == curses.KEY_ENTER or char == 10 or char == 13:
|
||||
if globals.current_window == 2:
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import curses
|
||||
|
||||
def dialog(stdscr, title, message):
|
||||
height, width = stdscr.getmaxyx()
|
||||
|
||||
# Calculate dialog dimensions
|
||||
dialog_width = max(len(title) + 4, len(message) + 4)
|
||||
dialog_height = 5
|
||||
x = (width - dialog_width) // 2
|
||||
y = (height - dialog_height) // 2
|
||||
|
||||
# Create dialog window
|
||||
win = curses.newwin(dialog_height, dialog_width, y, x)
|
||||
win.border(0)
|
||||
|
||||
# Add title
|
||||
win.addstr(0, 2, title)
|
||||
|
||||
# Add message
|
||||
win.addstr(2, 2, message)
|
||||
|
||||
# Add button
|
||||
win.addstr(dialog_height - 2, (dialog_width - 4) // 2, " Ok ")
|
||||
|
||||
# Refresh dialog window
|
||||
win.refresh()
|
||||
|
||||
# Get user input
|
||||
while True:
|
||||
char = win.getch()
|
||||
if char == curses.KEY_ENTER or char == 10 or char == 13:
|
||||
win.clear()
|
||||
win.refresh()
|
||||
return
|
||||
Reference in New Issue
Block a user