コード例 #1
0
ファイル: main.py プロジェクト: interwho/WinCalc
def paperTape(): #Build the Paper Tape Window
    global tapetext
    global papertape
    try:
        papertape.destroy()
    except:
        error = True #print "DEBUG - NO PAPER TAPE"
    papertape = Gui()
    papertape.option_add( "*font", "Arial 9" )
    papertape.minsize(300,400)
    papertape.maxsize(300,400)
    papertape.iconbitmap('icon.ico')
    papertape.title("WinCalc (Paper Tape)")
    menubar = Menu(papertape)
    filemenu = Menu(menubar, tearoff=0)
    filemenu.add_command(label="Save to File", command=saveTape)
    filemenu.add_separator()
    filemenu.add_command(label="Close", command=papertape.destroy)
    menubar.add_cascade(label="File", menu=filemenu)
    editmenu = Menu(menubar, tearoff=0)
    editmenu.add_command(label="Copy All", command=copyButtonp)
    editmenu.add_separator()
    editmenu.add_command(label="Select All", command=selectallButtonp)
    editmenu.add_command(label="Clear Paper Tape", command=clearButtonp)
    menubar.add_cascade(label="Edit", menu=editmenu)
    papertape.config(menu=menubar)
    tapetext = papertape.te(width=280, height=390, padx=2, pady=2, ipadx=2, ipady=2, borderwidth = 1, relief = SUNKEN)
    papertape.mainloop()
コード例 #2
0
ファイル: main.py プロジェクト: interwho/WinCalc
def tableMode(): #Build the Table Mode Window
    global tableentry
    global tableentrymin
    global tableentrymax
    global tableentrystep
    global tabletext
    global tablemode
    try:
        tablemode.destroy()
    except:
        error = True #print "DEBUG - NO TABLE ENABLED"
    tablemode = Gui()
    tablemode.option_add( "*font", "Arial 9" )
    tablemode.minsize(300,420)
    tablemode.maxsize(300,420)
    tablemode.iconbitmap('icon.ico')
    tablemode.title("WinCalc (Table Mode)")
    menubar = Menu(tablemode)
    filemenu = Menu(menubar, tearoff=0)
    filemenu.add_command(label="Save to File", command=saveTable)
    filemenu.add_separator()
    filemenu.add_command(label="Close", command=tablemode.destroy)
    menubar.add_cascade(label="File", menu=filemenu)
    editmenu = Menu(menubar, tearoff=0)
    editmenu.add_command(label="Copy All", command=copyButtont)
    editmenu.add_separator()
    editmenu.add_command(label="Select All", command=selectallButtont)
    editmenu.add_command(label="Clear Table", command=clearButtont)
    menubar.add_cascade(label="Edit", menu=editmenu)
    tablemode.config(menu=menubar)
    tablemode.gr(cols=2)
    tablemode.la(text="f(x)=")
    tableentry = tablemode.te(width=20,height=1,font=("Courier New", 16))
    tablemode.la(text="MIN=")
    tableentrymin = tablemode.te(width=20,height=1,font=("Courier New", 16))
    tablemode.la(text="MAX=")
    tableentrymax = tablemode.te(width=20,height=1,font=("Courier New", 16))
    tablemode.la(text="STEP")
    tableentrystep = tablemode.te(width=20,height=1,font=("Courier New", 16))
    tablemode.endgr()
    tablemode.gr(cols=1)
    tablemode.bu("Get Table of Values",command=tableIt)
    tablemode.endgr()
    tabletext = tablemode.te(width=280, height=390, padx=2, pady=2, ipadx=2, ipady=2, borderwidth = 1, relief = SUNKEN)
    tkMessageBox.showinfo(title="WinCalc Table Mode - Instructions", message="The table of values generator uses the same syntax as the advanced calculator. Radian mode only.")
    tablemode.mainloop()
