diff --git a/Colours.gif b/Colours.gif deleted file mode 100644 index e730fd30..00000000 Binary files a/Colours.gif and /dev/null differ diff --git a/ButtonClick.wav b/DemoPrograms/ButtonClick.wav similarity index 100% rename from ButtonClick.wav rename to DemoPrograms/ButtonClick.wav diff --git a/Color-Guide.png b/DemoPrograms/Color-Guide.png similarity index 100% rename from Color-Guide.png rename to DemoPrograms/Color-Guide.png diff --git a/Color-names.png b/DemoPrograms/Color-names.png similarity index 100% rename from Color-names.png rename to DemoPrograms/Color-names.png diff --git a/ProgrammingClassExamples/MacOS versions/10a PSG Plot (Matplotlib numpy pyplot(y=sinx)) .py b/ProgrammingClassExamples/MacOS versions/10a PSG Plot (Matplotlib numpy pyplot(y=sinx)) .py new file mode 100644 index 00000000..0343059c --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/10a PSG Plot (Matplotlib numpy pyplot(y=sinx)) .py @@ -0,0 +1,65 @@ +#matplotlib, numpy, pyplot +#Tony Crewe +#Oct 2018 MacOS + +import PySimpleGUI as sg +import matplotlib +# added this to work with MacOs +matplotlib.use('TkAgg') +import matplotlib.pyplot as plt +from matplotlib.backends.backend_tkagg import FigureCanvasAgg +import matplotlib.backends.tkagg as tkagg +import numpy as np +import tkinter as tk + +""" +Demonstrates one way of embedding Matplotlib figures into a PySimpleGUI window. +Adapted: From https://gitlab.com/lotspaih/PySimpleGUI/tree/master + +Basic steps are: + * Create a Canvas Element + * Layout form + * Display form (NON BLOCKING) + * Draw plots onto convas + * Display form (BLOCKING) +""" + +#No exactly sure how all this works, but taken from example given as a template. +def draw_figure(canvas, figure, loc = (0,0)): + + figure_canvas_agg = FigureCanvasAgg(figure) + figure_canvas_agg.draw() + figure_x, figure_y, figure_w, figure_h = figure.bbox.bounds + figure_w, figure_h = int(figure_w), int(figure_h) + photo = tk.PhotoImage(master=canvas, width=figure_w, height=figure_h) + canvas.create_image(loc[0] + figure_w/2, loc[1] + figure_h/2, image=photo) + tkagg.blit(photo, figure_canvas_agg.get_renderer()._renderer, colormode=2) + return photo + + +#------------ Matplotlib code ---------------------- +#see https://matplotlib.org/ +fig = plt.figure() +ax = fig.add_subplot(111) +#x-values +x = np.linspace(-np.pi*2, np.pi*2, 100) +#y-values +y = np.sin(x) +plt.plot(x,y) + +ax.set_title('sin(x)') +figure_x, figure_y, figure_w, figure_h = fig.bbox.bounds + +#------------End Matplotlib code -------------------- + +layout = [[sg.Text('Plot Test - PySimpleGUI and Matplotlib', font = ('Calibri', 18, 'bold'))], + [sg.Canvas(size = (figure_w, figure_h), key = '_canvas_')], + [sg.OK(pad=((figure_w / 2, 0), 3), size=(6, 2))]] + +window = sg.Window('Matplot in PySimpleGUI', force_toplevel = True).Layout(layout).Finalize() + +fig_photo = draw_figure(window.FindElement('_canvas_').TKCanvas, fig) + +button, value = window.Read() + + diff --git a/ProgrammingClassExamples/MacOS versions/10b PSG Plot (axes moved).py b/ProgrammingClassExamples/MacOS versions/10b PSG Plot (axes moved).py new file mode 100644 index 00000000..f20bce43 --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/10b PSG Plot (axes moved).py @@ -0,0 +1,57 @@ +#matplotlib, numpy, pyplot +#Tony Crewe +#Oct 2018 MacOS + +import PySimpleGUI as sg +import matplotlib +# added this to work with MacOs +matplotlib.use('TkAgg') +import matplotlib.pyplot as plt +from matplotlib.backends.backend_tkagg import FigureCanvasAgg +import matplotlib.backends.tkagg as tkagg +import numpy as np +import tkinter as tk + +def draw_figure(canvas, figure, loc = (0,0)): + + figure_canvas_agg = FigureCanvasAgg(figure) + figure_canvas_agg.draw() + figure_x, figure_y, figure_w, figure_h = figure.bbox.bounds + figure_w, figure_h = int(figure_w), int(figure_h) + photo = tk.PhotoImage(master=canvas, width=figure_w, height=figure_h) + canvas.create_image(loc[0] + figure_w/2, loc[1] + figure_h/2, image=photo) + tkagg.blit(photo, figure_canvas_agg.get_renderer()._renderer, colormode=2) + return photo + + +#------------ Matplotlib code -------------------- +fig=plt.figure() +ax = fig.add_subplot(111) +x = np.linspace(-np.pi*2, np.pi*2, 100) +y= np.sin(x) +plt.plot(x,y) + +ax.set_title('sin(x)') + +#centre bottom and left axes to zero + +ax.spines['left'].set_position('zero') +ax.spines['right'].set_color('none') +ax.spines['bottom'].set_position('zero') +ax.spines['top'].set_color('none') + +figure_x, figure_y, figure_w, figure_h = fig.bbox.bounds + +#------------End Matplotlib code -------------------- + +layout = [[sg.Text('Plot Test - PySimpleGUI and Matplotlib (axes centred)', font = ('Calibri', 18, 'bold'))], + [sg.Canvas(size = (figure_w, figure_h), key = '_canvas_')], + [sg.OK(pad=((figure_w / 2, 0), 3), size=(6, 2))]] + +window = sg.Window('Matplot in PySimpleGUI', force_toplevel = True).Layout(layout).Finalize() + +fig_photo = draw_figure(window.FindElement('_canvas_').TKCanvas, fig) + +button, value = window.Read() + + diff --git a/ProgrammingClassExamples/MacOS versions/10c PSG Plot (axes pi format).py b/ProgrammingClassExamples/MacOS versions/10c PSG Plot (axes pi format).py new file mode 100644 index 00000000..721ffbad --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/10c PSG Plot (axes pi format).py @@ -0,0 +1,73 @@ +#matplotlib, numpy, pyplot +#Tony Crewe +#Oct 2018 MacOS + +import PySimpleGUI as sg +import matplotlib +# added this to work with MacOs +matplotlib.use('TkAgg') +import matplotlib.pyplot as plt +import matplotlib.ticker as ticker +from matplotlib.backends.backend_tkagg import FigureCanvasAgg +import matplotlib.backends.tkagg as tkagg +import numpy as np +import tkinter as tk + + + +""" +Demonstrates one way of embedding Matplotlib figures into a PySimpleGUI window. + +Basic steps are: + * Create a Canvas Element + * Layout form + * Display form (NON BLOCKING) + * Draw plots onto convas + * Display form (BLOCKING) +""" + +def draw_figure(canvas, figure, loc = (0,0)): + + figure_canvas_agg = FigureCanvasAgg(figure) + figure_canvas_agg.draw() + figure_x, figure_y, figure_w, figure_h = figure.bbox.bounds + figure_w, figure_h = int(figure_w), int(figure_h) + photo = tk.PhotoImage(master=canvas, width=figure_w, height=figure_h) + canvas.create_image(loc[0] + figure_w/2, loc[1] + figure_h/2, image=photo) + tkagg.blit(photo, figure_canvas_agg.get_renderer()._renderer, colormode=2) + return photo + + +#------------ Matplotlib code -------------------- +fig=plt.figure() +ax = fig.add_subplot(111) +x = np.linspace(-np.pi*2, np.pi*2, 100) +y= np.sin(x) +plt.plot(x/np.pi,y) + +ax.set_title('sin(x)') +#centre bottom and left axes to zero + +ax.spines['left'].set_position('zero') +ax.spines['right'].set_color('none') +ax.spines['bottom'].set_position('zero') +ax.spines['top'].set_color('none') + +#Format axes - nicer eh! +ax.xaxis.set_major_formatter(ticker.FormatStrFormatter('%g $\pi$')) + +figure_x, figure_y, figure_w, figure_h = fig.bbox.bounds + +#------------End Matplotlib code -------------------- + +layout = [[sg.Text('Plot Test - PySimpleGUI and Matplotlib (axes pi format)', font = ('Calibri', 18, 'bold'))], + [sg.Canvas(size = (figure_w, figure_h), key = '_canvas_')], + [sg.OK(pad=((figure_w / 2, 0), 3), size=(6, 2))]] + +window = sg.Window('Matplot in PySimpleGUI', force_toplevel = True).Layout(layout).Finalize() + +fig_photo = draw_figure(window.FindElement('_canvas_').TKCanvas, fig) + +button, value = window.Read() + + diff --git a/ProgrammingClassExamples/MacOS versions/10d PSG (Plots Tabs and sin cos options).py b/ProgrammingClassExamples/MacOS versions/10d PSG (Plots Tabs and sin cos options).py new file mode 100644 index 00000000..203c3281 --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/10d PSG (Plots Tabs and sin cos options).py @@ -0,0 +1,100 @@ +#matplotlib, numpy, pyplot +#Tony Crewe +#Oct 2018 MacOs + +import PySimpleGUI as sg +import matplotlib +# added this to work with MacOs +matplotlib.use('TkAgg') +import matplotlib.pyplot as plt +import matplotlib.ticker as ticker +from matplotlib.backends.backend_tkagg import FigureCanvasAgg +import matplotlib.backends.tkagg as tkagg +import numpy as np +import tkinter as tk + +sg.SetOptions (background_color = 'LightBlue', + element_background_color = 'LightBlue', + text_element_background_color = 'LightBlue', + font = ('Arial', 14, 'bold'), + text_color = 'DarkBlue', + input_text_color ='DarkBlue', + button_color = ('DarkBlue', 'White')) + +def draw_figure(canvas, figure, loc = (0,0)): + + figure_canvas_agg = FigureCanvasAgg(figure) + figure_canvas_agg.draw() + figure_x, figure_y, figure_w, figure_h = figure.bbox.bounds + figure_w, figure_h = int(figure_w), int(figure_h) + photo = tk.PhotoImage(master=canvas, width=figure_w, height=figure_h) + canvas.create_image(loc[0] + figure_w/2, loc[1] + figure_h/2, image=photo) + tkagg.blit(photo, figure_canvas_agg.get_renderer()._renderer, colormode=2) + return photo + + +#------------ Matplotlib code -------------------- + +def set_plot(amp, function): + global figure_w, figure_h, fig + fig=plt.figure() + ax = fig.add_subplot(111) + x = np.linspace(-np.pi*2, np.pi*2, 100) + if function == 'sine': + y= amp*np.sin(x) + ax.set_title('sin(x)') + else: + y=amp*np.cos(x) + ax.set_title('cos(x)') + plt.plot(x/np.pi,y) + + + #centre bottom and left axes to zero + + ax.spines['left'].set_position('zero') + ax.spines['right'].set_color('none') + ax.spines['bottom'].set_position('zero') + ax.spines['top'].set_color('none') + + #Format axes - nicer eh! + ax.xaxis.set_major_formatter(ticker.FormatStrFormatter('%g $\pi$')) + + figure_x, figure_y, figure_w, figure_h = fig.bbox.bounds +amp = 1 +function = 'sine' +set_plot(amp, function) + +#------------End Matplotlib code -------------------- + +#use Tabs - one for options, one for canvas to be displayed +#set spinner for amplitude and combo for function type + +tab1_layout = [[sg.Text('Select Amplitude and trig function type', font = ('Calibri', 18, 'bold'))], + [sg.Spin([sz for sz in range (1,5)], initial_value =1, size = (2,1), key = '_spin_'), + sg.Text('Amplitude', size = (10, 1), font = ('Calibri', 12, 'bold'))], + [sg.InputCombo(['sine', 'cosine'], size = (8, 4), key = '_function_'), + sg.Text('Function', size = (10, 1),font = ('Calibri', 12, 'bold'))], + [sg.ReadButton('Redraw Plot')], + [sg.Text('', size = (2, 25))]] + +tab2_layout = [[sg.Text('Plot Test - PySimpleGUI and Matplotlib and options', font = ('Calibri', 18, 'bold'))], + [sg.Canvas(size = (figure_w, figure_h), key = '_canvas_')], + [sg.OK(pad=((figure_w / 2, 0), 3), size=(6, 2))]] + +layout = [[sg.TabGroup([[sg.Tab('Select options', tab1_layout), sg.Tab('Display Plot', tab2_layout)]])]] +window = sg.Window('Matplot, PySimpleGUI and options', force_toplevel = True).Layout(layout).Finalize() + +fig_photo = draw_figure(window.FindElement('_canvas_').TKCanvas, fig) + +while True: + button, value = window.Read() + if button == 'Redraw Plot': + amp = int(value['_spin_']) + function = value['_function_'] + set_plot(amp,function) + fig_photo = draw_figure(window.FindElement('_canvas_').TKCanvas, fig) + + if button is None: + break + + diff --git a/ProgrammingClassExamples/MacOS versions/10e PSG (Same Window).py b/ProgrammingClassExamples/MacOS versions/10e PSG (Same Window).py new file mode 100644 index 00000000..041bfe54 --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/10e PSG (Same Window).py @@ -0,0 +1,98 @@ +#matplotlib, numpy, pyplot +#Tony Crewe +#Oct 2018 MacOs + +import PySimpleGUI as sg +import matplotlib +# added this to work with MacOs +matplotlib.use('TkAgg') +import matplotlib.pyplot as plt +import matplotlib.ticker as ticker +from matplotlib.backends.backend_tkagg import FigureCanvasAgg +import matplotlib.backends.tkagg as tkagg +import numpy as np +import tkinter as tk + +sg.SetOptions (background_color = 'LightBlue', + element_background_color = 'LightBlue', + text_element_background_color = 'LightBlue', + font = ('Arial', 14, 'bold'), + text_color = 'DarkBlue', + input_text_color ='DarkBlue', + button_color = ('DarkBlue', 'White')) + +def draw_figure(canvas, figure, loc = (0,0)): + + figure_canvas_agg = FigureCanvasAgg(figure) + figure_canvas_agg.draw() + figure_x, figure_y, figure_w, figure_h = figure.bbox.bounds + figure_w, figure_h = int(figure_w), int(figure_h) + photo = tk.PhotoImage(master=canvas, width=figure_w, height=figure_h) + canvas.create_image(loc[0] + figure_w/2, loc[1] + figure_h/2, image=photo) + tkagg.blit(photo, figure_canvas_agg.get_renderer()._renderer, colormode=2) + return photo + + +#------------ Matplotlib code -------------------- + +def set_plot(amp, function): + global figure_w, figure_h, fig + fig=plt.figure() + ax = fig.add_subplot(111) + x = np.linspace(-np.pi*2, np.pi*2, 100) + if function == 'sine': + y= amp*np.sin(x) + ax.set_title('sin(x)') + else: + y=amp*np.cos(x) + ax.set_title('cos(x)') + plt.plot(x/np.pi,y) + + + #centre bottom and left axes to zero + + ax.spines['left'].set_position('zero') + ax.spines['right'].set_color('none') + ax.spines['bottom'].set_position('zero') + ax.spines['top'].set_color('none') + + #Format axes - nicer eh! + ax.xaxis.set_major_formatter(ticker.FormatStrFormatter('%g $\pi$')) + + figure_x, figure_y, figure_w, figure_h = fig.bbox.bounds +amp = 1 +function = 'sine' +set_plot(amp, function) + +#------------End Matplotlib code -------------------- + +#using one window based on two columns instead of Tabs +column1 = [[sg.Text('Select Amplitude and trig function type', font = ('Calibri', 18, 'bold'))], + [sg.Spin([sz for sz in range (1,5)], initial_value =1, size = (2,1), key = '_spin_'), + sg.Text('Amplitude', size = (10, 1), font = ('Calibri', 12, 'bold'))], + [sg.InputCombo(['sine', 'cosine'], size = (8, 4), key = '_function_'), + sg.Text('Function', size = (10, 1),font = ('Calibri', 12, 'bold'))], + [sg.ReadButton('Redraw Plot')], + [sg.Text('', size = (1, 27))]] + +column2 = [[sg.Text('Plot Test - PySimpleGUI and Matplotlib and options', font = ('Calibri', 18, 'bold'))], + [sg.Canvas(size = (figure_w, figure_h), key = '_canvas_')], + [sg.OK(pad=((figure_w / 2, 0), 3), size=(6, 2))]] + +layout = [[sg.Column(column1), sg.Column(column2)]] +window = sg.Window('Matplot, PySimpleGUI and options', force_toplevel = True).Layout(layout).Finalize() + +fig_photo = draw_figure(window.FindElement('_canvas_').TKCanvas, fig) + +while True: + button, value = window.Read() + if button == 'Redraw Plot': + amp = int(value['_spin_']) + function = value['_function_'] + set_plot(amp,function) + fig_photo = draw_figure(window.FindElement('_canvas_').TKCanvas, fig) + + if button is None: + break + + diff --git a/ProgrammingClassExamples/MacOS versions/10f PSG (linear and quadratics).py b/ProgrammingClassExamples/MacOS versions/10f PSG (linear and quadratics).py new file mode 100644 index 00000000..580fa88f --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/10f PSG (linear and quadratics).py @@ -0,0 +1,121 @@ +#matplotlib, numpy, pyplot +#Tony Crewe +#Oct 2018 MacOs + +import PySimpleGUI as sg +import matplotlib +# added this to work with MacOs +matplotlib.use('TkAgg') +import matplotlib.pyplot as plt +import matplotlib.ticker as ticker +from matplotlib.backends.backend_tkagg import FigureCanvasAgg +import matplotlib.backends.tkagg as tkagg +import numpy as np +import tkinter as tk + +sg.SetOptions (background_color = 'Grey', + element_background_color = 'Grey', + text_element_background_color = 'Grey', + font = ('Arial', 14, 'bold'), + text_color = 'Black', + input_text_color ='Black', + button_color = ('Black', 'White')) + +#sg.ChangeLookAndFeel('Black') + +def draw_figure(canvas, figure, loc = (0,0)): + + figure_canvas_agg = FigureCanvasAgg(figure) + figure_canvas_agg.draw() + figure_x, figure_y, figure_w, figure_h = figure.bbox.bounds + figure_w, figure_h = int(figure_w), int(figure_h) + photo = tk.PhotoImage(master=canvas, width=figure_w, height=figure_h) + canvas.create_image(loc[0] + figure_w/2, loc[1] + figure_h/2, image=photo) + tkagg.blit(photo, figure_canvas_agg.get_renderer()._renderer, colormode=2) + return photo + + +#------------ Matplotlib code -------------------- + +def set_plot(a,b,c, function): + global figure_w, figure_h, fig + fig=plt.figure() + ax = fig.add_subplot(111) + x = np.linspace(-10, 10, 100) + if function == 'y = ax + b': + y= a*x + b + if a == 1: + a = '' + if a == -1: + a = '-' + title = str('y = ') + str(a) + 'x + ' + str(b) + ax.set_title(title) + else: + y = a*x**2 + b*x + c + #avoiding getting -1x or -1x**2 instead of -x for title + if a == 1: + a = '' + if a == -1: + a = '-' + if b == 1: + b = '' + if b == -1: + b = '-' + title = str('y = ') + str(a) + 'x**2 + ' + str(b) + 'x + ' + str(c) + ax.set_title(title) + plt.plot(x,y) + + + #centre bottom and left axes to zero + + ax.spines['left'].set_position('zero') + ax.spines['right'].set_color('none') + ax.spines['bottom'].set_position('zero') + ax.spines['top'].set_color('none') + + + figure_x, figure_y, figure_w, figure_h = fig.bbox.bounds +amp = 1 +function = 'y = ax + b' +set_plot(1,1,1, function) + +#------------End Matplotlib code -------------------- + +#column 1 for function type and constant values ... + +column1 = [ + [sg.Text('Select constants & function type', )], + [sg.InputCombo(['y = ax + b', 'y = ax^2 + bx + c'], size = (16, 4), key = '_function_'), + sg.Text('Function', size = (10, 1))], [sg.Text('', size = (1, 2))], + [sg.Spin([sz for sz in range (-6,6)], initial_value =1, size = (3,2), key = '_a_'), + sg.Text('a', size = (3, 1)), + sg.Spin([sz for sz in range (-6,6)], initial_value =1, size = (3,2), key = '_b_'), + sg.Text('b', size = (3, 1)), + sg.Spin([sz for sz in range (-6,6)], initial_value =1, size = (3,2), key = '_c_'), + sg.Text('c', size = (3, 1))], [sg.Text('', size = (1, 1))], + [sg.ReadButton('Redraw Plot', size = (14,1))], + [sg.Text('', size = (1, 14))]] + +column2 = [[sg.Text('Plot Test - PySimpleGUI and Matplotlib and options')], + [sg.Canvas(size = (figure_w, figure_h), key = '_canvas_')], + [sg.OK(pad=((figure_w / 2, 0), 1), size=(4, 1))]] + +layout = [[sg.Column(column1), sg.Column(column2)]] +window = sg.Window('Matplot, PySimpleGUI and options', force_toplevel = True).Layout(layout).Finalize() + +fig_photo = draw_figure(window.FindElement('_canvas_').TKCanvas, fig) + +while True: + button, value = window.Read() + if button == 'Redraw Plot': + a = int(value['_a_']) + b = int(value['_b_']) + c = int(value['_c_']) + function = value['_function_'] + set_plot(a,b,c,function) + fig_photo = draw_figure(window.FindElement('_canvas_').TKCanvas, fig) + + if button is None: + break + + diff --git a/ProgrammingClassExamples/MacOS versions/1a PSG (Entry and PopUp).py b/ProgrammingClassExamples/MacOS versions/1a PSG (Entry and PopUp).py new file mode 100644 index 00000000..86ecab1c --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/1a PSG (Entry and PopUp).py @@ -0,0 +1,36 @@ +#PySimple examples (v 3.8) +#Tony Crewe +#Oct 2018 MacOs + +import PySimpleGUI as sg + +#layout, Text, Input,button on line below +layout = [ + [sg.Text('Celcius'), sg.InputText()], + [sg.Submit()], + ] + +#setup window with Title +window = sg.Window('Temperature Converter').Layout(layout) + +#get value (part of a list) +button, value = window.Read() +if button is None: + #windows was closed without button being pressed + exit(0) + +#convert and create string +fahrenheit = round(9/5*float(value[0]) +32, 1) +result = 'Temperature in Fahrenheit is: ' + str(fahrenheit) +#display in Popup +sg.Popup('Result', result) + + + + + + + + + + diff --git a/ProgrammingClassExamples/MacOS versions/1b PSG (Format).py b/ProgrammingClassExamples/MacOS versions/1b PSG (Format).py new file mode 100644 index 00000000..34670547 --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/1b PSG (Format).py @@ -0,0 +1,41 @@ +#PySimple examples (v 3.8) +#Tony Crewe +#Oct 2018 MacOs + +import PySimpleGUI as sg + +#Set formatting options for all elements rather than individually. +#MacOs - colour background issue buttons - make text LightBlue + +sg.SetOptions (background_color = 'LightBlue', + element_background_color = 'LightBlue', + text_element_background_color = 'LightBlue', + font = ('Arial', 10, 'bold'), + text_color = 'Blue', + input_text_color ='Blue', + button_color = ('Blue', 'White') + ) +#adjust widths +layout = [ + [sg.Text('Celcius', size =(12,1)), sg.InputText(size = (8,1))], + [sg.Submit()] + ] + +window = sg.Window('Converter').Layout(layout) +button, value = window.Read() +if button is None: + #windows was closed without button being pressed + exit(0) +fahrenheit = round(9/5*float(value[0]) +32, 1) +result = 'Temperature in Fahrenheit is: ' + str(fahrenheit) +sg.Popup('Result',result) + + + + + + + + + + diff --git a/ProgrammingClassExamples/MacOS versions/1c PSG (persistent form and bind key).py b/ProgrammingClassExamples/MacOS versions/1c PSG (persistent form and bind key).py new file mode 100644 index 00000000..e686da7f --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/1c PSG (persistent form and bind key).py @@ -0,0 +1,35 @@ +#PySimple examples (v 3.8) +#Tony Crewe +#Oct 2018 MacOs + +import PySimpleGUI as sg + +sg.SetOptions (background_color = 'LightBlue', + element_background_color = 'LightBlue', + text_element_background_color = 'LightBlue', + font = ('Arial', 12, 'bold'), + text_color = 'Blue', + input_text_color ='Blue', + button_color = ('Blue', 'White') + ) +#update (via list) values and and display answers +#value[0] is celcius input, value[1] is input to place result. +#Use ReadButton with while true: - keeps window open. + +layout = [ [sg.Text('Enter a Temperature in Celcius')], + [sg.Text('Celcius', size =(8,1)), sg.InputText(size = (15,1))], + [sg.Text('Result', size =(8,1)), sg.InputText(size = (15,1))], + [sg.ReadButton('Submit', bind_return_key = True)]] +#Return = button press +window = sg.Window('Converter').Layout(layout) + +while True: + #get result + button, value = window.Read() + #break out of loop is button not pressed. + if button is not None: + fahrenheit = round(9/5*float(value[0]) +32, 1) + #put result in 2nd input box + window.FindElement(1).Update(fahrenheit) + else: + break diff --git a/ProgrammingClassExamples/MacOS versions/1d PSG (named input keys and catch errors).py b/ProgrammingClassExamples/MacOS versions/1d PSG (named input keys and catch errors).py new file mode 100644 index 00000000..88c567ba --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/1d PSG (named input keys and catch errors).py @@ -0,0 +1,36 @@ +#PySimple examples (v 3.9) +#Tony Crewe +#Oct 2018 MacOs + +import PySimpleGUI as sg + +sg.SetOptions (background_color = 'LightBlue', + element_background_color = 'LightBlue', + text_element_background_color = 'LightBlue', + font = ('Arial', 12, 'bold'), + text_color = 'Blue', + input_text_color ='Blue', + button_color = ('Blue', 'White') + ) +#name inputs (key) uses dictionary- easy to see updating of results +#value[input] first input value te c... +layout = [ [sg.Text('Enter a Temperature in Celcius')], + [sg.Text('Celcius', size =(8,1)), sg.InputText(size = (15,1),key = '_input_')], + [sg.Text('Result', size =(8,1)), sg.InputText(size = (15,1),key = '_result_')], + [sg.ReadButton('Submit', bind_return_key = True)]] + +window = sg.FlexForm('Temp Converter').Layout(layout) + +while True: + button, value = window.Read() + if button is not None: + #catch program errors for text or blank entry: + try: + fahrenheit = round(9/5*float(value['_input_']) +32, 1) + #put result in text box + window.FindElement('_result_').Update(fahrenheit) + except ValueError: + sg.Popup('Error','Please try again') + + else: + break diff --git a/ProgrammingClassExamples/MacOS versions/1e PSG (validation and Look and Feel).py b/ProgrammingClassExamples/MacOS versions/1e PSG (validation and Look and Feel).py new file mode 100644 index 00000000..c31194ae --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/1e PSG (validation and Look and Feel).py @@ -0,0 +1,36 @@ +#PySimple examples (v 3.9) +#Tony Crewe +#Oct 2018 MacOS + +import PySimpleGUI as sg + +#Can use a variety of themes - plus individual options +#Not on MacOS +#sg.ChangeLookAndFeel('SandyBeach') +#use set Options see previous +sg.SetOptions (font = ('Calbri', 12, 'bold')) + + +layout = [ [sg.Text('Enter a Temperature in Celcius')], + [sg.Text('Celcius', size =(8,1)), sg.InputText(size = (6,1),key = '_input_')], + [sg.Text('Result', size =(8,1)), sg.InputText(size = (6,1),key = '_result_')], + [sg.ReadButton('Submit', bind_return_key = True)]] + +window = sg.Window('Temp Converter').Layout(layout) + +while True: + button, value = window.Read() + if button is not None: + #catch program errors for text, floats or blank entry: + #Also validation for range [0, 50] + try: + if float(value['_input_']) > 50 or float(value['_input_']) <0: + sg.Popup('Error','Out of range') + else: + fahrenheit = round(9/5*int(value['_input_']) +32, 1) + window.FindElement('_result_').Update(fahrenheit) + except ValueError: + sg.Popup('Error','Please try again') + + else: + break diff --git a/ProgrammingClassExamples/1e PSG (validation and Look and Feel).py b/ProgrammingClassExamples/MacOS versions/1e PSG (validation).py similarity index 100% rename from ProgrammingClassExamples/1e PSG (validation and Look and Feel).py rename to ProgrammingClassExamples/MacOS versions/1e PSG (validation).py diff --git a/ProgrammingClassExamples/MacOS versions/2a. PSG (checkbox and radiobuttons) - Copy.py b/ProgrammingClassExamples/MacOS versions/2a. PSG (checkbox and radiobuttons) - Copy.py new file mode 100644 index 00000000..189959b4 --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/2a. PSG (checkbox and radiobuttons) - Copy.py @@ -0,0 +1,49 @@ +#PySimple examples (v 3.9) +#Tony Crewe +#Oct 2018 MacOs + +import PySimpleGUI as sg + +#Set colour scheme and font +#sg.ChangeLookAndFeel('GreenTan') + +sg.SetOptions (background_color = 'LightPink', + element_background_color = 'LightPink', + text_element_background_color = 'LightPink', + font = ('Arial', 14, 'bold'), + text_color = 'Green', + input_text_color ='Green', + button_color = ('Green', 'White')) + +#One checkbox and three radio buttons (grouped as 'Radio1') +#value[0] - checkbox, Value[1-3] radiobutton selection +layout = [[sg.Text('Membership Calculator', font = ('Calibri', 16, 'bold'))], + [sg.Checkbox(' Student? 10% off', size = (25,1)), + sg.ReadButton('Display Cost', size = (14,1))], + [sg.Radio('1 month $50', 'Radio1', default = True), + sg.Radio('3 months $100', 'Radio1'), + sg.Radio('1 year $300', 'Radio1')], + [sg.Text('', size = (30,1), justification = 'center', font =('Calibri', 16, 'bold'), key = 'result')]] + +window = sg.Window('Gym Membership').Layout(layout) + +while True: + button, value = window.Read() + if button is not None: + if value[1]: + cost = 50 + elif value[2]: + cost = 100 + else: + cost = 300 + if value[0]: + #apply discount + cost = cost*0.9 + + #format as currency $ symbol and 2 d.p. - make a string + result = str(' Cost: ' + '${:.2f}'.format(cost)) + #put the result in Textbox + window.FindElement('result').Update(result) + + else: + break diff --git a/ProgrammingClassExamples/MacOS versions/2b. PSG (Add logo).py b/ProgrammingClassExamples/MacOS versions/2b. PSG (Add logo).py new file mode 100644 index 00000000..aa4d1038 --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/2b. PSG (Add logo).py @@ -0,0 +1,42 @@ +#PySimple examples (v 3.9) +#Tony Crewe +#Oct 2018 MacOS + +import PySimpleGUI as sg +import os + +sg.SetOptions (font =('Calibri',12,'bold')) + +#get pathname to current file +dirname, filename = os.path.split(os.path.abspath(__file__)) +#add file name for image +pathname = os.path.join(dirname ,'Gym_Logo.png') + +layout = [[sg.Image(pathname),sg.Text(' Membership Calculator', font = ('Calibri', 16, 'bold'))], + [sg.Checkbox(' Student? 10% off', size = (25,1)), + sg.ReadButton('Display Cost', size = (14,1),button_color = ('Red', 'White'))], + [sg.Radio('1 month $50', 'Radio1', default = True), + sg.Radio('3 months $100', 'Radio1'), + sg.Radio('1 year $300', 'Radio1')], + [sg.Text('', size = (30,1), justification = 'center', font =('Calibri', 16, 'bold'), key = 'result')]] + +window = sg.Window('Gym Membership').Layout(layout) + +while True: + button, value = window.Read() + if button is not None: + if value[1]: + cost = 50 + elif value[2]: + cost = 100 + else: + cost = 300 + if value[0]: + cost = cost*0.9 + + #format as currency $ symbol and 2 d.p. - make a string + result = str(' Cost: ' + '${:.2f}'.format(cost)) + window.FindElement('result').Update(result) + + else: + break diff --git a/ProgrammingClassExamples/MacOS versions/3 PSG (multiline display).py b/ProgrammingClassExamples/MacOS versions/3 PSG (multiline display).py new file mode 100644 index 00000000..d1348a91 --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/3 PSG (multiline display).py @@ -0,0 +1,46 @@ + +#PySimple examples (v 3.8) +#Tony Crewe +#Oct 2018 MacOS + +import PySimpleGUI as sg + +#sg.ChangeLookAndFeel('GreenTan') + +sg.SetOptions (background_color = 'Grey', + element_background_color = 'Grey', + text_element_background_color = 'Grey', + font = ('Courier New', 12, 'bold'), + text_color = 'White', + input_text_color ='White', + button_color = ('Grey', 'White')) + + +layout = [ + [sg.Text('Enter and Add Data to Display', font = ('Calibri', 16,'bold'))], + [sg.Text('Race:', size = (5,1)), sg.InputText(size = (8,1)), + sg.Text('Club:', size = (5,1)), sg.InputText(size = (8,1))], + [sg.Text('Name:', size = (5,1)), sg.InputText(size = (8,1)), + sg.Text('Time:', size = (5,1)), sg.InputText(size = (8,1)),sg.Text(' '), + sg.ReadButton('Add Data', font = ('Calibri', 12, 'bold'))], + [sg.Text('_'*40)], + [sg.Text(' Race Club Name Time')], + [sg.Multiline(size =(44,6),key = '_multiline_')] + ] + +window = sg.Window('Enter & Display Data').Layout(layout) + +string = '' +S=[] +while True: + + button, value = window.Read() + if button is not None: + #use string formatting - best way? plus Courier New font - non-proportional font + S = S + ['{:^9s}{:<11s}{:<10s}{:>8s}'.format(value[0],value[1],value[2],value[3])] + for s in S: + string = string + s + '\n' + window.FindElement('_multiline_').Update(string) + string ='' + else: + break diff --git a/ProgrammingClassExamples/MacOS versions/4a PSG (Sliders and combo).py b/ProgrammingClassExamples/MacOS versions/4a PSG (Sliders and combo).py new file mode 100644 index 00000000..77258ca8 --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/4a PSG (Sliders and combo).py @@ -0,0 +1,55 @@ +#PySimple examples (v 3.9) +#Tony Crewe +#Oct 2018 MacOs + +import PySimpleGUI as sg + +sg.SetOptions (background_color = 'LightPink', + element_background_color = 'LightPink', + text_element_background_color = 'LightPink', + font = ('Calibri', 14, 'bold'), + text_color = 'Black', + input_text_color ='Black', + button_color = ('Black', 'White')) +#use of Column to help with layout - vertical sliders take up space + +column1 = [ + [sg.Text('Pick operation', size = (15,1), font = ('Calibri', 16, 'bold'))], + [sg.InputCombo(['Add','Subtract','Multiply','Divide'], size = (10,8))], + [sg.Text('', size =(1,4))]] +column2 = [ + [sg.ReadButton('Submit', font = ('Calibri', 16, 'bold'), size = (8, 1))], + [sg.Text('Result:', font = ('Calibri', 16, 'bold'))],[sg.InputText(size = (12,1), key = '_result_')] + ] + + +layout = [ + [sg.Text('Slider and Combo box demo', font = ('Calibri', 16,'bold'))], + [sg.Slider(range = (-9, 9),orientation = 'v', size = (5,20), default_value = 0), + sg.Slider(range = (-9, 9),orientation = 'v', size = (5, 20), default_value = 0), + sg.Text(' '), sg.Column(column1), sg.Column(column2)]] + +#added grab_anywhere to when moving slider, who window doesn't move. + +window = sg.Window('Enter & Display Data',grab_anywhere = False).Layout(layout) + +#Get selection from combo: value[2] +#Slider values: value[0] and value[1] +while True: + button, value = window.Read() + if button is not None: + if value[2] == 'Add': + result = value[0] + value[1] + elif value[2] == 'Multiply': + result = value[0] * value[1] + elif value[2] == 'Subtract': + result = value[0] - value[1] + elif value[2] == 'Divide': #check for zero + if value[1] ==0: + sg.Popup('Second value can\'t be zero') + result = 'NA' + else: + result = value[0] / value[1] + window.FindElement('_result_').Update(result) + else: + break diff --git a/ProgrammingClassExamples/MacOS versions/4b PSG (Spinner and combo) .py b/ProgrammingClassExamples/MacOS versions/4b PSG (Spinner and combo) .py new file mode 100644 index 00000000..8d696c31 --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/4b PSG (Spinner and combo) .py @@ -0,0 +1,43 @@ +#PySimple examples (v 3.9) +#Tony Crewe +#Oct 2018 MacOs + +import PySimpleGUI as sg + +sg.SetOptions(background_color = 'LightGreen', + element_background_color = 'LightGreen', + text_element_background_color = 'LightGreen', + font= ('Calibri', 12, 'bold')) + +layout = [ + [sg.Text('Spinner and Combo box demo', font = ('Calibri', 14, 'bold'))], + [sg.Spin([sz for sz in range (-9,10)], size = (2,1),initial_value = 0), + sg.Spin([sz for sz in range (-9,10)], size = (2,1), initial_value = 0), + sg.Text('Pick operation ->', size = (15,1)), + sg.InputCombo(['Add','Subtract','Multiply','Divide'], size = (8,6))], + [sg.Text('Result: ')],[sg.InputText(size = (5,1), key = '_result_'), + sg.ReadButton('Calculate', button_color = ('Black', 'White'))]] + +window = sg.Window('Enter & Display Data', grab_anywhere= False).Layout(layout) + +while True: + button, value = window.Read() + + if button is not None: + #convert returned values to integers + val = [int(value[0]), int(value[1])] + if value[2] == 'Add': + result = val[0] + val[1] + elif value[2] == 'Multiply': + result = val[0] * val[1] + elif value[2] == 'Subtract': + result = val[0] - val[1] + elif value[2] == 'Divide': + if val[1] ==0: + sg.Popup('Second value can\'t be zero') + result = 'NA' + else: + result = round( val[0] / val[1], 3) + window.FindElement('_result_').Update(result) + else: + break diff --git a/ProgrammingClassExamples/MacOS versions/5a PSG (listboxes add remove).py b/ProgrammingClassExamples/MacOS versions/5a PSG (listboxes add remove).py new file mode 100644 index 00000000..293b6929 --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/5a PSG (listboxes add remove).py @@ -0,0 +1,51 @@ +#PySimple examples (v 3.9) +#Tony Crewe +#Oct 2018 MacOs + +import PySimpleGUI as sg + +#sg.ChangeLookAndFeel('BlueMono') +sg.SetOptions (background_color = 'LightBlue', + element_background_color = 'LightBlue', + text_element_background_color = 'LightBlue', + font = ('Calibri', 14, 'bold'), + text_color = 'Black', + input_text_color ='Black', + button_color = ('Black', 'White')) + +#use column feature with height listbox takes up +column1 = [ + [sg.Text('Add or Delete Items\nfrom a Listbox')], + [sg.InputText( size = (15,1), key = 'add'), sg.ReadButton('Add', size = (5,1))], + [sg.ReadButton('Delete selected entry', size = (18,1))]] + +#initial listbox entries +List = ['Austalia', 'Canada', 'Greece'] + +#add initial List to listbox +layout = [ + [sg.Listbox(values=[l for l in List], size = (20,8), key ='_listbox_'), + sg.Column(column1)]] + +window = sg.Window('Listbox').Layout(layout) + +while True: + button, value = window.Read() + if button is not None: + #value[listbox] returns a list + #using value[listbox][0] gives the string + if button == 'Delete selected entry': + #ensure something is selected + if value['_listbox_'] == []: + sg.Popup('Error','You must select a Country') + else: + #find and remove this + List.remove(value['_listbox_'][0]) + if button == 'Add': + #add string in add box to list + List.append(value['add']) + List.sort() + #update listbox + window.FindElement('_listbox_').Update(List) + else: + break diff --git a/ProgrammingClassExamples/MacOS versions/6a PSG (search linear and binary).py b/ProgrammingClassExamples/MacOS versions/6a PSG (search linear and binary).py new file mode 100644 index 00000000..45bf802a --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/6a PSG (search linear and binary).py @@ -0,0 +1,90 @@ +#PySimple examples (v 3.9) +#Tony Crewe +#Oct 2018 MacOs + +import PySimpleGUI as sg + + +sg.SetOptions(background_color = 'Grey', + element_background_color = 'Grey', + text_element_background_color = 'Grey', + font= ('Calibri', 14, 'bold')) + +layout =[[sg.Text('Search Demo', font =('Calibri', 18, 'bold')), sg.ReadButton('Show Names')], +[sg.Text('',size = (14, 11),relief=sg.RELIEF_SOLID,font = ('Calibri', 12), background_color ='White',key = '_display1_'), + sg.Text('',size = (14, 11),relief=sg.RELIEF_SOLID,font = ('Calibri', 12), background_color ='White',key = '_display2_')], + [sg.Text('_'*35,font = ('Calibri', 16))], + [sg.InputText(size = (10,1), key = '_linear_'), sg.InputText(size = (11,1), key = '_binary_')], + [sg.ReadButton('Linear Search', size = (11,1)), sg.ReadButton('Binary Search', size = (11,1))], + ] +window = sg.Window('Search Demo').Layout(layout) + +#names for Demo, could be loaded from a file +names = ['Roberta', 'Kylie', 'Jenny', 'Helen', + 'Andrea', 'Meredith','Deborah','Pauline', + 'Belinda', 'Wendy'] + +sorted_names = ['Andrea','Belinda','Deborah','Helen', + 'Jenny','Kylie','Meredith','Pauline', + 'Roberta','Wendy'] + +#function to display list +def display_list(list, display): + names = '' + for l in list: #add list elements with new line + names = names + l + '\n' + window.FindElement(display).Update(names) + +#Linear Search - no need for Ordered list +def linear_search(): + l = names[:] + found = False + for l in l: + if l == value['_linear_']: #Check each value + found = True + window.FindElement('_display1_').Update('Linear search\n' + l + ' found.') + break + if not found: + window.FindElement('_display1_').Update(value['_linear_'] + ' was \nNot found') + +#Binary Search - only works for ordered lists +def binary_search(): + l = sorted_names[:] + lo = 0 + hi = len(l)-1 + #Start with found is False + found = False + while lo <= hi: + #Start in middle + mid = (lo + hi) //2 + #get the value from the search box + if l[mid] == value['_binary_']: + window.FindElement('_display2_').Update('Binary search\n' + l[mid] + ' found.') + #If found display name and stop + found = True + break + elif l[mid] < value['_binary_']: + #Search in top half + lo = mid + 1 + else: + #Search in lower half + hi = mid - 1 + #If we get to end - display not found + if not found: + window.FindElement('_display2_').Update(value['_binary_'] + ' was \nNot found') + +while True: + button, value = window.Read() + + if button is not None: + #show names - unordered and sorted + if button == 'Show Names': + display_list(names,'_display1_') + display_list(sorted_names, '_display2_') + if button == 'Linear Search': + linear_search() + if button == 'Binary Search': + binary_search() + else: + break + diff --git a/ProgrammingClassExamples/MacOS versions/6b PSG (search - disabled buttons).py b/ProgrammingClassExamples/MacOS versions/6b PSG (search - disabled buttons).py new file mode 100644 index 00000000..8c917166 --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/6b PSG (search - disabled buttons).py @@ -0,0 +1,98 @@ +#PySimple examples (v 3.9) +#Tony Crewe +#Oct 2018 MacOs + +import PySimpleGUI as sg + +sg.SetOptions(background_color = 'LightBlue', + element_background_color = 'LightBlue', + text_element_background_color = 'LightBlue', + font= ('Calibri', 14, 'bold')) + +layout =[[sg.Text('Search Demo', font =('Calibri', 18, 'bold')), sg.ReadButton('Show Names')], +[sg.Text('',size = (14, 11),relief=sg.RELIEF_SOLID,font = ('Calibri', 12), background_color ='White',key = '_display1_'), + sg.Text('',size = (14, 11),relief=sg.RELIEF_SOLID,font = ('Calibri', 12), background_color ='White',key = '_display2_')], + [sg.Text('_'*35,font = ('Calibri', 16))], + [sg.InputText(size = (10,1), key = '_linear_'), sg.InputText(size = (11,1), key = '_binary_')], + [sg.ReadButton('Linear Search', key = '_ls_',size = (11,1)), sg.ReadButton('Binary Search', key ='_bs_',size = (11,1))], + ] +window = sg.Window('Search Demo').Layout(layout) + +#finalize allows the disabling of the two buttons before .Read statement +window.Finalize() +window.FindElement('_ls_').Update(disabled = True) +window.FindElement('_bs_').Update(disabled = True) + +#names for Demo, could be loaded from a file +names = ['Roberta', 'Kylie', 'Jenny', 'Helen', + 'Andrea', 'Meredith','Deborah','Pauline', + 'Belinda', 'Wendy'] + +sorted_names = ['Andrea','Belinda','Deborah','Helen', + 'Jenny','Kylie','Meredith','Pauline', + 'Roberta','Wendy'] + +#function to display list +def display_list(list, display): + names = '' + #add list elements with new line + for l in list: + names = names + l + '\n' + window.FindElement(display).Update(names) + #enable buttons now data loaded + window.FindElement('_ls_').Update(disabled = False) + window.FindElement('_bs_').Update(disabled = False) + +#Linear Search - no need for Ordered list +def linear_search(): + l = names[:] + found = False + for l in l: + #Check each value + if l == value['_linear_']: + found = True + window.FindElement('_display1_').Update('Linear search\n' + l + ' found.') + break + if not found: + window.FindElement('_display1_').Update(value['_linear_'] + ' was \nNot found') + +#Binary Search - only works for ordered lists +def binary_search(): + l = sorted_names[:] + lo = 0 + hi = len(l)-1 + #Start with found is Flase + found = False + while lo <= hi: + #Start in middle + mid = (lo + hi) //2 + #get the value from the search box + if l[mid] == value['_binary_']: + window.FindElement('_display2_').Update('Binary search\n' + l[mid] + ' found.') + #If found display and stop + found = True + break + elif l[mid] < value['_binary_']: + #Search in top half + lo = mid + 1 + else: + #Search in lower half + hi = mid - 1 + #If we get to end - display not found + if not found: + window.FindElement('_display2_').Update(value['_binary_'] + ' was \nNot found') + +while True: + button, value = window.Read() + if button is not None: + #show names - unordered and sorted + if button == 'Show Names': + display_list(names,'_display1_') + display_list(sorted_names, '_display2_') + if button == '_ls_': + linear_search() + if button == '_bs_': + binary_search() + else: + break + diff --git a/ProgrammingClassExamples/MacOS versions/6c PSG (search text preloaded).py b/ProgrammingClassExamples/MacOS versions/6c PSG (search text preloaded).py new file mode 100644 index 00000000..65b3c3b4 --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/6c PSG (search text preloaded).py @@ -0,0 +1,79 @@ +#PySimple examples (v 3.9) +#Tony Crewe +#Oct 2018 MacOs + +import PySimpleGUI as sg + +sg.SetOptions(background_color = 'Grey', + element_background_color = 'Grey', + text_element_background_color = 'Grey', + font= ('Calibri', 14, 'bold')) + +#names for Demo, could be loaded from a file + +names = ['Roberta', 'Kylie', 'Jenny', 'Helen', + 'Andrea', 'Meredith','Deborah','Pauline', + 'Belinda', 'Wendy'] +name = '' +for l in names: + name = name + l + '\n' + +sorted_names = ['Andrea','Belinda','Deborah','Helen', + 'Jenny','Kylie','Meredith','Pauline', + 'Roberta','Wendy'] + +sortname = '' +for l in sorted_names: + sortname = sortname + l +'\n' + +layout =[[sg.Text('Search Demo', font =('Calibri', 18, 'bold'))], +[sg.Text(name,size = (14, 11),relief=sg.RELIEF_SOLID,font = ('Calibri', 12), background_color ='White',key = '_display1_'), + sg.Text(sortname,size = (14, 11),relief=sg.RELIEF_SOLID,font = ('Calibri', 12), background_color ='White',key = '_display2_')], + [sg.Text('_'*35,font = ('Calibri', 16))], + [sg.InputText(size = (10,1), key = '_linear_'), sg.InputText(size = (11,1), key = '_binary_')], + [sg.ReadButton('Linear Search', size = (11,1)), sg.ReadButton('Binary Search', size = (11,1))], + ] +window = sg.Window('Search Demo').Layout(layout) + +#Linear Search - no need for Ordered list +def linear_search(): + l = names[:] + found = False + for l in l: + if l == value['_linear_']: + found = True + sg.Popup('Linear search\n' + l + ' found.') + break + if not found: + sg.Popup('Linear search\n' +(value['_linear_'] + ' was not found')) + +#Binary Search - only works for ordered lists +def binary_search(): + l = sorted_names[:] + lo = 0 + hi = len(l)-1 + found = False + while lo <= hi: + mid = (lo + hi) //2 + if l[mid] == value['_binary_']: + sg.Popup('Binary search\n' + l[mid] + ' found.') + found = True + break + elif l[mid] < value['_binary_']: + lo = mid + 1 + else: + hi = mid - 1 + if not found: + sg.Popup('Binary search\n' +(value['_binary_'] + ' was not found')) + +while True: + button, value = window.Read() + + if button is not None: + if button == 'Linear Search': + linear_search() + if button == 'Binary Search': + binary_search() + else: + break + diff --git a/ProgrammingClassExamples/MacOS versions/6d PSG (sort and search with textbox.py b/ProgrammingClassExamples/MacOS versions/6d PSG (sort and search with textbox.py new file mode 100644 index 00000000..ea354d90 --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/6d PSG (sort and search with textbox.py @@ -0,0 +1,139 @@ +#PySimple examples (v 3.9) +#Tony Crewe +#Oct 2018 MacOS + +import PySimpleGUI as sg + +sg.SetOptions(background_color = 'LightBlue', + element_background_color = 'LightBlue', + text_element_background_color = 'LightBlue', + font= ('Calibri', 14, 'bold')) + +#setup column (called column1) of buttons to use in layout + +column1 = [[sg.ReadButton('Original list', size = (11,1))], + [sg.ReadButton('Default sort', size = (11,1))], + [sg.ReadButton('Sort: selection',size = (11,1))], + [sg.ReadButton('Sort: quick', size = (11,1))]] + +layout =[[sg.Text('Search and Sort Demo', font =('Calibri', 20, 'bold'))], +[sg.Text('',size = (14, 11),relief=sg.RELIEF_SOLID,font = ('Calibri', 12), background_color = 'White',key = '_display_'), sg.Column(column1)], + [sg.Text('_'*35,font = ('Calibri', 16))], + [sg.InputText(size = (10,1), key = '_linear_'), sg.Text(' '), sg.InputText(size = (11,1), key = '_binary_')], + [sg.ReadButton('Linear Search', size = (11,1)), sg.Text(' '), sg.ReadButton('Binary Search', size = (11,1))], + ] + +window = sg.Window('Search and Sort Demo').Layout(layout) + +#names for Demo, could be loaded from a file +names= ['Roberta', 'Kylie', 'Jenny', 'Helen', + 'Andrea', 'Meredith','Deborah','Pauline', + 'Belinda', 'Wendy'] + +#function to display list +def display_list(list): + #store list in Multiline text globally + global list_displayed + list_displayed = list + display = '' + #add list elements with new line + for l in list: + display = display + l + '\n' + window.FindElement('_display_').Update(display) + +#use inbuilt python sort +def default(names): + l = names[:] + l.sort() + display_list(l) + +#Selection sort - See Janson Ch 7 +def sel_sort(names): + l = names[:] + for i in range(len(l)): + smallest = i + for j in range(i+1, len(l)): + #find smallest value + if l[j] < l[smallest]: + #swap it to front + smallest = j + #repeat from next position + l[smallest], l[i] = l[i], l[smallest] + display_list(l) + +#Quick sort - See Janson Ch 7 +def qsort_holder(names): + l = names[:] + #pass List, first and last + quick_sort(l, 0, len(l) -1) + display_list(l) +#Quicksort is a partition sort +def quick_sort(l, first, last): + if first >= last: + return l + pivot = l[first] + low = first + high = last + while low < high: + while l[high] > pivot: + high = high -1 + while l[low] < pivot: + low = low + 1 + if low <= high: + l[high], l[low] = l[low], l[high] + low = low + 1 + high = high -1 + #continue splitting - sort small list + quick_sort(l, first, low -1) + quick_sort(l, low, last) + +#Linear Search - no need for Ordered list +def linear_search(): + l = names[:] + found = False + for l in l: + if l == value['_linear_']: + found = True + window.FindElement('_display_').Update('Linear search\n' + l + ' found.') + break + if not found: + window.FindElement('_display_').Update(value['_linear_'] + ' was \nNot found') + +#Binary Search - only works for ordered lists +def binary_search(): + l= list_displayed[:] + lo = 0 + hi = len(l)-1 + found = False + while lo <= hi: + mid = (lo + hi) //2 + if l[mid] == value['_binary_']: + window.FindElement('_display_').Update('Binary search\n' + l[mid] + ' found.') + found = True + break + elif l[mid] < value['_binary_']: + lo = mid + 1 + else: + hi = mid - 1 + if not found: + window.FindElement('_display_').Update(value['_binary_'] + ' was \nNot found') + + +while True: + button, value = window.Read() + if button is not None: + if button == 'Original list': + display_list(names) + if button == 'Default sort': + default(names) + if button == 'Sort: selection': + sel_sort(names) + if button == 'Sort: quick': + qsort_holder(names) + if button == 'Linear Search': + linear_search() + if button == 'Binary Search': + binary_search() + else: + break + diff --git a/ProgrammingClassExamples/MacOS versions/6e PSG (sort and search with listbox).py b/ProgrammingClassExamples/MacOS versions/6e PSG (sort and search with listbox).py new file mode 100644 index 00000000..b39be3bb --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/6e PSG (sort and search with listbox).py @@ -0,0 +1,137 @@ +#PySimple examples (v 3.9) +#Tony Crewe +#Oct 2018 MacOs + +import PySimpleGUI as sg + +sg.SetOptions(background_color = 'DarkGrey', + element_background_color = 'DarkGrey', + text_element_background_color = 'DarkGrey', + font= ('Calibri', 14, 'bold')) + +#setup column (called column1) of buttons to use in layout + +column1 = [[sg.ReadButton('Original list', size = (10,1))], + [sg.ReadButton('Default sort', size = (10,1))], + [sg.ReadButton('Sort: selection',size = (10,1))], + [sg.ReadButton('Sort: quick', size = (10,1))]] + +layout =[[sg.Text('Search and Sort Demo', font =('Calibri', 20, 'bold'))], +[sg.Listbox(values =[''], size = (14, 11),font = ('Calibri', 12), background_color ='White',key = '_display_'), sg.Column(column1)], + [sg.Text('_'*38,font = ('Calibri', 16))], + [sg.InputText(size = (10,1), key = '_linear_'), sg.Text(' '), sg.InputText(size = (11,1), key = '_binary_')], + [sg.ReadButton('Linear Search', size = (11,1)), sg.Text(' '), sg.ReadButton('Binary Search', size = (11,1))], + ] + +window = sg.Window('Search and Sort Demo').Layout(layout) + +names= ['Roberta', 'Kylie', 'Jenny', 'Helen', + 'Andrea', 'Meredith','Deborah','Pauline', + 'Belinda', 'Wendy'] + +#function to display list +def display_list(list): + global list_displayed + #store list in Multiline text globally + list_displayed = list + #add list elements with new line + values = [l for l in list] + window.FindElement('_display_').Update(values) + +#use inbuilt python sort +def default(names): + l = names[:] + l.sort() + display_list(l) + +#Selection sort +def sel_sort(names): + l = names[:] + for i in range(len(l)): + smallest = i + for j in range(i+1, len(l)): + if l[j] < l[smallest]: + smallest = j + l[smallest], l[i] = l[i], l[smallest] + display_list(l) + +#Quick sort +def qsort_holder(names): + l = names[:] + quick_sort(l, 0, len(l) - 1) + display_list(l) + +def quick_sort(l, first, last): + if first >= last: + return l + pivot = l[first] + low = first + high = last + while low < high: + while l[high] > pivot: + high = high -1 + while l[low] < pivot: + low = low + 1 + if low <= high: + l[high], l[low] = l[low], l[high] + low = low + 1 + high = high -1 + quick_sort(l, first, low -1) + quick_sort(l, low, last) + +#Linear Search - no need for Ordered list +def linear_search(): + l = names[:] + found = False + for l in l: + if l == value['_linear_']: + found = True + #Create list for display + result = ['Linear search', l + ' found'] + window.FindElement('_display_').Update(result) + break + if not found: + #Create list for display + result = [value['_linear_'], 'was not found'] + window.FindElement('_display_').Update(result) + +#Binary Search +def binary_search(): + l = list_displayed[:] + lo = 0 + hi = len(l)-1 + found = False + while lo <= hi: + mid = (lo + hi) //2 + if l[mid] == value['_binary_']: + #Create list for display + result = ['Binary search', l[mid] + ' found.'] + window.FindElement('_display_').Update(result) + found = True + break + elif l[mid] < value['_binary_']: + lo = mid + 1 + else: + hi = mid - 1 + if not found: + #Create list for display + result = [value['_binary_'], 'was not found'] + window.FindElement('_display_').Update(result) + +while True: + button, value = window.Read() + if button is not None: + if button == 'Original list': + display_list(names) + if button == 'Default sort': + default(names) + if button == 'Sort: selection': + sel_sort(names) + if button == 'Sort: quick': + qsort_holder(names) + if button == 'Linear Search': + linear_search() + if button == 'Binary Search': + binary_search() + else: + break diff --git a/ProgrammingClassExamples/MacOS versions/6f PSG (data from text file).py b/ProgrammingClassExamples/MacOS versions/6f PSG (data from text file).py new file mode 100644 index 00000000..76118d8b --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/6f PSG (data from text file).py @@ -0,0 +1,148 @@ +#PySimple examples (v 3.9) +#Tony Crewe +#Oct 2018 MacOs + +import PySimpleGUI as sg +import os + +sg.SetOptions(background_color = 'LightBlue', + element_background_color = 'LightBlue', + text_element_background_color = 'LightBlue', + font= ('Calibri', 14, 'bold')) + +#get pathname to current file + +dirname, filename = os.path.split(os.path.abspath(__file__)) +pathname = os.path.join(dirname, 'Names.txt') #original data +spathname = os.path.join(dirname, 'Names(sorted).txt') #sorted data + +#Get data from file +names = [line.strip() for line in open(pathname)] + +column1 = [[sg.ReadButton('Original list', size = (11,1))], + [sg.ReadButton('Default sort', size = (11,1))], + [sg.ReadButton('Sort: selection',size = (11,1))], + [sg.ReadButton('Sort: quick', size = (11,1))], + [sg.Text('_________________',font = ('Calibri', 16))], + [sg.ReadButton('Save data\ndisplayed', size = (11,2))]] + +layout =[[sg.Text('Search and Sort Demo', font =('Calibri', 20, 'bold'))], +[sg.Listbox(values =[''], size = (14, 11),font = ('Calibri', 12), background_color ='White',key = '_display_'), sg.Column(column1)], + [sg.Text('_'*38,font = ('Calibri', 16))], + [sg.InputText(size = (11,1), key = '_linear_'), sg.Text(' '), sg.InputText(size = (11,1), key = '_binary_')], + [sg.ReadButton('Linear Search', size = (12,1)), sg.Text(' '), sg.ReadButton('Binary Search', size = (11,1))], + ] + +window = sg.Window('Search and Sort Demo').Layout(layout) + +#function to display list +def display_list(list): + global list_displayed + #store list in Multiline text globally + list_displayed = list + #add list elements with new line + values = [l for l in list] + window.FindElement('_display_').Update(values) + +#use inbuilt python sort +def default(names): + l = names[:] + l.sort() + display_list(l) + +#Selection sort +def sel_sort(names): + l = names[:] + for i in range(len(l)): + smallest = i + for j in range(i+1, len(l)): + if l[j] < l[smallest]: + smallest = j + l[smallest], l[i] = l[i], l[smallest] + display_list(l) + +#Quick sort +def qsort_holder(names): + l = names[:] + quick_sort(l, 0, len(l) - 1) + display_list(l) + +def quick_sort(l, first, last): + if first >= last: + return l + pivot = l[first] + low = first + high = last + while low < high: + while l[high] > pivot: + high = high -1 + while l[low] < pivot: + low = low + 1 + if low <= high: + l[high], l[low] = l[low], l[high] + low = low + 1 + high = high -1 + quick_sort(l, first, low -1) + quick_sort(l, low, last) + +#Linear Search - no need for Ordered list +def linear_search(): + l = names[:] + found = False + for l in l: + if l == value['_linear_']: + found = True + #Create list for display + result = ['Linear search', l + ' found'] + window.FindElement('_display_').Update(result) + break + if not found: + #Create list for display + result = [value['_linear_'], 'was not found'] + window.FindElement('_display_').Update(result) + +#Binary Search +def binary_search(): + l = list_displayed[:] + lo = 0 + hi = len(l)-1 + found = False + while lo <= hi: + mid = (lo + hi) //2 + if l[mid] == value['_binary_']: + #Create list for display + found = True + result = ['Binary search', l[mid] + ' found.'] + window.FindElement('_display_').Update(result) + break + elif l[mid] < value['_binary_']: + lo = mid + 1 + else: + hi = mid - 1 + if not found: + #Create list for display + result = [value['_binary_'], 'was not found'] + window.FindElement('_display_').Update(result) + +while True: + button, value = window.Read() + if button is not None: + if button == 'Original list': + display_list(names) + if button == 'Default sort': + default(names) + if button == 'Sort: selection': + sel_sort(names) + if button == 'Sort: quick': + qsort_holder(names) + if button == 'Linear Search': + linear_search() + if button == 'Binary Search': + binary_search() + if button == 'Save data\ndisplayed': + f = open(spathname, 'w') + for name in list_displayed: + print (name, file = f) + f.close() + else: + break diff --git a/ProgrammingClassExamples/MacOS versions/7a PSG (Data entry calc using file save retrieve).py b/ProgrammingClassExamples/MacOS versions/7a PSG (Data entry calc using file save retrieve).py new file mode 100644 index 00000000..e7ba2386 --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/7a PSG (Data entry calc using file save retrieve).py @@ -0,0 +1,67 @@ +#PySimple examples (v 3.9) +#Tony Crewe +#Oct 2018 MacOs + +import PySimpleGUI as sg +import os + +#sg.ChangeLookAndFeel('GreenTan') + +sg.SetOptions(background_color = 'LightBlue', + element_background_color = 'LightBlue', + text_element_background_color = 'LightBlue', + font= ('Calibri', 14, 'bold')) + +layout = [ + [sg.Text('Enter a Name and four Marks')], + [sg.Text('Name:', size =(8,1)), sg.InputText(size = (10,1), key = '_name_')], + [sg.Text('Mark1:', size =(8,1)), sg.InputText(size = (5,1), key = '_m1_')], + [sg.Text('Mark2:', size =(8,1)), sg.InputText(size = (5,1), key = '_m2_')], + [sg.Text('Mark3:', size =(8,1)), sg.InputText(size = (5,1), key = '_m3_')], + [sg.Text('Mark4:', size =(8,1)), sg.InputText(size = (5,1), key = '_m4_')], + [sg.ReadButton('Save', size = (6,1),key = '_save_'), sg.Text('Press to Save to file')], + [sg.ReadButton('Display',size = (6,1), key = '_display_'), sg.Text('To retrieve and Display')], + [sg.Multiline(size = (24,4), key = '_multiline_', pad = (2,15))]] + +window = sg.Window('Simple Average Finder').Layout(layout) + + +while True: + button, value = window.Read() #value is a dictionary holding name and marks (4) + if button is not None: + #initialise variables + total = 0.0 + index = '' + name = value['_name_'] + #get pathname to current file + dirname, filename = os.path.split(os.path.abspath(__file__)) + #add desired file name for saving to path + pathname = os.path.join(dirname , 'results.txt' ) + + #needs validation and try/catch error checking, will crash if blank or text entry for marks + + if button == '_save_': + #create dictionary index _m1_ ... _m4_ + for i in range (1,5): + index = '_m' + str(i) + '_' + total += float(value[index]) + average = total/4 + #open file and save + f = open(pathname, 'w') + print (name, file = f) + print (total, file = f) + print (average, file = f) + f.close() + + #some error checking for missing file needed here + + if button == '_display_': + #This loads the file line by line into a list called data. + #the strip() removes whitespaces from beginning and end of each line. + data = [line.strip() for line in open(pathname)] + #create single string to display in multiline object. + string = 'Name: ' + data[0] +'\nTotal: ' + str(data[1]) + '\nAverage: ' + str(data[2]) + window.FindElement('_multiline_').Update(string) + else: + break + diff --git a/ProgrammingClassExamples/MacOS versions/7b PSG (add validation and error trap).py b/ProgrammingClassExamples/MacOS versions/7b PSG (add validation and error trap).py new file mode 100644 index 00000000..412bbb64 --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/7b PSG (add validation and error trap).py @@ -0,0 +1,72 @@ +#PySimple examples (v 3.9) +#Tony Crewe +#Oct 2018 MacOs + +import PySimpleGUI as sg +import os #to work with windows OS + +#sg.ChangeLookAndFeel('GreenTan') + +sg.SetOptions(background_color = 'LightBlue', + element_background_color = 'LightBlue', + text_element_background_color = 'LightBlue', + font= ('Calibri', 14, 'bold')) + +layout = [ + [sg.Text('Enter a Name and four Marks')], + [sg.Text('Name:', size =(8,1)), sg.InputText(size = (10,1), key = '_name_')], + [sg.Text('Mark1:', size =(8,1)), sg.InputText(size = (5,1), key = '_m1_')], + [sg.Text('Mark2:', size =(8,1)), sg.InputText(size = (5,1), key = '_m2_')], + [sg.Text('Mark3:', size =(8,1)), sg.InputText(size = (5,1), key = '_m3_')], + [sg.Text('Mark4:', size =(8,1)), sg.InputText(size = (5,1), key = '_m4_')], + [sg.ReadButton('Save', size = (6,1),key = '_save_'), sg.Text('Press to Save to file')], + [sg.ReadButton('Display',size = (6,1), key = '_display_'), sg.Text('To retrieve and Display')], + [sg.Multiline(size = (24,4), key = '_multiline_', pad = (2,15))]] + +window = sg.Window('Simple Average Finder').Layout(layout) + + +while True: + button, value = window.Read() #value is a dictionary holding name and marks (4) + if button is not None: + #initialise variables + total = 0.0 + index = '' + name = value['_name_'] + #get pathname to current file + dirname, filename = os.path.split(os.path.abspath(__file__)) + #add desired file name for saving to path + pathname = os.path.join(dirname , 'results.txt' ) + #generic catch error - blanks or wrong data types + try: + if button == '_save_': + for i in range (1,5): + index = '_m' + str(i) + '_' + + #Check for values between 0 and 100 + if float(value[index]) < 0 or float(value[index]) >100: + sg.Popup('Out of Range', 'Enter Marks between 0 and 100') + else: + total += float(value[index]) + average = total/4 + f = open(pathname, 'w') + print (name, file = f) + print (total, file = f) + print (average, file = f) + f.close() + except ValueError: + sg.Popup('Error','Check entries and try again') + + if button == '_display_': + #This loads the file line by line into a list called data. + #the strip() removes whitespaces from beginning and end of each line. + try: + data = [line.strip() for line in open(pathname)] + #create single string to display in multiline object. + string = 'Name: ' + data[0] +'\nTotal: ' + str(data[1]) + '\nAverage: ' + str(data[2]) + window.FindElement('_multiline_').Update(string) + except: + sg.PopupError('Error', 'Problem finding or reading file') + else: + break + diff --git a/ProgrammingClassExamples/MacOS versions/7c PSG (add get pathname to save and retrieve files).py b/ProgrammingClassExamples/MacOS versions/7c PSG (add get pathname to save and retrieve files).py new file mode 100644 index 00000000..b3d208a3 --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/7c PSG (add get pathname to save and retrieve files).py @@ -0,0 +1,80 @@ +#PySimple examples (v 3.9) +#Tony Crewe +#Oct 2018 MacOs + +import PySimpleGUI as sg +import os #to work with windows OS + +#sg.ChangeLookAndFeel('GreenTan') + +sg.SetOptions(background_color = 'LightBlue', + element_background_color = 'LightBlue', + text_element_background_color = 'LightBlue', + font= ('Calibri', 14, 'bold')) + +layout = [ + [sg.Text('Enter a Name and four Marks')], + [sg.Text('Name:', size =(8,1)), sg.InputText(size = (10,1), key = '_name_')], + [sg.Text('Mark1:', size =(8,1)), sg.InputText(size = (5,1), key = '_m1_')], + [sg.Text('Mark2:', size =(8,1)), sg.InputText(size = (5,1), key = '_m2_')], + [sg.Text('Mark3:', size =(8,1)), sg.InputText(size = (5,1), key = '_m3_')], + [sg.Text('Mark4:', size =(8,1)), sg.InputText(size = (5,1), key = '_m4_')], + [sg.ReadButton('Save', size = (6,1),key = '_save_'), sg.Text('Press to Save to file')], + [sg.ReadButton('Display',size = (6,1), key = '_display_'), sg.Text('To retrieve and Display')], + [sg.Multiline(size = (24,4), key = '_multiline_', pad = (2,15))]] + +window = sg.Window('Simple Average Finder').Layout(layout) + + +while True: + button, value = window.Read() #value is a dictionary holding name and marks (4) + if button is not None: + #initialise variables + total = 0.0 + index = '' + name = value['_name_'] + #get pathname to current file + dirname, filename = os.path.split(os.path.abspath(__file__)) + #add desired file name for saving to path + pathname = os.path.join(dirname , 'results.txt') + #generic catch error - blanks or wrong data types + try: + if button == '_save_': + for i in range (1,5): + index = '_m' + str(i) + '_' + + #Check for values between 0 and 100 + if float(value[index]) < 0 or float(value[index]) >100: + sg.Popup('Out of Range', 'Enter Marks between 0 and 100') + else: + total += float(value[index]) + average = total/4 + #check location and file name for file, no_window so go straight to folder selection + + foldername = sg.PopupGetFolder('', no_window=True) + filename = sg.PopupGetFile('Please enter a file name for your results') + pathname = os.path.join(foldername ,filename + '.txt') + + f = open(pathname, 'w') + print (name, file = f) + print (total, file = f) + print (average, file = f) + f.close() + except ValueError: + sg.Popup('Error','Check entries and try again') + + if button == '_display_': + #get pathname: folder and file + pathname = sg.PopupGetFile('file to open', no_window=True, file_types=(("text files","*.txt"),)) + #This loads the file line by line into a list called data. + #the strip() removes whitespaces from beginning and end of each line. + try: + data = [line.strip() for line in open(pathname)] + #create single string to display in multiline object. + string = 'Name: ' + data[0] +'\nTotal: ' + str(data[1]) + '\nAverage: ' + str(data[2]) + window.FindElement('_multiline_').Update(string) + except: + sg.PopupError('Error', 'Problem finding or reading file') + else: + break + diff --git a/ProgrammingClassExamples/MacOS versions/8a PSG (Data to plot from csv file).py b/ProgrammingClassExamples/MacOS versions/8a PSG (Data to plot from csv file).py new file mode 100644 index 00000000..c8b6b85c --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/8a PSG (Data to plot from csv file).py @@ -0,0 +1,40 @@ +#matplotlib, pyplt and csv +#Tony Crewe +#Sep 2017 - updated Oct 2018 MacOs + +import matplotlib.pyplot as plt +import csv +from matplotlib.ticker import MaxNLocator + + +x=[] +y=[] + +with open('weight 2018.csv', 'r', encoding = 'utf-8-sig') as csvfile: + plots = csv.reader(csvfile) + for data in plots: + #get heading for x and y axes + var1 = (data[0]) + var2 = (data[1]) + break + for data in plots: + #get values - add to x list and y list + x.append(data[0]) + y.append(float(data[1])) + + +ax = plt.subplot(1,1,1) +ax.set_ylim([82, 96]) +ax.xaxis.set_major_locator(MaxNLocator(10)) +ax.spines['right'].set_color('none') +ax.spines['top'].set_color('none') + +plt.plot(x,y, label = 'data loaded\nfrom csv file') +plt.axhline(y = 85.5, color = 'orange', linestyle = '--', label = 'target') +plt.xlabel(var1) +plt.ylabel(var2) +plt.title('weight loss from\n first quarter 2018') + + +plt.legend() +plt.show() diff --git a/ProgrammingClassExamples/8b PSG (Tables and calc from csv file).py b/ProgrammingClassExamples/MacOS versions/8b PSG (Tables and calc from csv file).py similarity index 63% rename from ProgrammingClassExamples/8b PSG (Tables and calc from csv file).py rename to ProgrammingClassExamples/MacOS versions/8b PSG (Tables and calc from csv file).py index 0fae40a4..174303cd 100644 --- a/ProgrammingClassExamples/8b PSG (Tables and calc from csv file).py +++ b/ProgrammingClassExamples/MacOS versions/8b PSG (Tables and calc from csv file).py @@ -1,7 +1,6 @@ - -#PySimple examples (v 3.8) +#PySimple examples (v 3.9.3) #Tony Crewe -#Sep 2018 +#Oct 2018 MacOs #Based of Example program from MikeTheWatchGuy #https://gitlab.com/lotspaih/PySimpleGUI @@ -9,7 +8,9 @@ import sys import PySimpleGUI as sg import csv -sg.ChangeLookAndFeel('BrownBlue') +#sg.ChangeLookAndFeel('BrownBlue') +sg.SetOptions(background_color = 'LightBlue', + element_background_color = 'LightBlue') def calc_ladder(): @@ -44,18 +45,25 @@ def calc_ladder(): #use Table (explore settings) and add to column layout - col_layout = [[sg.Table(values=data, headings=header, auto_size_columns=True, - max_col_width = 12,justification='right', size=(None, len(data)))]] + # + #------ With MacOs -- manually adjust col_widths, auto to False ------------ + # + col_layout = [[sg.Table(values=data, headings=header,col_widths = (16, 4,4,4,4,6,6,7,4), auto_size_columns=False, + max_col_width = 30,justification='right', size=(None, len(data)))]] - layout = [[sg.Column(col_layout, size=(500,400), scrollable=True)],] + layout = [[sg.Column(col_layout, size=(520,360), scrollable=True)],] - window = sg.Window('Table', location = (700, 325), grab_anywhere=False).Layout(layout) + window = sg.Window('AFL Ladder',location = (500, 310), grab_anywhere = False).Layout(layout) b, v = window.Read() -slayout = [[sg.Text('Load AFL file to display results with points and percentage'),sg.ReadButton('Load File', size = (20,1))]] -swindow = sg.Window('Load File', location = (700,250)).Layout(slayout) +slayout = [[sg.Text('Load AFL file to display results with points and percentage', font = ('Arial', 14, 'bold')), + sg.ReadButton('Load File', font = ('Arial', 14, 'bold'), size = (15,1))]] +swindow = sg.Window('Load File', location = (500,250)).Layout(slayout) while True: button, value = swindow.Read() - if button == 'Load File': - calc_ladder() + if button is not None: + if button == 'Load File': + calc_ladder() + else: + break diff --git a/ProgrammingClassExamples/MacOS versions/8c PSG (Tables - add sort).py b/ProgrammingClassExamples/MacOS versions/8c PSG (Tables - add sort).py new file mode 100644 index 00000000..4071b971 --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/8c PSG (Tables - add sort).py @@ -0,0 +1,77 @@ +#PySimple examples (v 3.9.3) +#Tony Crewe +#Oct 2018 MacOs + +#Based of Example program from MikeTheWatchGuy +#https://gitlab.com/lotspaih/PySimpleGUI + +import sys +import PySimpleGUI as sg +import csv +import operator + +#sg.ChangeLookAndFeel('Dark') +sg.SetOptions(background_color = 'LightGrey', + element_background_color = 'LightGrey') + +def table_example(): + + filename = sg.PopupGetFile('Get required file', no_window = True,file_types=(("CSV Files","*.csv"),)) + #populate table with file contents + #Assume we know csv has heading in row 1 + #Assume we know 7 columns of data - relevenat to AFL w/o Pts or % shown + #data is a list of lists containing data about each team + #data[0] is one teams data data[0[[0] = team, data[0][1] P, data[0] [2] W, + #data[0][3] L, data [0][4] D, data [0][5] F, data [0][6] A + #no error checking or validation used. + + #initialise variables + data = [] + header_list = [] + with open(filename, "r") as infile: + reader = csv.reader(infile) + for i in range (1): + header = next(reader) + data = list(reader) + header = header + ['%', 'Pts'] + for i in range (len(data)): + #calculate % + percent = int(data[i][5])/int(data[i][6])*100 + data[i] = data[i] + [percent] + pts = int(data[i][2])*4 + int(data[i][4])*2 + data[i] = data[i] + [pts] + #sort data + #first by % + + data.sort(key = operator.itemgetter(7), reverse = True) + #then by pts + + data.sort(key = operator.itemgetter(8), reverse = True) + + #and format string to 2 decimal places + for i in range(len(data)): + data[i][7] = str('{:.2f}'.format(data[i][7])) + + #use Table (explore settings) and add to column layout + # + #------ With MacOs -- manually adjust col_widths, auto to False ------------ + # + col_layout = [[sg.Table(values=data, headings=header, col_widths = (16, 3,3,3,3,6,6,7,4), auto_size_columns=False, + max_col_width = 30,justification='right', size=(None, len(data)))]] + + layout = [[sg.Column(col_layout, size=(480,360), scrollable=True)],] + + window = sg.Window('Ladder', location = (350, 310), grab_anywhere = False).Layout(layout) + b, v = window.Read() + +slayout = [[sg.Text(' Load AFL (csv) file to display sorted results.', font = ('Calibri', 16, 'bold')), + sg.ReadButton('Load File', font = ('Calibri', 16, 'bold'), button_color = ('Red', 'White'), size = (10,1))]] +swindow = sg.Window('Load File', location = (350,250)).Layout(slayout) + +while True: + button, value = swindow.Read() + if button is not None: + if button == 'Load File': + table_example() + else: + break diff --git a/ProgrammingClassExamples/MacOS versions/8d PSG (Tables - add logo).py b/ProgrammingClassExamples/MacOS versions/8d PSG (Tables - add logo).py new file mode 100644 index 00000000..c2fe109b --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/8d PSG (Tables - add logo).py @@ -0,0 +1,71 @@ +#PySimple examples (v 3.9.3) +#Tony Crewe +#Oct 2018 MacOs + +#Based of Example program from MikeTheWatchGuy +#https://gitlab.com/lotspaih/PySimpleGUI + +import sys +import PySimpleGUI as sg +import csv +import operator +import os + +sg.SetOptions(background_color = 'Black', + element_background_color = 'Black', + font = ('Calibri', 16, 'bold'), + text_color = 'White') + +#get pathname to current file and add file name for image +dirname, filename = os.path.split(os.path.abspath(__file__)) + +pathname = os.path.join(dirname , 'AFL.png' ) + +def table_example(): + + filename = sg.PopupGetFile('Get required file', no_window = True,file_types=(("CSV Files","*.csv"),)) + + + data = [] + header_list = [] + + with open(filename, "r") as infile: + reader = csv.reader(infile) + for i in range (1): + header = next(reader) + data = list(reader) + header = header + ['%', 'Pts'] + for i in range (len(data)): + + percent = int(data[i][5])/int(data[i][6])*100 + data[i] = data[i] + [percent] + + pts = int(data[i][2])*4 + int(data[i][4])*2 + data[i] = data[i] + [pts] + + data.sort(key = operator.itemgetter(7), reverse = True) + data.sort(key = operator.itemgetter(8), reverse = True) + + for i in range(len(data)): + data[i][7] = str('{:.2f}'.format(data[i][7])) + + col_layout = [[sg.Table(values=data, headings=header, col_widths = (16, 3,3,3,3,6,6,6,4), auto_size_columns=False, + max_col_width = 30,justification='right', size=(None, len(data)))]] + + layout = [[sg.Column(col_layout, size=(480,360), scrollable=True)],] + + window = sg.Window('Table', no_titlebar = False, location = (350, 318), grab_anywhere = False).Layout(layout) + b, v = window.Read() + +slayout = [[sg.Image(pathname),sg.Text(' Load AFL (csv) file to display results. '), + sg.ReadButton('Load File', size = (10,1))]] +swindow = sg.Window('Load File', location = (350,250)).Layout(slayout) + +while True: + button, value = swindow.Read() + if button is not None: + if button == 'Load File': + table_example() + else: + break + diff --git a/ProgrammingClassExamples/MacOS versions/9a PSG Windows(location hide).py b/ProgrammingClassExamples/MacOS versions/9a PSG Windows(location hide).py new file mode 100644 index 00000000..312af3b4 --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/9a PSG Windows(location hide).py @@ -0,0 +1,52 @@ +#PySimple examples (v 3.9) +#Tony Crewe +#Sep 2018 MacOs + +import PySimpleGUI as sg + +#sg.ChangeLookAndFeel('SandyBeach') +sg.SetOptions (background_color = 'LightBlue', + element_background_color = 'LightBlue', + text_element_background_color = 'LightBlue', + font = ('Arial', 14, 'bold'), + text_color = 'Blue', + input_text_color ='Blue', + button_color = ('Blue', 'White') + ) + +layout0 = [[sg.ReadButton('Show/Hide window1'),sg.ReadButton('Show/Hide window2')]] + +layout1 =[[ sg.Text('window1')], [sg.Multiline( size = (35, 10))]] +layout2 =[[ sg.Text('window2')], [sg.Multiline( size = (35, 10))]] +window0 = sg.Window('Home Window', location = (200, 140)).Layout(layout0) + +window1 = sg.Window('Window1', location = (200, 200)).Layout(layout1).Finalize() +window1.Hide() +w1 = False + +window2 = sg.Window('Window2', location = (600, 200)).Layout(layout2).Finalize() +window2.Hide() +w2 = False + +while True: + button, v = window0.Read() + if button is not None: + if button =='Show/Hide window1': + if w1 == True: + window1.Hide() + w1 = False + else: + window1.UnHide() + w1=True + if button =='Show/Hide window2': + if w2 == True: + window2.Hide() + w2 = False + else: + window2.UnHide() + w2=True + else: + break + + + diff --git a/ProgrammingClassExamples/MacOS versions/9b PSG Tabs example.py b/ProgrammingClassExamples/MacOS versions/9b PSG Tabs example.py new file mode 100644 index 00000000..7c4ec0f5 --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/9b PSG Tabs example.py @@ -0,0 +1,22 @@ +#PySimple examples (v 3.9) +#Tony Crewe +#Oct 2018 MacOs + +import PySimpleGUI as sg + +tab1_layout = [[sg.Text('This is inside tab 1')]] + +tab2_layout = [[sg.Text('This is inside tab 2')]] + +layout = [[sg.TabGroup([[sg.Tab('Tab 1', tab1_layout), + sg.Tab('Tab 2', tab2_layout)]])], + [sg.ReadButton('Read')]] + +window = sg.Window('Main Window').Layout(layout) + +while True: + b, v = window.Read() + if b is not None: + print(b,v) + else: + break diff --git a/ProgrammingClassExamples/MacOS versions/9c PSG Tabs example plus.py b/ProgrammingClassExamples/MacOS versions/9c PSG Tabs example plus.py new file mode 100644 index 00000000..b69965e3 --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/9c PSG Tabs example plus.py @@ -0,0 +1,89 @@ +#PySimple examples (v 3.9) +#Tony Crewe +#Oct 2018 MacOs + +import PySimpleGUI as sg +import os + +#sg.ChangeLookAndFeel('BlueMono') +sg.SetOptions (background_color = 'LightBlue', + element_background_color = 'LightBlue', + text_element_background_color = 'LightBlue', + font = ('Arial', 12, 'bold'), + text_color = 'Blue', + input_text_color ='Blue', + button_color = ('Blue', 'White')) + +#get pathname to current file + +dirname, filename = os.path.split(os.path.abspath(__file__)) +pathname = os.path.join(dirname , 'Names.txt' ) + +#Get data from file +names = [line.strip() for line in open(pathname)] +sorted_names = names[:] +sorted_names.sort() + +tab1_layout =[[sg.Text('Linear Search Demo', font =('Calibri', 14, 'bold'))], + [sg.Listbox(values =[n for n in names], size = (15, 12),font = ('Calibri', 12), background_color ='White',key = '_display1_')], + [sg.Text('_'*25,font = ('Calibri', 12))], + [sg.Text('Enter name to search for:',font = ('Calibri', 14, 'bold'))], + [sg.InputText(size = (15,1), key = '_linear_')], + [sg.ReadButton('Linear Search', font = ('Calibri', 14, 'bold'), size = (11,1))]] + +tab2_layout = [[sg.Text('Binary Search Demo', font =('Calibri', 14, 'bold'))], + [sg.Listbox(values =[n for n in sorted_names], size = (15, 12),font = ('Calibri', 12), background_color ='White',key = '_display2_')], + [sg.Text('_'*25,font = ('Calibri', 12))], + [sg.Text('Enter name to search for:',font = ('Calibri', 14, 'bold'))], + [sg.InputText(size = (15,1), key = '_binary_')], + [sg.ReadButton('Binary Search',font = ('Calibri', 14, 'bold'), size = (11,1))]] + +layout = [ + [sg.TabGroup([[sg.Tab('Linear Search', tab1_layout),sg.Tab('Binary Search', tab2_layout)]])]] + +window = sg.Window('Main Window').Layout(layout) + +#Linear Search - no need for Ordered list +def linear_search(): + l = names[:] + found = False + for l in l: + if l == value['_linear_']: #Check each value + found = True + result = ['Linear search', l + ' found'] + window.FindElement('_display1_').Update(result) + break + if not found: + result = [value['_linear_'], 'was not found'] + window.FindElement('_display1_').Update(result) + +#Binary Search - only works for ordered lists +def binary_search(): + l = sorted_names + lo = 0 + hi = len(l)-1 + found = False + while lo <= hi: + mid = (lo + hi) //2 + if l[mid] == value['_binary_']: + found = True + result = ['Binary search', l[mid] + ' found.'] + window.FindElement('_display2_').Update(result) + break + elif l[mid] < value['_binary_']: + lo = mid + 1 + else: + hi = mid - 1 + if not found: + result = [value['_binary_'], 'was not found'] + window.FindElement('_display2_').Update(result) + +while True: + button, value = window.Read() + if button is not None: + if button == 'Linear Search': + linear_search() + if button == 'Binary Search': + binary_search() + else: + break diff --git a/ProgrammingClassExamples/AFL.png b/ProgrammingClassExamples/MacOS versions/AFL.png similarity index 100% rename from ProgrammingClassExamples/AFL.png rename to ProgrammingClassExamples/MacOS versions/AFL.png diff --git a/ProgrammingClassExamples/AFL2018 (sorted alpha teams).csv b/ProgrammingClassExamples/MacOS versions/AFL2018 (sorted alpha teams).csv similarity index 100% rename from ProgrammingClassExamples/AFL2018 (sorted alpha teams).csv rename to ProgrammingClassExamples/MacOS versions/AFL2018 (sorted alpha teams).csv diff --git a/ProgrammingClassExamples/AFL2018 (sorted pts and %).csv b/ProgrammingClassExamples/MacOS versions/AFL2018 (sorted pts and %).csv similarity index 100% rename from ProgrammingClassExamples/AFL2018 (sorted pts and %).csv rename to ProgrammingClassExamples/MacOS versions/AFL2018 (sorted pts and %).csv diff --git a/ProgrammingClassExamples/Gym_Logo.png b/ProgrammingClassExamples/MacOS versions/Gym_Logo.png similarity index 100% rename from ProgrammingClassExamples/Gym_Logo.png rename to ProgrammingClassExamples/MacOS versions/Gym_Logo.png diff --git a/ProgrammingClassExamples/Names(sorted).txt b/ProgrammingClassExamples/MacOS versions/Names(sorted).txt similarity index 100% rename from ProgrammingClassExamples/Names(sorted).txt rename to ProgrammingClassExamples/MacOS versions/Names(sorted).txt diff --git a/ProgrammingClassExamples/Names.txt b/ProgrammingClassExamples/MacOS versions/Names.txt similarity index 100% rename from ProgrammingClassExamples/Names.txt rename to ProgrammingClassExamples/MacOS versions/Names.txt diff --git a/ProgrammingClassExamples/MacOS versions/Test.txt b/ProgrammingClassExamples/MacOS versions/Test.txt new file mode 100644 index 00000000..6f15df0a --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/Test.txt @@ -0,0 +1,3 @@ +T +202.0 +50.5 diff --git a/ProgrammingClassExamples/MacOS versions/TonyCrewe2.txt b/ProgrammingClassExamples/MacOS versions/TonyCrewe2.txt new file mode 100644 index 00000000..5ee47eaf --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/TonyCrewe2.txt @@ -0,0 +1,3 @@ +Tony +158.0 +39.5 diff --git a/ProgrammingClassExamples/default_icon.ico b/ProgrammingClassExamples/MacOS versions/default_icon.ico similarity index 100% rename from ProgrammingClassExamples/default_icon.ico rename to ProgrammingClassExamples/MacOS versions/default_icon.ico diff --git a/ProgrammingClassExamples/MacOS versions/results.txt b/ProgrammingClassExamples/MacOS versions/results.txt new file mode 100644 index 00000000..0d13392a --- /dev/null +++ b/ProgrammingClassExamples/MacOS versions/results.txt @@ -0,0 +1,3 @@ +Tony +224.0 +56.0 diff --git a/ProgrammingClassExamples/weight 2018.csv b/ProgrammingClassExamples/MacOS versions/weight 2018.csv similarity index 100% rename from ProgrammingClassExamples/weight 2018.csv rename to ProgrammingClassExamples/MacOS versions/weight 2018.csv diff --git a/ProgrammingClassExamples/Tony.txt b/ProgrammingClassExamples/Tony.txt deleted file mode 100644 index c70fa00e..00000000 --- a/ProgrammingClassExamples/Tony.txt +++ /dev/null @@ -1,3 +0,0 @@ -Tony -275.0 -68.75 diff --git a/ProgrammingClassExamples/10a PSG Plot (Matplotlib numpy pyplot(y=sinx)) .py b/ProgrammingClassExamples/Win10 versions/10a PSG Plot (Matplotlib numpy pyplot(y=sinx)) .py similarity index 100% rename from ProgrammingClassExamples/10a PSG Plot (Matplotlib numpy pyplot(y=sinx)) .py rename to ProgrammingClassExamples/Win10 versions/10a PSG Plot (Matplotlib numpy pyplot(y=sinx)) .py diff --git a/ProgrammingClassExamples/10b PSG Plot (axes moved).py b/ProgrammingClassExamples/Win10 versions/10b PSG Plot (axes moved).py similarity index 100% rename from ProgrammingClassExamples/10b PSG Plot (axes moved).py rename to ProgrammingClassExamples/Win10 versions/10b PSG Plot (axes moved).py diff --git a/ProgrammingClassExamples/10c PSG Plot (axes pi format).py b/ProgrammingClassExamples/Win10 versions/10c PSG Plot (axes pi format).py similarity index 100% rename from ProgrammingClassExamples/10c PSG Plot (axes pi format).py rename to ProgrammingClassExamples/Win10 versions/10c PSG Plot (axes pi format).py diff --git a/ProgrammingClassExamples/10d PSG (Plots Tabs and sin cos options).py b/ProgrammingClassExamples/Win10 versions/10d PSG (Plots Tabs and sin cos options).py similarity index 100% rename from ProgrammingClassExamples/10d PSG (Plots Tabs and sin cos options).py rename to ProgrammingClassExamples/Win10 versions/10d PSG (Plots Tabs and sin cos options).py diff --git a/ProgrammingClassExamples/10e PSG (Same Window).py b/ProgrammingClassExamples/Win10 versions/10e PSG (Same Window).py similarity index 100% rename from ProgrammingClassExamples/10e PSG (Same Window).py rename to ProgrammingClassExamples/Win10 versions/10e PSG (Same Window).py diff --git a/ProgrammingClassExamples/10f PSG (linear and quadratics).py b/ProgrammingClassExamples/Win10 versions/10f PSG (linear and quadratics).py similarity index 89% rename from ProgrammingClassExamples/10f PSG (linear and quadratics).py rename to ProgrammingClassExamples/Win10 versions/10f PSG (linear and quadratics).py index 64625263..b208bd76 100644 --- a/ProgrammingClassExamples/10f PSG (linear and quadratics).py +++ b/ProgrammingClassExamples/Win10 versions/10f PSG (linear and quadratics).py @@ -10,7 +10,7 @@ import matplotlib.backends.tkagg as tkagg import numpy as np import tkinter as tk -sg.ChangeLookAndFeel('Purple') +sg.ChangeLookAndFeel('Black') sg.SetOptions(font = ('Calibri', 14, 'bold')) def draw_figure(canvas, figure, loc = (0,0)): @@ -74,21 +74,21 @@ set_plot(1,1,1, function) #column 1 for function type and constant values ... column1 = [ - [sg.Text('Select constants and function type', )], - [sg.InputCombo(['y = ax + b', 'y = ax^2 + bx + c'], size = (12, 4), key = '_function_'), + [sg.Text('Select constants & function type', )], + [sg.InputCombo(['y = ax + b', 'y = ax^2 + bx + c'], size = (16, 4), key = '_function_'), sg.Text('Function', size = (10, 1))], [sg.Text('', size = (1, 2))], - [sg.Spin([sz for sz in range (-6,6)], initial_value =1, size = (2,1), key = '_a_'), + [sg.Spin([sz for sz in range (-6,6)], initial_value =1, size = (3,2), key = '_a_'), sg.Text('a', size = (3, 1)), - sg.Spin([sz for sz in range (-6,6)], initial_value =1, size = (2,1), key = '_b_'), + sg.Spin([sz for sz in range (-6,6)], initial_value =1, size = (3,2), key = '_b_'), sg.Text('b', size = (3, 1)), - sg.Spin([sz for sz in range (-6,6)], initial_value =1, size = (2,1), key = '_c_'), + sg.Spin([sz for sz in range (-6,6)], initial_value =1, size = (3,2), key = '_c_'), sg.Text('c', size = (3, 1))], [sg.Text('', size = (1, 1))], - [sg.ReadButton('Redraw Plot')], + [sg.ReadButton('Redraw Plot', button_color = ('White', 'Red'))], [sg.Text('', size = (1, 14))]] column2 = [[sg.Text('Plot Test - PySimpleGUI and Matplotlib and options')], [sg.Canvas(size = (figure_w, figure_h), key = '_canvas_')], - [sg.OK(pad=((figure_w / 2, 0), 1), size=(4, 1))]] + [sg.OK(pad=((figure_w / 2, 0), 1), size=(4, 1), button_color = ('White', 'Red'))]] layout = [[sg.Column(column1), sg.Column(column2)]] window = sg.Window('Matplot, PySimpleGUI and options', force_toplevel = True).Layout(layout).Finalize() diff --git a/ProgrammingClassExamples/1a PSG (Entry and PopUp).py b/ProgrammingClassExamples/Win10 versions/1a PSG (Entry and PopUp).py similarity index 87% rename from ProgrammingClassExamples/1a PSG (Entry and PopUp).py rename to ProgrammingClassExamples/Win10 versions/1a PSG (Entry and PopUp).py index 377eabc7..1b7b9ded 100644 --- a/ProgrammingClassExamples/1a PSG (Entry and PopUp).py +++ b/ProgrammingClassExamples/Win10 versions/1a PSG (Entry and PopUp).py @@ -15,7 +15,10 @@ window = sg.Window('Temperature Converter').Layout(layout) #get value (part of a list) button, value = window.Read() - +if button is None: + #windows was closed without button being pressed + exit(0) + #convert and create string fahrenheit = round(9/5*float(value[0]) +32, 1) result = 'Temperature in Fahrenheit is: ' + str(fahrenheit) diff --git a/ProgrammingClassExamples/1b PSG (Format).py b/ProgrammingClassExamples/Win10 versions/1b PSG (Format).py similarity index 90% rename from ProgrammingClassExamples/1b PSG (Format).py rename to ProgrammingClassExamples/Win10 versions/1b PSG (Format).py index d5b5540b..2b65953f 100644 --- a/ProgrammingClassExamples/1b PSG (Format).py +++ b/ProgrammingClassExamples/Win10 versions/1b PSG (Format).py @@ -21,7 +21,9 @@ layout = [ window = sg.Window('Converter').Layout(layout) button, value = window.Read() - +if button is None: + #windows was closed without button being pressed + exit(0) fahrenheit = round(9/5*float(value[0]) +32, 1) result = 'Temperature in Fahrenheit is: ' + str(fahrenheit) sg.Popup('Result',result) diff --git a/ProgrammingClassExamples/1c PSG (persistent form and bind key).py b/ProgrammingClassExamples/Win10 versions/1c PSG (persistent form and bind key).py similarity index 100% rename from ProgrammingClassExamples/1c PSG (persistent form and bind key).py rename to ProgrammingClassExamples/Win10 versions/1c PSG (persistent form and bind key).py diff --git a/ProgrammingClassExamples/1d PSG (named input keys and catch errors).py b/ProgrammingClassExamples/Win10 versions/1d PSG (named input keys and catch errors).py similarity index 100% rename from ProgrammingClassExamples/1d PSG (named input keys and catch errors).py rename to ProgrammingClassExamples/Win10 versions/1d PSG (named input keys and catch errors).py diff --git a/ProgrammingClassExamples/Win10 versions/1e PSG (validation and Look and Feel).py b/ProgrammingClassExamples/Win10 versions/1e PSG (validation and Look and Feel).py new file mode 100644 index 00000000..3db950a1 --- /dev/null +++ b/ProgrammingClassExamples/Win10 versions/1e PSG (validation and Look and Feel).py @@ -0,0 +1,34 @@ +#PySimple examples (v 3.8) +#Tony Crewe +#Sep 2018 + +import PySimpleGUI as sg + +#Can use a variety of themes - plus individual options +sg.ChangeLookAndFeel('SandyBeach') +sg.SetOptions (font = ('Arial', 10, 'bold')) + + +layout = [ [sg.Text('Enter a Temperature in Celcius')], + [sg.Text('Celcius', size =(8,1)), sg.InputText(size = (15,1),key = '_input_')], + [sg.Text('Result', size =(8,1)), sg.InputText(size = (15,1),key = '_result_')], + [sg.ReadButton('Submit', bind_return_key = True)]] + +window = sg.Window('Temp Converter').Layout(layout) + +while True: + button, value = window.Read() + if button is not None: + #catch program errors for text, floats or blank entry: + #Also validation for range [0, 50] + try: + if float(value['_input_']) > 50 or float(value['_input_']) <0: + sg.Popup('Error','Out of range') + else: + fahrenheit = round(9/5*int(value['_input_']) +32, 1) + window.FindElement('_result_').Update(fahrenheit) + except ValueError: + sg.Popup('Error','Please try again') + + else: + break diff --git a/ProgrammingClassExamples/2a. PSG (checkbox and radiobuttons) - Copy.py b/ProgrammingClassExamples/Win10 versions/2a. PSG (checkbox and radiobuttons) - Copy.py similarity index 100% rename from ProgrammingClassExamples/2a. PSG (checkbox and radiobuttons) - Copy.py rename to ProgrammingClassExamples/Win10 versions/2a. PSG (checkbox and radiobuttons) - Copy.py diff --git a/ProgrammingClassExamples/2b. PSG (Add logo).py b/ProgrammingClassExamples/Win10 versions/2b. PSG (Add logo).py similarity index 94% rename from ProgrammingClassExamples/2b. PSG (Add logo).py rename to ProgrammingClassExamples/Win10 versions/2b. PSG (Add logo).py index c931028b..cf35f47d 100644 --- a/ProgrammingClassExamples/2b. PSG (Add logo).py +++ b/ProgrammingClassExamples/Win10 versions/2b. PSG (Add logo).py @@ -10,7 +10,7 @@ sg.SetOptions (font =('Calibri',12,'bold')) #get pathname to current file dirname, filename = os.path.split(os.path.abspath(__file__)) #add file name for image -pathname = dirname + '\\Gym_Logo.png' +pathname = os.path.join(dirname ,'Gym_Logo.png') layout = [[sg.Image(pathname),sg.Text(' Membership Calculator', font = ('Calibri', 16, 'bold'))], [sg.Checkbox(' Student? 10% off', size = (25,1)), diff --git a/ProgrammingClassExamples/2b_makewinexe_file.py b/ProgrammingClassExamples/Win10 versions/2b_makewinexe_file.py similarity index 100% rename from ProgrammingClassExamples/2b_makewinexe_file.py rename to ProgrammingClassExamples/Win10 versions/2b_makewinexe_file.py diff --git a/ProgrammingClassExamples/3 PSG (multiline display).py b/ProgrammingClassExamples/Win10 versions/3 PSG (multiline display).py similarity index 100% rename from ProgrammingClassExamples/3 PSG (multiline display).py rename to ProgrammingClassExamples/Win10 versions/3 PSG (multiline display).py diff --git a/ProgrammingClassExamples/4a PSG (Sliders and combo).py b/ProgrammingClassExamples/Win10 versions/4a PSG (Sliders and combo).py similarity index 100% rename from ProgrammingClassExamples/4a PSG (Sliders and combo).py rename to ProgrammingClassExamples/Win10 versions/4a PSG (Sliders and combo).py diff --git a/ProgrammingClassExamples/4b PSG (Spinner and combo) .py b/ProgrammingClassExamples/Win10 versions/4b PSG (Spinner and combo) .py similarity index 100% rename from ProgrammingClassExamples/4b PSG (Spinner and combo) .py rename to ProgrammingClassExamples/Win10 versions/4b PSG (Spinner and combo) .py diff --git a/ProgrammingClassExamples/5a PSG (listboxes add remove).py b/ProgrammingClassExamples/Win10 versions/5a PSG (listboxes add remove).py similarity index 100% rename from ProgrammingClassExamples/5a PSG (listboxes add remove).py rename to ProgrammingClassExamples/Win10 versions/5a PSG (listboxes add remove).py diff --git a/ProgrammingClassExamples/6a PSG (search linear and binary).py b/ProgrammingClassExamples/Win10 versions/6a PSG (search linear and binary).py similarity index 100% rename from ProgrammingClassExamples/6a PSG (search linear and binary).py rename to ProgrammingClassExamples/Win10 versions/6a PSG (search linear and binary).py diff --git a/ProgrammingClassExamples/6b PSG (search - disabled buttons).py b/ProgrammingClassExamples/Win10 versions/6b PSG (search - disabled buttons).py similarity index 100% rename from ProgrammingClassExamples/6b PSG (search - disabled buttons).py rename to ProgrammingClassExamples/Win10 versions/6b PSG (search - disabled buttons).py diff --git a/ProgrammingClassExamples/6c PSG (search text preloaded).py b/ProgrammingClassExamples/Win10 versions/6c PSG (search text preloaded).py similarity index 94% rename from ProgrammingClassExamples/6c PSG (search text preloaded).py rename to ProgrammingClassExamples/Win10 versions/6c PSG (search text preloaded).py index 164ff001..89009642 100644 --- a/ProgrammingClassExamples/6c PSG (search text preloaded).py +++ b/ProgrammingClassExamples/Win10 versions/6c PSG (search text preloaded).py @@ -67,9 +67,6 @@ while True: button, value = window.Read() if button is not None: - if button == 'Show Names': - display_list(names,'_display1_') - display_list(sorted_names, '_display2_') if button == 'Linear Search': linear_search() if button == 'Binary Search': diff --git a/ProgrammingClassExamples/6d PSG (sort and search with textbox.py b/ProgrammingClassExamples/Win10 versions/6d PSG (sort and search with textbox.py similarity index 100% rename from ProgrammingClassExamples/6d PSG (sort and search with textbox.py rename to ProgrammingClassExamples/Win10 versions/6d PSG (sort and search with textbox.py diff --git a/ProgrammingClassExamples/6e PSG (sort and search with listbox).py b/ProgrammingClassExamples/Win10 versions/6e PSG (sort and search with listbox).py similarity index 100% rename from ProgrammingClassExamples/6e PSG (sort and search with listbox).py rename to ProgrammingClassExamples/Win10 versions/6e PSG (sort and search with listbox).py diff --git a/ProgrammingClassExamples/6f PSG (data from text file).py b/ProgrammingClassExamples/Win10 versions/6f PSG (data from text file).py similarity index 88% rename from ProgrammingClassExamples/6f PSG (data from text file).py rename to ProgrammingClassExamples/Win10 versions/6f PSG (data from text file).py index 67e550bf..126dcfa0 100644 --- a/ProgrammingClassExamples/6f PSG (data from text file).py +++ b/ProgrammingClassExamples/Win10 versions/6f PSG (data from text file).py @@ -10,8 +10,8 @@ sg.SetOptions (font =('Calibri',12,'bold')) #get pathname to current file dirname, filename = os.path.split(os.path.abspath(__file__)) -pathname = dirname + '\\Names.txt' #original data -spathname = dirname + '\\Names(sorted).txt' #sorted data +pathname = os.path.join(dirname, 'Names.txt') #original data +spathname = os.path.join(dirname, 'Names(sorted).txt') #sorted data #Get data from file names = [line.strip() for line in open(pathname)] @@ -19,7 +19,9 @@ names = [line.strip() for line in open(pathname)] column1 = [[sg.ReadButton('Original list', size = (13,1))], [sg.ReadButton('Default sort', size = (13,1))], [sg.ReadButton('Sort: selection',size = (13,1))], - [sg.ReadButton('Sort: quick', size = (13,1))]] + [sg.ReadButton('Sort: quick', size = (13,1))], + [sg.Text('______________',font = ('Calibri', 12))], + [sg.ReadButton('Save data\ndisplayed', size = (13,2))]] layout =[[sg.Text('Search and Sort Demo', font =('Calibri', 20, 'bold'))], [sg.Listbox(values =[''], size = (14, 11),font = ('Calibri', 12), background_color ='White',key = '_display_'), sg.Column(column1)], @@ -134,5 +136,10 @@ while True: linear_search() if button == 'Binary Search': binary_search() + if button == 'Save data\ndisplayed': + f = open(spathname, 'w') + for name in list_displayed: + print (name, file = f) + f.close() else: break diff --git a/ProgrammingClassExamples/7a PSG (Data entry calc using file save retrieve).py b/ProgrammingClassExamples/Win10 versions/7a PSG (Data entry calc using file save retrieve).py similarity index 96% rename from ProgrammingClassExamples/7a PSG (Data entry calc using file save retrieve).py rename to ProgrammingClassExamples/Win10 versions/7a PSG (Data entry calc using file save retrieve).py index 8058e4e2..002599f1 100644 --- a/ProgrammingClassExamples/7a PSG (Data entry calc using file save retrieve).py +++ b/ProgrammingClassExamples/Win10 versions/7a PSG (Data entry calc using file save retrieve).py @@ -32,7 +32,7 @@ while True: #get pathname to current file dirname, filename = os.path.split(os.path.abspath(__file__)) #add desired file name for saving to path - pathname = dirname + '\\results.txt' + pathname = os.path.join(dirname , 'results.txt' ) #needs validation and try/catch error checking, will crash if blank or text entry for marks diff --git a/ProgrammingClassExamples/7b PSG (add validation and error trap).py b/ProgrammingClassExamples/Win10 versions/7b PSG (add validation and error trap).py similarity index 97% rename from ProgrammingClassExamples/7b PSG (add validation and error trap).py rename to ProgrammingClassExamples/Win10 versions/7b PSG (add validation and error trap).py index c3e5b59b..53bfb180 100644 --- a/ProgrammingClassExamples/7b PSG (add validation and error trap).py +++ b/ProgrammingClassExamples/Win10 versions/7b PSG (add validation and error trap).py @@ -32,7 +32,7 @@ while True: #get pathname to current file dirname, filename = os.path.split(os.path.abspath(__file__)) #add desired file name for saving to path - pathname = dirname + '\\results.txt' + pathname = os.path.join(dirname , 'results.txt' ) #generic catch error - blanks or wrong data types try: if button == '_save_': diff --git a/ProgrammingClassExamples/7c PSG (add get pathname to save and retrieve files), - Copy.py b/ProgrammingClassExamples/Win10 versions/7c PSG (add get pathname to save and retrieve files).py similarity index 97% rename from ProgrammingClassExamples/7c PSG (add get pathname to save and retrieve files), - Copy.py rename to ProgrammingClassExamples/Win10 versions/7c PSG (add get pathname to save and retrieve files).py index 8da13b48..a4af2ca2 100644 --- a/ProgrammingClassExamples/7c PSG (add get pathname to save and retrieve files), - Copy.py +++ b/ProgrammingClassExamples/Win10 versions/7c PSG (add get pathname to save and retrieve files).py @@ -49,7 +49,7 @@ while True: foldername = sg.PopupGetFolder('', no_window=True) filename = sg.PopupGetFile('Please enter a file name for your results') - pathname = foldername + '\\' + filename + '.txt' + pathname = os.path.join(foldername ,filename + '.txt') f = open(pathname, 'w') print (name, file = f) diff --git a/ProgrammingClassExamples/8a PSG (Data to plot from csv file).py b/ProgrammingClassExamples/Win10 versions/8a PSG (Data to plot from csv file).py similarity index 100% rename from ProgrammingClassExamples/8a PSG (Data to plot from csv file).py rename to ProgrammingClassExamples/Win10 versions/8a PSG (Data to plot from csv file).py diff --git a/ProgrammingClassExamples/Win10 versions/8b PSG (Tables and calc from csv file).py b/ProgrammingClassExamples/Win10 versions/8b PSG (Tables and calc from csv file).py new file mode 100644 index 00000000..880caee9 --- /dev/null +++ b/ProgrammingClassExamples/Win10 versions/8b PSG (Tables and calc from csv file).py @@ -0,0 +1,67 @@ +# PySimple examples (v 3.9.3) +# Tony Crewe +# Sep 2018 - updated Oct 2018 + +# Based of Example program from MikeTheWatchGuy +# https://gitlab.com/lotspaih/PySimpleGUI + +import sys +import PySimpleGUI as sg +import csv + +sg.ChangeLookAndFeel('BrownBlue') + + +def calc_ladder(): + filename = sg.PopupGetFile('Get required file', no_window=True, file_types=(("CSV Files", "*.csv"),)) + # populate table with file contents + # Assume we know csv has heading in row 1 + # Assume we know 7 columns of data - relevenat to AFL w/o Pts or % shown + # data is a list of lists containing data about each team + # data[0] is one teams data data[0[[0] = team, data[0][1] P, data[0] [2] W, + # data[0][3] L, data [0][4] D, data [0][5] F, data [0][6] A + # no error checking or validation used. + + # initialise variable + data = [] + header_list = [] + # read csv + with open(filename, "r") as infile: + reader = csv.reader(infile) + for i in range(1): + # get headings + header = next(reader) + # read everything else into a list of rows + data = list(reader) + # add headings + header = header + ['%', 'Pts'] + for i in range(len(data)): + # calculate % and format to 2 decimal places + percent = str('{:.2f}'.format(int(data[i][5]) / int(data[i][6]) * 100)) + data[i] = data[i] + [percent] # add to data + pts = int(data[i][2]) * 4 + int(data[i][4]) * 2 + data[i] = data[i] + [pts] # add to data + + # use Table (explore settings) and add to column layout + col_layout = [[sg.Table(values=data, headings=header, auto_size_columns=True, + max_col_width=12, justification='right', background_color='White', + text_color='Black', alternating_row_color='LightBlue', size=(None, len(data)))]] + + layout = [[sg.Column(col_layout, size=(500, 400), scrollable=True)], ] + + window = sg.Window('Table', location=(700, 325), grab_anywhere=False).Layout(layout) + b, v = window.Read() + + +slayout = [ + [sg.Text('Load AFL file to display results with points and percentage'), sg.ReadButton('Load File', size=(20, 1))]] +swindow = sg.Window('Load File', location=(700, 250)).Layout(slayout) + +while True: + button, value = swindow.Read() + if button is not None: + if button == 'Load File': + calc_ladder() + else: + break + diff --git a/ProgrammingClassExamples/8c PSG (Tables - add sort).py b/ProgrammingClassExamples/Win10 versions/8c PSG (Tables - add sort).py similarity index 87% rename from ProgrammingClassExamples/8c PSG (Tables - add sort).py rename to ProgrammingClassExamples/Win10 versions/8c PSG (Tables - add sort).py index 019eb71d..1880145d 100644 --- a/ProgrammingClassExamples/8c PSG (Tables - add sort).py +++ b/ProgrammingClassExamples/Win10 versions/8c PSG (Tables - add sort).py @@ -1,6 +1,6 @@ -#PySimple examples (v 3.8) +#PySimple examples (v 3.9.3) #Tony Crewe -#Sep 2018 +#Sep 2018 - updated Oct 2018 #Based of Example program from MikeTheWatchGuy #https://gitlab.com/lotspaih/PySimpleGUI @@ -48,7 +48,8 @@ def table_example(): data[i][7] = str('{:.2f}'.format(data[i][7])) #use Table (explore settings) and add to column layout col_layout = [[sg.Table(values=data, headings=header, auto_size_columns=True, - max_col_width = 12,justification='right', size=(None, len(data)))]] + max_col_width = 12,justification='right', text_color = 'White', + alternating_row_color = 'Grey', size=(None, len(data)))]] #experimented with size and location to get windows to fit :-) #remove titlebar of main display window @@ -62,5 +63,8 @@ swindow = sg.Window('Load File', location = (654,250)).Layout(slayout) while True: button, value = swindow.Read() - if button == 'Load File': - table_example() + if button is not None: + if button == 'Load File': + table_example() + else: + break diff --git a/ProgrammingClassExamples/8d PSG (Tables - add logo).py b/ProgrammingClassExamples/Win10 versions/8d PSG (Tables - add logo).py similarity index 78% rename from ProgrammingClassExamples/8d PSG (Tables - add logo).py rename to ProgrammingClassExamples/Win10 versions/8d PSG (Tables - add logo).py index 72c8d018..1e3819d5 100644 --- a/ProgrammingClassExamples/8d PSG (Tables - add logo).py +++ b/ProgrammingClassExamples/Win10 versions/8d PSG (Tables - add logo).py @@ -1,6 +1,6 @@ -#PySimple examples (v 3.8) +#PySimple examples (v 3.9.3) #Tony Crewe -#Sep 2018 +#Sep 2018 - updated Oct 2018 #Based of Example program from MikeTheWatchGuy #https://gitlab.com/lotspaih/PySimpleGUI @@ -11,9 +11,12 @@ import csv import operator import os +sg.ChangeLookAndFeel('Dark') + #get pathname to current file and add file name for image dirname, filename = os.path.split(os.path.abspath(__file__)) -pathname = dirname + '\\AFL.png' + +pathname = os.path.join(dirname , 'AFL.png' ) def table_example(): @@ -43,7 +46,8 @@ def table_example(): data[i][7] = str('{:.2f}'.format(data[i][7])) col_layout = [[sg.Table(values=data, headings=header, auto_size_columns=True, - max_col_width = 12,justification='right', size=(None, len(data)))]] + max_col_width = 12,justification='right', text_color = 'White', + alternating_row_color = 'Grey', size=(None, len(data)))]] layout = [[sg.Column(col_layout, size=(443,400), scrollable=True)],] window = sg.Window('Table', location = (662, 328), no_titlebar=True, grab_anywhere=False).Layout(layout) @@ -55,5 +59,8 @@ swindow = sg.Window('Load File', location = (654,250)).Layout(slayout) while True: button, value = swindow.Read() - if button == 'Load File': - table_example() + if button is not None: + if button == 'Load File': + table_example() + else: + break diff --git a/ProgrammingClassExamples/9a PSG Windows(location hide).py b/ProgrammingClassExamples/Win10 versions/9a PSG Windows(location hide).py similarity index 100% rename from ProgrammingClassExamples/9a PSG Windows(location hide).py rename to ProgrammingClassExamples/Win10 versions/9a PSG Windows(location hide).py diff --git a/ProgrammingClassExamples/9b PSG Tabs example.py b/ProgrammingClassExamples/Win10 versions/9b PSG Tabs example.py similarity index 89% rename from ProgrammingClassExamples/9b PSG Tabs example.py rename to ProgrammingClassExamples/Win10 versions/9b PSG Tabs example.py index 3f6dfb89..1ddcf009 100644 --- a/ProgrammingClassExamples/9b PSG Tabs example.py +++ b/ProgrammingClassExamples/Win10 versions/9b PSG Tabs example.py @@ -1,3 +1,7 @@ +#PySimple examples (v 3.9) +#Tony Crewe +#Oct 2018 + import PySimpleGUI as sg tab1_layout = [[sg.Text('This is inside tab 1')]] diff --git a/ProgrammingClassExamples/9c PSG Tabs example plus.py b/ProgrammingClassExamples/Win10 versions/9c PSG Tabs example plus.py similarity index 96% rename from ProgrammingClassExamples/9c PSG Tabs example plus.py rename to ProgrammingClassExamples/Win10 versions/9c PSG Tabs example plus.py index 85d57ede..68829e85 100644 --- a/ProgrammingClassExamples/9c PSG Tabs example plus.py +++ b/ProgrammingClassExamples/Win10 versions/9c PSG Tabs example plus.py @@ -6,8 +6,8 @@ sg.ChangeLookAndFeel('BlueMono') #get pathname to current file dirname, filename = os.path.split(os.path.abspath(__file__)) -pathname = dirname + '\\Names.txt' -spathname = dirname + '\\Names(sorted).txt' +pathname = os.path.join(dirname , 'Names.txt') + #Get data from file names = [line.strip() for line in open(pathname)] sorted_names = names[:] diff --git a/ProgrammingClassExamples/Win10 versions/AFL.png b/ProgrammingClassExamples/Win10 versions/AFL.png new file mode 100644 index 00000000..ee3a3559 Binary files /dev/null and b/ProgrammingClassExamples/Win10 versions/AFL.png differ diff --git a/ProgrammingClassExamples/Win10 versions/AFL2018 (sorted alpha teams).csv b/ProgrammingClassExamples/Win10 versions/AFL2018 (sorted alpha teams).csv new file mode 100644 index 00000000..798296f6 --- /dev/null +++ b/ProgrammingClassExamples/Win10 versions/AFL2018 (sorted alpha teams).csv @@ -0,0 +1,19 @@ +Team,P,W,L,D,F,A +Adelaide Crows,22,12,10,0,1941,1865 +Brisbane Lions,22,5,17,0,1825,2049 +Carlton,22,2,20,0,1353,2282 +Collingwood,22,15,7,0,2046,1699 +Essendon,22,12,10,0,1932,1838 +Fremantle,22,8,14,0,1556,2041 +Geelong Cats,22,13,9,0,2045,1554 +Gold Coast Suns,22,4,18,0,1308,2182 +GWS Giants,22,13,8,1,1898,1661 +Hawthorn,22,15,7,0,1972,1642 +Melbourne,22,14,8,0,2299,1749 +North Melbourne,22,12,10,0,1950,1790 +Port Adelaide,22,12,10,0,1780,1654 +Richmond,22,18,4,0,2143,1574 +St Kilda,22,4,17,1,1606,2125 +Sydney Swans,22,14,8,0,1822,1664 +West Coast Eagles,22,16,6,0,2012,1657 +Western Bulldogs,22,8,14,0,1575,2037 diff --git a/ProgrammingClassExamples/Win10 versions/AFL2018 (sorted pts and %).csv b/ProgrammingClassExamples/Win10 versions/AFL2018 (sorted pts and %).csv new file mode 100644 index 00000000..71cb8c18 --- /dev/null +++ b/ProgrammingClassExamples/Win10 versions/AFL2018 (sorted pts and %).csv @@ -0,0 +1,19 @@ +Team,P,W,L,D,F,A +Richmond,22,18,4,0,2143,1574 +West Coast Eagles,22,16,6,0,2012,1657 +Collingwood,22,15,7,0,2046,1699 +Hawthorn,22,15,7,0,1972,1642 +Melbourne,22,14,8,0,2299,1749 +Sydney Swans,22,14,8,0,1822,1664 +GWS Giants,22,13,8,1,1898,1661 +Geelong Cats,22,13,9,0,2045,1554 +North Melbourne,22,12,10,0,1950,1790 +Port Adelaide,22,12,10,0,1780,1654 +Essendon,22,12,10,0,1932,1838 +Adelaide Crows,22,12,10,0,1941,1865 +Western Bulldogs,22,8,14,0,1575,2037 +Fremantle,22,8,14,0,1556,2041 +Brisbane Lions,22,5,17,0,1825,2049 +St Kilda,22,4,17,1,1606,2125 +Gold Coast Suns,22,4,18,0,1308,2182 +Carlton,22,2,20,0,1353,2282 diff --git a/ProgrammingClassExamples/Win10 versions/Gym_Logo.png b/ProgrammingClassExamples/Win10 versions/Gym_Logo.png new file mode 100644 index 00000000..45bb5f7b Binary files /dev/null and b/ProgrammingClassExamples/Win10 versions/Gym_Logo.png differ diff --git a/ProgrammingClassExamples/Win10 versions/Names.txt b/ProgrammingClassExamples/Win10 versions/Names.txt new file mode 100644 index 00000000..d1b9fd24 --- /dev/null +++ b/ProgrammingClassExamples/Win10 versions/Names.txt @@ -0,0 +1,10 @@ +Roberta +Kylie +Jenny +Helen +Andrea +Meredith +Deborah +Pauline +Belinda +Wendy \ No newline at end of file diff --git a/ProgrammingClassExamples/Win10 versions/default_icon.ico b/ProgrammingClassExamples/Win10 versions/default_icon.ico new file mode 100644 index 00000000..1a41525e Binary files /dev/null and b/ProgrammingClassExamples/Win10 versions/default_icon.ico differ diff --git a/ProgrammingClassExamples/Win10 versions/weight 2018.csv b/ProgrammingClassExamples/Win10 versions/weight 2018.csv new file mode 100644 index 00000000..66e7c2d9 --- /dev/null +++ b/ProgrammingClassExamples/Win10 versions/weight 2018.csv @@ -0,0 +1,98 @@ +Date,Weight (kg) +29-Dec,94.5 +30-Dec,94 +31-Dec,94 +1-Jan,93.5 +2-Jan,94.2 +3-Jan,94 +4-Jan,94 +5-Jan,93.4 +6-Jan,92.6 +7-Jan,93.1 +8-Jan,92.7 +9-Jan,92.5 +10-Jan,92.3 +11-Jan,92.1 +12-Jan,92.5 +13-Jan,92.6 +14-Jan,92.5 +15-Jan,92.1 +16-Jan,91.6 +17-Jan,91.3 +18-Jan,91.8 +19-Jan,91.7 +20-Jan,91.9 +21-Jan,91.8 +22-Jan,91.1 +23-Jan,90.7 +24-Jan,90.5 +25-Jan,90.5 +26-Jan,90.3 +27-Jan,90.1 +28-Jan,89.9 +29-Jan,90.2 +30-Jan,90.1 +31-Jan,89.9 +1-Feb,89.5 +2-Feb,89.1 +3-Feb,89.3 +4-Feb,89.4 +5-Feb,89.2 +6-Feb,88.2 +7-Feb,88.2 +8-Feb,88.3 +9-Feb,88.2 +10-Feb,89.1 +11-Feb,88.9 +12-Feb,88.6 +13-Feb,88.7 +14-Feb,88.5 +15-Feb,88.1 +16-Feb,87.8 +17-Feb,87.9 +18-Feb,88.1 +19-Feb,87.9 +20-Feb,87.6 +21-Feb,87.5 +22-Feb,87.3 +23-Feb,87 +24-Feb,87.5 +25-Feb,87.7 +26-Feb,87.4 +27-Feb,87.2 +28-Feb,86.9 +1-Mar,86.9 +2-Mar,86.9 +3-Mar,86.5 +4-Mar,86.8 +5-Mar,87 +6-Mar,86.9 +7-Mar,86.2 +8-Mar,86.4 +9-Mar,86.1 +10-Mar,86.7 +11-Mar,85.6 +12-Mar,85.8 +13-Mar,85.3 +14-Mar,85.1 +15-Mar,85.4 +16-Mar,84.5 +17-Mar,85.1 +18-Mar,84.8 +19-Mar,84.8 +20-Mar,84.8 +21-Mar,84.9 +22-Mar,85.5 +23-Mar,85.1 +24-Mar,85.5 +25-Mar,85.6 +26-Mar,85.9 +27-Mar,85.9 +28-Mar,85.5 +29-Mar,85.9 +30-Mar,85.5 +1-Apr,85.2 +2-Apr,84.8 +3-Apr,85.3 +4-Apr,85.4 +5-Apr,85.3 diff --git a/ProgrammingClassExamples/results.txt b/ProgrammingClassExamples/results.txt deleted file mode 100644 index a751105a..00000000 --- a/ProgrammingClassExamples/results.txt +++ /dev/null @@ -1,3 +0,0 @@ -Jill -314.0 -78.5 diff --git a/requirements.txt b/requirements.txt index 7064e351..6ad116ec 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -pysimplegui==3.9.3 +pysimplegui==3.14.0 \ No newline at end of file