Beispiel #1
0
    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)
Beispiel #2
0
    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
Beispiel #3
0
    def __init__(self, db):
        """Creates and displays the main window.""" 
        # Store the database connection that was passed
        self.db = db

        # Set the correct path for the glade file
        gladefile = os.path.join(os.path.dirname(sys.argv[0]), 'MainWindow.glade')

        # Get widgets from the glade file
        self.widgets = gtk.glade.XML(gladefile)

        # Store the signals in a dictionary
        signals = {'on_Add' : self.onAdd,
                   'on_Edit' : self.onEdit,
                   'on_Delete' : self.onDelete,
                   'on_Refresh' : self.onRefresh,
                   'on_Preferences' : self.onPreferences,
                   'on_RowActivated' : self.onRowClick,
                   'on_Quit' : self.onQuit,
                   'on_Close' : self.onClose,
                   'on_About' : self.onAbout}

        # Autoconnect the signals
        self.widgets.signal_autoconnect(signals)

        # Store the window widget
        self.window = self.widgets.get_widget('MainWindow')

        # Put correct values in Task / Change Status
        config = Config()
        # Get status menu item
        status = self.widgets.get_widget('Status')
        # Make a submenu
        statusmenu = gtk.Menu()
        status.set_submenu (statusmenu)
        statusmenu.show()
        # Make a menu item for each status
        notstarted = gtk.MenuItem (config.statusNames()[task.TASK_NOTSTARTED], True)
        inprogress = gtk.MenuItem (config.statusNames()[task.TASK_INPROGRESS], True)
        completed = gtk.MenuItem (config.statusNames()[task.TASK_COMPLETED], True)
        # Add them to their menu
        statusmenu.append (notstarted)
        statusmenu.append (inprogress)
        statusmenu.append (completed)
        # Connect them to their appropriate handlers
        notstarted.connect ('activate', self.onNotStarted)
        inprogress.connect ('activate', self.onInProgress)
        completed.connect ('activate', self.onCompleted)
        # Show them
        notstarted.show()
        inprogress.show()
        completed.show()

        # Tell the window not to delete itself when it's hidden
        self.window.connect('delete_event', self.window.hide_on_delete)

        # Start the position in the top right corner
        self.position = [self.window.get_screen().get_width(), 0]
        self.window.move(self.position[0], self.position[1])

        # Create a ListStore to store the tasks in
        self.tasklist = gtk.ListStore(str, int, int, int)

        # Set the TreeView to use the ListStore
        self.widgets.get_widget('TaskView').set_model(self.tasklist)

        # Create a text renderer
        self.cell = gtk.CellRendererText()

        # Create a column for the tasks
        self.taskcolumn = gtk.TreeViewColumn('Task', self.cell, text=0)

        # Store the Tree view
        self.taskView = self.widgets.get_widget('TaskView')

        # Add the column to the TreeView
        self.taskView.append_column(self.taskcolumn)

        # Call taskViewProperties to set up the different styles for the tasks
        self.taskcolumn.set_cell_data_func(self.cell, self.taskViewProperties, None)