Major update of all demo programs to use new PEP8 bindings, etc
This commit is contained in:
parent
3f7c87c562
commit
7f52778bcc
307 changed files with 19546 additions and 3297 deletions
|
@ -1,19 +1,17 @@
|
|||
#!/usr/bin/env python
|
||||
import sys
|
||||
if sys.version_info[0] >= 3:
|
||||
import PySimpleGUI as sg
|
||||
else:
|
||||
import PySimpleGUI27 as sg
|
||||
import PySimpleGUI as sg
|
||||
import csv
|
||||
|
||||
# Show CSV data in Table
|
||||
|
||||
def table_example():
|
||||
filename = sg.PopupGetFile('filename to open', no_window=True, file_types=(("CSV Files","*.csv"),))
|
||||
filename = sg.popup_get_file('filename to open', no_window=True, file_types=(("CSV Files","*.csv"),))
|
||||
# --- populate table with file contents --- #
|
||||
if filename == '':
|
||||
sys.exit(69)
|
||||
return
|
||||
data = []
|
||||
header_list = []
|
||||
button = sg.PopupYesNo('Does this file have column names already?')
|
||||
button = sg.popup_yes_no('Does this file have column names already?')
|
||||
if filename is not None:
|
||||
with open(filename, "r") as infile:
|
||||
reader = csv.reader(infile)
|
||||
|
@ -24,9 +22,9 @@ def table_example():
|
|||
if button == 'No':
|
||||
header_list = ['column' + str(x) for x in range(len(data[0]))]
|
||||
except:
|
||||
sg.PopupError('Error reading file')
|
||||
sys.exit(69)
|
||||
sg.SetOptions(element_padding=(0, 0))
|
||||
sg.popup_error('Error reading file')
|
||||
return
|
||||
sg.set_options(element_padding=(0, 0))
|
||||
|
||||
layout = [[sg.Table(values=data,
|
||||
headings=header_list,
|
||||
|
@ -37,9 +35,9 @@ def table_example():
|
|||
num_rows=min(len(data), 20))]]
|
||||
|
||||
|
||||
window = sg.Window('Table', grab_anywhere=False).Layout(layout)
|
||||
event, values = window.Read()
|
||||
window = sg.Window('Table', layout, grab_anywhere=False)
|
||||
event, values = window.read()
|
||||
|
||||
sys.exit(69)
|
||||
window.close()
|
||||
|
||||
table_example()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue