Curses for Building UI in Python

My quest to build a terminal based ui for my network sniffer has been long. I have tried almost everything. There is no course for this kind of stuff. I have a clear picture… in my mind’s eye.. of what I want my app to do. There are a lot of things to take into consideration but, for now, I will take baby steps. This piece is about how to set up a curses interface and create a menu that the user can choose from.

I will be using Pycharm, Python 2.7, Anaconda on a Mac with Sierra. The O.S. that the app will be used on has linux- standard linux.

The first documentation I used was this. But that did not give me much. So I looked at this. The latter helped me start and create a menu that will give options to:

a) Run a console
b) Show a submenu (will house initialization for the tshark command to run the actual sniffer)
c)Run Eavesdrop
d) exit

This is my code:

from unicurses import *
from cursesmenu import CursesMenu, SelectionMenu
from cursesmenu.items import FunctionItem,SubmenuItem, CommandItem
from Eavesdrop import eavesdrop

menu = CursesMenu('Eavedrop Options',"When You Have Finished Run Eavesdrop")
command_item = CommandItem('Run Console Commands : ', 'Do Console Work Here: ')
function_item = FunctionItem("Run Eavesdrop", eavesdrop())
submenu = CursesMenu("This is the submenu")
submenu_item = SubmenuItem("Show a submenu", submenu, menu=menu)

At the bottom of the code, you can see three functions. Start starts the menu, join waits for the user to finish before continuing, and show…shows.

it outputs:

But, when I run the UI, the sniffer runs before the UI shows up. That is bad.

If you can tell what is wrong, please comment. For now, I will try Npyscreens again.