ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/MCP/Trunk/EditVendorFolderDialog.py
Revision: 270
Committed: Tue Feb 5 18:47:16 2013 UTC (13 years, 1 month ago) by nino.borges
Content type: text/x-python
Original Path: Python/NinoCode/Active_prgs/MCP/EditVendorFolderDialog.py
File size: 4131 byte(s)
Log Message:
Added the vendor folder dialog file

File Contents

# User Rev Content
1 nino.borges 270 """
2    
3     EditVendorFolderDialog
4    
5     Created by
6     Emanuel Borges
7     02.04.2013
8    
9     This dialog will let you attach, remove and edit vendor folders in the case.
10    
11     """
12    
13    
14     import wx, os
15    
16     class EditVendorFolderDialog(wx.Dialog):
17     def __init__(self, parent,casePath):
18     #self.CLM = CLM
19     self.parent = parent
20     wx.Dialog.__init__(self, parent, -1, "Add and Edit Vendor Folders", style = wx.DEFAULT_DIALOG_STYLE, size = (450,390))
21    
22     mainSizer = wx.BoxSizer(wx.VERTICAL)
23    
24     vendorListStaticBox = wx.StaticBox(self, -1, 'Right click to add and delete tags:')
25     vendorListStaticBoxSizer = wx.StaticBoxSizer(vendorListStaticBox, wx.VERTICAL)
26     self.vendorListBox = wx.ListCtrl(self,-1, style=wx.LC_REPORT|wx.LC_HRULES|wx.LC_NO_HEADER|wx.LC_EDIT_LABELS)
27     self.vendorListBox.InsertColumn(0, 'Vendor Folders', format=wx.LIST_FORMAT_LEFT, width=200)
28     vendorListStaticBoxSizer.Add(self.vendorListBox, 0, wx.EXPAND|wx.LEFT|wx.TOP|wx.RIGHT, 10)
29     addButton = wx.Button(self, -1, "+", size=(30,20), style=wx.NO_BORDER)
30     minusButton = wx.Button(self, -1, "-", size=(30,20), style=wx.NO_BORDER)
31     addRemoveButtonSizer = wx.BoxSizer(wx.HORIZONTAL)
32     addRemoveButtonSizer.Add(addButton, 0, wx.LEFT,3)
33     addRemoveButtonSizer.Add(minusButton, 0, wx.LEFT,0)
34     vendorListStaticBoxSizer.Add(addRemoveButtonSizer, 0, wx.LEFT,10)
35    
36     mainSizer.Add(vendorListStaticBoxSizer, 0, wx.EXPAND|wx.ALL, 20)
37    
38     oKButton = wx.Button(self, wx.ID_OK)
39     oKButton.SetDefault()
40     cancelButton = wx.Button(self, wx.ID_CANCEL)
41     buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
42     buttonSizer.Add(oKButton,0,wx.ALL,5)
43     buttonSizer.Add(cancelButton,0,wx.ALL,5)
44     mainSizer.Add(buttonSizer, 0, wx.ALIGN_CENTER|wx.ALL, 15)
45     self.SetSizer(mainSizer)
46    
47     self.Bind(wx.EVT_BUTTON, self.OnPopupOne, addButton)
48     self.Bind(wx.EVT_BUTTON, self.OnPopupTwo, minusButton)
49    
50     self.vendorListBox.Bind(wx.EVT_COMMAND_RIGHT_CLICK, self.OnRightClick)
51     self.vendorListBox.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)
52     self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected)
53    
54     def OnItemSelected(self, event):
55     ##print event.GetItem().GetTextColour()
56     self.currentItem = event.m_itemIndex
57     #print self.currentItem
58     #print self.tagListBox.GetItemCount()
59    
60     def OnRightDown(self, event):
61     x = event.GetX()
62     y = event.GetY()
63     #self.log.WriteText("x, y = %s\n" % str((x, y)))
64     item, flags = self.vendorListBox.HitTest((x, y))
65    
66     if item != wx.NOT_FOUND and flags & wx.LIST_HITTEST_ONITEM:
67     self.vendorListBox.Select(item)
68    
69     event.Skip()
70    
71     def OnRightClick(self, event):
72     #self.log.WriteText("OnRightClick %s\n" % self.list.GetItemText(self.currentItem))
73    
74     # only do this part the first time so the events are only bound once
75     if not hasattr(self, "popupID1"):
76     self.popupID1 = wx.NewId()
77     self.popupID2 = wx.NewId()
78    
79    
80     self.Bind(wx.EVT_MENU, self.OnPopupOne, id=self.popupID1)
81     self.Bind(wx.EVT_MENU, self.OnPopupTwo, id=self.popupID2)
82    
83    
84     # make a menu
85     menu = wx.Menu()
86     # add some items
87     menu.Append(self.popupID1, "Add New Vendor Folder")
88     menu.Append(self.popupID2, "Remove Selected Vendor Folder")
89    
90     # Popup the menu. If an item is selected then its handler
91     # will be called before PopupMenu returns.
92     self.PopupMenu(menu)
93     menu.Destroy()
94    
95    
96     def OnPopupOne(self, event):
97     nextIndexNumb = self.tagListBox.GetItemCount()
98     self.tagListBox.InsertStringItem(nextIndexNumb,"Reviewer_%s"% str(nextIndexNumb+1))
99     self.tagListBox.SetItemState(nextIndexNumb, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED)
100     #print "one"
101    
102     def OnPopupTwo(self, event):
103     self.tagListBox.DeleteItem(self.currentItem)