More work on using Glade. Also bumped the version to 1.0.0 (in development).

pull/54/head
Christian T. Jacobs 2017-02-15 23:17:51 +00:00
rodzic 295eb79b91
commit c9ffb5e11e
5 zmienionych plików z 236 dodań i 77 usunięć

Wyświetl plik

@ -34,7 +34,7 @@ sys.path.insert(0, pyqso_path)
import logging
logging.basicConfig(level=logging.INFO)
logging.info("PyQSO version 0.4")
logging.info("PyQSO version 1.0.0")
# PyQSO modules
from pyqso.adif import *
@ -45,7 +45,7 @@ from pyqso.toolbox import *
from pyqso.preferences_dialog import *
class PyQSO(Gtk.Window):
class PyQSO:
""" The PyQSO application class. """
@ -55,8 +55,9 @@ class PyQSO(Gtk.Window):
:arg str logbook_path: An optional argument containing the path of the logbook file to open. If no value is provided, this defaults to None and no logbook is opened.
"""
# Call the constructor of the super class (Gtk.Window)
Gtk.Window.__init__(self, title="PyQSO")
self.builder = Gtk.Builder()
self.builder.add_from_file(os.path.abspath(os.path.dirname(__file__)) + "/../pyqso/glade/pyqso.glade")
self.window = self.builder.get_object("pyqso")
# Check that the directory for holding PyQSO configuration files exists. If it doesn't, create it now.
config_directory = os.path.expanduser('~/.config/pyqso')
@ -74,68 +75,42 @@ class PyQSO(Gtk.Window):
# otherwise, we will resort to the defaults.
have_config = (config.read(os.path.expanduser("~/.config/pyqso/preferences.ini")) != [])
self.set_size_request(800, 600) # Default to an 800 x 600 resolution.
self.set_position(Gtk.WindowPosition.CENTER)
possible_icon_paths = [os.path.join(pyqso_path, "icons", "log_64x64.png")]
for icon_path in possible_icon_paths:
try:
self.set_icon_from_file(icon_path)
except Exception as error:
print(error.message)
window.set_icon_from_file(icon_path)
except Exception as e:
logging.error(e)
# Kills the application if the close button is clicked on the main window itself.
self.connect("delete-event", Gtk.main_quit)
self.window.connect("delete-event", Gtk.main_quit)
vbox_outer = Gtk.VBox()
self.add(vbox_outer)
self.statusbar = Gtk.Statusbar()
self.statusbar = self.builder.get_object("statusbar")
context_id = self.statusbar.get_context_id("Status")
self.statusbar.push(context_id, "No logbook is currently open.")
# Create a Logbook so we can add/remove/edit logs and records,
# once connected to the SQLite database.
self.logbook = Logbook(self)
self.logbook.set_scrollable(True)
#self.logbook = Logbook(self)
#self.logbook.set_scrollable(True)
self.toolbox = Toolbox(self)
#self.toolbox = Toolbox(self)
# Set up menu and tool bars
# These classes depend on the Logbook and Toolbox class,
# so pack the logbook and toolbox after the menu and toolbar.
self.menu = Menu(self)
self.toolbar = Toolbar(self)
#self.menu = Menu(self)
#self.toolbar = Toolbar(self)
vbox_outer.pack_start(self.menu, False, False, 0)
vbox_outer.pack_start(self.toolbar, False, False, 0)
vbox_outer.pack_start(self.logbook, True, True, 0)
vbox_outer.pack_start(self.toolbox, True, True, 0)
vbox_outer.pack_start(self.statusbar, False, False, 0)
#vbox_outer.pack_start(self.menu, False, False, 0)
#vbox_outer.pack_start(self.toolbar, False, False, 0)
#vbox_outer.pack_start(self.logbook, True, True, 0)
#vbox_outer.pack_start(self.toolbox, True, True, 0)
#vbox_outer.pack_start(self.statusbar, False, False, 0)
self.show_all()
self.toolbox = Toolbox(self.window, self.builder)
if(have_config):
if(config.get("general", "show_toolbox") == "False"):
self.toolbox.toggle_visible_callback()
else:
# Hide the Toolbox by default
self.toolbox.toggle_visible_callback()
if(logbook_path is not None):
logging.info("Opening logbook: %s" % logbook_path)
self.logbook.open(widget=None, path=logbook_path)
else:
# If no logbook path is specified at the command line,
# then check if the user wants to open a default logbook.
(section, option) = ("general", "default_logbook")
if(have_config and config.has_option(section, option)):
open_default_logbook = (config.get(section, option) == "True")
(section, option) = ("general", "default_logbook_path")
if(open_default_logbook and config.has_option(section, option)):
logbook_path = config.get(section, option)
if(logbook_path is not None and logbook_path != ""):
logging.info("Opening the default logbook: %s" % logbook_path)
self.logbook.open(widget=None, path=logbook_path)
self.window.show_all()
return
@ -145,7 +120,7 @@ class PyQSO(Gtk.Window):
about.set_modal(True)
about.set_transient_for(parent=self)
about.set_program_name("PyQSO")
about.set_version("0.4")
about.set_version("1.0.0")
about.set_authors(["Christian T. Jacobs (2E0ICL)"])
about.set_license("""This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

Wyświetl plik

@ -51,16 +51,16 @@ master_doc = 'index'
# General information about the project.
project = u'PyQSO'
copyright = u'2015-2016, Christian T. Jacobs (2E0ICL)'
copyright = u'2015-2017, Christian T. Jacobs (2E0ICL)'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.4'
version = '1.0.0'
# The full version, including alpha/beta/rc tags.
release = '0.4'
release = '1.0.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

