2018-09-27 20:24:09 +00:00
|
|
|
#!/usr/bin/env python
|
2018-09-24 22:01:00 +00:00
|
|
|
import sys
|
2018-09-27 20:24:09 +00:00
|
|
|
if sys.version_info[0] < 3:
|
|
|
|
import PySimpleGUI27 as sg
|
|
|
|
else:
|
|
|
|
import PySimpleGUI as sg
|
|
|
|
import csv
|
|
|
|
|
2018-09-13 16:13:27 +00:00
|
|
|
|
2018-09-20 14:41:47 +00:00
|
|
|
filename = sg.PopupGetFile('filename to open', no_window=True, file_types=(("CSV Files","*.csv"),))
|
2018-09-13 16:13:27 +00:00
|
|
|
# --- populate table with file contents --- #
|
|
|
|
data = []
|
|
|
|
if filename is not None:
|
|
|
|
with open(filename, "r") as infile:
|
|
|
|
reader = csv.reader(infile)
|
|
|
|
try:
|
|
|
|
data = list(reader) # read everything else into a list of rows
|
|
|
|
except:
|
|
|
|
sg.PopupError('Error reading file')
|
2018-09-24 22:01:00 +00:00
|
|
|
sys.exit(69)
|
2018-09-13 16:13:27 +00:00
|
|
|
|
|
|
|
sg.SetOptions(element_padding=(0, 0))
|
|
|
|
|
2018-09-15 19:44:57 +00:00
|
|
|
col_layout = [[sg.Table(values=data[1:][:], headings=[data[0][x] for x in range(len(data[0]))], max_col_width=25,
|
|
|
|
auto_size_columns=True, display_row_numbers=True, justification='right', size=(None, len(data)))]]
|
2018-09-13 16:13:27 +00:00
|
|
|
|
|
|
|
layout = [[sg.Column(col_layout, size=(1200,600), scrollable=True)],]
|
2018-09-24 22:01:00 +00:00
|
|
|
window = sg.Window('Table', grab_anywhere=False).Layout(layout)
|
2018-09-18 16:05:44 +00:00
|
|
|
|
2018-09-24 22:01:00 +00:00
|
|
|
b, v = window.Read()
|
2018-09-18 16:05:44 +00:00
|
|
|
|
2018-09-24 22:01:00 +00:00
|
|
|
sys.exit(69)
|