ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Sylronika自用

2021-05-24 23:34:39  阅读:167  来源: 互联网

标签:150 text gui inp lab 自用 place Sylronika


电子轨道图像很重要

xarr=[]
yarr=[]

from tkinter import *    
import matplotlib.pyplot as plt
gui=Tk(className='Flugbahn eines Elektrons')
gui.minsize(700,500)
gui['bg']='lightgreen'

lab_spannung=Label(gui, text='Spannung: ', bg='lightgreen')
lab_platte=Label(gui, text='Plattenabstand: ', bg='lightgreen')
lab_v=Label(gui, text='Startgeschwindigkeit: ', bg='lightgreen')
lab_laenge=Label(gui, text='Laenge des Kondensators: ', bg='lightgreen')
lab_s=Label(gui, text='Schrittweite: ', bg='lightgreen')

lab_spannung.place(x=150,y=50)
lab_platte.place(x=150,y=80)
lab_v.place(x=150,y=110)
lab_laenge.place(x=150,y=140)
lab_s.place(x=150,y=170)


inp_spannung=Entry(gui)
inp_platte=Entry(gui)
inp_v=Entry(gui)
inp_laenge=Entry(gui)
inp_s=Entry(gui)

inp_spannung.place(x=300,y=50)
inp_platte.place(x=300,y=80)
inp_v.place(x=300,y=110)  
inp_laenge.place(x=300,y=140)
inp_s.place(x=300,y=170)


def berechnen():

const_e=1.6022e-19 # Elementarladung
const_m=9.00e-31 # Masse des Elektrons

u=inp_spannung.get()
d=inp_platte.get()
v0=inp_v.get()
l=inp_laenge.get()
s=inp_s.get()

u=float(u)    #确保为整数
d=float(d)
v0=float(v0)
l=float(l)
s=float(s)

x=0 # Startwert fuer x
xarr.clear()
yarr.clear()

while x<l:
      y=-0.5*(const_e/const_m)*(u/d)*(x/v0)**2
      print(x,y)
      xarr.append(x)
      yarr.append(y)
      x+=s

plt.plot(xarr,yarr)
plt.savefig('C:/temp/el_im_feld.jpg')
plt.show()

def beenden():
  gui.destroy()

def externe_Daten():
   file1=open('c:/temp/elektron_ext.txt','w')
   for i in range(len(xarr)):
      file1.write(str(xarr[i])+','+str(yarr[i])+'\n')
   file1.close()

   file2=open('c:/temp/elektron_ext.html','w')
   file2.write('<html><body><table border="1" bgcolor="pink">')
   for i in range(len(xarr)):
      file2.write('<tr><td>'+str(xarr[i])+'</td><td>'+str(yarr[i])+'</td></tr>')
   file2.write('</table></body></html>')
   file2.close()

rechnen=Button(gui, text='Berechnen', command=berechnen)
ende=Button(gui, text='Ende', command=beenden)
extern=Button(gui, text='Extern', command=externe_Daten)

rechnen.place(x=150,y=220)
ende.place(x=300,y=220)
extern.place(x=235,y=220)

gui.mainloop()

标签:150,text,gui,inp,lab,自用,place,Sylronika
来源: https://blog.csdn.net/weixin_51652647/article/details/117234840

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有