-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlot_Bot.py
2304 lines (1953 loc) · 98.8 KB
/
Plot_Bot.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/python
'''
General plotting application where you can import txt, csv, and xlsx files, plot data in many different ways
(line, scatter, histogram, 3D, pair plot), save plotting profiles, exports png and html files, and interact
with data in ways you can't with excel!
'''
# import packages
import logging
import os
import sys
from pathlib import Path
from datetime import datetime
import dateutil
import webbrowser
import pandas as pd
import numexpr as ne
import math
import hjson
import plotly.express as px
import plotly.graph_objects as go
import plotly.offline
from plotly.subplots import make_subplots
from PyQt5.QtWidgets import QMainWindow, QCheckBox, QAction, QWidget, QGroupBox, QLabel, QSplitter, QHBoxLayout, QGridLayout, QLineEdit, QListWidget, QTabWidget, QComboBox, QSpinBox, QPushButton, QInputDialog, QApplication, QMessageBox, QFileDialog, QDialog, QListWidgetItem, QDesktopWidget, QAbstractItemView
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import Qt, QUrl, QFileInfo, pyqtSlot
from PyQt5.QtWebEngineWidgets import QWebEngineView
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
#print('running in a PyInstaller bundle')
try:
ICON = sys._MEIPASS + os.path.sep + "Icons" + os.path.sep + "plot_bot.ico"
SAVE_ICON = sys._MEIPASS + os.path.sep + "Icons" + os.path.sep + "save_icon.ico"
OPEN_ICON = sys._MEIPASS + os.path.sep + "Icons" + os.path.sep + "open_icon.ico"
PLOT_ICON = sys._MEIPASS + os.path.sep + "Icons" + os.path.sep + "run_icon.ico"
EXPORT_ICON = sys._MEIPASS + os.path.sep + "Icons" + os.path.sep + "export_html.ico"
DOC_PATH = sys._MEIPASS + os.path.sep + "Documents"
except IOError:
VERSION = "ERROR"
else:
#print('running in a normal Python process')
VERSION = "DEVELOPMENT VERSION"
ICON = "Icons" + os.path.sep + "plot_bot.ico"
SAVE_ICON = "Icons" + os.path.sep + "save_icon.ico"
OPEN_ICON = "Icons" + os.path.sep + "open_icon.ico"
PLOT_ICON = "Icons" + os.path.sep + "run_icon.ico"
EXPORT_ICON = "Icons" + os.path.sep + "export_html.ico"
DOC_PATH = "Documents"
# define application class
class Plot_Bot(QMainWindow):
def __init__(self):
# init
super().__init__()
# verify that the temp plot folder exists in this directory --> make directory if doesn't exist
if not os.path.exists("Temp Plots"):
os.mkdir("Temp Plots")
# import app config file -- this stores locations for log files, default profiles, and file import methods
with open("Plot_Bot.config", "r") as file:
app_config = hjson.load(file)
# create some object variables, making them if they don't exist
self.log_path = app_config["Log_Path"]
if not os.path.exists(self.log_path):
os.makedirs(self.log_path)
self.file_imports_path = app_config["File_Import_Methods_Path"]
if not os.path.exists(self.file_imports_path):
os.makedirs(self.file_imports_path)
self.profiles_path = app_config["Profiles_Path"]
if not os.path.exists(self.profiles_path):
os.makedirs(self.profiles_path)
# create logger
self.log_file = self.log_path + os.path.sep + datetime.now().strftime("%Y-%m-%d %H.%M.%S") + ".log"
logging.basicConfig(filename=self.log_file, filemode="w", level=logging.DEBUG)
# more object variables
self.filenames = []
self.path = ""
self.data = pd.DataFrame()
self.version = "2.0"
# base window creation
self.resize(800, 800)
self.center()
self.setWindowTitle("Plot Bot")
self.setWindowIcon(QIcon(ICON))
# create menu & toolbar actions
save_prof_action = QAction(QIcon(SAVE_ICON), "&Save Profile", self)
save_prof_action.setShortcut("Ctrl+S")
save_prof_action.setIconVisibleInMenu(False)
save_prof_action.triggered.connect(self.save_prof)
load_prof_action = QAction("&Load Profile", self)
load_prof_action.setShortcut("Ctrl+L")
load_prof_action.triggered.connect(self.load_prof)
open_file_action = QAction(QIcon(OPEN_ICON), "&Open Data File", self)
open_file_action.setShortcut("Ctrl+O")
open_file_action.setIconVisibleInMenu(False)
open_file_action.triggered.connect(self.open_file)
plot_action = QAction(QIcon(PLOT_ICON), "&Update Plot", self)
plot_action.setShortcut("Ctrl+R")
plot_action.setIconVisibleInMenu(False)
plot_action.triggered.connect(self.update_plot)
export_csv_action = QAction("&Export Data to CSV", self)
export_csv_action.setShortcut("Ctrl+E")
export_csv_action.triggered.connect(self.export_csv)
export_html_action = QAction(QIcon(EXPORT_ICON), "&Export HTML", self)
export_html_action.setShortcut("Ctrl+H")
export_html_action.setIconVisibleInMenu(False)
export_html_action.triggered.connect(self.export_html)
unit_conversion_action = QAction("&Unit Conversion", self)
unit_conversion_action.setShortcut("Ctrl+U")
unit_conversion_action.triggered.connect(self.add_unit_conversion)
math_action = QAction("&Add Math Channel", self)
math_action.setShortcut("Ctrl+M")
math_action.triggered.connect(self.add_math_channel)
user_manual_action = QAction("&User Manual", self)
user_manual_action.setShortcut("Ctrl+Shift+U")
user_manual_action.triggered.connect(self.open_user_manual)
#open_issue_action = QAction("&Report Issue", self)
#open_issue_action.setShortcut("Ctrl+Shift+R")
#open_issue_action.triggered.connect(self.open_issue)
get_version_action = QAction("&Version", self)
get_version_action.setShortcut("Ctrl+Shift+V")
get_version_action.triggered.connect(self.get_version)
# create menu
menu_bar = self.menuBar()
file_menu = menu_bar.addMenu("&File")
file_menu.addAction(save_prof_action)
file_menu.addAction(load_prof_action)
data_menu = menu_bar.addMenu("&Data")
data_menu.addAction(open_file_action)
data_menu.addAction(export_csv_action)
data_menu.addAction(plot_action)
data_menu.addAction(export_html_action)
math_menu = menu_bar.addMenu("&Math")
math_menu.addAction(unit_conversion_action)
math_menu.addAction(math_action)
help_menu = menu_bar.addMenu("&Help")
help_menu.addAction(user_manual_action)
#help_menu.addAction(open_issue_action)
help_menu.addAction(get_version_action)
# create toolbar
self.toolbar = self.addToolBar("Toolbar")
self.toolbar.addAction(save_prof_action)
self.toolbar.addAction(open_file_action)
self.toolbar.addAction(plot_action)
self.toolbar.addAction(export_html_action)
# central widget
wid = QWidget(self)
self.setCentralWidget(wid)
# create left side splitter (vertical splitter)
top_left_frame = QGroupBox("File Information")
top_left_frame.setMinimumWidth(400)
top_left_frame.setMaximumWidth(500)
#top_left_frame.setFrameShape(QFrame.StyledPanel)
bottom_left_frame = QGroupBox("Chart Settings")
bottom_left_frame.setMinimumWidth(400)
bottom_left_frame.setMaximumWidth(500)
#bottom_left_frame.setFrameShape(QFrame.StyledPanel)
v_splitter = QSplitter(Qt.Vertical)
v_splitter.addWidget(top_left_frame)
v_splitter.addWidget(bottom_left_frame)
v_splitter.setSizes([30, 70])
# create overall horizontal splitter
hbox = QHBoxLayout(wid)
right_frame = QGroupBox("Chart Display")
#right_frame.setFrameShape(QFrame.StyledPanel)
h_splitter = QSplitter(Qt.Horizontal)
h_splitter.addWidget(v_splitter)
h_splitter.addWidget(right_frame)
h_splitter.setSizes([30, 70])
hbox.addWidget(h_splitter)
# create top left grid layout in left frame
upper_grid = QGridLayout()
upper_grid.setHorizontalSpacing(5)
upper_grid.setVerticalSpacing(10)
top_left_frame.setLayout(upper_grid)
# create path display widgets
path_disp_label = QLabel("Current Path")
path_disp_label.setAlignment(Qt.AlignRight)
self.path_disp = QLineEdit()
self.path_disp.setAlignment(Qt.AlignLeft)
self.path_disp.setReadOnly(True)
# create file names dislay
filenames_disp_label = QLabel("Current Files")
filenames_disp_label.setAlignment(Qt.AlignRight)
self.files_disp = QListWidget()
self.files_disp.setItemAlignment(Qt.AlignLeft)
self.files_disp.setDragEnabled(False)
self.files_disp.setAcceptDrops(False)
self.files_disp.setMaximumHeight(100)
# create variable list display
var_list_label = QLabel("Variables")
var_list_label.setAlignment(Qt.AlignRight)
self.var_list = QListWidget()
self.var_list.setItemAlignment(Qt.AlignLeft)
self.var_list.setDragEnabled(True)
self.var_list.setAcceptDrops(False)
self.var_list.setSelectionMode(QAbstractItemView.ExtendedSelection)
upper_grid.addWidget(path_disp_label, 0, 0, 1, 1, Qt.AlignTop)
upper_grid.addWidget(self.path_disp, 0, 1, 1, 1)
upper_grid.addWidget(filenames_disp_label, 1, 0, 1, 1, Qt.AlignTop)
upper_grid.addWidget(self.files_disp, 1, 1, 1, 1)
upper_grid.addWidget(var_list_label, 2, 0, 1, 1, Qt.AlignTop)
upper_grid.addWidget(self.var_list, 2, 1, 4, 1)
# create lower tab panel for plot setup
self.setup_panel = QTabWidget()
ts_tab = QWidget()
xy_tab = QWidget()
hist_tab = QWidget()
three_dim_tab = QWidget()
pair_tab = QWidget()
self.setup_panel.addTab(ts_tab, "&Time Series")
self.setup_panel.addTab(xy_tab, "&X-Y")
self.setup_panel.addTab(three_dim_tab, "&3D")
self.setup_panel.addTab(hist_tab, "&Histogram")
self.setup_panel.addTab(pair_tab, "&Pair Plot")
# add setup panel to lower left frame
setup_layout = QGridLayout()
bottom_left_frame.setLayout(setup_layout)
setup_layout.addWidget(self.setup_panel)
# time series setup tab
self.setup_panel.currentWidget().setStyleSheet("QCheckBox{font-size: 12px;} QLineEdit{font-size: 12px;}")
# create widgets for time series setup tab
ts_num_subplots_label = QLabel("Plots")
self.ts_num_subplots_disp = QSpinBox()
self.ts_num_subplots_disp.setValue(1)
self.ts_num_subplots_disp.valueChanged.connect(self.ts_subplots_changed)
ts_t_label = QLabel("Time")
self.ts_t_disp = QComboBox()
self.ts_t_disp.addItem("")
ts_chart_title_label = QLabel("Chart Title")
self.ts_chart_title = QLineEdit()
self.ts_chart_title.setAlignment(Qt.AlignLeft)
y1_left_label = QLabel("Y1 Left")
self.y1_left_disp = QListWidget()
self.y1_left_disp.setAcceptDrops(True)
self.y1_left_disp.itemDoubleClicked.connect(self.remove_list_item)
self.y1_left_log = QCheckBox()
self.y1_left_log.setText("Log Scale")
self.y1_left_log.setLayoutDirection(Qt.RightToLeft)
self.y1_left_ax_label = QLineEdit()
self.y1_left_ax_label.setAlignment(Qt.AlignLeft)
y1_right_label = QLabel("Y1 Right")
self.y1_right_disp = QListWidget()
self.y1_right_disp.setAcceptDrops(True)
self.y1_right_disp.itemDoubleClicked.connect(self.remove_list_item)
self.y1_right_log = QCheckBox()
self.y1_right_log.setText("Log Scale")
self.y1_right_log.setLayoutDirection(Qt.RightToLeft)
self.y1_right_ax_label = QLineEdit()
self.y1_right_ax_label.setAlignment(Qt.AlignLeft)
y2_left_label = QLabel("Y2 Left")
self.y2_left_disp = QListWidget()
self.y2_left_disp.setAcceptDrops(True)
self.y2_left_disp.itemDoubleClicked.connect(self.remove_list_item)
self.y2_left_disp.setEnabled(False)
self.y2_left_log = QCheckBox()
self.y2_left_log.setText("Log Scale")
self.y2_left_log.setLayoutDirection(Qt.RightToLeft)
self.y2_left_log.setEnabled(False)
self.y2_left_ax_label = QLineEdit()
self.y2_left_ax_label.setAlignment(Qt.AlignLeft)
self.y2_left_ax_label.setEnabled(False)
y2_right_label = QLabel("Y2 Right")
self.y2_right_disp = QListWidget()
self.y2_right_disp.setAcceptDrops(True)
self.y2_right_disp.itemDoubleClicked.connect(self.remove_list_item)
self.y2_right_disp.setEnabled(False)
self.y2_right_log = QCheckBox()
self.y2_right_log.setText("Log Scale")
self.y2_right_log.setLayoutDirection(Qt.RightToLeft)
self.y2_right_log.setEnabled(False)
self.y2_right_ax_label = QLineEdit()
self.y2_right_ax_label.setAlignment(Qt.AlignLeft)
self.y2_right_ax_label.setEnabled(False)
y3_left_label = QLabel("Y3 Left")
self.y3_left_disp = QListWidget()
self.y3_left_disp.setAcceptDrops(True)
self.y3_left_disp.itemDoubleClicked.connect(self.remove_list_item)
self.y3_left_disp.setEnabled(False)
self.y3_left_ax_label = QLineEdit()
self.y3_left_ax_label.setAlignment(Qt.AlignLeft)
self.y3_left_ax_label.setEnabled(False)
self.y3_left_log = QCheckBox()
self.y3_left_log.setText("Log Scale")
self.y3_left_log.setLayoutDirection(Qt.RightToLeft)
self.y3_left_log.setEnabled(False)
y3_right_label = QLabel("Y3 Right")
self.y3_right_disp = QListWidget()
self.y3_right_disp.setAcceptDrops(True)
self.y3_right_disp.itemDoubleClicked.connect(self.remove_list_item)
self.y3_right_disp.setEnabled(False)
self.y3_right_log = QCheckBox()
self.y3_right_log.setText("Log Scale")
self.y3_right_log.setLayoutDirection(Qt.RightToLeft)
self.y3_right_log.setEnabled(False)
self.y3_right_ax_label = QLineEdit()
self.y3_right_ax_label.setAlignment(Qt.AlignLeft)
self.y3_right_ax_label.setEnabled(False)
y4_left_label = QLabel("Y4 Left")
self.y4_left_disp = QListWidget()
self.y4_left_disp.setAcceptDrops(True)
self.y4_left_disp.itemDoubleClicked.connect(self.remove_list_item)
self.y4_left_disp.setEnabled(False)
self.y4_left_log = QCheckBox()
self.y4_left_log.setText("Log Scale")
self.y4_left_log.setLayoutDirection(Qt.RightToLeft)
self.y4_left_log.setEnabled(False)
self.y4_left_ax_label = QLineEdit()
self.y4_left_ax_label.setAlignment(Qt.AlignLeft)
self.y4_left_ax_label.setEnabled(False)
y4_right_label = QLabel("Y4 Right")
self.y4_right_disp = QListWidget()
self.y4_right_disp.setAcceptDrops(True)
self.y4_right_disp.itemDoubleClicked.connect(self.remove_list_item)
self.y4_right_disp.setEnabled(False)
self.y4_right_log = QCheckBox()
self.y4_right_log.setText("Log Scale")
self.y4_right_log.setLayoutDirection(Qt.RightToLeft)
self.y4_right_log.setEnabled(False)
self.y4_right_ax_label = QLineEdit()
self.y4_right_ax_label.setAlignment(Qt.AlignLeft)
self.y4_right_ax_label.setEnabled(False)
self.clear_ts_button = QPushButton("Clear Variables")
self.clear_ts_button.pressed.connect(self.clear_ts_var)
# add grid to time series tab and add widgets
ts_grid = QGridLayout()
self.setup_panel.setCurrentIndex(0)
self.setup_panel.currentWidget().setLayout(ts_grid)
ts_grid.addWidget(ts_num_subplots_label, 0, 0, 1, 1, Qt.AlignRight)
ts_grid.addWidget(self.ts_num_subplots_disp, 0, 1, 1, 1, Qt.AlignVCenter)
ts_grid.addWidget(self.clear_ts_button, 0, 4, 1, 2, Qt.AlignRight)
ts_grid.addWidget(ts_t_label, 1, 0, 1, 1, Qt.AlignRight)
ts_grid.addWidget(self.ts_t_disp, 1, 1, 1, 2, Qt.AlignVCenter)
ts_grid.addWidget(ts_chart_title_label, 1, 3, 1, 1, Qt.AlignRight)
ts_grid.addWidget(self.ts_chart_title, 1, 4, 1, 2)
ts_grid.addWidget(y1_left_label, 2, 0, 2, 1, Qt.AlignTop | Qt.AlignRight)
ts_grid.addWidget(self.y1_left_log, 2, 0, 2, 1, Qt.AlignVCenter | Qt.AlignRight)
ts_grid.addWidget(self.y1_left_ax_label, 2, 0, 2, 1, Qt.AlignBottom)
ts_grid.addWidget(self.y1_left_disp, 2, 1, 2, 2)
ts_grid.addWidget(y1_right_label, 2, 3, 2, 1, Qt.AlignTop | Qt.AlignRight)
ts_grid.addWidget(self.y1_right_log, 2, 3, 2, 1, Qt.AlignVCenter | Qt.AlignRight)
ts_grid.addWidget(self.y1_right_ax_label, 2, 3, 2, 1, Qt.AlignBottom)
ts_grid.addWidget(self.y1_right_disp, 2, 4, 2, 2)
ts_grid.addWidget(y2_left_label, 4, 0, 2, 1, Qt.AlignTop | Qt.AlignRight)
ts_grid.addWidget(self.y2_left_log, 4, 0, 2, 1, Qt.AlignVCenter | Qt.AlignRight)
ts_grid.addWidget(self.y2_left_ax_label, 4, 0, 2, 1, Qt.AlignBottom)
ts_grid.addWidget(self.y2_left_disp, 4, 1, 2, 2)
ts_grid.addWidget(y2_right_label, 4, 3, 2, 1, Qt.AlignTop | Qt.AlignRight)
ts_grid.addWidget(self.y2_right_log, 4, 3, 2, 1, Qt.AlignVCenter | Qt.AlignRight)
ts_grid.addWidget(self.y2_right_ax_label, 4, 3, 2, 1, Qt.AlignBottom)
ts_grid.addWidget(self.y2_right_disp, 4, 4, 2, 2)
ts_grid.addWidget(y3_left_label, 6, 0, 2, 1, Qt.AlignTop | Qt.AlignRight)
ts_grid.addWidget(self.y3_left_log, 6, 0, 2, 1, Qt.AlignVCenter | Qt.AlignRight)
ts_grid.addWidget(self.y3_left_ax_label, 6, 0, 2, 1, Qt.AlignBottom)
ts_grid.addWidget(self.y3_left_disp, 6, 1, 2, 2)
ts_grid.addWidget(y3_right_label, 6, 3, 2, 1, Qt.AlignTop | Qt.AlignRight)
ts_grid.addWidget(self.y3_right_log, 6, 3, 2, 1, Qt.AlignVCenter | Qt.AlignRight)
ts_grid.addWidget(self.y3_right_ax_label, 6, 3, 2, 1, Qt.AlignBottom)
ts_grid.addWidget(self.y3_right_disp, 6, 4, 2, 2)
ts_grid.addWidget(y4_left_label, 8, 0, 2, 1, Qt.AlignTop | Qt.AlignRight)
ts_grid.addWidget(self.y4_left_log, 8, 0, 2, 1, Qt.AlignVCenter | Qt.AlignRight)
ts_grid.addWidget(self.y4_left_ax_label, 8, 0, 2, 1, Qt.AlignBottom)
ts_grid.addWidget(self.y4_left_disp, 8, 1, 2, 2)
ts_grid.addWidget(y4_right_label, 8, 3, 2, 1, Qt.AlignTop | Qt.AlignRight)
ts_grid.addWidget(self.y4_right_log, 8, 3, 2, 1, Qt.AlignVCenter | Qt.AlignRight)
ts_grid.addWidget(self.y4_right_ax_label, 8, 3, 2, 1, Qt.AlignBottom)
ts_grid.addWidget(self.y4_right_disp, 8, 4, 2, 2)
# X-Y setup tab
xy_style_label = QLabel("Line Style")
self.xy_style_disp = QComboBox()
self.xy_style_disp.addItem("Scatter")
self.xy_style_disp.addItem("Line")
xy_chart_title_label = QLabel("Chart Title")
self.xy_chart_title = QLineEdit()
self.xy_chart_title.setAlignment(Qt.AlignLeft)
xy_x_label = QLabel("X Variable")
self.xy_x_disp = QComboBox()
self.xy_x_disp.addItem("")
xy_x_title_label = QLabel("X Axis Title")
self.xy_x_title = QLineEdit()
self.xy_x_title.setAlignment(Qt.AlignLeft)
self.xy_x_log = QCheckBox()
self.xy_x_log.setText("Log Scale X")
self.xy_x_log.setLayoutDirection(Qt.RightToLeft)
xy_y_label = QLabel("Y Variable")
self.xy_y_disp = QComboBox()
self.xy_y_disp.addItem("")
xy_y_title_label = QLabel("Y Axis Title")
self.xy_y_title = QLineEdit()
self.xy_y_title.setAlignment(Qt.AlignLeft)
self.xy_y_log = QCheckBox()
self.xy_y_log.setText("Log Scale Y")
self.xy_y_log.setLayoutDirection(Qt.RightToLeft)
xy_color_label = QLabel("Color Variable")
self.xy_color_disp = QComboBox()
self.xy_color_disp.addItem("None")
xy_trendline_label = QLabel("Trendline")
self.xy_trendline_disp = QComboBox()
self.xy_trendline_disp.addItem("None")
self.xy_trendline_disp.addItem("Least Sqaures")
# add X-Y widgets to grid
xy_grid = QGridLayout()
self.setup_panel.setCurrentIndex(1)
self.setup_panel.currentWidget().setLayout(xy_grid)
xy_grid.addWidget(xy_style_label, 0, 0, 1, 1, Qt.AlignVCenter | Qt.AlignRight)
xy_grid.addWidget(self.xy_style_disp, 0, 1, 1, 2)
xy_grid.addWidget(xy_chart_title_label, 1, 0 , 1, 1, Qt.AlignVCenter | Qt.AlignRight)
xy_grid.addWidget(self.xy_chart_title, 1, 1, 1, 2)
xy_grid.addWidget(xy_x_label, 2, 0, 1, 1, Qt.AlignVCenter | Qt.AlignRight)
xy_grid.addWidget(self.xy_x_disp, 2, 1, 1, 2)
xy_grid.addWidget(xy_x_title_label, 3, 0, 1, 1, Qt.AlignVCenter | Qt.AlignRight)
xy_grid.addWidget(self.xy_x_title, 3, 1, 1, 2)
xy_grid.addWidget(self.xy_x_log, 4, 0, 1, 1, Qt.AlignLeft)
xy_grid.addWidget(xy_y_label, 5, 0, 1, 1, Qt.AlignVCenter | Qt.AlignRight)
xy_grid.addWidget(self.xy_y_disp, 5, 1, 1, 2)
xy_grid.addWidget(xy_y_title_label, 6, 0, 1, 1, Qt.AlignVCenter | Qt.AlignRight)
xy_grid.addWidget(self.xy_y_title, 6, 1, 1, 2)
xy_grid.addWidget(self.xy_y_log, 7, 0, 1, 1, Qt.AlignLeft)
xy_grid.addWidget(xy_color_label, 8, 0, 1, 1, Qt.AlignVCenter | Qt.AlignRight)
xy_grid.addWidget(self.xy_color_disp, 8, 1, 1, 2)
xy_grid.addWidget(xy_trendline_label, 9, 0, 1, 1, Qt.AlignVCenter | Qt.AlignRight)
xy_grid.addWidget(self.xy_trendline_disp, 9, 1, 1, 2)
# create widgets for 3D tab
three_dim_chart_title_label = QLabel("Chart Title")
self.three_dim_chart_title = QLineEdit()
self.three_dim_chart_title.setAlignment(Qt.AlignLeft)
three_dim_x_label = QLabel("X Variable")
self.three_dim_x_disp = QComboBox()
self.three_dim_x_disp.addItem("")
three_dim_x_title_label = QLabel("X Axis Title")
self.three_dim_x_title = QLineEdit()
self.three_dim_x_title.setAlignment(Qt.AlignLeft)
three_dim_y_label = QLabel("Y Variable")
self.three_dim_y_disp = QComboBox()
self.three_dim_y_disp.addItem("")
three_dim_y_title_label = QLabel("Y Axis Title")
self.three_dim_y_title = QLineEdit()
self.three_dim_y_title.setAlignment(Qt.AlignLeft)
three_dim_z_label = QLabel("Z Variable")
self.three_dim_z_disp = QComboBox()
self.three_dim_z_disp.addItem("")
three_dim_z_title_label = QLabel("Z Axis Title")
self.three_dim_z_title = QLineEdit()
self.three_dim_z_title.setAlignment(Qt.AlignLeft)
three_dim_color_label = QLabel("Color Variable")
self.three_dim_color_disp = QComboBox()
self.three_dim_color_disp.addItem("None")
# put in grid container
three_dim_grid = QGridLayout()
self.setup_panel.setCurrentIndex(2)
self.setup_panel.currentWidget().setLayout(three_dim_grid)
three_dim_grid.addWidget(three_dim_chart_title_label, 0, 0, 1, 1, Qt.AlignVCenter | Qt.AlignRight)
three_dim_grid.addWidget(self.three_dim_chart_title, 0, 1, 1, 2)
three_dim_grid.addWidget(three_dim_x_label, 1, 0, 1, 1, Qt.AlignVCenter | Qt.AlignRight)
three_dim_grid.addWidget(self.three_dim_x_disp, 1, 1, 1, 2)
three_dim_grid.addWidget(three_dim_x_title_label, 2, 0, 1, 1, Qt.AlignVCenter | Qt.AlignRight)
three_dim_grid.addWidget(self.three_dim_x_title, 2, 1, 1, 2)
three_dim_grid.addWidget(three_dim_y_label, 3, 0, 1, 1, Qt.AlignVCenter | Qt.AlignRight)
three_dim_grid.addWidget(self.three_dim_y_disp, 3, 1, 1, 2)
three_dim_grid.addWidget(three_dim_y_title_label, 4, 0, 1, 1, Qt.AlignVCenter | Qt.AlignRight)
three_dim_grid.addWidget(self.three_dim_y_title, 4, 1, 1, 2)
three_dim_grid.addWidget(three_dim_z_label, 5, 0, 1, 1, Qt.AlignVCenter | Qt.AlignRight)
three_dim_grid.addWidget(self.three_dim_z_disp, 5, 1, 1, 2)
three_dim_grid.addWidget(three_dim_z_title_label, 6, 0, 1, 1, Qt.AlignVCenter | Qt.AlignRight)
three_dim_grid.addWidget(self.three_dim_z_title, 6, 1, 1, 2)
three_dim_grid.addWidget(three_dim_color_label, 7, 0, 1, 1, Qt.AlignVCenter | Qt.AlignRight)
three_dim_grid.addWidget(self.three_dim_color_disp, 7, 1, 1, 2)
# create widgets for histogram
hist_chart_title_label = QLabel("Chart Title")
self.hist_chart_title = QLineEdit()
self.hist_chart_title.setAlignment(Qt.AlignLeft)
hist_x_label = QLabel("X Variable")
self.hist_x_disp = QComboBox()
self.hist_x_disp.addItem("")
hist_x_title_label = QLabel("X Axis Title")
self.hist_x_title = QLineEdit()
self.hist_x_title.setAlignment(Qt.AlignLeft)
hist_num_bins_label = QLabel("Number of Bins")
self.hist_num_bins_disp = QSpinBox()
self.hist_num_bins_disp.setValue(0)
self.hist_num_bins_disp.setSingleStep(5)
hist_normal_label = QLabel("Normalization")
self.hist_normal_disp = QComboBox()
self.hist_normal_disp.addItem("None")
self.hist_normal_disp.addItem("Percent")
self.hist_normal_disp.addItem("Density")
self.hist_normal_disp.addItem("Probability Density")
hist_color_label = QLabel("Color Variable")
self.hist_color_disp = QComboBox()
self.hist_color_disp.addItem("None")
hist_func_label = QLabel("Bin Function")
self.hist_func_disp = QComboBox()
self.hist_func_disp.addItem("Count")
self.hist_func_disp.addItem("Sum")
self.hist_func_disp.addItem("Avg")
self.hist_func_disp.addItem("Min")
self.hist_func_disp.addItem("Max")
self.hist_func_disp.currentTextChanged.connect(self.hist_func_change)
hist_y_label = QLabel("Y Variable")
self.hist_y_disp = QComboBox()
self.hist_y_disp.addItem("None")
self.hist_y_disp.setEnabled(False)
# add hist widgets to the grid
hist_grid = QGridLayout()
self.setup_panel.setCurrentIndex(3)
self.setup_panel.currentWidget().setLayout(hist_grid)
hist_grid.addWidget(hist_chart_title_label, 0, 0, 1, 1, Qt.AlignVCenter | Qt.AlignRight)
hist_grid.addWidget(self.hist_chart_title, 0, 1, 1, 2)
hist_grid.addWidget(hist_x_label, 1, 0, 1, 1, Qt.AlignVCenter | Qt.AlignRight)
hist_grid.addWidget(self.hist_x_disp, 1, 1, 1, 2)
hist_grid.addWidget(hist_x_title_label, 2, 0, 1, 1, Qt.AlignVCenter | Qt.AlignRight)
hist_grid.addWidget(self.hist_x_title, 2, 1, 1, 2)
hist_grid.addWidget(hist_num_bins_label, 3, 0, 1, 1, Qt.AlignVCenter | Qt.AlignRight)
hist_grid.addWidget(self.hist_num_bins_disp, 3, 1, 1, 2)
hist_grid.addWidget(hist_normal_label, 4, 0, 1, 1, Qt.AlignVCenter | Qt.AlignRight)
hist_grid.addWidget(self.hist_normal_disp, 4, 1, 1, 2)
hist_grid.addWidget(hist_color_label, 5, 0, 1, 1, Qt.AlignVCenter | Qt.AlignRight)
hist_grid.addWidget(self.hist_color_disp, 5, 1, 1, 2)
hist_grid.addWidget(hist_func_label, 6, 0, 1, 1, Qt.AlignVCenter | Qt.AlignRight)
hist_grid.addWidget(self.hist_func_disp, 6, 1, 1, 2)
hist_grid.addWidget(hist_y_label, 7, 0, 1, 1, Qt.AlignVCenter | Qt.AlignRight)
hist_grid.addWidget(self.hist_y_disp, 7, 1, 1, 2)
# create widgets for pair plot
pp_chart_title_label = QLabel("Chart Title")
self.pp_chart_title = QLineEdit()
self.pp_chart_title.setAlignment(Qt.AlignLeft)
pp_var_label = QLabel("Variables")
self.pp_var_disp = QListWidget()
self.pp_var_disp.setAcceptDrops(True)
self.pp_var_disp.itemDoubleClicked.connect(self.remove_list_item)
pp_color_label = QLabel("Color Variable")
self.pp_color_disp = QComboBox()
self.pp_color_disp.addItem("None")
pp_clear_button = QPushButton("Clear")
pp_clear_button.clicked.connect(self.clear_pp_var)
# add to pair plot tab
pp_grid = QGridLayout()
self.setup_panel.setCurrentIndex(4)
self.setup_panel.currentWidget().setLayout(pp_grid)
pp_grid.addWidget(pp_chart_title_label, 0, 0, 1, 1, Qt.AlignHCenter | Qt.AlignBottom)
pp_grid.addWidget(self.pp_chart_title, 1, 0, 1, 1, Qt.AlignTop)
pp_grid.addWidget(pp_var_label, 2, 0, 1, 1, Qt.AlignBottom | Qt.AlignHCenter)
pp_grid.addWidget(self.pp_var_disp, 3, 0, 1, 1)
pp_grid.addWidget(pp_color_label, 0, 1, 1, 1, Qt.AlignHCenter | Qt.AlignBottom)
pp_grid.addWidget(self.pp_color_disp, 1, 1, 1, 1, Qt.AlignTop)
pp_grid.addWidget(pp_clear_button, 3, 1, 1, 1, Qt.AlignBottom)
# set tab to time series
self.setup_panel.setCurrentIndex(0)
# create plot tabs
self.plot_panel = QTabWidget()
ts_tab = QWidget()
xy_tab = QWidget()
hist_tab = QWidget()
three_dim_tab = QWidget()
pair_tab = QWidget()
self.plot_panel.addTab(ts_tab, "&Time Series")
self.plot_panel.addTab(xy_tab, "&X-Y")
self.plot_panel.addTab(three_dim_tab, "&3D")
self.plot_panel.addTab(hist_tab, "&Histogram")
self.plot_panel.addTab(pair_tab, "&Pair Plot")
# add plot panel to right frame
plot_layout = QGridLayout()
right_frame.setLayout(plot_layout)
plot_layout.addWidget(self.plot_panel)
# add html containers to each plot tab
self.ts_plot = QWebEngineView()
self.ts_plot.page().profile().downloadRequested.connect(self.download_requested)
ts_plot_grid = QGridLayout()
self.plot_panel.setCurrentIndex(0)
self.plot_panel.currentWidget().setLayout(ts_plot_grid)
ts_plot_grid.addWidget(self.ts_plot)
self.xy_plot = QWebEngineView()
self.xy_plot.page().profile().downloadRequested.connect(self.download_requested)
xy_plot_grid = QGridLayout()
self.plot_panel.setCurrentIndex(1)
self.plot_panel.currentWidget().setLayout(xy_plot_grid)
xy_plot_grid.addWidget(self.xy_plot)
self.three_dim_plot = QWebEngineView()
self.three_dim_plot.page().profile().downloadRequested.connect(self.download_requested)
three_dim_plot_grid = QGridLayout()
self.plot_panel.setCurrentIndex(2)
self.plot_panel.currentWidget().setLayout(three_dim_plot_grid)
three_dim_plot_grid.addWidget(self.three_dim_plot)
self.hist_plot = QWebEngineView()
self.hist_plot.page().profile().downloadRequested.connect(self.download_requested)
hist_plot_grid = QGridLayout()
self.plot_panel.setCurrentIndex(3)
self.plot_panel.currentWidget().setLayout(hist_plot_grid)
hist_plot_grid.addWidget(self.hist_plot)
self.pp_plot = QWebEngineView()
self.pp_plot.page().profile().downloadRequested.connect(self.download_requested)
pp_plot_grid = QGridLayout()
self.plot_panel.setCurrentIndex(4)
self.plot_panel.currentWidget().setLayout(pp_plot_grid)
pp_plot_grid.addWidget(self.pp_plot)
# set plot panel back to time series
self.plot_panel.setCurrentIndex(0)
# add in setup and plot panel callbacks
self.setup_panel.currentChanged.connect(self.setup_panel_changed)
self.plot_panel.currentChanged.connect(self.plot_panel_changed)
# show UI
self.showMaximized()
def center(self):
# centers window geometry
qr = self.frameGeometry()
cp = QDesktopWidget().availableGeometry().center()
qr.moveCenter(cp)
self.move(qr.topLeft())
def save_prof(self):
try:
# ask user for name of the file
name, ok = QInputDialog.getText(self, "Input Profile name", "Enter a profile name")
if not ok:
return
# open file
with open(self.profiles_path + os.path.sep + name + ".pbprof", "w") as f:
# create lists for timeseries subplots
y1_l = []
for i in range(self.y1_left_disp.count()):
y1_l.append(self.y1_left_disp.item(i).text())
y1_r = []
for i in range(self.y1_right_disp.count()):
y1_r.append(self.y1_right_disp.item(i).text())
y2_l = []
for i in range(self.y2_left_disp.count()):
y2_l.append(self.y2_left_disp.item(i).text())
y2_r = []
for i in range(self.y2_right_disp.count()):
y2_r.append(self.y2_right_disp.item(i).text())
y3_l = []
for i in range(self.y3_left_disp.count()):
y3_l.append(self.y3_left_disp.item(i).text())
y3_r = []
for i in range(self.y3_right_disp.count()):
y3_r.append(self.y3_right_disp.item(i).text())
y4_l = []
for i in range(self.y4_left_disp.count()):
y4_l.append(self.y4_left_disp.item(i).text())
y4_r = []
for i in range(self.y4_right_disp.count()):
y4_r.append(self.y4_right_disp.item(i).text())
# create list for pair plot
pp = []
for i in range(self.pp_var_disp.count()):
pp.append(self.pp_var_disp.item(i).text())
# create dictionary for time series plotting
ts_d = {"Number of Subplots":self.ts_num_subplots_disp.value(),
"Chart Title":self.ts_chart_title.text(),
"Time Variable":self.ts_t_disp.currentText(),
"Y1 Left Variables":y1_l, "Y1 Left Log Plot":self.y1_left_log.isChecked(), "Y1 Left Axis Title":self.y1_left_ax_label.text(),
"Y1 Right Variables":y1_r, "Y1 Right Log Plot":self.y1_right_log.isChecked(), "Y1 Right Axis Title":self.y1_right_ax_label.text(),
"Y2 Left Variables":y2_l, "Y2 Left Log Plot":self.y2_left_log.isChecked(), "Y2 Left Axis Title":self.y2_left_ax_label.text(),
"Y2 Right Variables":y2_r, "Y2 Right Log Plot":self.y2_right_log.isChecked(), "Y2 Right Axis Title":self.y2_right_ax_label.text(),
"Y3 Left Variables":y3_l, "Y3 Left Log Plot":self.y3_left_log.isChecked(), "Y3 Left Axis Title":self.y3_left_ax_label.text(),
"Y3 Right Variables":y3_r, "Y3 Right Log Plot":self.y3_right_log.isChecked(), "Y3 Right Axis Title":self.y3_right_ax_label.text(),
"Y4 Left Variables":y4_l, "Y4 Left Log Plot":self.y4_left_log.isChecked(), "Y4 Left Axis Title":self.y4_left_ax_label.text(),
"Y4 Right Variables":y4_r, "Y4 Right Log Plot":self.y4_right_log.isChecked(), "Y4 Right Axis Title":self.y4_right_ax_label.text()}
# create dictionary for x-y plotting
xy_d = {"Chart Title":self.xy_chart_title.text(),
"Line Style":self.xy_style_disp.currentText(),
"X Variable":self.xy_x_disp.currentText(),
"X Axis Title":self.xy_x_title.text(),
"X Axis Log Plot":self.xy_x_log.isChecked(),
"Y Variable":self.xy_y_disp.currentText(),
"Y Axis Title":self.xy_y_title.text(),
"Y Axis Log Plot":self.xy_y_log.isChecked(),
"Color Variable":self.xy_color_disp.currentText(),
"Trendline":self.xy_trendline_disp.currentText()
}
# create dict for three d plotting
three_d = {"Chart Title":self.three_dim_chart_title.text(),
"X Variable":self.three_dim_x_disp.currentText(),
"X Axis Title":self.three_dim_x_title.text(),
"Y Variable":self.three_dim_y_disp.currentText(),
"Y Axis Title":self.three_dim_y_title.text(),
"Z Variable":self.three_dim_z_disp.currentText(),
"Z Axis Title":self.three_dim_z_title.text(),
"Color Variable":self.three_dim_color_disp.currentText()}
# create dict for histogram
hist_d = {"Chart Title":self.hist_chart_title.text(),
"X Variable":self.hist_x_disp.currentText(),
"X Axis Title":self.hist_x_title.text(),
"Number of Bins":self.hist_num_bins_disp.value(),
"Normalization":self.hist_normal_disp.currentText(),
"Color Variable":self.hist_color_disp.currentText(),
"Bin Function":self.hist_func_disp.currentText(),
"Y Variable":self.hist_y_disp.currentText()}
# create dict for pair plot
pp_d = {"Chart Title":self.pp_chart_title.text(),
"Variables":pp,
"Color Variable":self.pp_color_disp.currentText()}
# create dictionary of all items needed
d = {"Time Series":ts_d,
"X-Y":xy_d,
"3D":three_d,
"Histogram":hist_d,
"Pair Plot":pp_d}
# write dictionary to file
hjson.dump(d, f)
except Exception:
logging.exception("Exception thrown while saving profile!")
msg = QMessageBox()
msg.setWindowTitle("Something Went Wrong")
msg.setIcon(QMessageBox.Critical)
msg.setText("Uh oh!")
msg.setInformativeText("Looks like something went wrong. Please check %s" % self.log_file)
msg.exec()
def load_prof(self):
try:
# ask user for file
(file, _) = QFileDialog.getOpenFileName(filter="*.pbprof", caption="Select File", directory=self.profiles_path)
# cancel handling
if file == "":
return
# open file
with open(file, "r") as f:
main_d = hjson.load(f)
# write values to timeseries data
d = main_d["Time Series"]
self.ts_chart_title.setText(d["Chart Title"])
self.ts_num_subplots_disp.setValue(d["Number of Subplots"])
self.ts_t_disp.setCurrentText(d["Time Variable"])
self.y1_left_disp.clear()
self.y1_left_disp.addItems(d["Y1 Left Variables"])
self.y1_left_ax_label.setText(d["Y1 Left Axis Title"])
self.y1_left_log.setChecked(d["Y1 Left Log Plot"])
self.y1_right_disp.clear()
self.y1_right_disp.addItems(d["Y1 Right Variables"])
self.y1_right_ax_label.setText(d["Y1 Right Axis Title"])
self.y1_right_log.setChecked(d["Y1 Right Log Plot"])
self.y2_left_disp.clear()
self.y2_left_disp.addItems(d["Y2 Left Variables"])
self.y2_left_ax_label.setText(d["Y2 Left Axis Title"])
self.y2_left_log.setChecked(d["Y2 Left Log Plot"])
self.y2_right_disp.clear()
self.y2_right_disp.addItems(d["Y2 Right Variables"])
self.y2_right_ax_label.setText(d["Y2 Right Axis Title"])
self.y2_right_log.setChecked(d["Y2 Right Log Plot"])
self.y3_left_disp.clear()
self.y3_left_disp.addItems(d["Y3 Left Variables"])
self.y3_left_ax_label.setText(d["Y3 Left Axis Title"])
self.y3_left_log.setChecked(d["Y3 Left Log Plot"])
self.y3_right_disp.clear()
self.y3_right_disp.addItems(d["Y3 Right Variables"])
self.y3_right_ax_label.setText(d["Y3 Right Axis Title"])
self.y3_right_log.setChecked(d["Y3 Right Log Plot"])
self.y4_left_disp.clear()
self.y4_left_disp.addItems(d["Y4 Left Variables"])
self.y4_left_ax_label.setText(d["Y4 Left Axis Title"])
self.y4_left_log.setChecked(d["Y4 Left Log Plot"])
self.y4_right_disp.clear()
self.y4_right_disp.addItems(d["Y4 Right Variables"])
self.y4_right_ax_label.setText(d["Y4 Right Axis Title"])
self.y4_right_log.setChecked(d["Y4 Right Log Plot"])
# write xy items
d = main_d["X-Y"]
self.xy_chart_title.setText(d["Chart Title"])
self.xy_style_disp.setCurrentText(d["Line Style"])
self.xy_x_disp.setCurrentText(d["X Variable"])
self.xy_x_title.setText(d["X Axis Title"])
self.xy_x_log.setChecked(d["X Axis Log Plot"])
self.xy_y_disp.setCurrentText(d["Y Variable"])
self.xy_y_title.setText(d["Y Axis Title"])
self.xy_y_log.setChecked(d["Y Axis Log Plot"])
self.xy_color_disp.setCurrentText(d["Color Variable"])
self.xy_trendline_disp.setCurrentText(d["Trendline"])
# set 3d tab values
d = main_d["3D"]
self.three_dim_chart_title.setText(d["Chart Title"])
self.three_dim_x_disp.setCurrentText(d["X Variable"])
self.three_dim_x_title.setText(d["X Axis Title"])
self.three_dim_y_disp.setCurrentText(d["Y Variable"])
self.three_dim_y_title.setText(d["Y Axis Title"])
self.three_dim_z_disp.setCurrentText(d["Z Variable"])
self.three_dim_z_title.setText(d["Z Axis Title"])
self.three_dim_color_disp.setCurrentText(d["Color Variable"])
# set histogram values
d = main_d["Histogram"]
self.hist_chart_title.setText(d["Chart Title"])
self.hist_x_disp.setCurrentText(d["X Variable"])
self.hist_x_title.setText(d["X Axis Title"])
self.hist_num_bins_disp.setValue(d["Number of Bins"])
self.hist_normal_disp.setCurrentText(d["Normalization"])
self.hist_color_disp.setCurrentText(d["Color Variable"])
self.hist_func_disp.setCurrentText(d["Bin Function"])
self.hist_y_disp.setCurrentText(d["Y Variable"])
# set pair plot values
d = main_d["Pair Plot"]
self.pp_chart_title.setText(d["Chart Title"])
self.pp_var_disp.clear()
self.pp_var_disp.addItems(d["Variables"])
self.pp_color_disp.setCurrentText(d["Color Variable"])
except Exception:
logging.exception("Exception thrown while saving profile!")
msg = QMessageBox()
msg.setWindowTitle("Something Went Wrong")
msg.setIcon(QMessageBox.Critical)
msg.setText("Uh oh!")
msg.setInformativeText("Looks like something went wrong. Please check %s" % self.log_file)
msg.exec()
def open_file(self):
# ask user for file
(files, _) = QFileDialog.getOpenFileNames(filter="Text (*.csv *.txt);; Workbook (*.xls *.xlsx)", caption="Select File", directory=os.path.abspath(os.sep))
# cancel handling
if not files:
return
# sort files by date
files.sort(key=os.path.getctime)
#print(files)
# get header and data start rows
d = File_Import_Settings(self.file_imports_path)
d.exec()
# make sure the usre actually loaded in settings
if not d.loaded:
return
# create list of rows between header and data start
if d.data_start - d.header <= 1:
head = d.header - 1
else:
head = range(start=d.header-1, stop=d.data_start-2)
# determine path
i = files[0].rfind("/")
self.path = files[0][0:i+1]
# get filenames
self.filenames = []
for file in files:
i = file.rfind("/")
self.filenames.append(file[i+1:])
# show path
self.path_disp.setText(self.path)
# show filenames in the proper field
self.files_disp.clear()
self.files_disp.addItems(self.filenames)
# set date/time parser for loading data
if d.datetime_format.lower() == "iso":
date_format = True
date_parser = dateutil.parser.isoparse
else: # unix epoch
date_format = False
date_parser = None
# concatenate dataframes
self.data = pd.DataFrame()
import_success = True
for file in files:
# load in file, with error handling
try:
# determine whether it is a txt file or speadsheet