Exemplo n.º 1
0
    def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent)
        try:
            self.bookResults = controller.getAllRecords()
        except:
            self.bookResults = []

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        searchSizer = wx.BoxSizer(wx.HORIZONTAL)
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
        font = wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD)

        # create the search related widgets
        cat = ["Author", "Title", "ISBN", "Publisher"]
        searchByLbl = wx.StaticText(self, label="Search By:")
        searchByLbl.SetFont(font)
        searchSizer.Add(searchByLbl, 0, wx.ALL, 5)

        self.categories = wx.ComboBox(self, value="Author", choices=cat)
        searchSizer.Add(self.categories, 0, wx.ALL, 5)

        self.search = wx.SearchCtrl(self, style=wx.TE_PROCESS_ENTER)
        self.search.Bind(wx.EVT_TEXT_ENTER, self.onSearch)
        searchSizer.Add(self.search, 0, wx.ALL, 5)

        self.bookResultsOlv = ObjectListView(self,
                                             style=wx.LC_REPORT
                                             | wx.SUNKEN_BORDER)
        self.bookResultsOlv.SetEmptyListMsg("No Records Found")
        self.setBooks()

        # create the button row
        btnAddRecord = wx.Button(self, label="Add")
        btnAddRecord.Bind(wx.EVT_BUTTON, self.onAddRecord)
        btnSizer.Add(btnAddRecord, 0, wx.ALL, 5)

        btnEditRecord = wx.Button(self, label="Edit")
        btnEditRecord.Bind(wx.EVT_BUTTON, self.onEditRecord)
        btnSizer.Add(btnEditRecord, 0, wx.ALL, 5)

        btnDeleteRecord = wx.Button(self, label="Delete")
        btnDeleteRecord.Bind(wx.EVT_BUTTON, self.onDelete)
        btnSizer.Add(btnDeleteRecord, 0, wx.ALL, 5)

        btnShowAll = wx.Button(self, label="Show All")
        btnShowAll.Bind(wx.EVT_BUTTON, self.onShowAllRecord)
        btnSizer.Add(btnShowAll, 0, wx.ALL, 5)

        btnClose = wx.Button(self, label="Close")
        btnClose.Bind(wx.EVT_BUTTON, self.onClose)
        btnSizer.Add(btnClose, 0, wx.ALL, 5)

        mainSizer.Add(searchSizer)
        mainSizer.Add(self.bookResultsOlv, 1, wx.ALL | wx.EXPAND, 5)
        mainSizer.Add(btnSizer, 0, wx.CENTER)
        self.SetSizer(mainSizer)
Exemplo n.º 2
0
 def __init__(self, parent):
     """Constructor"""
     wx.Panel.__init__(self, parent)
     try:
         self.bookResults = controller.getAllRecords()
     except:
         self.bookResults = []
     
     mainSizer = wx.BoxSizer(wx.VERTICAL)
     searchSizer = wx.BoxSizer(wx.HORIZONTAL)
     btnSizer = wx.BoxSizer(wx.HORIZONTAL)
     font = wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD) 
     
     # create the search related widgets
     cat = ["Author", "Title", "ISBN", "Publisher"]
     searchByLbl = wx.StaticText(self, label="Search By:")
     searchByLbl.SetFont(font)
     searchSizer.Add(searchByLbl, 0, wx.ALL, 5)
     
     self.categories = wx.ComboBox(self, value="Author", choices=cat)
     searchSizer.Add(self.categories, 0, wx.ALL, 5)
     
     self.search = wx.SearchCtrl(self, style=wx.TE_PROCESS_ENTER)
     self.search.Bind(wx.EVT_TEXT_ENTER, self.onSearch)
     searchSizer.Add(self.search, 0, wx.ALL, 5)
     
     self.bookResultsOlv = ObjectListView(self, style=wx.LC_REPORT
                                                     |wx.SUNKEN_BORDER)
     self.bookResultsOlv.SetEmptyListMsg("No Records Found")
     self.setBooks()
     
     # create the button row
     addRecordBtn = wx.Button(self, label="Add")
     addRecordBtn.Bind(wx.EVT_BUTTON, self.onAddRecord)
     btnSizer.Add(addRecordBtn, 0, wx.ALL, 5)
     
     editRecordBtn = wx.Button(self, label="Edit")
     editRecordBtn.Bind(wx.EVT_BUTTON, self.onEditRecord)
     btnSizer.Add(editRecordBtn, 0, wx.ALL, 5)
     
     deleteRecordBtn = wx.Button(self, label="Delete")
     deleteRecordBtn.Bind(wx.EVT_BUTTON, self.onDelete)
     btnSizer.Add(deleteRecordBtn, 0, wx.ALL, 5)
     
     showAllBtn = wx.Button(self, label="Show All")
     showAllBtn.Bind(wx.EVT_BUTTON, self.onShowAllRecord)
     btnSizer.Add(showAllBtn, 0, wx.ALL, 5)
     
     mainSizer.Add(searchSizer)
     mainSizer.Add(self.bookResultsOlv, 1, wx.ALL|wx.EXPAND, 5)
     mainSizer.Add(btnSizer, 0, wx.CENTER)
     self.SetSizer(mainSizer)
