コード例 #1
0
 def updateCategoryList (self):
     self.category_list = ToDoListDatabase.getDistinctCategories()
     self.CategoryTF.Clear()
     for item in self.category_list:
         self.CategoryTF.Append(item)
     if not self.category_list:
         self.category_list = ["[Category]","Other"]
     self.CategoryTF.SetValue(self.category_list[0])
コード例 #2
0
    def __init__ (self, *args, **kwargs):
        super(windowClass, self).__init__(*args, **kwargs)
        #Creat Window basics
        self.SetTitle("To Do List Express")
        self.CreateStatusBar()
        self.SetStatusText('Ready')
        self.SetSize((770,710))
        self.width = self.GetSize()[0]
        self.height = self.GetSize()[1]
        self.Centre()
        #panel = wx.Panel(self)
        #panel.SetSize((self.width,self.height))

        #size=DefaultSize
        panel = wx.PyScrolledWindow( self, -1)
        panel.SetScrollbars(10, 10, (self.width/10)-3.5, (self.height/10)-8.5)
        #print panel.GetSize()

        
        

        #SET variables
        self.MainTable = "ToDoListTable"
        self.DailyTable = "DailyTasksTable"
        self.category_list = None
        self.toDoTF = None
        self.CurrentDateTF = None
        self.DueDateTF = None
        #
        self.NoRB = None
        self.YesRB = None
        self.DailyTask = "False"
        #
        self.MainRB = None
        self.DailyRB = None
        self.CurrentTable = self.MainTable
        self.tableLabel = None
        #
        self.listCtrl = None
        self.itemCountLabel = None
        self.itemCount = 0
        self.item_ID = 1
        self.ASC_DESC = "ASC"
        colmn_list=["[Item 1]","ID", "Category", "Item", "Current_date", "Due_date", "Daily_task"]
        self.SortCatOne = None
        self.SortCatTwo = None
        #dates
        self.now = str(datetime.datetime.now())
        self.now = self.now[:10]
        #
        #self.deletedItems = []
        #buttons
        '''addBTN
        #sortCatBTN
        #editBTN
        #refreshBTN
        #deleteBTN'''
        #functions
        '''setTableFunction
        getDailyTask
        getTaskInfoFunction'''
 
        #CREATE MENU BAR
        menuBar = wx.MenuBar()
        fileButton = wx.Menu()
        helpButton = wx.Menu()
        newItem = fileButton.Append(wx.ID_ANY, "&New\tCtrl+N", "Clears information in Task Box")
        saveItem = fileButton.Append(wx.ID_ANY, "&Save\tCtrl+S", "Adds the task item from Task Box to list")
        editItem = fileButton.Append(wx.ID_ANY, "&Edit\tCtrl+E", "Edits the selected item")
        deleteItem = fileButton.Append(wx.ID_ANY, "&Delete\tCtrl+D", "Deletes the selected item")
        changeDatabase = fileButton.Append(wx.ID_ANY, "Change Database", "Lets you work from a different database")
        addDailyItem = fileButton.Append(wx.ID_ANY, "&Add Daily", "Adds the tasks that you do daily to the list")
        exitItem = fileButton.Append(wx.ID_ANY, "&Quit\tCtrl+Q", "Quit the program")
        helpLabel = "About {}".format(self.GetTitle())
        helpItem = helpButton.Append(wx.ID_ANY, helpLabel, "About the program")

        menuBar.Append(fileButton, "&File")
        menuBar.Append(helpButton, "&Help")

        self.SetMenuBar(menuBar)
        self.Bind (wx.EVT_MENU, self.newFunction, newItem)
        self.Bind (wx.EVT_MENU, self.addTaskFunction, saveItem)
        self.Bind (wx.EVT_MENU, self.editFunction, editItem)
        self.Bind (wx.EVT_MENU , self.deleteFunction, deleteItem)
        self.Bind (wx.EVT_MENU, self.changeDatabaseFunction, changeDatabase)
        self.Bind (wx.EVT_MENU, self.addDailyFunction, addDailyItem)
        self.Bind (wx.EVT_MENU, self.Quit, exitItem)
        self.Bind (wx.EVT_MENU, self.helpFunction, helpItem)

        

        #CREATE PANELS
        #panel
        wx.StaticBox(panel, label="Task Box: ", pos=(10,10),size=(715,165))

        #category
        wx.StaticText(panel, label="Category:",pos=(20,30))
        self.category_list = ToDoListDatabase.getDistinctCategories()
        if not self.category_list:
            self.category_list = ["[Category]","Other"]
        self.CategoryTF = wx.ComboBox (panel, pos=(20,55), size=(230,-1), \
                                   choices=self.category_list, value =self.category_list[0])
        #to do list description
        wx.StaticText(panel, label="To Do Item:",pos=(20,90))
        self.toDoTF = wx.TextCtrl (panel, style=wx.TE_MULTILINE,
                                         pos=(20,110), size=(230,50) )


        
        #current date
        wx.StaticText(panel, label="Current Date:",pos=(370,30))
        self.CurrentDateTF = wx.TextCtrl(panel, pos=(370,50), size=(150,-1))
        self.CurrentDateTF.SetValue(str(self.now))
        #due date
        wx.StaticText(panel, label="Due Date:",pos=(370,80))
        self.DueDateTF = wx.TextCtrl(panel, pos=(370,100), size=(150,-1))
        self.DueDateTF.SetValue(str(self.now))

        #Daily task
        wx.StaticText(panel, label="Daily Task?",pos=(570,30))
        self.NoRB = wx.RadioButton(panel, label='No', pos=(570, 55), 
            style=wx.RB_GROUP)
        self.YesRB = wx.RadioButton(panel, label='Yes', pos=(570, 75))

        #create add button
        addBTN = wx.Button (panel, label = "Add", pos=(570,130), size=(100,30))
        addBTN.Bind(wx.EVT_BUTTON, self.addTaskFunction)

        #---------------------------------------------------------------------

        #Daily task
        wx.StaticText(panel, label="Choose List:",pos=(20,190))
        self.MainRB = wx.RadioButton(panel, label='To Do List', pos=(100, 190), 
            style=wx.RB_GROUP)
        self.DailyRB = wx.RadioButton(panel, label='Daily Tasks', pos=(180, 190))
        self.MainRB.Bind(wx.EVT_RADIOBUTTON, self.setTableFunction)
        self.DailyRB.Bind(wx.EVT_RADIOBUTTON, self.setTableFunction)
        self.tableLabel = wx.StaticText(panel, label="You are currently working on: To Do List",pos=(450,190))

        #add list
        self.listCtrl = wx.ListCtrl (panel, pos=(20,215), size=(700,340), \
                                style=wx.LC_REPORT | wx.BORDER_SUNKEN)
        #set columns
        self.listCtrl.InsertColumn(0, "ID")
        self.listCtrl.InsertColumn(1, "Category")     
        self.listCtrl.InsertColumn(2, "To Do List Item              ", width=-1)
        self.listCtrl.InsertColumn(3, "Creation Date")
        self.listCtrl.InsertColumn(4, "Due Date")
        self.listCtrl.InsertColumn (5, "Daily Task")
        self.listCtrl.SetColumnWidth(0, -1)
        self.listCtrl.SetColumnWidth(2, -2)
        self.listCtrl.Bind(wx.EVT_LIST_ITEM_SELECTED, self.getRow)
        

        #display item Count
        self.itemCountLabel = wx.StaticText(panel, label="Item count:",pos=(625,560))


        #add sort by
        self.SortCatOne = wx.ComboBox (panel, pos=(20,580), \
                                   choices=colmn_list, style=wx.CB_READONLY, value =colmn_list[0])

        colmn_list[0] = "[Item 2]"
        self.SortCatTwo = wx.ComboBox (panel, pos=(130,580), \
                                   choices=colmn_list, style=wx.CB_READONLY, value =colmn_list[0])
        sortCatBTN = wx.Button (panel, label = "Sort By Cat", pos=(240,580), size=(100,30))
        sortCatBTN.Bind(wx.EVT_BUTTON, self.sortCatFunction)
        
        #add edit
        editBTN = wx.Button (panel, label = "Edit Item", pos=(410,580), size=(100,30))
        editBTN.Bind(wx.EVT_BUTTON, self.editFunction)
        #add update list
        refreshBTN = wx.Button (panel, label = "Refresh List", pos=(520,580), size=(100,30))
        refreshBTN.Bind(wx.EVT_BUTTON, self.refreshFunction)
        #add delete
        deleteBTN = wx.Button (panel, label = "Delete Item", pos=(630,580), size=(100,30))
        deleteBTN.Bind(wx.EVT_BUTTON, self.deleteFunction)


        #populate listbox
        self.addToListBox()