# Paignton

## November 8, 2021

Paignton Library STEM Group

First event 13th November 2021

VIDEO

Tags

## November 6, 2021

Code Club Saturday 6th November part 2

I spent about ½ an hour on Friday setting up and preparing for Code Club, here are a few photos of the room all set up and ready to go.

Tags

## November 5, 2021

Code Club Saturday 6th November

The next Paignton Library Code Club is Saturday 6th November 2021. Usual time.

We will just carry on from where we left off last time, catch up on what has been undertaken since the last code club.

Tags

## May 21, 2020

I have added a few more maths functions to the application and also provided a clear function. There are still a few items to add to help improve debugging but the application is starting to take shape.

Notes

window = Tk()
window.title('Maths Application')
window.geometry("570x150") # w x h
window.resizable(0,0)

1. The above code is being modified as I go. So I am changing the window size depending on what is being displayed.

2. I have also made the Window title reflect the purpose of the application.

3. That the source code now has 'result' as a label rather than output. This will show up future screenshots.

The code for the above is as follows.

#!/usr/bin/env python
import Tkinter # note use of caps
from Tkinter import *

window = Tk()
window.title('Maths Application')
window.geometry("570x150") # w x h
window.resizable(0,0)

#define button actions
def btn1():
#convert box text in to integers
ent1 = int(entrytext.get())
ent2 = int(entrytext2.get())

#insert value of variable add in	to box outtext

def btn2():
#print("subtraction")
ent1 = int(entrytext.get())
ent2 = int(entrytext2.get())

#subtract the 2 integers and store in variable sub
sub = (ent1 - ent2)

#insert value of variable sub in	to box outtext
outtext1.insert(0,str(sub)) # insert response

def btn3():
#print("multiply")
ent1 = int(entrytext.get())
ent2 = int(entrytext2.get())

#multiply the 2 integers and store in variable mul
mul = (ent1 * ent2)

#insert value of variable mul in	to box outtext
outtext1.insert(0,str(mul)) # insert response

def btn4():
#print("divide")
ent1 = int(entrytext.get())
ent2 = int(entrytext2.get())

#multiply the 2 integers and store in variable div
div = (ent1 / ent2)

#insert value of variable mul in	to box outtext
outtext1.insert(0,str(div)) # insert response

#clear boxes
def clear():
#print("clear boxes") # leave in for legacy testing
entrytext.delete(0, END) # clear input box
entrytext2.delete(0, END) # clear input box2
outtext1.delete(0, END) # clear output box

btn_tog2 = Button( window, text ='+', command=btn1) # add
btn_tog3 = Button( window, text ='-', command=btn2)  # subtract
btn_tog4 = Button( window, text ='x', command=btn3) #multiply
btn_tog5 = Button( window, text ='/', command=btn4) #divide
btn_tog6 = Button( window, text ='Clear', command=clear) #clear
btn_exit = Button( window, text ='Exit',command=exit)	 #exit

# define some labels
box1 = Label(window, text="1st Value")
box2 = Label(window, text="2nd Value")
box3 = Label(window, text="Result")

#define entry box
entry1 = StringVar() # this is our entry box
entry2 = StringVar()
entrytext = Entry(window, textvariable=entry1) # this is our entry box
entrytext2 = Entry(window, textvariable=entry2) # this is our second entry box

#define out box

entry2 = StringVar() # this is our output box
outtext1 = Entry(window, textvariable=entry2) # this is our output box

#display boxes
entrytext.grid(row = 3, column = 2,)  #display entry box
entrytext2.grid(row = 3, column = 3,)  #display entry box
outtext1.grid(row = 3, column = 4,) #display output box

#place labels
box1.grid(row = 1	, column = 2, padx = 5, pady = 5)
box2.grid(row = 1	, column = 3, padx = 5, pady = 5)
box3.grid(row = 1	, column = 4, padx = 5, pady = 5)

#buttons
btn_tog3.grid(row = 4, column = 3, padx = 1, pady = 1) # subtraction button
btn_tog4.grid(row = 5, column = 2, padx = 1, pady = 1) # multiply button
btn_tog5.grid(row = 5, column = 3, padx = 1, pady = 1) # divide button
btn_tog6.grid(row = 4, column = 6, padx = 1, pady = 1) # clear button
btn_exit.grid(row = 3, column = 6, padx = 1, pady = 1) # exit button

window.mainloop()



The code that I used for a previous application to detect if numerical values have been used is below but provided 'as is' for now.

def response():

msg = "error : must be a text value"

i = circletext.get()
y = i.isdigit()
l = len(circletext.get())
#print l
if y == True or l == 0:
circletext.insert(0,(msg))

else:
x = random.choice(RESPONSES)
circletext2.delete(0, END) # clear prev output
circletext2.insert(0,str(x)) # insert response


I will integrate a version of this in to the main code.

Happy to provide help and support via decentralised social media. I can be contacted on Mastodon here. You can get a free account on the http://qoto.org instance by following this link.

