-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraf_z_txt.py
More file actions
86 lines (65 loc) · 2.16 KB
/
Copy pathgraf_z_txt.py
File metadata and controls
86 lines (65 loc) · 2.16 KB
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
import tkinter as tk
from tkinter import messagebox
from tkinter import filedialog
import pylab as pl
"""
messagebox.showerror("Titulek","Soráč eroráč")
odpoved = messagebox.askquestion("titulek","message", icon = "icon")
print(odpoved)
soubor = filedialog.askopenfile(title = "vyber soubor", initialdir="/")
print(soubor)
"""
class MyEntry(tk.Entry):
def __init__(self, master=None, cnf={}, **kw):
super().__init__(master, cnf, **kw)
if "textvariable" not in kw:
self.variable = tk.StringVar()
self.config(textvariable=self.variable)
else:
self.variable = kw["textvariable"]
@property
def value(self):
return self.variable.get()
@value.setter
def value(self, new: str):
self.variable.set(new)
class Application(tk.Tk):
name = "Foo"
title_ = "dialogy"
def __init__(self):
super().__init__(className=self.name)
self.title(self.title_)
self.bind("<Escape>", self.quit)
self.lbl = tk.Label(self, text="...")
self.lbl.pack()
self.btn1 = tk.Button(self, text="načíst",width= 5)
self.btn1.pack(side="top")
self.btn1.bind("<ButtonRelease-1>",self.soubor)
self.btn2 = tk.Button(self, text="spustit",width= 5)
self.btn2.pack(side="top")
self.btn2.bind("<ButtonRelease-1>",self.show)
def show(self,event=None):
axisx = []
axisy = []
with open(self.filename,"r") as f:
while True:
line = f.readline()
if line == "":
break
linesplit = line.split()
if len(linesplit) == 2:
x, y = line.split()
axisx.append(float(x))
axisy.append(float(y))
print(axisx)
print(axisy)
pl.plot(axisx,axisy)
pl.grid(True)
pl.show()
def soubor(self,event=None):
self.filename = filedialog.askopenfilename()
self.lbl.config(text=self.filename)
def quit(self, event=None):
super().quit()
app = Application()
app.mainloop()