kopia lustrzana https://github.com/ctjacobs/pyqso
Added a data entry panel for adding/removing/editing records in the logbook. Each logbook cell itself no longer needs to be directly editable.
rodzic
1263a45a55
commit
562afa8ee7
|
@ -26,13 +26,9 @@ from record import *
|
|||
|
||||
# All the possible field names and their associated data types
|
||||
# from the ADIF specification (version 3.0.2)
|
||||
AVAILABLE_FIELD_NAMES_TYPES = {"ADDRESS": "M",
|
||||
"ADDRESS__INTL": "G",
|
||||
"AGE": "N",
|
||||
"CALL": "S",
|
||||
AVAILABLE_FIELD_NAMES_TYPES = {"CALL": "S",
|
||||
"FREQ": "N",
|
||||
"DATE": "D",
|
||||
"QSO__RANDOM": "B"}
|
||||
"DATE": "D"}
|
||||
|
||||
# A: AwardList
|
||||
# B: Boolean
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/env python
|
||||
# File: data_entry_panel.py
|
||||
|
||||
# Copyright (C) 2013 Christian Jacobs.
|
||||
|
||||
# This file is part of PyQSO.
|
||||
|
||||
# PyQSO is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# PyQSO is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with PyQSO. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from gi.repository import Gtk, GObject
|
||||
import logging
|
||||
|
||||
class DataEntryPanel(Gtk.VBox):
|
||||
|
||||
def __init__(self, parent, hbox):
|
||||
logging.debug("New DataEntryPanel instance created!")
|
||||
|
||||
Gtk.VBox.__init__(self, spacing=6)
|
||||
|
||||
self.edit_call = Gtk.Entry()
|
||||
temp_hbox = Gtk.HBox(spacing=6)
|
||||
temp_hbox.pack_start(Gtk.Label("Call: "), False, False, 0)
|
||||
temp_hbox.pack_start(self.edit_call, False, False, 0)
|
||||
self.pack_start(temp_hbox, False, False, 0)
|
||||
|
||||
|
||||
hbox.pack_start(self, False, False, 0)
|
||||
|
||||
return
|
|
@ -35,7 +35,7 @@ class Menu(Gtk.MenuBar):
|
|||
parent.add_accel_group(agrp)
|
||||
|
||||
###### FILE ######
|
||||
mitem_file = Gtk.MenuItem("File")
|
||||
mitem_file = Gtk.MenuItem("Log")
|
||||
self.append(mitem_file)
|
||||
subm_file = Gtk.Menu()
|
||||
mitem_file.set_submenu(subm_file)
|
||||
|
@ -72,7 +72,7 @@ class Menu(Gtk.MenuBar):
|
|||
|
||||
|
||||
###### LOG ######
|
||||
mitem_log = Gtk.MenuItem("Log")
|
||||
mitem_log = Gtk.MenuItem("Record")
|
||||
self.append(mitem_log)
|
||||
subm_log = Gtk.Menu()
|
||||
mitem_log.set_submenu(subm_log)
|
||||
|
|
51
src/pyqso.py
51
src/pyqso.py
|
@ -26,6 +26,7 @@ import optparse
|
|||
from adif import *
|
||||
from logbook import *
|
||||
from menu import *
|
||||
from data_entry_panel import *
|
||||
|
||||
# The PyQSO application class
|
||||
class PyQSO(Gtk.Window):
|
||||
|
@ -41,20 +42,25 @@ class PyQSO(Gtk.Window):
|
|||
# on the main window itself.
|
||||
self.connect("delete-event", Gtk.main_quit)
|
||||
|
||||
# Vertically aligned packing layout
|
||||
vbox = Gtk.VBox(spacing=6)
|
||||
self.add(vbox)
|
||||
vbox_outer = Gtk.VBox()
|
||||
self.add(vbox_outer)
|
||||
|
||||
# Set up menu bar and populate it
|
||||
menu = Menu(self, vbox)
|
||||
menu = Menu(self, vbox_outer)
|
||||
|
||||
# SCROLLED WINDOW to host the list box defined below.
|
||||
# Under the menu, we want the data entry panel on the left and the logbook on the right,
|
||||
# so we'll place these in an HBox.
|
||||
hbox = Gtk.HBox()
|
||||
vbox_outer.pack_start(hbox, True, True, 0)
|
||||
|
||||
data_entry_panel = DataEntryPanel(self, hbox)
|
||||
|
||||
# Allow the Logbook to be scrolled up/down
|
||||
sw = Gtk.ScrolledWindow()
|
||||
sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
|
||||
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
vbox.pack_start(sw, True, True, 0)
|
||||
|
||||
# LIST BOX for the radio log entries
|
||||
hbox.pack_start(sw, True, True, 0)
|
||||
# Create a new Logbook so we can add/remove/edit Record objects
|
||||
self.logbook = Logbook()
|
||||
self.treeview = Gtk.TreeView(self.logbook)
|
||||
self.treeview.set_grid_lines(Gtk.TreeViewGridLines.BOTH)
|
||||
|
@ -73,31 +79,10 @@ class PyQSO(Gtk.Window):
|
|||
field_names = self.logbook.SELECTED_FIELD_NAMES_TYPES.keys()
|
||||
data_types = self.logbook.SELECTED_FIELD_NAMES_TYPES.values()
|
||||
for i in range(0, len(self.logbook.SELECTED_FIELD_NAMES_TYPES)):
|
||||
|
||||
if(data_types[i] == "S"):
|
||||
renderer = Gtk.CellRendererText()
|
||||
renderer.set_property("editable", True)
|
||||
renderer.connect("edited", self.textcell_edited_callback, self.treeview, i+1)
|
||||
column = Gtk.TreeViewColumn(field_names[i], renderer, text=i+1)
|
||||
|
||||
elif(data_types[i] == "B"):
|
||||
choices = Gtk.ListStore(str)
|
||||
for item in ["", "Yes", "No"]:
|
||||
choices.append([item])
|
||||
|
||||
renderer = Gtk.CellRendererCombo()
|
||||
renderer.set_property("editable", True)
|
||||
renderer.set_property("model", choices)
|
||||
renderer.set_property("text-column", 0)
|
||||
renderer.connect("edited", self.booleancell_edited_callback, self.treeview, i+1)
|
||||
column = Gtk.TreeViewColumn(field_names[i], renderer, text=i+1)
|
||||
|
||||
else:
|
||||
# Default to a text-based cell if the field name is unknown.
|
||||
renderer = Gtk.CellRendererText()
|
||||
renderer.set_property("editable", True)
|
||||
renderer.connect("edited", self.textcell_edited_callback, self.treeview, i+1)
|
||||
column = Gtk.TreeViewColumn(field_names[i], renderer, text=i+1)
|
||||
renderer = Gtk.CellRendererText()
|
||||
renderer.set_property("editable", True)
|
||||
renderer.connect("edited", self.textcell_edited_callback, self.treeview, i+1)
|
||||
column = Gtk.TreeViewColumn(field_names[i], renderer, text=i+1)
|
||||
|
||||
column.set_resizable(True)
|
||||
column.set_min_width(50)
|
||||
|
|
Ładowanie…
Reference in New Issue