kopia lustrzana https://github.com/ctjacobs/pyqso
Started to hook the data sources up with the logbook.
rodzic
91922d5a26
commit
6c3f917355
|
@ -26,15 +26,37 @@ class DataEntryPanel(Gtk.VBox):
|
|||
def __init__(self, parent, hbox):
|
||||
logging.debug("New DataEntryPanel instance created!")
|
||||
|
||||
Gtk.VBox.__init__(self, spacing=6)
|
||||
Gtk.VBox.__init__(self, spacing=2)
|
||||
|
||||
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.source_call = Gtk.Entry()
|
||||
temp_hbox = Gtk.HBox(spacing=2)
|
||||
temp_hbox.pack_start(Gtk.Label("Call: "), False, False, 2)
|
||||
temp_hbox.pack_start(self.source_call, expand=True, fill=True, padding=2)
|
||||
self.pack_start(temp_hbox, False, False, 0)
|
||||
|
||||
self.source_date = Gtk.Entry()
|
||||
temp_hbox = Gtk.HBox(spacing=2)
|
||||
temp_hbox.pack_start(Gtk.Label("Date: "), False, False, 2)
|
||||
temp_hbox.pack_start(self.source_date, expand=True, fill=True, padding=2)
|
||||
self.pack_start(temp_hbox, False, False, 0)
|
||||
|
||||
self.source_freq = Gtk.Entry()
|
||||
temp_hbox = Gtk.HBox(spacing=6)
|
||||
temp_hbox.pack_start(Gtk.Label("Freq.: "), False, False, 2)
|
||||
temp_hbox.pack_start(self.source_freq, expand=True, fill=True, padding=2)
|
||||
self.pack_start(temp_hbox, False, False, 0)
|
||||
|
||||
self.sources = {"CALL":self.source_call,
|
||||
"DATE":self.source_date,
|
||||
"FREQ":self.source_freq}
|
||||
|
||||
self.store = Gtk.Button("Store Data")
|
||||
self.store.connect("clicked", parent.edit_record_callback)
|
||||
self.pack_start(self.store, expand=False, fill=True, padding=2)
|
||||
|
||||
hbox.pack_start(self, False, False, 0)
|
||||
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
|
42
src/pyqso.py
42
src/pyqso.py
|
@ -52,20 +52,21 @@ class PyQSO(Gtk.Window):
|
|||
# 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)
|
||||
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)
|
||||
|
||||
self.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)
|
||||
sw.add(self.treeview)
|
||||
|
||||
hbox.pack_start(sw, True, True, 0)
|
||||
|
||||
# The first column of the logbook will always be the unique record index.
|
||||
# Let's append this separately to the field names.
|
||||
renderer = Gtk.CellRendererText()
|
||||
|
@ -151,8 +152,7 @@ class PyQSO(Gtk.Window):
|
|||
return
|
||||
|
||||
def delete_record_callback(self, widget):
|
||||
# Get the selected row in the logbook and
|
||||
# delete it.
|
||||
# Get the selected row in the logbook and delete it.
|
||||
selection = self.treeview.get_selection()
|
||||
selection.set_mode(Gtk.SelectionMode.SINGLE)
|
||||
(model, path) = selection.get_selected_rows()
|
||||
|
@ -172,7 +172,29 @@ class PyQSO(Gtk.Window):
|
|||
|
||||
dialog.destroy()
|
||||
return
|
||||
|
||||
def edit_record_callback(self, widget):
|
||||
|
||||
#TODO: Validate user input!
|
||||
|
||||
selection = self.treeview.get_selection()
|
||||
selection.set_mode(Gtk.SelectionMode.SINGLE)
|
||||
(model, path) = selection.get_selected_rows()
|
||||
iter = model.get_iter(path[0])
|
||||
row_index = model.get_value(iter,0)
|
||||
|
||||
field_names = self.logbook.SELECTED_FIELD_NAMES_TYPES.keys()
|
||||
for column_index in range(0, len(field_names)):
|
||||
data = self.data_entry_panel.sources[field_names[column_index]].get_text()
|
||||
# First update the Record object...
|
||||
# (we add 1 onto the column_index here because we don't want to consider the index column)
|
||||
column_name = self.treeview.get_column(column_index+1).get_title()
|
||||
self.logbook.records[row_index].set_field(column_name, data)
|
||||
# ...and then the Logbook.
|
||||
self.logbook[row_index][column_index+1] = data
|
||||
|
||||
return
|
||||
|
||||
def show_about(self, widget):
|
||||
about = Gtk.AboutDialog()
|
||||
about.set_program_name("PyQSO")
|
||||
|
|
Ładowanie…
Reference in New Issue