一 開發環境說明: python3.5+wxpython包+math包 win10環境下開發,兼任win7 編譯工具:pycharm 二 運行界面展示: 三 開源共用: 四 打包xe文件下載地址: 百度網盤:https://pan.baidu.com/s/15Ee0xfJNYUCUpKViLIQQq ...
一 開發環境說明:
python3.5+wxpython包+math包
win10環境下開發,兼任win7
編譯工具:pycharm
二 運行界面展示:
三 開源共用:
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何處藏。縱使上線又如何,新版本,繼續忙。黑白顛倒沒商量,睡地鋪,吃食堂。夜半夢醒,無人在身旁。最怕燈火闌珊時,手機響,心裡慌。