Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 38 additions & 6 deletions FormUI/FormControl.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import wx.lib.scrolledpanel as scrolled
import wx.lib.filebrowsebutton


global gControlTypeRegister
gControlTypeRegister = {}

Expand All @@ -40,6 +39,24 @@ def SetValue(self,value):
pass
gControlTypeRegister['static'] = Static

class Image(wx.Panel, FormControlBase):
def __init__(self, item, parent, windowControl):
FormControlBase.__init__(self, item,parent)
para = FormControlUtil.makeCommonPara(item,parent)
wx.Panel.__init__(self,**para)
para['src'] = BuilderUtil.getItemValue(item, 'src')
png = wx.Image(BuilderUtil.modulePath()+os.path.sep +para['src'], wx.BITMAP_TYPE_ANY).ConvertToBitmap()
if para['size'] is None or para['size']==(0,0):
para['size'] = (png.getWidth(),png.getHeight())
wx.StaticBitmap(self, -1, png,(0,0), para['size'])

def GetValue(self):
return None

def SetValue(self,value):
pass
gControlTypeRegister['img'] = Image

class Choise(wx.Choice, FormControlBase):
def __init__(self, item, parent, windowControl):
para = FormControlUtil.makeCommonPara(item, parent)
Expand Down Expand Up @@ -193,7 +210,19 @@ def __init__(self, item, parent, windowControl):
if FormControlUtil.conventBool(value):
itemCtrl.SetValue(value)
elif len(choices) > 0:
wx.ComboBox.SetValue(self,choices[0])
wx.ComboBox.SetValue(self,"")
windowControl.registItemHandler(self, para['id'],wx.EVT_COMBOBOX,'evt_combobox')
windowControl.registItemHandler(self, para['id'],wx.EVT_TEXT,'evt_text')

# def GetValue(self):
# choices = FormControlUtil.convertList(BuilderUtil.getItemValue(self.item, 'choices', []))
# return choices[wx.ComboBox.GetSelection(self)]
#
# def SetValue(self,value):
# choices = FormControlUtil.convertList(BuilderUtil.getItemValue(self.item, 'choices', []))
# index = choices.index(value)
# if index >= 0:
# wx.ComboBox.Select(self,index)
gControlTypeRegister['combo_box'] = ComboBox

class Date(wx.DatePickerCtrl,FormControlBase):
Expand Down Expand Up @@ -336,12 +365,14 @@ def __init__(self, item, parent, windowControl):
tableList = BuilderUtil.getItemValue(item, 'data', [])
columnList = FormControlUtil.convertList(BuilderUtil.getItemValue(item, 'columns', []))
columnWidthList = FormControlUtil.convertList(BuilderUtil.getItemValue(item, 'columns_width', []))
columnList[0:0] = ['No.']
columnWidthList[0:0] = ['50']
columnIndex = 0
for column in columnList:
width = -1
if columnIndex < len(columnWidthList):
width = int(columnWidthList[columnIndex])
self.InsertColumn(columnIndex, column, width=width)
self.InsertColumn(columnIndex, column,format=wx.LIST_FORMAT_CENTRE, width=width)
columnIndex = columnIndex + 1
item['indexMap'] = {}
item['idMap'] = {}
Expand All @@ -351,9 +382,10 @@ def __init__(self, item, parent, windowControl):
item['idMap'][line['id']] = str(index)
lineItems = FormControlUtil.convertList(line['items'])
self.InsertStringItem(index, '')
self.SetStringItem(index, 0, str(line['id']))
columnIndex = 0
for lineitem in lineItems:
self.SetStringItem(index, columnIndex, lineitem)
self.SetStringItem(index, columnIndex+1, lineitem)
columnIndex = columnIndex + 1
windowControl.registItemHandler(self, para['id'],wx.EVT_LIST_ITEM_SELECTED,'evt_list_item_selected')
windowControl.registItemHandler(self, para['id'],wx.EVT_LIST_ITEM_DESELECTED,'evt_list_item_deselected')
Expand All @@ -369,7 +401,7 @@ def GetValue(self):
def SetValue(self,value):
valueList = FormControlUtil.convertList(value)
for value in valueList:
index = self.item['idMap'][str(value)]
index = self.item['idMap'][value]
wx.ListCtrl.SetItemState(self,long(index), wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED)
gControlTypeRegister['table'] = Table

Expand Down Expand Up @@ -406,4 +438,4 @@ def SetValue(self,value):
for value in valueList:
valueId = self.item['idMap'][str(value)]
wx.TreeCtrl.SelectItem(self,valueId)
gControlTypeRegister['tree'] = Tree
gControlTypeRegister['tree'] = Tree