Licenced under Attribution 4.0 International (CC BY 4.0)

## May 20, 2020

So following on from the previous posts, I am how sharing a small application, that makes use of what we have been learning.

This presents 2 input boxes and an output box, any values entered in to the first two, the sum is placed in to the last box.

This is not perfect, but getting there slowly.

We need to:-

• Fix the name of the button from button1
• Detect if the user has entered numerical values
• Detect for empty boxes
• Make labels more useful

The code for the above is as follows.

#!/usr/bin/env python
import Tkinter # note use of caps
from Tkinter import *

window = Tk()
window.title('App 1')
window.geometry("650x125") # w x h
window.resizable(0,0)

#define button actions
def btn1():
#convert box text in to integers
ent1 = int(entrytext.get())
ent2 = int(entrytext2.get())

#instert value add in	to box outtext

btn_tog2 = Button( window, text ='button1', command=btn1)
btn_exit = Button( window, text ='exit',command=exit)

# define some labels
box1 = Label(window, text="Entry 1: ")
box2 = Label(window, text="Entry 2: ")
box3 = Label(window, text="Ouput1: ")

#define entry box
entry1 = StringVar() # this is our entry box
entry2 = StringVar()
entrytext = Entry(window, textvariable=entry1) # this is our entry box
entrytext2 = Entry(window, textvariable=entry2) # this is our second entry box

#define out box

entry2 = StringVar() # this is our output box
outtext1 = Entry(window, textvariable=entry2) # this is our output box

#display boxes
entrytext.grid(row = 3, column = 2,)  #display entry box
entrytext2.grid(row = 3, column = 3,)  #display entry box
outtext1.grid(row = 3, column = 4,) #display output box

#place labels
box1.grid(row = 1	, column = 2, padx = 5, pady = 5)
box2.grid(row = 1	, column = 3, padx = 5, pady = 5)
box3.grid(row = 1	, column = 4, padx = 5, pady = 5)

#buttons
btn_tog2.grid(row = 3, column = 5, padx = 5, pady = 5)
btn_exit.grid(row = 3, column = 6, padx = 5, pady = 5)

window.mainloop()



Happy to provide help and support via decentralised social media. I can be contacted on Mastodon here. You can get a free account on the http://qoto.org instance by following this link.

Licenced under Attribution 4.0 International (CC BY 4.0)

## Coding with Trinket and Blocks

At Paignton virtual Code Club, we are now approaching the end of the Scratch modules. Well done to everyone. The next step is probably to progress to Python [2][3].

If you don't feel ready to do lots of typing, you may want to look at Trinket and blocks. Then perhaps move to the Code Club modules [3].

Blocks, as the name suggests, is a block based system. The difference here is, that the blocks are all Python statements and code. So combining these allow you to easily start coding in Python.

To get started you need to sign up for an account on the Trinket website [1]

Click you user name and select new trinket and then select blocks

You are now presented with your development area.

You may want to change your project title to something meaningful.

You can select the category of block, then simply use click / drag in similar way as you would with Scratch.

So in this example I am just going to draw a square.

As we are using turtle, you will need to change the pen up, block so that it says pen down.

Adding comments to your code is important, as it helps you keep track of what the code is doing and helps with debugging also helps others understand your code.

You can also view the Python code that is produced, this can be copy / pasted to IDE so you can just run the Python code on its own.

![View Python]

https://raw.githubusercontent.com/zleap/blogmedia/master/trinket/square-python-code.png

Finally you can share your project with others.

Resources

Licenced under Attribution 4.0 International (CC BY 4.0)

## March 8, 2020

South Devon Tech Jam – March 2020

The next Tech jam will be on Saturday 14th March 2020. Following on from the previous jam in February

Time : 11am to 15:00 Cost : £2

Website : http://www.sdtj.org.uk.

What have :-

It may be good to have a discussion on the Tech Pledge which I posted about a while back.

You can find me on Friendica at zleap@social.isurf.ca

## February 23, 2020

Chobham game Result

On Saturday 22nd February, Paignton Rugby Club welcomed their old friends from Chobham RFC in Surrey. The Vets team played the Chobham Vets.

Kick off : 12:30 at Paignton Rugby Club

Game Result Paignton — Chobham — Unknown. However this is unimportant. The game represents a really strong relationship between two clubs, great friendships and good times. We will see Chobham again in 2021.

I have put some videos on diode.zone. I have a few more to upload.

## February 19, 2020

Chobham game

On Saturday 22nd February, Paignton Rugby Club will welcome their old friends from Chobham RFC in Surrey. The Vets team will be playing the Chobham Vets.

Kick off : 12:30 at Paignton Rugby Club

## February 1, 2020

South Devon Tech Jam reminder – Feb 2020

The February 2020 tech jam will be on Saturday 8th February at Paignton Library and information Centre.

Time : 11am to 15:00 Cost : £2

Website : http://www.sdtj.org.uk.

What are we hoping to have :-

You can find me on Friendica at zleap@social.isurf.ca