Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback #1

Open
wants to merge 2 commits into
base: feedback
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 69 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,69 @@
#!/usr/bin/env python3


with open("soubor.txt", "r") as f:
pass
import pylab as pl
import tkinter as tk
from pylab import linspace, pi, plot,sin,cos, show,grid,legend
from os.path import basename, splitext
from tkinter import *
class Application(tk.Tk):
name = basename(splitext(basename(__file__.capitalize()))[0])
name = "Graf"
def __init__(self):
super().__init__(className=self.name)
self.var_entryP = tk.IntVar()
self.var_entryF = tk.IntVar()
self.var_entryA = tk.IntVar()
self.title(self.name)
self.bind("<Escape>", self.quit)
self.lbl = tk.Label(self, text="Graf")
self.lbl.pack()
self.btnVypsat = tk.Button(self, text="Načtení ze souboru", command=self.zeSouboru)
self.btnVypsat.pack()
self.lbl1 = tk.Label(self, text=" Napište počet period")
self.lbl1.pack()
self.entryP = tk.Entry(self, textvariable = self.var_entryP)
self.entryP.pack()
self.lbl3 = tk.Label(self, text="Napište Frekvenci")
self.lbl3.pack()
self.entryF = tk.Entry(self, textvariable = self.var_entryF)
self.entryF.pack()
self.lbl4 = tk.Label(self, text="Napište Amplitudu")
self.lbl4.pack()
self.entryA = tk.Entry(self, textvariable = self.var_entryA)
self.entryA.pack()
self.btnGraf = tk.Button(self, text="Načtení grafu", command=self.graf)
self.btnGraf.pack()
self.btn = tk.Button(self, text="Odejít", command=self.quit)
self.btn.pack()
def about(self):
window = About(self)
window.grab_set()
def quit(self, event=None):
super().quit()
def graf(self):
self.f = self.var_entryF.get()
self.a = self.var_entryA.get()
self.p = self.var_entryP.get()
t = pl.linspace(0, self.p/self.f, self.f*10000)
y = self.a * (pl.cos(2*pi*self.f*t ))
pl.plot(t,y)
pl.title("výkon")
pl.xlabel("t[s]")
pl.ylabel("u[V],i[A], p[W]")
pl.show()
def zeSouboru(self):
f = open("soubor-win.txt", "r")
x = []
y = []
while 1:
radek = f.readline()
if radek =="":
break
cisla = radek.split()
x.append(float(cisla[0]))
y.append(float(cisla[1]))
f.close()
pl.figure()
pl.plot(x,y)
pl.grid(True)
pl.show()
app = Application()
app.mainloop()