コード例 #3
0
ファイル: main.py プロジェクト: interwho/WinCalc
def advCalc(): #Advanced Calculator
    global window
    global display
    global prevans
    global mrc
    prevans = ''
    window.destroy()
    window = Gui()
    window.option_add( "*font", "Arial 9" ) 
    window.minsize(300,400)
    window.maxsize(300,400)
    window.iconbitmap('icon.ico')
    window.title("WinCalc (Advanced Mode)")
    window.bind('<Return>', solveAdv)
    window.bind('<Control-a>', selectallButton)
    window.bind('<Control-A>', selectallButton)
    window.bind('<Control-v>', pasteButton)
    window.bind('<Control-V>', pasteButton)
    window.bind('<Control-e>', copyButton)
    window.bind('<Control-E>', copyButton)
    menubar = Menu(window)
    filemenu = Menu(menubar, tearoff=0)
    filemenu.add_command(label="Basic Mode", command=basicCalc)
    filemenu.add_command(label="Reset Calculator", command=advCalc)
    filemenu.add_separator()
    filemenu.add_command(label="Radian Mode", command=radMode)
    filemenu.add_command(label="Degree Mode", command=degMode)
    filemenu.add_separator()
    filemenu.add_command(label="Exit", command=exitProgram)
    menubar.add_cascade(label="File", menu=filemenu)
    editmenu = Menu(menubar, tearoff=0)
    editmenu.add_command(label="Undo", command=undoButton)
    editmenu.add_separator()
    editmenu.add_command(label="Cut Equation", command=cutButton)
    editmenu.add_command(label="Copy Equation (Ctrl-E)", command=copyButton)
    editmenu.add_command(label="Paste Equation (Ctrl-V)", command=pasteButton)
    editmenu.add_separator()
    editmenu.add_command(label="Select All (Ctrl-A)", command=selectallButton)
    editmenu.add_command(label="Clear Equation", command=clearButton)
    menubar.add_cascade(label="Edit", menu=editmenu)
    goodies = Menu(menubar, tearoff=0)
    goodies.add_command(label="Equation Grapher", command=grapherCalc)
    goodies.add_command(label="Table of Values Generator", command=tableMode)
    goodies.add_separator()
    goodies.add_command(label="Show Paper Tape", command=paperTape)
    menubar.add_cascade(label="Goodies", menu=goodies)
    helpmenu = Menu(menubar, tearoff=0)
    helpmenu.add_command(label="Instructions - Basic Mode", command=basicDialog)
    helpmenu.add_command(label="Instructions - Advanced Mode", command=advDialog)
    helpmenu.add_separator()
    helpmenu.add_command(label="About", command=aboutDialog)
    menubar.add_cascade(label="Help", menu=helpmenu)
    window.config(menu=menubar)
    window.row()
    display = window.te(width=10, height=2, padx=2, pady=2, ipadx=2, ipady=2, borderwidth = 1, relief = SUNKEN, font=("Courier New", 16))
    window.endrow()
    window.row(pady=5,padx=5)
    window.gr(cols=5)
    ###BEGIN BUTTONS###
    mrc = window.bu(text='MRC',width=5,command=memRc)
    window.bu(text='M+',width=5,command=amemPlus)
    window.bu(text='M-',width=5,command=amemMinus)
    window.bu(text='DEL',width=5,command=delButton)
    window.bu(text='AC',width=5,command=clearDisplay)
    ######BEGIN ADVANCED FUNCTIONS#######
    window.la(dmode)
    window.bu(text='1/x',width=5,command=Callable(buttonPress,'1/('))
    window.bu(text='x^x',width=5,command=Callable(buttonPress,'**'))
    window.bu(text='x^2',width=5,command=Callable(buttonPress,'**2'))
    window.bu(text='π',width=5,command=Callable(buttonPress,'(3.14159265359)'))
    ##
    window.bu(text='sin^-1',width=5,command=Callable(buttonPress,'sin^-1('))
    window.bu(text='cos^-1',width=5,command=Callable(buttonPress,'cos^-1('))
    window.bu(text='tan^-1',width=5,command=Callable(buttonPress,'tan^-1('))
    window.bu(text='sinh',width=5,command=Callable(buttonPress,'sinh('))
    window.bu(text='sinh^-1',width=5,command=Callable(buttonPress,'sinh^-1('))
    ##
    window.bu(text='sin',width=5,command=Callable(buttonPress,'sin('))
    window.bu(text='cos',width=5,command=Callable(buttonPress,'cos('))
    window.bu(text='tan',width=5,command=Callable(buttonPress,'tan('))
    window.bu(text='cosh',width=5,command=Callable(buttonPress,'cosh('))
    window.bu(text='cosh^-1',width=5,command=Callable(buttonPress,'cosh^-1('))
    ##
    window.bu(text='DEG(x)',width=5,command=Callable(buttonPress,'degrees('))
    window.bu(text='RAD(x)',width=5,command=Callable(buttonPress,'radians('))
    window.bu(text='Ran#',width=5,command=Callable(buttonPress,'Ran#'))
    window.bu(text='tanh',width=5,command=Callable(buttonPress,'tanh('))
    window.bu(text='tanh^-1',width=5,command=Callable(buttonPress,'tanh^-1('))
    ##
    window.bu(text='DICE',width=5,command=diceRoll)
    window.bu(text='D->BIN',width=5,command=binConvert)
    window.bu(text='D->OCT',width=5,command=octConvert)
    window.bu(text='D->HEX',width=5,command=hexConvert)
    window.bu(text='x(2)√x(1)',width=5,command=Callable(buttonPress,'**(1.0/'))
    ##
    window.bu(text='(',width=5,command=Callable(buttonPress,'('))
    window.bu(text=')',width=5,command=Callable(buttonPress,')'))
    window.bu(text='x!',width=5,command=Callable(buttonPress,'!('))
    window.bu(text='ln(x)',width=5,command=Callable(buttonPress,'ln('))
    window.bu(text='e^x',width=5,command=Callable(buttonPress,'(2.71828182846)**'))
    ###END ADVANCED FUNCTIONS###
    window.bu(text='7',width=5,command=Callable(buttonPress,7))
    window.bu(text='8',width=5,command=Callable(buttonPress,8))
    window.bu(text='9',width=5,command=Callable(buttonPress,9))
    window.bu(text='%',width=5,command=Callable(buttonPress,'*0.01'))
    window.bu(text='+/-',width=5,command=Callable(buttonPress,'*-1'))
    ##
    window.bu(text='4',width=5,command=Callable(buttonPress,4))
    window.bu(text='5',width=5,command=Callable(buttonPress,5))
    window.bu(text='6',width=5,command=Callable(buttonPress,6))
    window.bu(text='×',width=5,command=Callable(buttonPress,'*'))
    window.bu(text='÷',width=5,command=Callable(buttonPress,'/'))
    ##
    window.bu(text='1',width=5,command=Callable(buttonPress,1))
    window.bu(text='2',width=5,command=Callable(buttonPress,2))
    window.bu(text='3',width=5,command=Callable(buttonPress,3))
    window.bu(text='+',width=5,command=Callable(buttonPress,'+'))
    window.bu(text='−',width=5,command=Callable(buttonPress,'-'))
    ##
    window.bu(text='0',width=5,command=Callable(buttonPress,0))
    window.bu(text='.',width=5,command=Callable(buttonPress,'.'))
    window.bu(text='Ans',width=5,command=prevAns)
    window.bu(text='√',width=5,command=Callable(buttonPress,'sqrt('))
    window.bu(text='=',width=5,command=solveAdv)
    ###END BUTTONS###
    window.endgr()
    window.endrow()
    display.focus_set()
    window.mainloop()
    try:
        papertape.destroy()
    except:
        error = True #print "DEBUG - NO PAPER TAPE ENABLED"
    try:
        grapher.destroy()
    except:
        error = True #print "DEBUG - NO GRAPHER ENABLED"
