Python

December 29, 2021

Open CV Tutorial

Open Computer Vision Tutorial. This looks interesting and something else to have an experiment with at some point. Would also be good at the Paignton Library STEM group meetings.

Posted to Mastodon on 23/12/2021 by Danie

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

September 4, 2021

Code Club 4/10/2021

I am back at Code Club today, 2nd session since our return. If you are still not sure what Code Club is, then you have clearly being living in a cave since about 2012. Anyway, it is a coding club for children, generally 9-13 years of age.

The Paignton Club is a little more advanced, in that some of the attendees are working through a responsive web design course.

It would be really good to get MORE code clubs in Torbay, and in fact would be really nice if those clubs could collaborate, share expertise, maybe some resources.

Tags

May 8, 2021

Confy – Conferences schedule viewer

This was mentioned at the South Devon Tech Jam in May 2021, so thank you to Seabass for this. It is a conference schedule viewer, has been used as events such as Fosdem, so looks really good. I think Noisytoot was trying to compile this, so hopefully get an update over the next month and perhaps at the next Jam on June 12th. Or perhaps next week at the DCGLUG meet, Saturday 15th May 2021 @ 12:00 on jit.si.

I am also at a Debian Conference 2021 planning meeting on Monday 10th May, so will give this a mention too. Could be useful.

REFERENCES

TAGS

January 18, 2021

Website on pi

I spent some time on last night, setting up a mini web server on m Raspberry pi.

So running a http server on a Raspberry Pi.

For this project I am just using the python3-test-server package,

1. Install python3-test-server
2. Create a directory to hold some html files
3. Change to this directory
4. Create a very basic html file e.g index.html
5. run python3 -m http.server:7800 where 7800 is the port you want to use

In the browser go to ip:7800

What I have done here, however is

• Run the server on the pi,
• Connected via ssh to create the site files and run the server
• Edited the basic website on the pi via ssh, by running a text editor
• To copy other files directly from my main PC to the Pi i used

• scp file.jpg pi@ip:path e.g
• scp file.jpg pi@ip:/home/pi/html/

I have, gone a little further than this:

In order to share my free software video dvd (and other resources) with people I:-

• Uploaded files to the server
• Created a web link to the iso file
• Edited my router firewall so it would allow a connection to the pi

I then shared the appropriate IP address with a friend via irc so he could download the ISO file, and it worked really well.

REFERENCES

TAGS

#YearOfTheFediverse,#httpServer,#website,#html,#css, #Python,#Firewall,#Networking,ProblemSolving,#Skills,#IT

August 17, 2020

Paignton library summer virtual Code Club-4

Further to previous post

Carrying on with a Python theme. If you have been following this Virtual Code Club since March, then you will have completed the modules, so I don't think it is fair to keep repeating this.

It look like Repl.it now supports Turtle graphics, which is great for the Code Club modules.

Repl.it supports the following:-

Pgzero – This is a simpler framework for teaching using creation of games.

So feel free to check out these and the websites and see if you can get coding games in Python, as Repl.it is collaborative then it makes it easier to work as part of small teams on this.

I am on Repl.it as @zleap

#PLAIC_codeclub,#codeclub,#replit,#codeclub,#python,#games, #pygame,#pgzero,#pyxel

August 12, 2020

Paignton Library Summer Virtual Code Club 3

So further to the previous post

Lets move on to Python.

Paignton Library will be sending these activities out via Social media using the hashtag #PLAIC_codeclub

If you don't already have an account for either home or school then you can sign up to a free Trinket account at:-

While all activities are here

I appreciate that if you have been following the virtual code club since march. If you have, and you would like to move on then FreeCodeCamp have lots of tutorials:-

You may also want to look at signing up to Repl.it in order to gain collaborative browser based developer environment.

A new feature of Repl.it is Teams. I am currently investigating this.

#python,#codeclub,#PLAIC_codeclub

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)