#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
__title__ = 'caculator'
__author__ = 'Steve'
__mtime__ = '2017/9/24'
"""
import SimpleGUICS2Pygame.simpleguics2pygame as simplegui
store = 0
operand = 0
def output():
print "Store = ", store
print "Operand = ", operand
print ""
def swap():
global store, operand
store, operand = operand, store
output()
def add():
global store, operand
store = store + operand
output()
def sub():
global store, operand
store = store - operand
output()
def mult():
global store, operand
store = store * operand
output()
def div():
global store, operand
store = store / operand
output()
def enter(inp):
global operand
operand = float(inp)
output()
f = simplegui.create_frame("Caculator", 300, 300)
f.add_button("Print", output, 100)
f.add_button("Swap", swap, 100)
f.add_button("Add", add, 100)
f.add_button("Sub", sub, 100)
f.add_button("Mult", mult, 100)
f.add_button("Div", div, 100)
f.add_input("Enter operand", enter, 100)
f.start()
练习week2 'caculator'
最新推荐文章于 2024-08-08 14:28:23 发布