Paul Sutton

programming

Tilde – text editor

Donate using Liberapay

Tilde is a nice, curses based text editor. It is useful for if you are at the console or terminal in Linux and want a menu driven editor.

tilde

While other tools are more command driven (nano, emacs, vi, vim and joe to name a few). Tilde is being mentioned for those of you who may find it useful

As you would expect with a modern editor, tilde has support for syntax highlighting.

Tilde Syntax Highlighting

Which is really useful for programming or editing website code for example.

REFERENCES

TAGS

#YearOfTheFediverse,#Linux,#TextEditor,#Editor,#Text, #Tilde,#Programming,#SyntaxHighlighting,#console, #terminal

Creative Commons Licence
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License

Ansi Weather

Donate using Liberapay

Getting weather information is really useful. What happens if you're at the command line in Linux? I found a really little application that can help

ansiweather

apt install ansiweather

ansiweather -l Plymouth, UK

Ansi Weather Output

So what else can we do with this

  1. Send the output to Mastodon with toot post

This is a two step process

  1. ansiweather -l Plymouth, UK > weather.txt
  2. toot post < weather.txt

Will send the weather info to Mastodon.

However this does not include any date info

We can fix this with

  1. date > weatherinfo.txt
  2. ansiweather -l Plymouth, UK >> weatherinfo.txt

then send the whole lot to Mastodon with

  1. toot post < weatherinfo.txt

So, if we put this in to a final shell script we need:-

#send weather info to Mastodon
# current date
date > weatherinfo.txt
# current weather
ansiweather -l Plymouth, UK >> weatherinfo.txt
#send to Mastodon
toot post < weatherinfo.txt
# done
echo done

Again released under GPLv3

I tried to get festival to speak the weather, it is not perfect but this sort of works, you will need to direct to weather.txt first.

festival —tts < weather.txt

Looking in to this further, the issue is the brackets etc, so this stackoverflow post

strips out the colour formatting

sed 's/\x1b[[^\x1b]*m//g' weatherinfo.txt

Therefore

sed 's/\x1b[[^\x1b]*m//g' weatherinfo.txt > weatherinfo2.txt

Sends the newly formatted text to weatherinfo2.txt

So running back through festival

festival —tts < weather.txt

Is perhaps a little better, but not perfect

So going back to what we wrote earlier to send to Mastodon, the new script

  1 #send weather info to Mastodon
  2 # current date
  3 date > weatherinfo.txt
  4 # current weather
  5 ansiweather -l Plymouth, UK >> weatherinfo.txt
  6 # clean up output with sed
  7 sed 's/\x1b\[[^\x1b]*m//g' weatherinfo.txt > weatherinfo2.txt
  8 #send to Mastodon
  9 toot post < weatherinfo2.txt
 10 # done
 11 echo done

Produces much nicer output. The top bottom part of this illustrates what was sent before we stripped out the colour formatting

However it still isn't perfect, as it removes part some of the wording, but it is hopefully getting there.

Weather Output (new)

REFERENCES

TAGS

#YearOfTheFediverse,#Weather,#Scripting,#Bash,#Linux, #Mastodon,#ProblemSolving,#AnsiWeather,#programming, #Stackoverflow,#sed,#cat,#grep,GPL3,#FSF

Creative Commons Licence
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License

Site Index

Donate using Liberapay

  1. Click on a link.
  2. Scroll to bottom of page.
    • Any posts / pages within this blog will be displayed.

A

#Astronify #Adenine #AminoAcid #Astronomy #AralBalkan #AstroBiology #AstroChemistry #apg #Apt #Aptitude #Africa #Activism #Analytics #Api #Arduino #AMES #arXiv #Academy

B

#Blog #BioChemistry #Biology #bash #better #BigBluButton #BibTeX #Browser

C

#Cytosine #Conditions #Cryptpad #Cosmology #Chemistry #Console #Chat #Conference #Code #Coding #CodeClub #Cornwall #Covid19 #Corona #CoronaVirus #CreativeCommons #Commons #Chrome #Chromium #Charity #Creative #Education #CPD #cpd #CreativeEducation

D

#dna #DNA #Disroot #disroot #Decentralised #Decentralized #dcglug #dclug #Debian #Donate #Donation #Debconf #BASH #Devon #Digital #DRM #Diaspora #DiodeZone #Development #Data #Detox

E

#emacs #Editing #Events #EventManagement #Employment #Email #Education #Exploration, #Ethics #Elements #Exploration

F

#Flockingbird #Framablog #FramaBlog #Fediverse #Federated #Firefox #Fosdem #Freedom #FreeSoftware #Foundation #FSF #FSFE #Friendica #Framework #FreeBSD #FalconsEye #FOSSandCrafts

G

#GoatCounter #Guanine #Greek #Gimp #Galaxy #GoDot #GNU #GNOME #GUI #Gamma #Ghostreply #GPL #GraphicsMagick #gm #GoAccess #gold #GettingStarted

H

#Hubble #Hexchat #Hack #Hacking #Hardware #Hosting #htop

I

#information #Inkscape #Image #ImageManipulation #IRC #Index

