Changeset 399
- Timestamp:
- Sat May 17 13:33:16 2008
- Files:
-
- ganttpv/trunk/Menu.py (modified) (diff)
- ganttpv/trunk/GanttReport.py (modified) (diff)
- ganttpv/trunk/ReportAids.py (modified) (diff)
- ganttpv/trunk/UI.py (modified) (diff)
- ganttpv/trunk/GanttPV.py (modified) (diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ganttpv/trunk/Menu.py
r396 r399 147 147 148 148 if debug: print "Continue doExit" 149 Data.SaveOption() 149 150 Data.CloseReports() 150 151 Data.CloseReport(1) -
ganttpv/trunk/GanttReport.py
r397 r399 94 94 # 080516 - Alexander - added search box to assignment dialog 95 95 # 080516 - Brian - added actual and baseline plan bars 96 # 080517 - Alex - sorted the insert column list 96 97 97 98 import wx, wx.grid 98 99 import datetime 99 100 from wx.lib.dialogs import MultipleChoiceDialog as wxMultipleChoiceDialog 100 import Data, UI, ID, Menu 101 import Data, UI, ID, Menu, ReportAids 100 101 # import images 101 102 import re … … 802 803 #------------------ MultiSelect Frame ----------------------------------- 803 804 804 class MultiSelection(UI.MultipleSelection): 805 class SearchSelection(UI.MultipleSelection): 806 # should this be merged into the parent class in UI? 807 805 808 def __init__(self, *args, **kwds): 806 809 # begin wxGlade: ReportFrame.__init__ … … 809 812 self.selections = {} 810 813 811 wx.EVT_BUTTON(self, self.OK.GetId(), self.onOK)812 wx.EVT_BUTTON(self, self.Cancel.GetId(), self.onCancel)813 814 wx.EVT_TEXT(self, self.Search.GetId(), self.onSearch) 814 815 wx.EVT_CHAR(self.Search, self.onChar) 815 816 wx.EVT_CHAR(self.SelectionListBox, self.onChar) 816 817 818 ReportAids.RegisterSize(self, "SearchSelection") 819 820 def GetValue(self): 821 self.Search.SetValue("") 822 return self.SelectionListBox.GetSelections() 823 824 def onSearch(self, event): 825 # get the visible selection set 826 choices = self.SelectionListBox.GetStrings() 827 sel_numbers = self.SelectionListBox.GetSelections() 828 selections = dict.fromkeys([choices[n] for n in sel_numbers]) 829 830 # update the full selection set (includes invisible selections) 831 for choice in choices: 832 if choice in selections: 833 self.selections[choice] = None 834 elif choice in self.selections: 835 del self.selections[choice] 836 837 # save the original list of choices 838 if not self.choices: 839 self.choices = choices 840 841 # limit the visible choices to those that match the search 842 search = self.Search.GetValue() 843 if search == "=": 844 choices = [x for x in self.choices if x in self.selections] 845 else: 846 choices = [x for x in self.choices if re.search(search, x, re.I)] 847 self.SelectionListBox.Set(choices) 848 for i, choice in enumerate(choices): 849 if choice in self.selections: 850 self.SelectionListBox.Select(i) 851 852 def onChar(self, event): 853 if event.GetKeyCode() == wx.WXK_ESCAPE: 854 self.Search.SetValue("") 855 self.Search.SetFocus() 856 event.Skip() 857 858 class MultiSelection(SearchSelection): 859 # better name might be "LinkTableSelection" 860 # or we could transfer the functionality of this class somewhere else 861 862 def __init__(self, *args, **kwds): 863 # begin wxGlade: ReportFrame.__init__ 864 SearchSelection.__init__(self, *args, **kwds) 865 wx.EVT_BUTTON(self, wx.ID_OK, self.onOK) 866 817 867 # ID == ID of this record 818 868 # TargetIDs == IDs of candidate target records … … 881 931 882 932 Data.SetUndo(self.Message) 883 self.Destroy()884 885 def onCancel(self, event):886 self.Destroy()887 888 def onSearch(self, event):889 # get the visible selection set890 choices = self.SelectionListBox.GetStrings()891 sel_numbers = self.SelectionListBox.GetSelections()892 selections = dict.fromkeys([choices[n] for n in sel_numbers])893 894 # update the full selection set (includes invisible selections)895 for choice in choices:896 if choice in selections:897 self.selections[choice] = None898 elif choice in self.selections:899 del self.selections[choice]900 901 # save the original list of choices902 if not self.choices:903 self.choices = choices904 905 # limit the visible choices to those that match the search906 search = self.Search.GetValue()907 if search == "=":908 choices = [x for x in self.choices if x in self.selections]909 else:910 choices = [x for x in self.choices if re.search(search, x, re.I)]911 self.SelectionListBox.Set(choices)912 for i, choice in enumerate(choices):913 if choice in self.selections:914 self.SelectionListBox.Select(i)915 916 def onChar(self, event):917 if event.GetKeyCode() == wx.WXK_ESCAPE:918 self.Search.SetValue("")919 self.Search.SetFocus()920 933 event.Skip() 921 934 935 922 936 #------------------ Gantt Report Frame ----------------------------------- 923 937 … … 1458 1472 status[i] = -k 1459 1473 1460 dialog = MultiSelection(self, -1, "", size=(240,320)) 1474 dialog = MultiSelection(self, -1, "Assign Prerequisite", size=(240,320)) 1460 1474 dialog.Instructions.SetLabel("Select prerequisite tasks:") 1461 1475 # dialog.SelectionListBox.Clear() … … 1524 1538 status[i] = -k 1525 1539 1526 dialog = MultiSelection(self, -1, "", size=(240,320)) 1540 dialog = MultiSelection(self, -1, "Resource Grouping", size=(240,320)) 1526 1540 dialog.Instructions.SetLabel(prompt) 1527 1541 # dialog.SelectionListBox.Clear() … … 1597 1611 status = [assigns.get(id, 0) for id in ids] 1598 1612 1599 dialog = MultiSelection(self, -1, "", size=(240,320)) 1613 dialog = MultiSelection(self, -1, "Assign Resource", size=(240,320)) 1599 1613 dialog.Instructions.SetLabel(dialogPrompt) 1600 1614 # dialog.SelectionListBox.Clear() … … 1658 1672 if '\n' in v: 1659 1673 menutext[i] = v.replace('\n', ' ') 1674 menuT = [ Data.ColumnType[x].get('T') for x in menuid ] 1675 1676 # sort menu 1677 menus = zip(menuT, menutext, menuid) 1678 menus.sort() 1679 menuT, menutext, menuid = zip(*menus) 1660 1680 if debug: print menuid, menutext 1661 dlg = wxMultipleChoiceDialog(self, 1662 "Select columns to add:", 1663 "New Columns", menutext, style=wx.DEFAULT_FRAME_STYLE, size=(240, 320)) 1681 1682 dlg = SearchSelection(self, -1, "New Columns", size=(240, 320)) 1683 dlg.Instructions.SetLabel("Select columns to add:") 1684 dlg.SelectionListBox.Set(menutext) 1685 # dlg = wxMultipleChoiceDialog(self, "Select columns to add:", "New Columns", menutext, style=wx.DEFAULT_FRAME_STYLE, size=(240, 320)) 1664 1686 dlg.Centre() 1665 1687 if (dlg.ShowModal() != wx.ID_OK): return -
ganttpv/trunk/ReportAids.py
r271 r399 23 23 # 060325 - Alex - moved logic for main window title into RefreshReports 24 24 # 060606 - Alex - added hint method; preserved window order 25 # 080517 - Alex - added RegisterSizePos 25 26 26 27 # import datetime, calendar … … 44 45 This dictionary should be passed to any scripts run with execfile. 45 46 """ 46 import Data, GanttPV, GanttReport, ID, Menu, UI, wx 47 import Data, GanttPV, GanttReport, ID, Menu, ReportAids, UI, wx 46 47 return locals() 47 48 … … 252 253 Data.Hint = Hint 253 254 255 def RegisterSize(frame, name): 256 sizeName = "FrameSize_" + name 257 if sizeName in Data.Option: 258 size = Data.Option[sizeName] 259 frame.SetSize(size) 260 261 def OnSize(event): 262 Data.Option[sizeName] = event.GetSize() 263 event.Skip() 264 265 wx.EVT_SIZE(frame, OnSize) 266 267 def RegisterPos(frame, name): 268 posName = "FramePos_" + name 269 if posName in Data.Option: 270 pos = Data.Option[posName] 271 frame.SetPosition(pos) 272 273 def OnMove(event): 274 pos = event.GetPosition() 275 if pos.x > 0 and pos.y > 0: 276 if Data.platform == "win": 277 Data.Option[posName] = (pos.x - 4, pos.y - 50) 278 else: 279 Data.Option[posName] = pos 280 event.Skip() 281 282 wx.EVT_MOVE(frame, OnMove) 283 284 def RegisterSizePos(frame, name): 285 RegisterSize(frame, name) 286 RegisterPos(frame, name) 287 288 def ClearRegistry(): 289 for key in Data.Option.keys(): 290 for prefix in ["FrameSize_", "FramePos_"]: 291 if key.startswith(prefix): 292 del Data.Option[key] 293 254 294 if debug: print "end ReportAids.py" -
ganttpv/trunk/UI.py
r395 r399 554 554 kwds["style"] = wx.DEFAULT_FRAME_STYLE 555 555 wx.Dialog.__init__(self, *args, **kwds) 556 self.Instructions = wx.StaticText(self, -1, _("Make selection\n")) 557 self.SelectionListBox = wx.ListBox(self, -1, choices=[_("choice 1"), _("choice 2")], style=wx.LB_MULTIPLE) 556 self.Instructions = wx.StaticText(self, -1, _("Make selection:")) 557 self.SelectionListBox = wx.ListBox(self, -1, choices=[], style=wx.LB_MULTIPLE) 558 558 self.SearchLabel = wx.StaticText(self, -1, _("Search:\n")) 559 559 self.Search = wx.TextCtrl(self, -1) 560 self.OK = wx.Button(self, -1, _("OK")) 561 self.Cancel = wx.Button(self, -1, _("Cancel")) 560 self.OK = wx.Button(self, wx.ID_OK, _("OK")) 561 self.Cancel = wx.Button(self, wx.ID_CANCEL, _("Cancel")) 562 562 563 563 self.__set_properties() … … 567 567 def __set_properties(self): 568 568 # begin wxGlade: MultipleSelection.__set_properties 569 self.SetTitle(_("Selection")) 569 # self.SetTitle(_("Selection")) 569 569 # self.SelectionListBox.SetMinSize((295, 200)) 570 self.SelectionListBox.SetSelection(0) 570 # self.SelectionListBox.SetSelection(0) 570 570 self.OK.SetDefault() 571 self.Search.SetFocus() 571 572 # end wxGlade 572 573 -
ganttpv/trunk/GanttPV.py
r394 r399 345 345 names = [(rt.get('Label') or rt.get('Name') or '') for rt in types] 346 346 menutext = [s.replace('\n', ' ') for s in names] 347 348 # sort menu 349 # menus = zip(menutext, menuid) 350 # menus.sort() 351 # menutext, menuid = zip(*menus) 347 352 if debug: print menuid, menutext 348 353 354 # dlg = GanttReport.SearchSelection(self, -1, "New Report", size=(240, 320)) 355 # dlg.Instructions.SetLabel("Select reports to add:") 356 # dlg.SelectionListBox.Set(menutext) 349 357 dlg = wxMultipleChoiceDialog(self, "Select reports to add:", "New Report", menutext) 350 358 dlg.SetSize((240,320))