Wyświetl plik

@ -345,7 +345,7 @@ class ADIF:
<adif_ver:%d>%s
<programid:5>PyQSO
<programversion:3>0.4
<programversion:5>1.0.0
<eoh>\n""" % (dt, len(records), len(str(ADIF_VERSION)), ADIF_VERSION))
# Then write each log to the file.
@ -649,7 +649,7 @@ class TestADIF(unittest.TestCase):
assert("""
<adif_ver:5>3.0.4
<programid:5>PyQSO
<programversion:3>0.4
<programversion:5>1.0.0
<eoh>
<call:7>TEST123
<qso_date:8>20120402
@ -690,7 +690,7 @@ class TestADIF(unittest.TestCase):
assert("""
<adif_ver:5>3.0.4
<programid:5>PyQSO
<programversion:3>0.4
<programversion:5>1.0.0
<eoh>
<call:7>TEST123
<qso_date:8>20120402

Wyświetl plik

@ -2,26 +2,196 @@
<!-- Generated with glade 3.16.1 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-close</property>
</object>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-open</property>
</object>
<object class="GtkImage" id="image3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-new</property>
</object>
<object class="GtkImage" id="image4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-add</property>
</object>
<object class="GtkWindow" id="pyqso">
<property name="can_focus">False</property>
<property name="title" translatable="yes">PyQSO</property>
<property name="window_position">center</property>
<property name="default_width">800</property>
<property name="default_height">600</property>
<property name="icon">log_64x64.png</property>
<child>
<object class="GtkBox" id="vbox_outer">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
<object class="GtkMenuBar" id="menu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="mitem_logbook">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Logbook</property>
<child type="submenu">
<object class="GtkMenu" id="subm_logbook">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="mitem_new_logbook">
<property name="label" translatable="yes">Create a New Logbook...</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="image">image3</property>
<property name="use_stock">False</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="mitem_open_logbook">
<property name="label" translatable="yes">Open an Existing Logbook...</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="image">image2</property>
<property name="use_stock">False</property>
<accelerator key="o" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="mitem_close_logbook">
<property name="label" translatable="yes">Close Logbook</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="image">image1</property>
<property name="use_stock">False</property>
<accelerator key="w" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="separatormenuitem2">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="mitem_new_log">
<property name="label" translatable="yes">New Log</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="image">image4</property>
<property name="use_stock">False</property>
<accelerator key="n" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem" id="mitem_records">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Records</property>
<child type="submenu">
<object class="GtkMenu" id="menu3">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem" id="mitem_view">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">View</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="mitem_help">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Help</property>
<child type="submenu">
<object class="GtkMenu" id="menu4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem15">
<property name="label">gtk-about</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
<object class="GtkBox" id="toolbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>
<object class="GtkNotebook" id="logbook">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="toolbox">
@ -44,15 +214,16 @@
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkMenuBar" id="menubar">
<object class="GtkMenuBar" id="dx_cluster_menu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="connection">
<object class="GtkMenuItem" id="mitem_connection">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Connection</property>
<child type="submenu">
<object class="GtkMenu" id="menu1">
<object class="GtkMenu" id="connection_menu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
@ -123,7 +294,7 @@
</object>
</child>
<child type="tab">
<object class="GtkLabel" id="label2">
<object class="GtkLabel" id="dxcluster_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">DX Cluster</property>
@ -133,10 +304,18 @@
</packing>
</child>
<child>
<placeholder/>
<object class="GtkButton" id="button1">
<property name="label" translatable="yes">button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="label3">
<object class="GtkLabel" id="greyline_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Grey Line</property>
@ -147,10 +326,18 @@
</packing>
</child>
<child>
<placeholder/>
<object class="GtkButton" id="button2">
<property name="label" translatable="yes">button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="label4">
<object class="GtkLabel" id="awards_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Awards</property>
@ -165,7 +352,7 @@
</object>
</child>
<child type="label">
<object class="GtkLabel" id="title">
<object class="GtkLabel" id="toolbox_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Toolbox</property>
@ -173,7 +360,7 @@
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
@ -191,7 +378,7 @@
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="fill">False</property>
<property name="position">4</property>
</packing>
</child>

Wyświetl plik

@ -25,29 +25,26 @@ from pyqso.grey_line import *
from pyqso.awards import *
class Toolbox(Gtk.Frame):
class Toolbox:
""" Contains a Gtk.Notebook full of amateur radio-related tools. """
def __init__(self, parent):
def __init__(self, parent, builder):
""" Instantiate and insert the various tools into the toolbox. """
logging.debug("Setting up the toolbox...")
Gtk.Frame.__init__(self)
self.set_label("Toolbox")
self.parent = parent
self.tools = Gtk.Notebook()
self.tools = builder.get_object("tools")
self.dx_cluster = DXCluster(self.parent)
self.tools.insert_page(self.dx_cluster, Gtk.Label("DX Cluster"), 0)
self.grey_line = GreyLine(self.parent)
self.tools.insert_page(self.grey_line, Gtk.Label("Grey Line"), 1)
self.awards = Awards(self.parent)
self.tools.insert_page(self.awards, Gtk.Label("Awards"), 2)
#self.awards = Awards(self.parent)
#self.tools.insert_page(self.awards, Gtk.Label("Awards"), 2)
self.add(self.tools)
self.tools.connect_after("switch-page", self._on_switch_page)
logging.debug("Toolbox ready!")