diff --git a/pyqso/logbook.py b/pyqso/logbook.py
index ebbebac..d6d4def 100644
--- a/pyqso/logbook.py
+++ b/pyqso/logbook.py
@@ -38,6 +38,7 @@ from pyqso.auxiliary_dialogs import *
from pyqso.log_name_dialog import LogNameDialog
from pyqso.record_dialog import RecordDialog
from pyqso.cabrillo_export_dialog import CabrilloExportDialog
+from pyqso.summary import Summary
from pyqso.printer import Printer
from pyqso.compare import compare_date_and_time, compare_default
@@ -56,7 +57,6 @@ class Logbook:
self.builder = self.application.builder
self.notebook = self.builder.get_object("logbook")
self.connection = None
- self.summary = {}
self.logs = []
logging.debug("New Logbook instance created!")
return
@@ -150,7 +150,7 @@ class Logbook:
self._render_log(i)
logging.debug("All logs rendered successfully.")
- self.update_summary()
+ self.summary.update()
self.application.toolbox.awards.count(self)
context_id = self.application.statusbar.get_context_id("Status")
diff --git a/pyqso/summary.py b/pyqso/summary.py
index 1d5991e..233765b 100644
--- a/pyqso/summary.py
+++ b/pyqso/summary.py
@@ -21,6 +21,8 @@ from gi.repository import Gtk
import logging
from os.path import basename, getmtime, expanduser
from datetime import datetime, date
+import os
+import os.path
try:
import configparser
except ImportError:
@@ -41,43 +43,27 @@ except ImportError as e:
class Summary(object):
- def __init__(self, logbook):
- """ Create a summary page containing the number of logs in the logbook, and the logbook's modification date. """
+ def __init__(self, application):
+ """ Create a summary page containing the number of logs in the logbook, and the logbook's modification date.
- self.logbook = logbook
+ :arg application: The PyQSO application containing the main Gtk window, etc.
+ """
- vbox = Gtk.VBox()
+ self.application = application
+ self.logbook = self.application.logbook
+
+ self.builder = self.application.builder
+ glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res/pyqso.glade")
+ self.builder.add_objects_from_file(glade_file_path, ("summary_page",))
+ self.summary_page = self.builder.get_object("summary_page")
+
+ self.items = {}
# Database name in large font at the top of the summary page
- hbox = Gtk.HBox()
- label = Gtk.Label(halign=Gtk.Align.START)
- label.set_markup("%s" % basename(self.path))
- hbox.pack_start(label, False, False, 6)
- vbox.pack_start(hbox, False, False, 4)
-
- hbox = Gtk.HBox()
- label = Gtk.Label("Number of logs: ", halign=Gtk.Align.START)
- hbox.pack_start(label, False, False, 6)
- self.summary["LOG_COUNT"] = Gtk.Label("0")
- hbox.pack_start(self.summary["LOG_COUNT"], False, False, 4)
- vbox.pack_start(hbox, False, False, 4)
-
- hbox = Gtk.HBox()
- label = Gtk.Label("Total number of QSOs: ", halign=Gtk.Align.START)
- hbox.pack_start(label, False, False, 6)
- self.summary["QSO_COUNT"] = Gtk.Label("0")
- hbox.pack_start(self.summary["QSO_COUNT"], False, False, 4)
- vbox.pack_start(hbox, False, False, 4)
-
- hbox = Gtk.HBox()
- label = Gtk.Label("Date modified: ", halign=Gtk.Align.START)
- hbox.pack_start(label, False, False, 6)
- self.summary["DATE_MODIFIED"] = Gtk.Label("0")
- hbox.pack_start(self.summary["DATE_MODIFIED"], False, False, 4)
- vbox.pack_start(hbox, False, False, 4)
-
- hseparator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)
- vbox.pack_start(hseparator, False, False, 4)
+ self.builder.get_object("database_name").set_markup("%s" % basename(self.logbook.path))
+ self.items["LOG_COUNT"] = self.builder.get_object("log_count")
+ self.items["QSO_COUNT"] = self.builder.get_object("qso_count")
+ self.items["DATE_MODIFIED"] = self.builder.get_object("date_modified")
# Yearly statistics
config = configparser.ConfigParser()
@@ -88,32 +74,32 @@ class Summary(object):
hbox = Gtk.HBox()
label = Gtk.Label("Display statistics for year: ", halign=Gtk.Align.START)
hbox.pack_start(label, False, False, 6)
- self.summary["YEAR_SELECT"] = Gtk.ComboBoxText()
- min_year, max_year = self._find_year_bounds()
+ year_select = Gtk.ComboBoxText()
+ min_year, max_year = self.find_year_bounds()
if min_year and max_year:
for year in range(max_year, min_year-1, -1):
- self.summary["YEAR_SELECT"].append_text(str(year))
- self.summary["YEAR_SELECT"].append_text("")
- self.summary["YEAR_SELECT"].connect("changed", self._on_year_changed)
- hbox.pack_start(self.summary["YEAR_SELECT"], False, False, 6)
- vbox.pack_start(hbox, False, False, 4)
+ year_select.append_text(str(year))
+ year_select.append_text("")
+ year_select.connect("changed", self.on_year_changed)
+ hbox.pack_start(year_select, False, False, 6)
+ self.summary_page.pack_start(hbox, False, False, 4)
- self.summary["YEARLY_STATISTICS"] = Figure()
- canvas = FigureCanvas(self.summary["YEARLY_STATISTICS"])
+ self.items["YEARLY_STATISTICS"] = Figure()
+ canvas = FigureCanvas(self.items["YEARLY_STATISTICS"])
canvas.set_size_request(800, 250)
canvas.show()
- vbox.pack_start(canvas, True, True, 4)
+ self.summary_page.pack_start(canvas, True, True, 4)
# Summary tab label and icon.
- hbox = Gtk.HBox(False, 0)
+ tab = Gtk.HBox(False, 0)
label = Gtk.Label("Summary ")
icon = Gtk.Image.new_from_stock(Gtk.STOCK_INDEX, Gtk.IconSize.MENU)
- hbox.pack_start(label, False, False, 0)
- hbox.pack_start(icon, False, False, 0)
- hbox.show_all()
+ tab.pack_start(label, False, False, 0)
+ tab.pack_start(icon, False, False, 0)
+ tab.show_all()
- self.notebook.insert_page(vbox, hbox, 0) # Append as a new tab
- self.notebook.show_all()
+ self.logbook.notebook.insert_page(self.summary_page, tab, 0) # Append as a new tab
+ self.logbook.notebook.show_all()
return
@@ -121,8 +107,8 @@ class Summary(object):
""" Re-plot the statistics for the year selected by the user. """
# Clear figure
- self.summary["YEARLY_STATISTICS"].clf()
- self.summary["YEARLY_STATISTICS"].canvas.draw()
+ self.items["YEARLY_STATISTICS"].clf()
+ self.items["YEARLY_STATISTICS"].canvas.draw()
# Get year to show statistics for.
year = combo.get_active_text()
@@ -133,8 +119,8 @@ class Summary(object):
return
# Number of contacts made each month
- contact_count_plot = self.summary["YEARLY_STATISTICS"].add_subplot(121)
- contact_count = self._get_annual_contact_count(year)
+ contact_count_plot = self.items["YEARLY_STATISTICS"].add_subplot(121)
+ contact_count = self.get_annual_contact_count(year)
# x-axis formatting based on the date
contact_count_plot.bar(list(contact_count.keys()), list(contact_count.values()), color="k", width=15, align="center")
@@ -149,15 +135,15 @@ class Summary(object):
contact_count_plot.set_xlim([date(year-1, 12, 16), date(year, 12, 15)]) # Make a bit of space either side of January and December of the selected year.
# Pie chart of all the modes used.
- mode_count_plot = self.summary["YEARLY_STATISTICS"].add_subplot(122)
- mode_count = self._get_annual_mode_count(year)
+ mode_count_plot = self.items["YEARLY_STATISTICS"].add_subplot(122)
+ mode_count = self.get_annual_mode_count(year)
(patches, texts, autotexts) = mode_count_plot.pie(list(mode_count.values()), labels=mode_count.keys(), autopct='%1.1f%%', shadow=False)
for p in patches:
# Make the patches partially transparent.
p.set_alpha(0.75)
mode_count_plot.set_title("Modes used")
- self.summary["YEARLY_STATISTICS"].canvas.draw()
+ self.items["YEARLY_STATISTICS"].canvas.draw()
return
@@ -231,11 +217,11 @@ class Summary(object):
def update(self):
""" Update the information presented on the summary page. """
- self.summary["LOG_COUNT"].set_label(str(self.logbook.log_count))
- self.summary["QSO_COUNT"].set_label(str(self.logbook.record_count))
+ self.items["LOG_COUNT"].set_label(str(self.logbook.log_count))
+ self.items["QSO_COUNT"].set_label(str(self.logbook.record_count))
try:
t = datetime.fromtimestamp(getmtime(self.logbook.path)).strftime("%d %B %Y @ %H:%M")
- self.summary["DATE_MODIFIED"].set_label(str(t))
+ self.items["DATE_MODIFIED"].set_label(str(t))
except (IOError, OSError) as e:
logging.exception(e)
return
diff --git a/res/pyqso.glade b/res/pyqso.glade
index 698e8a0..8716e7b 100644
--- a/res/pyqso.glade
+++ b/res/pyqso.glade
@@ -1,149 +1,7 @@
-
+
-
True
False
@@ -1057,6 +915,148 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ False
+ Cabrillo Export
+ True
+ dialog
+ pyqso
+
+
+ False
+ vertical
+ 2
+
+
+ True
+ False
+
+
+ True
+ False
+ 0
+ Contest
+ 12
+
+
+ False
+ True
+ 2
+ 0
+
+
+
+
+ True
+ False
+ True
+
+
+ True
+
+
+
+
+ True
+ True
+ 2
+ 1
+
+
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ False
+
+
+ True
+ False
+ 0
+ My callsign
+ 12
+
+
+ False
+ True
+ 2
+ 0
+
+
+
+
+ True
+ True
+
+
+ True
+ True
+ 2
+ 1
+
+
+
+
+ False
+ True
+ 2
+
+
+
+
+ False
+ end
+
+
+ gtk-cancel
+ True
+ True
+ True
+ True
+ True
+
+
+ False
+ True
+ 0
+
+
+
+
+ gtk-ok
+ True
+ True
+ True
+ True
+ True
+
+
+ False
+ True
+ 1
+
+
+
+
+ False
+ True
+ end
+ 2
+
+
+
+
+
+ cabrillo_export_cancel_button
+ cabrillo_export_ok_button
+
+
False
New Log
@@ -1118,9 +1118,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
True
False
+ 0
Log Name
12
- 0
False
@@ -1416,9 +1416,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
True
False
+ 0
Name
10
- 0
False
@@ -1476,9 +1476,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
True
False
+ 0
Latitude
10
- 0
False
@@ -1501,9 +1501,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
True
False
+ 0
Longitude
10
- 0
False
@@ -2131,9 +2131,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
True
False
+ 0
Mode
15
- 0
False
@@ -2170,9 +2170,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
True
False
+ 0
Submode
15
- 0
False
@@ -2209,9 +2209,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
True
False
+ 0
TX Power (W)
15
- 0
False
@@ -2282,9 +2282,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
True
False
+ 0
Database
15
- 0
False
@@ -2336,9 +2336,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
True
False
+ 0
Username
15
- 0
False
@@ -2376,9 +2376,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
True
False
+ 0
Password
15
- 0
False
@@ -2610,9 +2610,9 @@ Base64-encoded plain text in the configuration file.
True
False
+ 0
Model
18
- 0
False
@@ -2649,9 +2649,9 @@ Base64-encoded plain text in the configuration file.
True
False
+ 0
Path to radio device
18
- 0
False
@@ -2740,48 +2740,6 @@ Base64-encoded plain text in the configuration file.
False
vertical
2
-
-
- False
- end
-
-
- gtk-cancel
- True
- True
- True
- True
- True
-
-
- False
- True
- 0
-
-
-
-
- gtk-ok
- True
- True
- True
- True
- True
-
-
- False
- True
- 1
-
-
-
-
- False
- True
- end
- 2
-
-
True
@@ -2811,9 +2769,9 @@ Base64-encoded plain text in the configuration file.
True
False
+ 0
Callsign
15
- 0
False
@@ -2874,9 +2832,9 @@ Base64-encoded plain text in the configuration file.
True
False
+ 0
Date
15
- 0
False
@@ -2937,9 +2895,9 @@ Base64-encoded plain text in the configuration file.
True
False
+ 0
Time
15
- 0
False
@@ -3000,9 +2958,9 @@ Base64-encoded plain text in the configuration file.
True
False
+ 0
Frequency (MHz)
15
- 0
False
@@ -3040,9 +2998,9 @@ Base64-encoded plain text in the configuration file.
True
False
+ 0
Band
15
- 0
False
@@ -3079,9 +3037,9 @@ Base64-encoded plain text in the configuration file.
True
False
+ 0
Mode
15
- 0
False
@@ -3118,9 +3076,9 @@ Base64-encoded plain text in the configuration file.
True
False
+ 0
Submode
15
- 0
False
@@ -3157,9 +3115,9 @@ Base64-encoded plain text in the configuration file.
True
False
+ 0
TX Power (W)
15
- 0
False
@@ -3211,9 +3169,9 @@ Base64-encoded plain text in the configuration file.
True
False
+ 0
RST Sent
15
- 0
False
@@ -3251,9 +3209,9 @@ Base64-encoded plain text in the configuration file.
True
False
+ 0
RST Received
15
- 0
False
@@ -3291,9 +3249,9 @@ Base64-encoded plain text in the configuration file.
True
False
+ 0
QSL Sent
15
- 0
False
@@ -3330,9 +3288,9 @@ Base64-encoded plain text in the configuration file.
True
False
+ 0
QSL Received
15
- 0
False
@@ -3369,9 +3327,9 @@ Base64-encoded plain text in the configuration file.
True
False
+ 0
Notes
15
- 0
False
@@ -3464,9 +3422,9 @@ Base64-encoded plain text in the configuration file.
True
False
+ 0
Name
15
- 0
False
@@ -3504,9 +3462,9 @@ Base64-encoded plain text in the configuration file.
True
False
+ 0
Address
15
- 0
False
@@ -3544,9 +3502,9 @@ Base64-encoded plain text in the configuration file.
True
False
+ 0
State
15
- 0
False
@@ -3584,9 +3542,9 @@ Base64-encoded plain text in the configuration file.
True
False
+ 0
Country
15
- 0
False
@@ -3638,9 +3596,9 @@ Base64-encoded plain text in the configuration file.
True
False
+ 0
DXCC
15
- 0
False
@@ -3678,9 +3636,9 @@ Base64-encoded plain text in the configuration file.
True
False
+ 0
CQ Zone
15
- 0
False
@@ -3718,9 +3676,9 @@ Base64-encoded plain text in the configuration file.
True
False
+ 0
ITU Zone
15
- 0
False
@@ -3758,9 +3716,9 @@ Base64-encoded plain text in the configuration file.
True
False
+ 0
IOTA Designator
15
- 0
False
@@ -3816,6 +3774,48 @@ Base64-encoded plain text in the configuration file.
1
+
+
+ False
+ end
+
+
+ gtk-cancel
+ True
+ True
+ True
+ True
+ True
+
+
+ False
+ True
+ 0
+
+
+
+
+ gtk-ok
+ True
+ True
+ True
+ True
+ True
+
+
+ False
+ True
+ 1
+
+
+
+
+ False
+ True
+ end
+ 2
+
+
@@ -3909,6 +3909,165 @@ Base64-encoded plain text in the configuration file.
False
vertical
2
+
+
+ True
+ False
+
+
+ True
+ False
+ 0
+ Host
+ 10
+
+
+ False
+ False
+ 6
+ 0
+
+
+
+
+ True
+ True
+
+
+ True
+ True
+ 6
+ 1
+
+
+
+
+ False
+ True
+ 6
+ 0
+
+
+
+
+ True
+ False
+
+
+ True
+ False
+ start
+ 0
+ Port
+ 10
+
+
+ False
+ False
+ 6
+ 0
+
+
+
+
+ True
+ True
+ number
+
+
+ True
+ True
+ 6
+ 1
+
+
+
+
+ False
+ True
+ 6
+ 1
+
+
+
+
+ True
+ False
+
+
+ True
+ False
+ 0
+ Username
+ 10
+
+
+ False
+ False
+ 6
+ 0
+
+
+
+
+ True
+ True
+
+
+ True
+ True
+ 6
+ 1
+
+
+
+
+ False
+ True
+ 6
+ 2
+
+
+
+
+ True
+ False
+
+
+ True
+ False
+ 0
+ Password
+ 10
+
+
+ False
+ False
+ 6
+ 0
+
+
+
+
+ True
+ True
+ password
+
+
+ True
+ True
+ 6
+ 1
+
+
+
+
+ False
+ True
+ 6
+ 3
+
+
False
@@ -3952,33 +4111,23 @@ Base64-encoded plain text in the configuration file.
-
+
True
False
-
+
+ Bookmark server details
True
- False
- Host
- 12
+ True
+ False
+ 0
+ True
False
- False
- 6
- 0
-
-
-
-
- True
- True
-
-
- True
True
6
- 1
+ 0
@@ -3986,140 +4135,7 @@ Base64-encoded plain text in the configuration file.
False
True
6
- 0
-
-
-
-
- True
- False
-
-
- True
- False
- start
- Port
- 12
-
-
- False
- False
- 6
- 0
-
-
-
-
- True
- True
- number
-
-
- True
- True
- 6
- 1
-
-
-
-
- False
- True
- 6
- 1
-
-
-
-
- True
- False
-
-
- True
- False
- Username
- 12
-
-
- False
- False
- 6
- 0
-
-
-
-
- True
- True
-
-
- True
- True
- 6
- 1
-
-
-
-
- False
- True
- 6
- 2
-
-
-
-
- True
- False
-
-
- True
- False
- Password
- 12
-
-
- False
- False
- 6
- 0
-
-
-
-
- True
- True
- password
-
-
- True
- True
- 6
- 1
-
-
-
-
- False
- True
- 6
- 3
-
-
-
-
- Bookmark server details
- True
- True
- False
- 0
- True
-
-
- False
- False
- 6
- 4
+ 6
@@ -4129,4 +4145,162 @@ Base64-encoded plain text in the configuration file.
telnet_connection_ok_button
+
+ True
+ False
+ vertical
+
+
+ True
+ False
+
+
+ True
+ False
+ start
+ 4
+ True
+
+
+ False
+ True
+ 2
+ 0
+
+
+
+
+ False
+ True
+ 4
+ 0
+
+
+
+
+ True
+ False
+
+
+ True
+ False
+ Number of logs:
+
+
+ False
+ True
+ 6
+ 0
+
+
+
+
+ True
+ False
+ 0
+
+
+ False
+ True
+ 6
+ 1
+
+
+
+
+ False
+ True
+ 4
+ 1
+
+
+
+
+ True
+ False
+
+
+ True
+ False
+ Total number of QSOs:
+
+
+ False
+ True
+ 6
+ 0
+
+
+
+
+ True
+ False
+ 0
+
+
+ False
+ True
+ 6
+ 1
+
+
+
+
+ False
+ True
+ 4
+ 2
+
+
+
+
+ True
+ False
+
+
+ True
+ False
+ Date modified:
+
+
+ False
+ True
+ 6
+ 0
+
+
+
+
+ True
+ False
+ 0
+
+
+ False
+ True
+ 6
+ 1
+
+
+
+
+ False
+ True
+ 4
+ 3
+
+
+
+
+ True
+ False
+
+
+ False
+ True
+ 4
+ 4
+
+
+