コード例 #4
0
ファイル: main.py プロジェクト: interwho/WinCalc
def basicCalc(): #Basic Calculator
    global window
    global display
    global prevans
    global mrc
    prevans = ''
    window.destroy()
    window = Gui()
    window.option_add( "*font", "Arial 9" ) 
    window.minsize(300,240)
    window.maxsize(300,240)
    window.iconbitmap('icon.ico')
    window.title("WinCalc (Basic Mode)")
    window.bind('<Return>', solveEqn)
    window.bind('<Control-a>', selectallButton)
    window.bind('<Control-A>', selectallButton)
    window.bind('<Control-v>', pasteButton)
    window.bind('<Control-V>', pasteButton)
    window.bind('<Control-e>', copyButton)
    window.bind('<Control-E>', copyButton)
    menubar = Menu(window)
    filemenu = Menu(menubar, tearoff=0)
    filemenu.add_command(label="Advanced Mode", command=advCalc)
    filemenu.add_command(label="Reset Calculator", command=basicCalc)
    filemenu.add_separator()
    filemenu.add_command(label="Exit", command=exitProgram)
    menubar.add_cascade(label="File", menu=filemenu)
    editmenu = Menu(menubar, tearoff=0)
    editmenu.add_command(label="Undo", command=undoButton)
    editmenu.add_separator()
    editmenu.add_command(label="Cut Equation", command=cutButton)
    editmenu.add_command(label="Copy Equation (Ctrl-E)", command=copyButton)
    editmenu.add_command(label="Paste Equation (Ctrl-V)", command=pasteButton)
    editmenu.add_separator()
    editmenu.add_command(label="Select All (Ctrl-A)", command=selectallButton)
    editmenu.add_command(label="Clear Equation", command=clearButton)
    menubar.add_cascade(label="Edit", menu=editmenu)
    goodies = Menu(menubar, tearoff=0)
    goodies.add_command(label="Equation Grapher", command=grapherCalc)
    goodies.add_command(label="Table of Values Generator", command=tableMode)
    goodies.add_separator()
    goodies.add_command(label="Show Paper Tape", command=paperTape)
    menubar.add_cascade(label="Goodies", menu=goodies)
    helpmenu = Menu(menubar, tearoff=0)
    helpmenu.add_command(label="Instructions - Basic Mode", command=basicDialog)
    helpmenu.add_command(label="Instructions - Advanced Mode", command=advDialog)
    helpmenu.add_separator()
    helpmenu.add_command(label="About", command=aboutDialog)
    menubar.add_cascade(label="Help", menu=helpmenu)
    window.config(menu=menubar)
    window.row()
    display = window.te(width=10, height=2, padx=2, pady=2, ipadx=2, ipady=2, borderwidth = 1, relief = SUNKEN, font=("Courier New", 16))
    window.endrow()
    window.row(pady=5,padx=5)
    window.gr(cols=5)
    mrc = window.bu(text='MRC',width=5,command=memRc)
    window.bu(text='M+',width=5,command=memPlus)
    window.bu(text='M-',width=5,command=memMinus)
    window.bu(text='DEL',width=5,command=delButton)
    window.bu(text='AC',width=5,command=clearDisplay)
    window.bu(text='7',width=5,command=Callable(buttonPress,7))
    window.bu(text='8',width=5,command=Callable(buttonPress,8))
    window.bu(text='9',width=5,command=Callable(buttonPress,9))
    window.bu(text='%',width=5,command=percentButton)
    window.bu(text='+/-',width=5,command=plusMinus)
    window.bu(text='4',width=5,command=Callable(buttonPress,4))
    window.bu(text='5',width=5,command=Callable(buttonPress,5))
    window.bu(text='6',width=5,command=Callable(buttonPress,6))
    window.bu(text='×',width=5,command=Callable(buttonPress,'*'))
    window.bu(text='÷',width=5,command=Callable(buttonPress,'/'))
    window.bu(text='1',width=5,command=Callable(buttonPress,1))
    window.bu(text='2',width=5,command=Callable(buttonPress,2))
    window.bu(text='3',width=5,command=Callable(buttonPress,3))
    window.bu(text='+',width=5,command=Callable(buttonPress,'+'))
    window.bu(text='−',width=5,command=Callable(buttonPress,'-'))
    window.bu(text='0',width=5,command=Callable(buttonPress,0))
    window.bu(text='.',width=5,command=Callable(buttonPress,'.'))
    window.bu(text='Ans',width=5,command=prevAns)
    window.bu(text='√',width=5,command=squareRoot)
    window.bu(text='=',width=5,command=solveEqn)
    window.endgr()
    window.endrow()
    display.focus_set()
    window.mainloop()
    try:
        papertape.destroy()
    except:
        error = True #print "DEBUG - NO PAPER TAPE ENABLED"
    try:
        grapher.destroy()
    except:
        error = True #print "DEBUG - NO GRAPHER ENABLED"