aboutsummaryrefslogtreecommitdiffstats
path: root/misc
diff options
context:
space:
mode:
Diffstat (limited to 'misc')
-rwxr-xr-xmisc/gui/wxbe110
1 files changed, 74 insertions, 36 deletions
diff --git a/misc/gui/wxbe b/misc/gui/wxbe
index 40c584d..e71ae0c 100755
--- a/misc/gui/wxbe
+++ b/misc/gui/wxbe
@@ -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()