Creating a Menu in Python [closed]

def my_add_fn(): print “SUM:%s”%sum(map(int,raw_input(“Enter 2 numbers seperated by a space”).split())) def my_quit_fn(): raise SystemExit def invalid(): print “INVALID CHOICE!” menu = {“1”:(“Sum”,my_add_fn), “2”:(“Quit”,my_quit_fn) } for key in sorted(menu.keys()): print key+”:” + menu[key][0] ans = raw_input(“Make A Choice”) menu.get(ans,[None,invalid])[1]()

Bootstrap 4 responsive navbar vertical

For Bootstrap 4, the breakpoints have changed. You should override the navbar CSS like this if you want it to be vertical on small screens: @media(max-width: 544px) { .navbar .navbar-nav>.nav-item { float: none; margin-left: .1rem; } .navbar .navbar-nav { float:none !important; } .navbar .collapse.in, .navbar .collapsing { clear:both; } } Demo http://codeply.com/go/Ar1H2G4JVH Note: The @media … Read more

active menu item – asp.net mvc3 master page

A custom HTML helper usually does the job fine: public static MvcHtmlString MenuLink( this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName ) { string currentAction = htmlHelper.ViewContext.RouteData.GetRequiredString(“action”); string currentController = htmlHelper.ViewContext.RouteData.GetRequiredString(“controller”); if (actionName == currentAction && controllerName == currentController) { return htmlHelper.ActionLink( linkText, actionName, controllerName, null, new { @class = “current” }); } return … Read more

creating a menu after a long click event on a list view

First you need to register your context menu on list view. lv = (ListView) findViewById(R.id.list_view); registerForContextMenu(lv); Then, just override activity methods. /** * MENU */ @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); if (v.getId()==R.id.list_view) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_list, menu); } } @Override public boolean onContextItemSelected(MenuItem item) { … Read more