Skip to content

Commit

Permalink
Report in Tkinter GUI window
Browse files Browse the repository at this point in the history
Used matplotlib.backends.backend_tkagg
  • Loading branch information
suchintan-p committed Dec 8, 2019
1 parent a7ca410 commit 31ba8de
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions track.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import win32gui
import psutil
import win32process
import matplotlib.pyplot as plotter
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg as fcta
from matplotlib.figure import Figure as fig
from pathlib import Path
import json
import configparser as cp
Expand All @@ -13,7 +14,7 @@ class TrackTime:
def __init__(self):
config = cp.ConfigParser()
config.read('conf.ini')
DEF = config['DEFAULT']
DEF = config['DEFAULT']
self.titles = DEF['titles'].split(',')
self.ignore_processes = DEF['ignore'].split(',')

Expand Down Expand Up @@ -68,7 +69,7 @@ def start_recording(self):
self.stop_btn.pack(side='left')
self.start_btn['state']='disabled'
self.stop_btn['state']='normal'
self.recording=True
self.recording=True
self.record(None, 0)

def stop_recording(self):
Expand Down Expand Up @@ -110,20 +111,19 @@ def save_data(self):
with open('data.json','w+') as file:
file.write(data)

def create_report(self):
def create_report(self):
del self.data_dict[None]
for process in self.ignore_processes:
if process in self.data_dict.keys():
del self.data_dict[process]
labels = list(self.data_dict.keys())
val = list(self.data_dict.values())
logging.warning(labels)
logging.warning(val)
plotter.pie(val, labels=labels, autopct='%1.2f', startangle=90)
plotter.legend()
plotter.show()


self.figure = fig()
subplot = self.figure.add_subplot()
subplot.title.set_text("Report")
subplot.pie(val,labels=labels,autopct='%1.2f',startangle=90)
piechart = fcta(self.figure, self.root)
piechart.get_tk_widget().pack()

try:
tracker = TrackTime()
Expand Down

2 comments on commit 31ba8de

@suchintan-p
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used matplotlib.backends.backend_tkagg for creating report in tkinter gui

@suchintan-p
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used matplotlib.backends.backend_tkagg for creating report in tkinter gui

Please sign in to comment.