-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.py
106 lines (106 loc) · 4.28 KB
/
menu.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#/usr/bin/env python
#coding=utf-8
import wx
import squares
class myframe(wx.Frame):
def __init__(self):
wx.Frame.__init__(self,None,-1,'计算软件')
panel=wx.Panel(self)
mymenubar=wx.MenuBar()
mymenu1=wx.Menu()
mymenu2=wx.Menu()
myexit=mymenu1.Append(wx.NewId(),'&退出')
item1=mymenu2.Append(-1,'方板质量')
item2=mymenu2.Append(-1,'圆板质量')
item3=mymenu2.Append(-1,'钢管')
mymenu2.Append(-1,'材料下偏差')
mymenu2.Append(-1,'安全阀最小口径')
mymenubar.Append(mymenu1,'文件')
mymenubar.Append(mymenu2,'计算')
self.SetMenuBar(mymenubar)
self.Bind(wx.EVT_MENU,self.exit,myexit)
self.Bind(wx.EVT_MENU,self.squ,item1)
self.Bind(wx.EVT_MENU,self.cir,item2)
self.Bind(wx.EVT_MENU,self.cyl,item3)
def squ(self,event):
frame1=myframe1()
frame1.Show()
def cir(self,event):
frame2=myframe2()
frame2.Show()
def cyl(self,event):
frame3=myframe3()
frame3.Show()
def exit(self,event):
self.Close(True)
class myframe1(wx.Frame):
def __init__(self):
wx.Frame.__init__(self,None,-1,'方板质量计算')
panel=wx.Panel(self)
wx.StaticText(panel,-1,'长度(mm):',pos=(50,50))
wx.StaticText(panel,-1,'宽度(mm):',pos=(50,100))
wx.StaticText(panel,-1,'高度(mm):',pos=(50,150))
self.text1=wx.TextCtrl(panel,-1,'',pos=(160,45))
self.text2=wx.TextCtrl(panel,-1,'',pos=(160,95))
self.text3=wx.TextCtrl(panel,-1,'',pos=(160,145))
self.text4=wx.TextCtrl(panel,-1,'',pos=(200,250))
# textvalue1=text1.GetStringSelection()
self.button=wx.Button(panel,-1,'计算',pos=(100,245))
self.Bind(wx.EVT_BUTTON,self.calcu,self.button)
def calcu(self,event):
length=float(self.text1.GetValue())
width=float(self.text2.GetValue())
height=float(self.text3.GetValue())
density=7850
ans=length*width*height*7850/pow(10,9)
self.text4.SetValue(`ans`)
class myframe2(wx.Frame):
def __init__(self):
wx.Frame.__init__(self,None,-1,'圆板质量计算')
panel=wx.Panel(self)
wx.StaticText(panel,-1,'直径(mm):',pos=(50,50))
wx.StaticText(panel,-1,'厚度(mm):',pos=(50,100))
wx.StaticText(panel,-1,'数量(mm):',pos=(50,150))
self.text1=wx.TextCtrl(panel,-1,'',pos=(160,45))
self.text2=wx.TextCtrl(panel,-1,'',pos=(160,95))
self.text3=wx.TextCtrl(panel,-1,'',pos=(160,145))
self.text4=wx.TextCtrl(panel,-1,'',pos=(200,250))
# textvalue1=text1.GetStringSelection()
self.button=wx.Button(panel,-1,'计算',pos=(100,245))
self.Bind(wx.EVT_BUTTON,self.calcu,self.button)
def calcu(self,event):
pi=3.14159265357
D=float(self.text1.GetValue())
t=float(self.text2.GetValue())
quantity=float(self.text3.GetValue())
density=7850
ans=pi*D*D/4*t*quantity*7850/pow(10,9)
self.text4.SetValue(`ans`)
class myframe3(wx.Frame):
def __init__(self):
wx.Frame.__init__(self,None,-1,'方板质量计算')
panel=wx.Panel(self)
wx.StaticText(panel,-1,'直径(mm):',pos=(50,50))
wx.StaticText(panel,-1,'壁厚(mm):',pos=(50,100))
wx.StaticText(panel,-1,'长度(mm):',pos=(50,150))
self.text1=wx.TextCtrl(panel,-1,'',pos=(160,45))
self.text2=wx.TextCtrl(panel,-1,'',pos=(160,95))
self.text3=wx.TextCtrl(panel,-1,'',pos=(160,145))
self.text4=wx.TextCtrl(panel,-1,'',pos=(200,250))
# textvalue1=text1.GetStringSelection()
self.button=wx.Button(panel,-1,'计算',pos=(100,245))
self.Bind(wx.EVT_BUTTON,self.calcu,self.button)
def calcu(self,event):
pi=3.14159265357
D=float(self.text1.GetValue())
t=float(self.text2.GetValue())
d=D-2*t
length=float(self.text3.GetValue())
density=7850
ans=pi/4*(D*D-d*d)*length*7850/pow(10,9)
self.text4.SetValue(`ans`)
if __name__=='__main__':
myapp=wx.PySimpleApp()
frame=myframe()
frame.Show()
myapp.MainLoop()