Skip to main content

Tkinter GUI for Morse program



# Simple Tkinter GUI for G4AKW Morse Program
# Geoff Robinson Dec 2011
# Version 1.1


from Tkinter import *

'''
This differs from the traditional import statement
in that it puts everything in the module into the
default namespace of this program, so now rather
than needing to refer to a textbox as Tkinter.Textbox
we can just write Textbox
'''

import tkSimpleDialog as tks
import tkMessageBox

root = Tk()

# window geometry is width x height + x_offset + y_offset
root.geometry("600x160+350+300")
root.title('G4AKW Morse Program')
Label(root, text='Enter code to send in box').pack(pady=10)

# Left frame to hold buttons
left = Frame(root)
left.pack(side=LEFT, expand=True, fill=Y)

# Right frame to hold display
right = Frame(root, height=100, width=300, bd=3, relief=GROOVE)
right.pack(expand=True, fill=BOTH)

# change the colour of the right-hand frame
def changeColour(c):
    def change():
        right.config(background=c)
    return change

# Buttons
q_code = ['QSY', 'QRX', 'QRZ?', 'QTH?']
for c in q_code:
    b = Button(left, text=c, width=10, command=changeColour(c))
    b.pack(side=TOP, expand=True)


def ask():
        """Remember: this Dialog returns a value!"""
      
        morse_speed=str(tks.askinteger("Enter morse speed", " Enter integer value", initialvalue=20))

def station():
        station = str(tks.askstring("Distant Station", "enter callsign"))
    print station

def your_call():
         call = str(tks.askstring("Your Callsign", "enter", initialvalue="G4AKW"))
    print call

def your_QTH():
        QTH = str(tks.askstring("Your QTH", "enter your location", initialvalue="Woodbridge"))
    print QTH

def your_name():
        name = str(tks.askstring("Your name", "enter", initialvalue="Geoff"))
    print name

def your_rig():
        rig = str(tks.askstring("Your Rig", "enter details", initialvalue="FT817 + h/b pa"))
    print rig

def your_power():
        power = str(tks.askstring("Your Power", "enter output in Watts", initialvalue="400"))
    print power

def your_antenna():
        antenna = str(tks.askstring("Your Antenna", "enter details", initialvalue="doublet"))
    print antenna

def version():
        tkMessageBox.showinfo("Version", "1.1")


def send_cq():
    cqmsg = "cq cq cq de g4akw g4akw g4akw \
    cq cq cq de g4akw g4akw g4akw \
    cq cq cq de g4akw g4akw g4akw pse k"
   
    print cqmsg

def end_qso():
    end_qso = "mni tnx fer QSO OC \
    very best 73 to you and yours \
    cul de g4akw + k"
   
    print end_qso

def ok(event):   
    my_text = e.get()
    print my_text
    e.delete(0,END)

def hello():
    print "hello!"

menubar = Menu(root)

# create the Setup pulldown menu, and add it to the menu bar
setupmenu = Menu(menubar, tearoff=0)
setupmenu.add_command(label="Your Call", command=your_call)
setupmenu.add_command(label="Your QTH", command=your_QTH)
setupmenu.add_command(label="Your name", command=your_name)
setupmenu.add_command(label="Your rig", command=your_rig)
setupmenu.add_command(label="Your power", command=your_power)
setupmenu.add_command(label="Your antenna", command=your_antenna)
setupmenu.add_command(label="What morse speed?", command=ask)
setupmenu.add_separator()
setupmenu.add_command(label="Exit", command=root.quit)
menubar.add_cascade(label="Setup", menu=setupmenu)

# create the Call CQ menu button next
menubar.add_command(label="Call CQ", command=send_cq)

# create the Send Station detail pulldown menu
editmenu = Menu(menubar, tearoff=0)
editmenu.add_command(label="5 watts", command=changeColour('green'))
editmenu.add_command(label="100 watts", command=changeColour('yellow'))
editmenu.add_command(label="400 watts", command=changeColour('blue'))
editmenu.add_command(label="1000 watts", command=changeColour('red'))
menubar.add_cascade(label="Send Station Details", menu=editmenu)

# create the End QSO menu button next
menubar.add_command(label="End QSO", command=end_qso)

# last menu button is the help button
helpmenu = Menu(menubar, tearoff=0)
helpmenu.add_command(label="About", command=version)
menubar.add_cascade(label="Help", menu=helpmenu)

# display the menu
root.config(menu=menubar)

# display the RST (Tone) Spinbox
w1 = Spinbox(root, from_=1, to=9, width=2, font=4, wrap=TRUE)
w1.pack(side=RIGHT)
w1.delete(0,"end")
w1.insert(0,9)

# display the RST (Strength) Spinbox
w2 = Spinbox(root, from_=1, to=9, width=2, font=4, wrap=TRUE)
w2.pack(side=RIGHT)
w2.delete(0,"end")
w2.insert(0,9)

# display the RST (Readability) Spinbox
w3 = Spinbox(root, from_=1, to=5, width=2, font=4, wrap=TRUE)
w3.pack(side=RIGHT)
w3.delete(0,"end")
w3.insert(0,5)

# Create Enter Station button
app_button = Button(root, text="Enter Station", width=10, command = station)
app_button.pack(side=LEFT)

# Create Call Station button
app_button = Button(root, text="Call Station", width=10, command = send_cq)
app_button.pack(side=LEFT)

# Create Station report button
app_button = Button(root, text="Station report RST", width=15)
app_button.pack(side=LEFT)

# text entry box
e = Entry(right, width=45)
e.pack(padx=15)

root.bind("", ok)

root.mainloop()

Comments

Popular posts from this blog

FT 817 Power Amplifier

This very simple 2 Fet power amplifier easily achieves 250W output with an FT817 5W drive. The key design details as follows: 3:1 broadband input transformer matches the 5.5 ohm gate load resistor (4 x 22 ohms in parallel) to the 50 ohms required by the FT817 . The 4:1 output broadband transformer presents 3 ohms (16:1 impedance ratio) to the balanced HEXFET pair each mounted on a 3mm copper heat spreader which is insulated from the 2 1w/degC heatsinks. These are blown cool by a fan underneath. The power supply required is 28v at 30 amps. The amp is around 50% efficient with a standing 750mAmp temperature compensated bias. An IC 703, with 10watts output will drive the output to around 400 watts. The output filter shown is a 5 pole topband filter with T130-2 torroids and 400v silver mica caps. Peak output voltage on 160 metres with 5 watts drive is 160v or 320v p-p in 50 ohms equating to 250watts. This is slightly higher than the reading on the 3kw MFJ power meter. The inline F...

Splunk Cheat Sheet (Linux)

1. set root's password:  sudo su passwd root Enter new UNIX password: < new_root_password > Retype new UNIX password: < new_root_password > passwd: password updated successfully # su - 2. Remove any existing Splunk directories & create user etc: # rm -rf /opt/splunkforwarder # userdel -r splunk # this will remove as above if user splunk's home directory # groupadd siem # useradd -g siem -s /bin/bash -d /home/siem -m siem # vi ~/.profile # chage -I -1 -m -0 -M -99999 -E -1 siem If above fails because of multiple passwd fails: # pam_tally --reset check with #chage -l siem # uname -a # check OS version # dpkg -i splunk-4.3.1...........intel.deb # chown -R siem:siem /opt/splunk # su - siem : $SPLUNK_HOME/bin/splunk start --accept-license : $SPLUNK_HOME/bin/splunk edit user admin -password newpassword -role admin -auth admin:changeme 3. vi ~/.profile (as follows) (OR .bash_profile) # ~/.profile: executed by the command interpreter for log...
Beautiful Soup HTML parsing The following Python code fetches the specific windspeed web page and extracts the timestamp, average windspeed, direction, gust speed and writes out data to a date stamped file named say /home/user/wind_data/windspeed_date(2015-04-21-12).txt. Schedule a cron job to run this every day at midnight say. The windspeed file can be selected for a particular day and processed by graph.py.  #!/usr/bin/python import os import requests import time from bs4 import BeautifulSoup date_stamp = time.strftime('%Y-%m-%d-%H',(time.localtime(time.time()))) outfile = os.path.join(os.path.expanduser('~'), 'wind_data', "windspeed_%s.txt"%date_stamp) f = open(outfile,'w') list = [] r = requests.get("http://xxxxx.wwww.yyyyy") soup = BeautifulSoup(r.content) table = soup.find("table", {"id":"grid"}) for line in table.findAll('tr'): for l in line.findAll('td'): ...