Updated misc/gui/wxbe with wxPython -> wx changes.
authorW. Trevor King <wking@drexel.edu>
Thu, 20 Nov 2008 00:47:46 +0000 (19:47 -0500)
committerW. Trevor King <wking@drexel.edu>
Thu, 20 Nov 2008 00:47:46 +0000 (19:47 -0500)
I'd like to be able to sort the bugs by clicking on the various column
titles, but I don't know enough about wxPython to pull it off.  After
wrestling with it for a bit, I realized that I'll only be using the
command line interface anyway, and other people can use the web
interface.  Probably a common feeling, which would explain why the
GUIs feel so abandoned ;).

At any rate, I think the effects of turning the RCSs into classes have
been passed through and stabilized, so my churning should decrease...

.be/bugs/c4ea43d5-4964-49ea-a1eb-2bab2bde8e2e/comments/acbecd72-988c-4899-a340-fea370ce15a8/body [new file with mode: 0644]
.be/bugs/c4ea43d5-4964-49ea-a1eb-2bab2bde8e2e/comments/acbecd72-988c-4899-a340-fea370ce15a8/values [new file with mode: 0644]
.be/bugs/c4ea43d5-4964-49ea-a1eb-2bab2bde8e2e/values
misc/gui/wxbe

diff --git a/.be/bugs/c4ea43d5-4964-49ea-a1eb-2bab2bde8e2e/comments/acbecd72-988c-4899-a340-fea370ce15a8/body b/.be/bugs/c4ea43d5-4964-49ea-a1eb-2bab2bde8e2e/comments/acbecd72-988c-4899-a340-fea370ce15a8/body
new file mode 100644 (file)
index 0000000..cf9af30
--- /dev/null
@@ -0,0 +1,5 @@
+I rewrote test.py, so I suppose I'm the person who understands it
+better now ;).  The usage is now documented in the test.py lead
+comment.  The becommand tests now attempt to run with the first
+*installed* versioning system, which should reduce cryptic errors.
+
diff --git a/.be/bugs/c4ea43d5-4964-49ea-a1eb-2bab2bde8e2e/comments/acbecd72-988c-4899-a340-fea370ce15a8/values b/.be/bugs/c4ea43d5-4964-49ea-a1eb-2bab2bde8e2e/comments/acbecd72-988c-4899-a340-fea370ce15a8/values
new file mode 100644 (file)
index 0000000..9b72e2c
--- /dev/null
@@ -0,0 +1,21 @@
+
+
+
+Content-type=text/plain
+
+
+
+
+
+
+Date=Wed, 19 Nov 2008 17:11:51 +0000
+
+
+
+
+
+
+From=W. Trevor King <wking@drexel.edu>
+
+
+
index 5ecca358cb58a8b84c24f490e438c293e147269d..483916d65d7bce3d1b2ab6976f71a1f71d7e2f84 100644 (file)
@@ -15,7 +15,7 @@ severity=minor
 
 
 
-status=open
+status=fixed
 
 
 
index 40c584d11e6cd61f1f8eb005041f1177935862af..e71ae0c962fc43290ef5311fbb6e950bceae79d8 100755 (executable)
@@ -1,49 +1,87 @@
 #!/usr/bin/env python
-from wxPython.wx import *
-from wxPython.lib.mixins.listctrl import wxListCtrlAutoWidthMixin
+import wx
+from wx.lib.mixins.listctrl import ListCtrlAutoWidthMixin
 import sys, os.path
-sys.path.append(os.path.realpath(os.path.join".."))
-from libbe import bugdir
+from libbe import bugdir, names
+from libbe.bug import cmp_status, cmp_severity, cmp_time, cmp_full
 
-class MyApp(wxApp):
+class MyApp(wx.App):
     def OnInit(self):
-        frame = wxFrame(NULL, -1, "Bug display")
-        frame.Show(true)
+        frame = BugListFrame(None, title="Bug List")
+        frame.Show(True)
         self.SetTopWindow(frame)
