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 addInsertRow(self, strIndex): rowList = [] funcLayout = SBoxLayout(size_hint=(.25, 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=(.5, 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 = "left" contentLabel.valign = "middle" rowList.append(contentLabel) self.contentLayout.add_widget(contentLabel) self.def_ids[int(strIndex)] = rowList
def _getDefaultRowDict(self, aDict): dispObjDict = {} for colIndexStr in self.dispFieldMapping.keys(): headId = self.dispFieldMapping.get(colIndexStr) fieldList = aDict.get(headId) contentObj = None if headId == "id": contentObj = SButton(size_hint = (self.idWidth_hint, None), height=30) contentObj.text = fieldList[0] contentObj.halign = "center" contentObj.bind(on_press=self._id_press) elif headId == "name": contentObj = SButton(size_hint = (self.idWidth_hint, None), height=30) contentObj.text = fieldList[0] contentObj.halign = "center" contentObj.bind(on_press=self._name_press) else: contentObj = SContentLabel(size_hint = (self.otherWidth_hint, None), height=30) contentObj.text = fieldList[0] contentObj.color = colorHex(fieldList[1]) if headId == "TT": contentObj.halign = "center" else: contentObj.halign = "right" dispObjDict[colIndexStr] = contentObj return dispObjDict
def addListRow(self, alist, aflag): if aflag: self.deleteRow(self.maxIndex) rowList = [] funcLayout = SBoxLayout(size_hint=(.25, None), height=30) funcLayout.orientation = "horizontal" funcLayout.padding = (1, 1, 1, 1) funcLayout.add_widget(BoxLayout(size_hint=(.06, 1))) btn = SInfoButton(extra_info=self.maxIndex, text="修", size_hint=(.14, 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=(.14, 1)) btn.halign = "center" btn.valign = "middle" btn.bind(on_release=self.deleteRecordPopup) funcLayout.add_widget(btn) funcLayout.add_widget(BoxLayout(size_hint=(.02, 1))) btn = SInfoButton(extra_info=self.maxIndex, text="編輯策略", size_hint=(.56, 1)) btn.halign = "center" btn.valign = "middle" btn.bind(on_release=self.editContent) funcLayout.add_widget(btn) funcLayout.add_widget(BoxLayout(size_hint=(.06, 1))) rowList.append(funcLayout) self.contentLayout.add_widget(funcLayout) contentLabel = SContentLabel(text=alist[0], size_hint=(.5, 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 = "left" contentLabel.valign = "middle" rowList.append(contentLabel) self.contentLayout.add_widget(contentLabel) self.def_ids[self.maxIndex] = 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 _addStockData(self): self.contentLayout.clear_widgets() dataFields = self.result.get("DataFields") headNum = len(dataFields) for aData in self.currStockDataList: if aData == "": continue aFieldList = aData.split("|") num = -1 for aField in aFieldList: if aField == "": continue num += 1 contentLabel = SContentLabel(size_hint=(1.0 / headNum, None), height=30) contentLabel.color = colorHex("#000000") if dataFields[num] == "ID" or dataFields[num] == "NAME": contentLabel.text = aField contentLabel.halign = "center" else: contentLabel.text = "{:.2f}".format(float(aField)) contentLabel.halign = "right" contentLabel.valign = "middle" self.contentLayout.add_widget(contentLabel)