#!/usr/bin/env python ## CURSES BASIC-MAIL GUI # This is the Basic-Mail program, a basic email client written in python # with a curses interface. # # To Run: Go to the Basic-Mail directory and type "python Basic-Mail.py", # without the quotes. # If it doesn't open, make sure that the size of the console window # is at least 80 x 30 pixels. ## ## Filename: pop_up.py ## # This file contains functions that deal with pop ups. ## ## IMPORTS ## import curses, curses.ascii, curses.panel # Curses imports import traceback, os, sys, select, string # Random imports from variables import * # Imports all variables from draw import * # Imports the window drawing functions ## Function: Creates appropriate pop-up window for the option selected. ## Different functions programmed for each option. ## Also returns different things depending on the option selected. ## Fourth variables, selection, determines function: ## 0 = Quits, 1: Cannot Close Tab, 2: Cannot Open Tab ## Usage: live = create_pop_up(0) def create_pop_up(selection): # If the user selects Quit from the File menu if selection == 0: pop_up_win = curses.newwin(4,30,13,25) pop_up = curses.panel.new_panel(pop_up_win) fill_line(pop_up_win, 30,"Quit",' ',2,0) draw_borders(pop_up_win,30,4) pop_up_win.addstr(1,4,"Would you like to exit?") pop_up_win.addstr(2,9,"[Yes] or [No]") pop_up_win.addch(2,10,'Y',curses.color_pair(3)) pop_up_win.addch(2,19,'N',curses.color_pair(3)) # Waits for the user's response live = 1 while(live): pop_up_win.move(0,0) # Moves cursor input = pop_up_win.getch(0,0) # Takes input at location if curses.ascii.unctrl(input) == 'y' or\ curses.ascii.unctrl(input) == 'Y': return 0 live = 0 elif curses.ascii.unctrl(input) == 'n' or\ curses.ascii.unctrl(input) == 'N': return 1 live = 0 # If the user has selected to close the last open tab elif selection == 1: pop_up_win = curses.newwin(5,30,13,25) pop_up = curses.panel.new_panel(pop_up_win) fill_line(pop_up_win, 30,"Quit",' ',2,0) draw_borders(pop_up_win,30,5) pop_up_win.addstr(1,4,"The last remaining tab") pop_up_win.addstr(2,6,"cannot be closed.") pop_up_win.addstr(3,11,"[Enter]",curses.color_pair(3)) # Waits for the user's response live = 1 while(live): pop_up_win.move(0,0) # Moves cursor input = pop_up_win.getch(0,0) # Takes input at location if input == ord('\n'): live = 0 elif selection == 2: pop_up_win = curses.newwin(5,34,13,23) pop_up = curses.panel.new_panel(pop_up_win) fill_line(pop_up_win, 34,"Quit",' ',2,0) draw_borders(pop_up_win,34,5) pop_up_win.addstr(1,3,"There are too many tabs open.") pop_up_win.addstr(2,6,"You cannot open another.") pop_up_win.addstr(3,13,"[Enter]",curses.color_pair(3)) # Waits for the user's response live = 1 while(live): pop_up_win.move(0,0) # Moves cursor input = pop_up_win.getch(0,0) # Takes input at location if input == ord('\n'): live = 0 else: return 0