wxpython总体

人到夏天就特别懒

from math import *

import wx

def sin_fun(event):
    a=text_angle.GetValue()
    b=sin(radians(float(a)))
    text_result.SetValue(str(round(b,3)))

def cos_fun(event):
    a=text_angle.GetValue()
    b=cos(radians(float(a)))
    text_result.SetValue(str(round(b,3)))

def tan_fun(event):
    a=text_angle.GetValue()
    b=tan(radians(float(a)))
    text_result.SetValue(str(round(b,3)))

def cot_fun(event):
    a = text_angle.GetValue()
    b = tan(radians(float(a)))
    text_result.SetValue(str(round(1/b, 3)))

app=wx.App()
frame=wx.Frame(None,title='waves',pos=(200,200),size=(800,400))
button_sin=wx.Button(frame,label='sin',pos=(20,20),size=(80,40))
button_cos=wx.Button(frame,label='cos',pos=(200,20),size=(80,40))
button_tan=wx.Button(frame,label='tan',pos=(380,20),size=(80,40))
button_cot=wx.Button(frame,label='cot',pos=(560,20),size=(80,40))
text=wx.StaticText(frame,label='请输入角度',pos=(290,100),size=(80,20))
text_angle=wx.TextCtrl(frame,pos=(290,150),size=(80,20))
text1=wx.StaticText(frame,label='结果',pos=(290,200),size=(80,20))
text_result=wx.TextCtrl(frame,pos=(290,250),size=(80,20))

button_sin.Bind(wx.EVT_BUTTON,sin_fun)
button_cos.Bind(wx.EVT_BUTTON,cos_fun)
button_tan.Bind(wx.EVT_BUTTON,tan_fun)
button_cot.Bind(wx.EVT_BUTTON,cot_fun)


frame.Show()
app.MainLoop()

 

 

wxpython文档:http://xoomer.virgilio.it/infinity77/wxPython/widgets.html

posted @ 2019-05-08 10:32  mghhz816  阅读(192)  评论(0编辑  收藏  举报