def addInsertRow(self, strIndex): rowList = [] funcLayout = SBoxLayout(size_hint=(.15, None), height=30) funcLayout.orientation = "horizontal" funcLayout.padding = (1, 1, 1, 1) funcLayout.add_widget(BoxLayout(size_hint=(.1, 1))) btn = SButton(text="新增", size_hint=(.8, 1)) btn.halign = "center" btn.valign = "middle" btn.bind(on_release=self.addRecordPopup) funcLayout.add_widget(btn) funcLayout.add_widget(BoxLayout(size_hint=(.1, 1))) rowList.append(funcLayout) self.contentLayout.add_widget(funcLayout) contentLabel = SContentLabel(text="", size_hint=(.4, None), height=30) contentLabel.halign = "left" contentLabel.valign = "middle" rowList.append(contentLabel) self.contentLayout.add_widget(contentLabel) contentLabel = SContentLabel(text="", size_hint=(.25, None), height=30) contentLabel.halign = "right" contentLabel.valign = "middle" rowList.append(contentLabel) self.contentLayout.add_widget(contentLabel) contentLabel = SContentLabel(text="", size_hint=(.2, None), height=30) contentLabel.halign = "right" contentLabel.valign = "middle" rowList.append(contentLabel) self.contentLayout.add_widget(contentLabel) self.def_ids[int(strIndex)] = rowList
def addListRow(self, alist): rowList = [] funcLayout = SBoxLayout(size_hint=(.15, None), height=30) funcLayout.orientation = "horizontal" funcLayout.padding = (1, 1, 1, 1) funcLayout.add_widget(BoxLayout(size_hint=(.1, 1))) btn = SInfoButton(extra_info=alist[0], text="刪", size_hint=(.8, 1)) btn.halign = "center" btn.valign = "middle" btn.bind(on_release=self.deleteRecordPopup) funcLayout.add_widget(btn) funcLayout.add_widget(BoxLayout(size_hint=(.1, 1))) rowList.append(funcLayout) self.contentLayout.add_widget(funcLayout) contentLabel = SContentLabel(text=alist[0][2:], size_hint=(.2, None), height=30) contentLabel.color = colorHex("#000000") contentLabel.halign = "center" contentLabel.valign = "middle" rowList.append(contentLabel) self.contentLayout.add_widget(contentLabel) contentLabel = SContentLabel(text=alist[1], size_hint=(.65, None), height=30) contentLabel.color = colorHex("#000000") contentLabel.halign = "left" contentLabel.valign = "middle" rowList.append(contentLabel) self.contentLayout.add_widget(contentLabel) self.def_ids[alist[0]] = rowList
def _addContentData(self): self.gridLayout.clear_widgets() startIdx = (self.page_num - 1) * NUM_PER_PAGE endIdx = self.page_num * NUM_PER_PAGE if endIdx > len(self.resultIdNameList): endIdx = len(self.resultIdNameList) idNameList = None refParam = None for aIdx in range(startIdx, endIdx): idNameList = self.resultIdNameList[aIdx] funcLayout = SBoxLayout(size_hint=(.15, None), height=30) funcLayout.orientation = "horizontal" funcLayout.padding = (1, 1, 1, 1) funcLayout.add_widget(BoxLayout(size_hint=(.1, 1))) refParam = {} refParam["idNameList"] = idNameList acbObj = SCheckBox(refParam) acbObj.size_hint = (1, 1) if idNameList[0] in self.selectDict: acbObj.active = True else: acbObj.active = False acbObj.bind(active=self._on_checkbox_active) funcLayout.add_widget(acbObj) funcLayout.add_widget(BoxLayout(size_hint=(.1, 1))) self.gridLayout.add_widget(funcLayout) contentLabel = SContentLabel(text=idNameList[0][2:], size_hint=(.2, None), height=30) contentLabel.color = colorHex("#000000") contentLabel.halign = "center" contentLabel.valign = "middle" self.gridLayout.add_widget(contentLabel) contentLabel = SContentLabel(text=idNameList[1], size_hint=(.65, None), height=30) contentLabel.color = colorHex("#000000") contentLabel.halign = "left" contentLabel.valign = "middle" self.gridLayout.add_widget(contentLabel)
def addListRow(self, alist, aflag): if aflag: self.deleteRow(self.maxIndex) rowList = [] funcLayout = SBoxLayout(size_hint=(.15, None), height=30) funcLayout.orientation = "horizontal" funcLayout.padding = (1, 1, 1, 1) funcLayout.add_widget(BoxLayout(size_hint=(.09, 1))) btn = SInfoButton(extra_info=self.maxIndex, text="修", size_hint=(.4, 1)) btn.halign = "center" btn.valign = "middle" btn.bind(on_release=self.updateRecordPopup) funcLayout.add_widget(btn) funcLayout.add_widget(BoxLayout(size_hint=(.02, 1))) btn = SInfoButton(extra_info=self.maxIndex, text="刪", size_hint=(.4, 1)) btn.halign = "center" btn.valign = "middle" btn.bind(on_release=self.deleteRecordPopup) if alist[0] == "證券普通股" or alist[0] == "台指期貨": btn.disabled = True funcLayout.add_widget(btn) funcLayout.add_widget(BoxLayout(size_hint=(.09, 1))) rowList.append(funcLayout) self.contentLayout.add_widget(funcLayout) contentLabel = SContentLabel(text=alist[0], size_hint=(.4, None), height=30) contentLabel.color = colorHex("#000000") contentLabel.halign = "left" contentLabel.valign = "middle" rowList.append(contentLabel) self.contentLayout.add_widget(contentLabel) contentLabel = SContentLabel(text=alist[1], size_hint=(.25, None), height=30) contentLabel.color = colorHex("#000000") contentLabel.halign = "right" contentLabel.valign = "middle" rowList.append(contentLabel) self.contentLayout.add_widget(contentLabel) contentLabel = SContentLabel(text=alist[2], size_hint=(.2, None), height=30) contentLabel.color = colorHex("#000000") contentLabel.halign = "right" contentLabel.valign = "middle" rowList.append(contentLabel) self.contentLayout.add_widget(contentLabel) self.def_ids[self.maxIndex] = rowList
def __init__(self, paramDict, **kwargs): super(SelfStkSetting, self).__init__(**kwargs) self.paramDict = paramDict self.app = self.paramDict.get(CONSTS.S_APP) self.selfgroup_index = self.paramDict.get("SelfGroupIndex") self.selfgroup_name = self.paramDict.get("SelfGroupName") self.selfStkList = self.paramDict.get("SelfStkList") self.size_hint = (1, 1) self.orientation = "vertical" self.add_widget(STableBoxLayout(size_hint=(1, None), height=1)) nameLayout = SBoxLayout(size_hint=(1, None), height=30) nameLayout.orientation = "horizontal" nameLayout.add_widget(STableBoxLayout(size_hint=(.02, 1))) nameLabel = SLabel(text="名稱:", size_hint=(.15, 1)) nameLabel.color = colorHex("#000000") nameLayout.add_widget(nameLabel) self.selfgroup_name_id = STextInput(text=self.selfgroup_name, size_hint=(.65, 1)) nameLayout.add_widget(self.selfgroup_name_id) nameLayout.add_widget(STableBoxLayout(size_hint=(.23, 1))) self.add_widget(nameLayout) self.add_widget(STableBoxLayout(size_hint=(1, None), height=1)) headLayout = STableGridLayout(cols=3, rows=1, spacing=2, size_hint=(1, None), height=30) headLabel = SHeadLabel(text="功能", size_hint=(.15, 1)) headLabel.halign: 'center' headLabel.valign: 'middle' headLayout.add_widget(headLabel) headLabel = SHeadLabel(text="代碼", size_hint=(.2, 1)) headLabel.halign: 'center' headLabel.valign: 'middle' headLayout.add_widget(headLabel) headLabel = SHeadLabel(text="名稱", size_hint=(.65, 1)) headLabel.halign: 'center' headLabel.valign: 'middle' headLayout.add_widget(headLabel) self.add_widget(headLayout) self.add_widget(STableBoxLayout(size_hint=(1, None), height=2)) self.def_ids = {} slview = STableScrollView() slview.size_hint = (1, None) slview.size = (360, 320) self.contentLayout = STableGridLayout(cols=3, spacing=2, size_hint_y=None) # Make sure the height is such that there is something to scroll. self.contentLayout.bind( minimum_height=self.contentLayout.setter('height')) tmpList = None stkName = None for stkId in self.selfStkList: tmpList = [] tmpList.append(stkId) stkName = self.app.stkNameDict.get(stkId) if stkName == None: tmpList.append("") else: tmpList.append(stkName) self.addListRow(tmpList) self.addInsertRow() slview.add_widget(self.contentLayout) self.add_widget(slview) bottomLayout = BoxLayout(size_hint=(1, None), height=30) self.ensurebtn_id = SButton(text="確定", size_hint=(.49, 1)) bottomLayout.add_widget(self.ensurebtn_id) bottomLayout.add_widget(BoxLayout(size_hint=(.02, 1))) self.cancelbtn_id = SButton(text="取消", size_hint=(.49, 1)) bottomLayout.add_widget(self.cancelbtn_id) self.add_widget(bottomLayout)