-        panel = wxPanel(frame, -1, style=(wxVSCROLL | wxHSCROLL))
-        panel.SetSize((500, 400))
-        sizer = wxBoxSizer(wxVERTICAL)
-        sizer.Add(panel, wxGROW)
-        frame.SetSizer(sizer)
-        bugs = BugList(panel)
-        bugs.SetSize((400, -1))
-#        bugs.SetDimensions(-1, -1, -1, -1)
-        sizer = wxBoxSizer(wxVERTICAL)
-        sizer.Add(bugs, wxGROW)
-        frame.SetSizer(sizer)
-        return true
-
-class BugList(wxListCtrl, wxListCtrlAutoWidthMixin):
+        return True
+
+class BugListFrame(wx.Frame):
+    def __init__(self, *args, **kwargs):
+        wx.Frame.__init__(self, *args, **kwargs)
+        bugs = BugList(self)
+
+        # Widgets to display/sort/edit will go in this panel
+        # for now it is just a placeholder
+        panel = wx.Panel(self)
+        panel.SetBackgroundColour("RED")
+
+        vbox = wx.BoxSizer(wx.VERTICAL)
+        vbox.Add(panel, 0, wx.EXPAND)
+        vbox.Add(bugs, 1, wx.EXPAND)
+        
+        self.SetAutoLayout(True)
+        self.SetSizer(vbox)
+        self.Layout()
+
+class BugList(wx.ListCtrl, ListCtrlAutoWidthMixin):
     def __init__(self, parent):
-        wxListCtrl.__init__(self, parent, -1, 
-                            style = wxLC_REPORT|wxLC_VRULES|wxLC_HRULES)
-        wxListCtrlAutoWidthMixin.__init__(self)
-        columns = ("Severity", "Creator", "Summary")
-        for x in range(len(columns)):
-            self.InsertColumn(x, columns[x])
-            self.SetColumnWidth(x, wxLIST_AUTOSIZE_USEHEADER)
-        for bug in [b for b in bugdir.tree_root(".").list() if b.active]:
-            id = self.InsertStringItem(self.GetItemCount(), bug.severity)
-            self.SetStringItem(id, 1, bug.creator)
-            self.SetStringItem(id, 2, bug.summary)
+        wx.ListCtrl.__init__(self, parent,
+                             style=wx.LC_REPORT)
+        ListCtrlAutoWidthMixin.__init__(self)
+
+        self.bugdir = bugdir.tree_root(".")
+        self.buglist = list(self.bugdir.list())
+        self.buglist.sort()
+        self.columns = ("id", "status", "severity", "summary")
+
+        dataIndex = 0
+        for x in range(len(self.columns)):
+            self.InsertColumn(x, self.columns[x].capitalize())
+            self.SetColumnWidth(x, wx.LIST_AUTOSIZE_USEHEADER)
+        for bug in [b for b in self.buglist if b.active]:
+            name = names.unique_name(bug, self.buglist)
+            id = self.InsertStringItem(self.GetItemCount(), name)
+            self.SetStringItem(id, 1, bug.status)
+            self.SetStringItem(id, 2, bug.severity)
+            self.SetStringItem(id, 3, bug.summary)
+            self.SetItemData(id, dataIndex) # set keys for each line
+            dataIndex += 1
             self.EnsureVisible(id)
-        for x in range(len(columns)):
-            self.SetColumnWidth(x, wxLIST_AUTOSIZE)
+        for x in range(len(self.columns)):
+            self.SetColumnWidth(x, wx.LIST_AUTOSIZE)
             conts_width = self.GetColumnWidth(x)
-            self.SetColumnWidth(x, wxLIST_AUTOSIZE_USEHEADER)
+            self.SetColumnWidth(x, wx.LIST_AUTOSIZE_USEHEADER)
             if conts_width > self.GetColumnWidth(x):
                 self.SetColumnWidth(x, conts_width)
 
+        self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColumnClick)
+        self.bugcmp_fn = cmp_full
+        # For reasons I don't understant, sorting is broken...
+        #self.SortItems(self.Sorter)
+        #self.Refresh()
+    def Sorter(self, key1, key2):
+        """Get bug info from the keys and pass to self.bugcmp_fn"""
+        bug1 = self.buglist[key1-1]
+        bug2 = self.buglist[key2-1]
+        # Another way of getting bug information
+        #bug1uuid = self.GetItem(key1, 0).GetText()
+        #bug2uuid = self.GetItem(key2, 0).GetText()
+        #print bug1uuid, bug2uuid
+        #bug1 = self.bugdir.get_bug(bug1uuid)
+        #bug2 = self.bugdir.get_bug(bug1uuid)
+        print self.bugcmp_fn(bug1,bug2)
+        return self.bugcmp_fn(bug1,bug2)
+    def OnColumnClick(self, event):
+        """Resort bug list depending on which column was clicked"""
+        print "TODO: sort by column %d" % event.Column
+        # change self.bugcmp_fn and resort, but I can't get it working
 
-app = MyApp(0)
+app = MyApp()
 app.MainLoop()