MCPcopy Create free account
hub / github.com/Image-Py/imagepy / GridDialog

Class GridDialog

imagepy/ui/propertygrid.py:16–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14key = {'Sample_ID': ['str', 'Sample_ID', '5', "image's name"], 'Operator_Name': ['str', 'Operator_Name', None, 'your name'], 'Date': ['date', 'Date', None, 'today'], 'Original_Image': ['img', 'Original_Image', '[8.16,5.76,0.9,0]', 'the original image'], 'Mask_Image': ['img', 'Mask_Image', '[8.16,5.76,0.9,0]', ''], 'Record': ['tab', 'Record', '[1,3,0,0]', 'records']}
15
16class GridDialog( wx.Dialog ):
17
18 def __init__( self, parent, title, tree, key):
19 wx.Dialog.__init__ (self, parent, -1, title, style = wx.DEFAULT_DIALOG_STYLE, size = wx.Size((300, 480)))
20 # wx.Panel.__init__(self, parent, wx.ID_ANY)
21
22 self.panel = panel = wx.Panel(self, wx.ID_ANY)
23 topsizer = wx.BoxSizer(wx.VERTICAL)
24
25 # Difference between using PropertyGridManager vs PropertyGrid is that
26 # the manager supports multiple pages and a description box.
27 self.pg = pg = wxpg.PropertyGridManager(panel,
28 style=wxpg.PG_SPLITTER_AUTO_CENTER)
29
30 # Show help as tooltips
31 pg.SetExtraStyle(wxpg.PG_EX_HELP_AS_TOOLTIPS)
32
33 pg.Bind( wxpg.EVT_PG_CHANGED, self.OnPropGridChange )
34 pg.Bind( wxpg.EVT_PG_SELECTED, self.OnPropGridSelect )
35
36 pg.AddPage('Page 1')
37 self.key = key
38 for page in tree:
39 pg.Append(wxpg.PropertyCategory(page[0]))
40 for item in page[1]:
41 v = item[1]
42 if v[0] == 'int': pg.Append( wxpg.IntProperty(v[1], value=int(v[2]) or 0))
43 if v[0] == 'float': pg.Append( wxpg.FloatProperty(v[1], value=float(v[2]) or 0))
44 if v[0] == 'str': pg.Append( wxpg.StringProperty(v[1], value=v[2] or ''))
45 if v[0] == 'txt': pg.Append( wxpg.LongStringProperty(v[1], value=v[2] or ''))
46 if v[0] == 'bool': pg.Append( wxpg.BoolProperty(v[1]))
47 if v[0] == 'date': pg.Append( wxpg.DateProperty(v[1], value=wx.DateTime.Now()))
48 if v[0] == 'list': pg.Append( wxpg.EnumProperty(v[1], v[1], [i.strip() for i in v[2][1:-1].split(',')]))
49 if v[0] == 'img': pg.Append( wxpg.EnumProperty(v[1], v[1], ImageManager.get_titles()))
50 if v[0] == 'tab': pg.Append( wxpg.EnumProperty(v[1], v[1], TableManager.get_titles()))
51
52 topsizer.Add(pg, 1, wx.EXPAND)
53 self.txt_info = wx.TextCtrl( self, wx.ID_ANY, 'information', wx.DefaultPosition, wx.Size(80, 80), wx.TE_MULTILINE|wx.TRANSPARENT_WINDOW )
54 topsizer.Add(self.txt_info, 0, wx.EXPAND|wx.ALL, 0)
55 rowsizer = wx.BoxSizer(wx.HORIZONTAL)
56 but = wx.Button(panel, wx.ID_OK, "OK")
57 rowsizer.Add(but,1)
58 #but.Bind( wx.EVT_BUTTON, self.OnGetPropertyValues )
59 but = wx.Button(panel, wx.ID_CANCEL,"Cancel")
60 rowsizer.Add(but,1)
61 topsizer.Add(rowsizer,0,wx.EXPAND)
62
63 panel.SetSizer(topsizer)
64 topsizer.SetSizeHints(panel)
65
66 sizer = wx.BoxSizer(wx.VERTICAL)
67 sizer.Add(panel, 1, wx.EXPAND)
68 self.SetSizer(sizer)
69 self.SetAutoLayout(True)
70
71 def GetValue(self):
72 return self.pg.GetPropertyValues(as_strings=True)
73

Callers 2

startMethod · 0.90
propertygrid.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected