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

Digital Bandpass Filter FIR design - Python

The python code generates the Finite Impulse Response (FIR) filter coefficients for a lowpass filter (LPF) at 10 (Hz) cut off using firwin from scipy.  A highpass filter is then created by subtracting the lowpass filter output(s) from the output of an allpass filter. To do this the coefficients of the LPF are multiplied by -1 and 1 added to the centre tap (to create the allpass filter with subtraction). A second LPF is then created with a cutoff at 15 (Hz) and the bandpass filter formed by addition of the LPF and HPF coefficients. The program also generates a test sine wave of a given amplitude and power and to this noise from a Normal distribution is added.  The graph below shows the signal and nois, and the signal (green) after filtering. The input snr is approximately 3dB. The frequency response below shows the passband centered on 12.5 (Hz), the Nyquist frequency is 50 (Hz). from numpy import cos, sin, pi, absolute, arange from numpy.random import normal fr...

GNU Radio Waterfall and CW Filter

The following GNU radio application adds a waterfall spectrogram to the previous CW filter program. The plot show 4 CW signals in the audio band (lower sideband) at 7023 kHz. The 700Hz signal is filtered and output to the laptop headphones by the CW bandpass filter. The frequency display is shown after the script which is as follows: #!/usr/bin/env python from gnuradio import gr from gnuradio import audio from lpf_bpf_class import Bandpass from gnuradio.qtgui import qtgui from PyQt4 import QtGui import sys, sip     class cw_filter(gr.top_block):     def __init__(self):         gr.top_block.__init__(self)           sample_rate = 44100         out_rate = 8000         kaiser = Bandpass()         cw_flr = gr.fir_filter_fff(1, kaiser.bpftaps)         decimate = int...

Norton Wideband HF pre-amp

The 20m vertical antenna looks good, VSWR < 1.3 : 1 but RX might be a bit deaf. RX details: 1dB antenna cable loss: + 14MHz to 144MHz SBL-1 mixer (straight 6dB loss) :+ IC 202 144MHz receiver (8dB NF). Hence total receive noise figure is at least 15dB. Built a Norton HF preamp (2n5109) to try and improve situation. (Is this necessary given the noise level at 14MHz? see following. Photo below shows the circuit and the measured cbe voltages resulting from a 13.9v supply. First audible results were however not particularly impressive. The dominant noise is the external noise? and this is in excess of any receiver contribution - even at 15dB noise fugure? But I will look into this and quantify the position. OK, this is a simple circuit and the 50 ohm output load is transformed by the broadband auto transformer to the collector load. The actual turns ratio used was 3 to the tap and then 11 to the collector. The turns ratio is then 14/3 or 4.6 which is the voltage transformation. ...