J

#JamesWebb #JoeEditor #Jitsi #Jit.si

K

#kstars #Kanban #Kenya #KDE

L

#Linux #LinuxMint #LibreOffice #LiberaPay #LibrePlanet #Lecture #Learning #LibreOfficeWriter #LibreOfficeCalc #LibreOfficeImpres #LibreOfficeDraw #LibreOfficeGettingStarted #LaTeX #LXDE #LGPL #Lynx #Librem #Libre #LibreLounge

M

#Mastodon #Meetings #Management #Mobilizon #Meeting #Matomo #Map #Mapscii #Mercury #mercury #mining #Matrix #Moon #Mars

N

#Nextcloud #Nebula #NetHack #Nano #Nucleobases #network

O

#OpenUniversity #OU #Online #Overleaf #OwnCloud #OpenStreetMap #OpenData #Open

P

#Physics #Podcast #Payment #Password #Public #Paypal #Photo #Photograph #Photos #Photographs #Python #Python3 #Programming #PixelFed #PeerTube #PowderToy #Pleroma #Planet #PDF #Package #pinebook #pinephone #Purism #Plausible #ProtoSchool #PeriodicTable #Paper

Q

R

#rna #RNA #Rights #RocksAndDiamonds #Recovery #RadioAstronomy

S

#Science #Scratch #Scratch2 #Scratch3 #smallweb #Sitejs #Space #Stars #Stellarium #Stripe #Security #stsci #Seagl #Social #SocialHub #SDTJ #SouthDevonTechJam #Solarus #Synaptic #Schools #Solid #Shynet

T

#terms #Telescope #TheOpenUniversity #Terminal #Talk #Thunderbird #Torbay #TeX #Topic #Thunar #Thymine #tailings #Top #Tilde #TextEditor #Toot #Translation

U

#Uracil #Umami

V

#Vaccine #VokoScreen #VLC #Volunteering #Volunteer #VultureNethack #vultureseye #Virgo

W

#Website #Work #wireless #wicd #wayland #weatherinfo

X

#Xournal #Xchat #XFCE #XFCE4 #xray #XMPP #xorg

Y

#YearOfTheFediverse

Z

#Zoo

Contribute to f-droid

This was originally shared on Mastodon, so am sharing here for any of my followers who may be interested.

  • F-droid is looking for project contributors. There is a good article here with some more information.

The contribution page is also here

Looks like lots of opportunities to get involved. If you are interested you can also get in touch with IzzyOnDroid.

You can join Mastodon here then connect with IssyOnDroid and ask how to get involved.

I am on Mastodon here

#freesoftware,#fdroid,#contribution,#foss,#repository, #android,#technology,#programming,#testing,#docs, #development,#software

Scratch projects 20/11/2020

Still occasionally create simple Scratch projects to add to my portfolio. Mostly simple stuff, that can be built upon.

Resources

#scratch,#programming,#basics,#development,#lookingforwork

New Repl.it course 3/8/2020

New course – How to teach yourself coding with Quizlet Founder Andrew Sutherland.

This may complement Paignton Code Club nicely. You can find more details here

I still need to complete the FreeCodeCamp course I am undertaking, I am also undertaking Teaching Primary Science : Chemistry With futurelearn.

Hopefully however, this is useful. I have shared on with Paignton Library on Twitter and with the Local Children and Young People partnership.

#course,#repl.it,#programming,#coding

Free Virtual Summer camps – from Microsoft

Just sharing this, in case anyone is interested

#coding,#camp,#learning,#programming,#microsoft,#virtual

Add more functions

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.

addition app

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())
	
	#add the 2 integers and store in variable add
	add = (ent1 + ent2)
	print (add)
	
	#insert value of variable add in	to box outtext 
	outtext1.insert(0,str(add)) # insert response

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_tog2.grid(row = 4, column = 2, padx = 1, pady = 1) # addition button
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.

#python, #tkinter, #programming, #python, #graphic, #applications, #bugs, #troubleshooting, #howto, #paignton, #library, #virtual, #codeclub

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.

cc-by logo

Licenced under Attribution 4.0 International (CC BY 4.0)

Addition Application

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.

addition app

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
  • Fix spelling in comments
  • Fix clarity of comments

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())
	
	#add the 2 integers and store in variable add
	add = (ent1 + ent2)
	print add
	
	#instert value add in	to box outtext 
	outtext1.insert(0,str(add)) # insert response
	
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()

#python, #tkinter, #programming, #python, #graphic, #applications, #bugs, #troubleshooting, #howto, #paignton, #library, #virtual, #codeclub

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.

cc-by logo

Licenced under Attribution 4.0 International (CC BY 4.0)

More improvements

Adding labels

So last time we added some text boxes and made the application a little more presentable. Now we are going to do is add some labels above the boxes to help describe what they do.

Add this above were we define the entry boxes

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

Now add this below where we place the entry boxes but above window.mainloop()

#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)

So here we have a window, with three text boxes.

app1

So again we have something that looks a little more like an application.

#tkinter,#python,#gui,#programming.