Exemplo n.º 3
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        try:
            self.result = controller.getAllRecords()
        except:
            self.result = []

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        topSizer = wx.BoxSizer(wx.HORIZONTAL)

        addBtn = wx.Button(self, label=u"新增")
        addBtn.Bind(wx.EVT_BUTTON, self.onAdd)
        topSizer.Add(addBtn, 1, wx.ALL, 10)
        editBtn = wx.Button(self, label=u"修改")
        editBtn.Bind(wx.EVT_BUTTON, self.onEdit)
        topSizer.Add(editBtn, 1, wx.ALL, 10)
        delBtn = wx.Button(self, label=u"删除")
        delBtn.Bind(wx.EVT_BUTTON, self.onDel)
        topSizer.Add(delBtn, 1, wx.ALL, 10)
        showallBtn = wx.Button(self, label=u"显示全部")
        showallBtn.Bind(wx.EVT_BUTTON, self.onShowall)
        topSizer.Add(showallBtn, 1, wx.ALL, 10)
 
        self.search = wx.SearchCtrl(self, style=wx.TE_PROCESS_ENTER)
        self.search.SetFocus()
        self.search.Bind(wx.EVT_TEXT_ENTER, self.onSearch)
        topSizer.Add(self.search, 1, wx.ALL, 10)
        self.resultOlv = ObjectListView(self,
                style=wx.LC_REPORT|wx.SUNKEN_BORDER)
        self.resultOlv.SetEmptyListMsg(u"找不到记录")
        self.setList()

        mainSizer.Add(topSizer)
        mainSizer.Add(self.resultOlv, 1, wx.ALL|wx.EXPAND, 10)
        self.SetSizer(mainSizer)

        # 弹出菜单
        self.popmenu = wx.Menu()
        item = self.popmenu.Append(-1, u"新增")
        self.Bind(wx.EVT_MENU, self.onAdd, item)
        item = self.popmenu.Append(-1, u"修改")
        self.Bind(wx.EVT_MENU, self.onEdit, item)
        item = self.popmenu.Append(-1, u"删除")
        self.Bind(wx.EVT_MENU, self.onDel, item)
        item = self.popmenu.Append(-1, u"显示全部")
        self.Bind(wx.EVT_MENU, self.onShowall, item)
        self.Bind(wx.EVT_CONTEXT_MENU, self.onShowPop)
        # 绑定双击事件
        self.resultOlv.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onEdit)
Exemplo n.º 4
0
    def __init__(self, parent):
        """Conostructor"""
        wx.Panel.__init__(self, parent)
        try:
            self.bookResults = controller.getAllRecords()
        except:
            self.bookResults = []

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        #searchSizer = wx.BoxSizer(wx.HORIZONTAL)
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
        #font = wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD)

        self.bookResultsOlv = ObjectListView(self,
                                             style=wx.LC_REPORT
                                             | wx.SUNKEN_BORDER)
        self.bookResultsOlv.SetEmptyListMsg("No Records Found")

        self.bookResultsOlv.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onEditRecord)

        self.setBooks()

        # create the button row
        addRecordBtn = wx.Button(self, label="Add")
        addRecordBtn.Bind(wx.EVT_BUTTON, self.onAddRecord)
        btnSizer.Add(addRecordBtn, 0, wx.ALL, 5)

        editRecordBtn = wx.Button(self, label="Edit")
        editRecordBtn.Bind(wx.EVT_BUTTON, self.onEditRecord)
        btnSizer.Add(editRecordBtn, 0, wx.ALL, 5)

        deleteRecordBtn = wx.Button(self, label="Delete")
        deleteRecordBtn.Bind(wx.EVT_BUTTON, self.onDelete)
        btnSizer.Add(deleteRecordBtn, 0, wx.ALL, 5)

        showAllBtn = wx.Button(self, label="Show All")
        showAllBtn.Bind(wx.EVT_BUTTON, self.onShowAllRecord)
        btnSizer.Add(showAllBtn, 0, wx.ALL, 5)

        #mainSizer.Add(searchSizer)
        mainSizer.Add(self.bookResultsOlv, 1, wx.ALL | wx.EXPAND, 5)
        mainSizer.Add(btnSizer, 0, wx.CENTER)
        self.SetSizer(mainSizer)

        self.Hide()
Exemplo n.º 5
0
 def showall(self):
     self.result = controller.getAllRecords()
     self.setList()
Exemplo n.º 6
0
 def showAllRecords(self):
     """
     Show all records in the object list view control
     """
     self.bookResults = controller.getAllRecords()
     self.setBooks()
Exemplo n.º 7
0
 def showAllRecords(self):
     """
     Show all records in the object list view control
     """
     self.bookResults = controller.getAllRecords()
     self.setBooks()