def __init__(self, db): """Reads the glade file and creates the dialog.""" # Set the path to the glade file to be the path to Tuxedo.py gladefile = os.path.join(os.path.dirname(sys.argv[0]), 'AddDialog.glade') # Read the widgets from the glade file self.widgets = gtk.glade.XML(gladefile) # Store the signals in a dictionary signals = {"on_Add" : self.onAdd, "on_Cancel" : self.onCancel} # Autoconnect the signals self.widgets.signal_autoconnect(signals) # Store the database connection that was passed self.db = db # Store the dialog widget self.dialog = self.widgets.get_widget('AddDialog') # Fill priorities combobox with names of priorities config = Config() for priority in config.priorityNames(): self.widgets.get_widget('PriorityEntry').append_text(priority) # Fill status combobox with names of statuses for status in config.statusNames(): self.widgets.get_widget('StatusEntry').append_text(status) # Set the priority to normal self.widgets.get_widget('PriorityEntry').set_active(task.TASK_PRIORITY_NORMAL) # Set the status to not started self.widgets.get_widget('StatusEntry').set_active(task.TASK_NOTSTARTED)
def __init__(self, db, t): """Reads the glade file and creates the dialog with the task's current data already entered.""" # Set the path to the glade file to be the path to Tuxedo.py gladefile = os.path.join(os.path.dirname(sys.argv[0]), 'EditDialog.glade') # Read the widgets from the glade file self.widgets = gtk.glade.XML(gladefile) # Store the signals in a dictionary signals = {"on_Apply" : self.onApply, "on_Cancel" : self.onCancel} # Autoconnect the signals self.widgets.signal_autoconnect(signals) # Store the database connection that was passed self.db = db # Store the dialog widget self.dialog = self.widgets.get_widget('EditDialog') # Fill priorities combobox with names of priorities config = Config() for priority in config.priorityNames(): self.widgets.get_widget('PriorityEntry').append_text(priority) # Fill statuses combobox with names of statuses for status in config.statusNames(): self.widgets.get_widget('StatusEntry').append_text(status) # Set the values to be the task's current properties self.widgets.get_widget('TaskEntry').set_text(t.name) self.widgets.get_widget('PriorityEntry').set_active(t.priority) self.widgets.get_widget('StatusEntry').set_active(t.status) self.widgets.get_widget('DateEntry').select_month(t.duedate[1], t.duedate[0]) self.widgets.get_widget('DateEntry').select_day(t.duedate[2]) # Store the id of the task that is being edited self.taskid = t.id