欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

自学python---03_Spur计算工具开发

程序员文章站 2022-11-21 21:15:03
一 开发环境说明: python3.5+wxpython包+math包 win10环境下开发,兼任win7 编译工具:pycharm 二 运行界面展示: 三 开源共享: 四 打包xe文件下载地址: 百度网盘:https://pan.baidu.com/s/15Ee0xfJNYUCUpKViLIQQq ......

一 开发环境说明:

  python3.5+wxpython包+math包

  win10环境下开发,兼任win7

  编译工具:pycharm

 

二 运行界面展示:

自学python---03_Spur计算工具开发

 

自学python---03_Spur计算工具开发

 

三 开源共享:

  1 #! /user/bin/env python
  2 #coding=utf-8
  3 import sys
  4 sys.path.append('c:\program files\python35\lib\site-packages')
  5 import wx
  6 import math
  7 
  8 class myframe(wx.frame):
  9     def __init__(self):
 10         wx.frame.__init__(self,none,-1,"spur计算_chenyuyang",size=(560,300))
 11         self.center()
 12         panel = wx.panel(self)
 13         panel.center()
 14 
 15         boxsize= wx.boxsizer(wx.vertical)
 16         font = wx.font(16,wx.roman,wx.normal,wx.bold,underline=false)
 17         font1 = wx.font(8,wx.roman,wx.normal,wx.bold,underline = false)
 18         font2 = wx.font(10,wx.roman,wx.normal,wx.bold,underline = false)
 19 
 20         self.btn0 = wx.statictext(panel,-1,label='\n信号频率',style = wx.align_center)
 21         self.btn1 = wx.textctrl(panel,-1)
 22 
 23         self.btn2 = wx.statictext(panel,-1,label='\n干扰频率',style = wx.align_center)
 24         self.btn3 = wx.textctrl(panel,-1)
 25 
 26         self.btn4 = wx.statictext(panel,-1,label='\nn次谐波',style = wx.align_center)
 27         self.btn5 = wx.textctrl(panel,-1)
 28 
 29         self.btn6 = wx.statictext(panel,-1,label='\nspur值',style = wx.align_center)
 30         self.btn7 = wx.textctrl(panel,-1)
 31 
 32         self.btn8 = wx.button(panel,-1,label='计算')
 33         self.btn9 = wx.button(panel, -1, label='清除')
 34 
 35         self.btn8.bind(wx.evt_button,self.oneclick)
 36         self.btn9.bind(wx.evt_button, self.oneclick1)
 37 
 38         for i in range(10,20):
 39             j = i - 9
 40             exec("self.btn%s = wx.button(panel,label='%s')"%(i,j))
 41 
 42         for i in range(20,30):
 43             exec("self.btn%s = wx.textctrl(panel,-1)"%i)
 44 
 45         for i in range(30, 40):
 46             j = i - 19
 47             exec("self.btn%s = wx.button(panel,label='%s')" % (i, j))
 48 
 49         for i in range(40, 50):
 50             exec("self.btn%s = wx.textctrl(panel,-1)" %i)
 51 
 52         for i in range(50, 60):
 53             j = i - 29
 54             exec("self.btn%s = wx.button(panel,label='%s')" % (i, j))
 55 
 56         for i in range(60, 70):
 57             exec("self.btn%s = wx.textctrl(panel,-1)" %i)
 58 
 59         for i in range(70, 80):
 60             j = i - 9
 61             exec("self.btn%s = wx.button(panel,label='%s')" % (i, j))
 62 
 63         for i in range(80, 90):
 64             exec("self.btn%s = wx.textctrl(panel,-1)" %i)
 65 
 66 
 67         for i in range(0,10):
 68             exec("self.btn%s.setfont(font1)"%i)
 69 
 70         for i in range(10,90):
 71             exec("self.btn%s.setfont(font)" %i)
 72 
 73         for i in range(20,30):
 74             exec("self.btn%s.setfont(font2)"%i)
 75 
 76         for i in range(40,50):
 77             exec("self.btn%s.setfont(font2)"%i)
 78 
 79         for i in range(60,70):
 80             exec("self.btn%s.setfont(font2)"%i)
 81 
 82         for i in range(80,90):
 83             exec("self.btn%s.setfont(font2)"%i)
 84 
 85         gridsizer = wx.gridsizer(cols = 10,rows = 9,vgap = 0,hgap = 0)
 86 
 87         gridsizer.addmany([(self.btn0,0,wx.expand),
 88         (self.btn1,0,wx.expand),
 89         (self.btn2, 0, wx.expand),
 90         (self.btn3, 0, wx.expand),
 91         (self.btn4, 0, wx.expand),
 92         (self.btn5, 0, wx.expand),
 93         (self.btn6, 0, wx.expand),
 94         (self.btn7, 0, wx.expand),
 95         (self.btn8, 0, wx.expand),
 96         (self.btn9, 0, wx.expand),
 97         (self.btn10, 0, wx.expand),
 98         (self.btn11, 0, wx.expand),
 99         (self.btn12, 0, wx.expand),
100         (self.btn13, 0, wx.expand),
101         (self.btn14, 0, wx.expand),
102         (self.btn15, 0, wx.expand),
103         (self.btn16, 0, wx.expand),
104         (self.btn17, 0, wx.expand),
105         (self.btn18, 0, wx.expand),
106         (self.btn19, 0, wx.expand),
107         (self.btn20, 0, wx.expand),
108         (self.btn21,0,wx.expand),
109         (self.btn22, 0, wx.expand),
110         (self.btn23, 0, wx.expand),
111         (self.btn24, 0, wx.expand),
112         (self.btn25, 0, wx.expand),
113         (self.btn26, 0, wx.expand),
114         (self.btn27, 0, wx.expand),
115         (self.btn28, 0, wx.expand),
116         (self.btn29, 0, wx.expand),
117         (self.btn30, 0, wx.expand),
118         (self.btn31, 0, wx.expand),
119         (self.btn32, 0, wx.expand),
120         (self.btn33, 0, wx.expand),
121         (self.btn34, 0, wx.expand),
122         (self.btn35, 0, wx.expand),
123         (self.btn36, 0, wx.expand),
124         (self.btn37, 0, wx.expand),
125         (self.btn38, 0, wx.expand),
126         (self.btn39, 0, wx.expand),
127         (self.btn40, 0, wx.expand),
128         (self.btn41, 0, wx.expand),
129         (self.btn42, 0, wx.expand),
130         (self.btn43, 0, wx.expand),
131         (self.btn44, 0, wx.expand),
132         (self.btn45, 0, wx.expand),
133         (self.btn46, 0, wx.expand),
134         (self.btn47, 0, wx.expand),
135         (self.btn48, 0, wx.expand),
136         (self.btn49, 0, wx.expand),
137         (self.btn50, 0, wx.expand),
138         (self.btn51, 0, wx.expand),
139         (self.btn52, 0, wx.expand),
140         (self.btn53, 0, wx.expand),
141         (self.btn54, 0, wx.expand),
142         (self.btn55, 0, wx.expand),
143         (self.btn56, 0, wx.expand),
144         (self.btn57, 0, wx.expand),
145         (self.btn58, 0, wx.expand),
146         (self.btn59, 0, wx.expand),
147         (self.btn60, 0, wx.expand),
148         (self.btn61, 0, wx.expand),
149         (self.btn62, 0, wx.expand),
150         (self.btn63, 0, wx.expand),
151         (self.btn64, 0, wx.expand),
152         (self.btn65, 0, wx.expand),
153         (self.btn66, 0, wx.expand),
154         (self.btn67, 0, wx.expand),
155         (self.btn68, 0, wx.expand),
156         (self.btn69, 0, wx.expand),
157         (self.btn70, 0, wx.expand),
158         (self.btn71, 0, wx.expand),
159         (self.btn72, 0, wx.expand),
160         (self.btn73, 0, wx.expand),
161         (self.btn74, 0, wx.expand),
162         (self.btn75, 0, wx.expand),
163         (self.btn76, 0, wx.expand),
164         (self.btn77, 0, wx.expand),
165         (self.btn78, 0, wx.expand),
166         (self.btn79, 0, wx.expand),
167         (self.btn80, 0, wx.expand),
168         (self.btn81, 0, wx.expand),
169         (self.btn82, 0, wx.expand),
170         (self.btn83, 0, wx.expand),
171         (self.btn84, 0, wx.expand),
172         (self.btn85, 0, wx.expand),
173         (self.btn86, 0, wx.expand),
174         (self.btn87, 0, wx.expand),
175         (self.btn88, 0, wx.expand),
176         (self.btn89, 0, wx.expand)])
177 
178         for i in range(10,20):
179             exec("self.btn%s.backgroundcolour='pale green'"%i)
180 
181         for i in range(30,40):
182             exec("self.btn%s.backgroundcolour='pale green'" %i)
183 
184         for i in range(50, 60):
185             exec("self.btn%s.backgroundcolour='pale green'" %i)
186 
187         for i in range(70, 80):
188             exec("self.btn%s.backgroundcolour='pale green'" %i)
189 
190         self.btn9.backgroundcolour = 'pink'
191         self.btn8.backgroundcolour = 'aquamarine'
192 
193         boxsize.add(gridsizer,6,wx.expand)
194         panel.setsizerandfit(boxsize)
195 
196     def oneclick(self,event):
197         str18 = self.btn1.getvalue()
198         a19 = float(str18)
199 
200         str21 = self.btn3.getvalue()
201         a11 = float(str21)
202 
203         for a15 in range(1,11):
204             x = a15*a11
205             y = int(x/a19)
206             z = x - y*a19
207 
208             if z < a19/2:
209                 a38 = z
210             else:
211                 a38 = a19 - z
212             a39 = int(a38*10**5)/(10**5)
213 
214             a40 = "%.5f"%a39
215             j = a15 + 19
216 
217             exec("self.btn%s.setvalue('%s')"%(j,a40))
218 
219         for a15 in range(11, 21):
220             x = a15 * a11
221             y = int(x / a19)
222             z = x - y * a19
223 
224             if z < a19 / 2:
225                 a38 = z
226             else:
227                 a38 = a19 - z
228             a39 = int(a38 * 10 ** 5) / (10 ** 5)
229 
230             a40 = "%.5f" % a39
231             j = a15 + 29
232 
233             exec("self.btn%s.setvalue('%s')" % (j, a40))
234 
235         for a15 in range(21, 31):
236             x = a15 * a11
237             y = int(x / a19)
238             z = x - y * a19
239 
240             if z < a19 / 2:
241                 a38 = z
242             else:
243                 a38 = a19 - z
244             a39 = int(a38 * 10 ** 5) / (10 ** 5)
245 
246             a40 = "%.5f" % a39
247             j = a15 + 39
248 
249             exec("self.btn%s.setvalue('%s')" % (j, a40))
250 
251         for a15 in range(31, 41):
252             x = a15 * a11
253             y = int(x / a19)
254             z = x - y * a19
255 
256             if z < a19 / 2:
257                 a38 = z
258             else:
259                 a38 = a19 - z
260             a39 = int(a38 * 10 ** 5) / (10 ** 5)
261 
262             a40 = "%.5f" % a39
263             j = a15 + 49
264 
265             exec("self.btn%s.setvalue('%s')" % (j, a40))
266 
267 
268             str18 = self.btn1.getvalue()
269             a19 = float(str18)
270 
271             str21 = self.btn3.getvalue()
272             a11 = float(str21)
273 
274             str38 = self.btn5.getvalue()
275             a15 = float(str38)
276 
277             x = a15*a11
278             y=int(x/a19)
279             z = x -y*a19
280 
281             if z < a19/2:
282                 a38 = z
283             else:
284                 a38 = a19 -z
285 
286             self.btn7.setvalue("%.5f"%a39)
287 
288 
289     def oneclick1(self,event):
290         self.btn1.clear()
291         self.btn3.clear()
292         self.btn5.clear()
293         self.btn7.clear()
294 
295         for i in range(20,30):
296             exec("self.btn%s.clear()"%i)
297 
298         for i in range(40,50):
299             exec("self.btn%s.clear()"%i)
300 
301         for i in range(60,70):
302             exec("self.btn%s.clear()"%i)
303 
304         for i in range(80,90):
305             exec("self.btn%s.clear()"%i)
306 
307 class app(wx.app):
308     def oninit(self):
309         self.cyy = myframe()
310         self.cyy.bind(wx.evt_close,self.onclose,self.cyy)
311         self.cyy.show()
312         return true
313 
314     def onclose(self,event):
315         dlg = wx.messagedialog(none,"陈玉洋提示您:是否要关闭窗口?","请确认",wx.yes_no | wx.icon_question)
316         retcode = dlg.showmodal()
317         if(retcode == wx.id_yes):
318             self.cyy.destroy()
319         else:
320             pass
321 if __name__ == '__main__':
322     app = app()
323     app.mainloop()

 

四 打包xe文件下载地址:

  百度网盘:https://pan.baidu.com/s/15ee0xfjnyucupkviliqqqw

 

十年编程两茫茫,工期短,需求长。千行代码,bug何处藏。纵使上线又如何,新版本,继续忙。黑白颠倒没商量,睡地铺,吃食堂。夜半梦醒,无人在身旁。最怕灯火阑珊时,手机响,心里慌。