forked from NITDgpOS/PlotIt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui_support.py
79 lines (59 loc) · 1.88 KB
/
gui_support.py
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
#! /usr/bin/env python
#
# Support module generated by PAGE version 4.9
# In conjunction with Tcl version 8.6
# Oct 12, 2017 07:53:10 PM
import sys
try:
from Tkinter import *
except ImportError:
from tkinter import *
try:
import ttk
py3 = 0
except ImportError:
import tkinter.ttk as ttk
py3 = 1
from PIL import Image, ImageTk
from lib import plotutil as plu
# Global variable to check if any function has been plotted
plotted = False
def Plot(fx, xpoints, color_name, theme, canvas, line_style, file_path,discrete=False):
global plotted
if fx:
plu.plot(fx, xpoints, color_name, 'X-axis', 'Y-axis', theme, True, line_style, file_path,discrete)
image = Image.open(".temp/generated_plot.png").resize(
(canvas.winfo_width(), canvas.winfo_height()))
gif1 = ImageTk.PhotoImage(image, Image.ANTIALIAS)
canvas.create_image(0, 0, image=gif1, anchor=NW)
canvas.gif1 = gif1
plotted = True
else:
canvas.delete(ALL)
sys.stdout.flush()
def Plot_line(arrays, color_name, theme, canvas, line_style, file_path):
global plotted
if arrays:
plu.plot_line(arrays, color_name, 'X-axis', 'Y-axis', theme, True, line_style, file_path)
image = Image.open(".temp/generated_plot.png").resize(
(canvas.winfo_width(), canvas.winfo_height()))
gif1 = ImageTk.PhotoImage(image, Image.ANTIALIAS)
canvas.create_image(0, 0, image=gif1, anchor=NW)
canvas.gif1 = gif1
plotted = True
else:
canvas.delete(ALL)
sys.stdout.flush()
def init(top, gui, *args, **kwargs):
global w, top_level, root
w = gui
top_level = top
root = top
def destroy_window():
# Function which closes the window.
global top_level
top_level.destroy()
top_level = None
if __name__ == "__main__":
import gui_main
gui_main.vp_start_gui()