def showExplain(self): filePath = os.path.join(os.path.dirname(__file__), "../conf/explain.ini") with open(filePath, 'r', encoding='utf-8-sig') as f: lineList = f.readlines() explainStr = "" for astr in lineList: explainStr += astr contentLayout = STableBoxLayout(size_hint=(1, 1), orientation="vertical") slview = STableScrollView(size_hint=(1, .92)) contentLayout.add_widget(slview) explainLayout = STableBoxLayout(size_hint=(1, None)) explainLayout.bind(minimum_height=explainLayout.setter('height')) explainLabel = SLabel(text=explainStr, size_hint=(1, None)) explainLabel.font_name = CONSTS.FONT_NAME explainLabel.color = colorHex("#000000") explainLayout.add_widget(explainLabel) slview.add_widget(explainLayout) bottomLayout = BoxLayout(size_hint=(1, .08)) closebtn_id = SButton(text="關閉", size_hint=(1, .8)) bottomLayout.add_widget(closebtn_id) contentLayout.add_widget(bottomLayout) popup = SPopup(title="股票代碼說明", content=contentLayout, size_hint=(None, None), size=(500, 400), auto_dismiss=False) closebtn_id.bind(on_press=popup.dismiss) popup.title_font = CONSTS.FONT_NAME popup.open()
def showSelectedOptionDesc(self): if self.optionList == None: return mainContent = BoxLayout(size_hint=(1, 1), orientation="vertical") slview = STableScrollView() slview.size_hint = (1, None) slview.size = (480, 160) contentLayout = STableGridLayout(cols=1, spacing=2, size_hint_y=None) # Make sure the height is such that there is something to scroll. contentLayout.bind(minimum_height=contentLayout.setter('height')) slview.add_widget(contentLayout) aLabel = None rowIndex = 0 for aObj in self.optionList: if aObj.isSelected() != True: continue rowIndex += 1 aStr = str(rowIndex) + ". " + aObj.getOptionDesc() aLabel = SLabel(text=aStr,size_hint=(1, None), height=30) aLabel.color = colorHex("#000000") contentLayout.add_widget(aLabel) showSelectFile_popup = SPopup(title="已選條件", content=mainContent, size_hint=(None, None), size=(480, 250), auto_dismiss=False) showSelectFile_popup.title_font = CONSTS.FONT_NAME mainContent.add_widget(slview) closeBtn = SButton(text="關閉") closeBtn.bind(on_press=showSelectFile_popup.dismiss) mainContent.add_widget(closeBtn) showSelectFile_popup.open()
def _createMixedChartInfoObj(self, lineSetupList): if lineSetupList == None or len(lineSetupList) == 0: return self.mixedChartInfo_layout.clear_widgets() aLabel = SLabel(text=" ", size_hint=(None, 1), width=10) aLabel.color = colorHex("#00142D") self.mixedChartInfo_layout.add_widget(aLabel) self.mixedChartInfoObjDict = {} isAmt = False for aDict in lineSetupList: aName = aDict.get("name") if aName == "成交金額": isAmt = True lwidth = schartutil.getInfoLayoutWidth( schartutil.calcCharNum(aName)) aLabel = SLabel(text=aName + " ", size_hint=(None, 1), width=lwidth) aLabel.color = aDict.get("color") self.mixedChartInfo_layout.add_widget(aLabel) if isAmt == True: lwidth = DEFAULT_WIDTH2 else: lwidth = DEFAULT_WIDTH aLabel = SLabel(text="", size_hint=(None, 1), width=lwidth) aLabel.color = DEFAULT_COLOR aLabel.halign = "left" self.mixedChartInfo_layout.add_widget(aLabel) self.mixedChartInfoObjDict[aName] = aLabel
def __init__(self, paramDict, **kwargs): super(STradeGraph, self).__init__(**kwargs) self.paramDict = paramDict self.btmenu = self.paramDict.get(CONSTS.S_BTMENU) self.dataList = self.paramDict.get("dataList") # 1001-Start: 計算最大及最小獲利率 self.min_profitPer = 0 self.max_profitPer = 0 tmpProfitPer = None if self.dataList != None and len(self.dataList) != 0: for profitPer in self.dataList: if profitPer < 0: tmpProfitPer = math.floor(profitPer) else: tmpProfitPer = math.ceil(profitPer) if tmpProfitPer > self.max_profitPer: self.max_profitPer = tmpProfitPer if tmpProfitPer < self.min_profitPer: self.min_profitPer = tmpProfitPer self.min_profitPer = int(self.min_profitPer) self.max_profitPer = int(self.max_profitPer) # 1001-End. self.maxNum = 5 self.yscale = 1 tradeGraphDict = sutil.getDictFromFile(os.path.join(os.path.dirname(__file__), ".." + os.sep + "conf" + os.sep + "trade_graph.ini")) self.shift_left = int(tradeGraphDict.get("SHIFT_LEFT")) self.shift_right = int(tradeGraphDict.get("SHIFT_RIGHT")) self.shift_bottom = int(tradeGraphDict.get("SHIFT_BOTTOM")) self.shift_top = int(tradeGraphDict.get("SHIFT_TOP")) self.ycordWidth = int(tradeGraphDict.get("YCORD_WIDTH")) self.pillarPoint = int(tradeGraphDict.get("PILLAR_POINT")) self.pillarGapPoint = int(tradeGraphDict.get("PILLAR_GAP_POINT")) self.pillarSumPoint = self.pillarPoint + self.pillarGapPoint self.FRAME_COLOR = colorHex(tradeGraphDict.get("FRAME_COLOR")) self.GRID_COLOR = colorHex(tradeGraphDict.get("GRID_COLOR")) self.CORD_INFO_COLOR = colorHex(tradeGraphDict.get("CORD_INFO_COLOR")) self.CROSS_LINE_COLOR = colorHex(tradeGraphDict.get("CROSS_LINE_COLOR")) self.TRADE_INFO_FGCOLOR = colorHex(tradeGraphDict.get("TRADE_INFO_FGCOLOR")) self.info_tradeNum = SLabel(text="") #交易次數 self.info_tradeNum.color = self.TRADE_INFO_FGCOLOR self.info_profitPer = SLabel(text="") #獲利率 self.info_profitPer.color = self.TRADE_INFO_FGCOLOR self.bind(pos=self.charting) self.bind(size=self.charting) Window.bind(mouse_pos=self.mousePos)
def __init__(self, paramDict): super().__init__(paramDict) self.CORD_INFO_COLOR = paramDict.get("CORD_INFO_COLOR") #座標資訊的文字顏色 self.DATA_INFO_COLOR = paramDict.get("DATA_INFO_COLOR") #資訊的文字顏色 self.CURV_COLOR = paramDict.get("CURV_COLOR") #線條顏色 self.CROSS_LINE_COLOR = paramDict.get("CROSS_LINE_COLOR") #十字線顏色 self.techType = paramDict.get("TechType") #技術分析類型 self.isPriceMA = paramDict.get("IsPriceMA") #是否為價格MA self.info_time = SLabel(text="") #時間 self.info_time.color = self.DATA_INFO_COLOR self.info_data = SLabel(text="") #訊息的值 self.info_data.color = self.DATA_INFO_COLOR
def __init__(self, paramDict): super().__init__(paramDict) self.CORD_INFO_COLOR = paramDict.get("CORD_INFO_COLOR") #座標資訊的文字顏色 self.DATA_INFO_COLOR = paramDict.get("DATA_INFO_COLOR") #資訊的文字顏色 self.UP_COLOR = paramDict.get("UP_COLOR") #正數時條狀圖的顏色 self.DOWN_COLOR = paramDict.get("DOWN_COLOR") #負數時條狀圖的顏色 self.CROSS_LINE_COLOR = paramDict.get("CROSS_LINE_COLOR") #十字線顏色 self.techType = paramDict.get("TechType") #技術分析類型 self.info_time = SLabel(text="") #時間 self.info_time.color = self.DATA_INFO_COLOR self.info_data = SLabel(text="") #訊息的值 self.info_data.color = self.DATA_INFO_COLOR
def __init__(self, paramDict): super().__init__(paramDict) self.CORD_INFO_COLOR = paramDict.get("CORD_INFO_COLOR") #座標資訊的文字顏色 self.DATA_INFO_COLOR = paramDict.get("DATA_INFO_COLOR") #資訊的文字顏色 self.UP_COLOR = paramDict.get("UP_COLOR") #上漲時條狀圖的顏色 self.DOWN_COLOR = paramDict.get("DOWN_COLOR") #下跌時條狀圖的顏色 self.EQUAL_COLOR = paramDict.get("EQUAL_COLOR") #持平時條狀圖的顏色 self.CROSS_LINE_COLOR = paramDict.get("CROSS_LINE_COLOR") #十字線顏色 self.techType = paramDict.get("TechType") #技術分析類型 self.info_time = SLabel(text="") #時間 self.info_time.color = self.DATA_INFO_COLOR self.info_vol = SLabel(text="") #成交量 self.info_vol.color = self.DATA_INFO_COLOR
def __init__(self, paramDict): self.paramDict = paramDict self.layout = self.paramDict.get("Layout") #繪圖之layout self.canvas = self.paramDict.get("Canvas") #繪圖之canvas self.shift_left = self.paramDict.get("SHIFT_LEFT") #圖形左邊位移距離 self.shift_gapheight = self.paramDict.get("SHIFT_GAPHEIGHT") #價圖及量圖的間距 self.shift_bottom = self.paramDict.get("SHIFT_BOTTOM") #圖形底部位移距離 self.shift_top = self.paramDict.get("SHIFT_TOP") #圖形上方位移距離 self.price_height_per = self.paramDict.get("PRICE_HEIGHT_PER") #價圖高度佔比 self.volume_height_per = self.paramDict.get( "VOLUME_HEIGHT_PER") #量圖高度佔比 self.CORD_INFO_COLOR = self.paramDict.get( "CORD_INFO_COLOR") #座標資訊的文字顏色 self.DATA_INFO_COLOR = self.paramDict.get("DATA_INFO_COLOR") #資訊的文字顏色 self.UP_COLOR = self.paramDict.get("UP_COLOR") #上漲時線條顏色 self.DOWN_COLOR = self.paramDict.get("DOWN_COLOR") #下跌時線條顏色 self.EQUAL_COLOR = self.paramDict.get("EQUAL_COLOR") #持平時線條顏色 self.VOLUME_COLOR = self.paramDict.get("VOLUME_COLOR") #量的線條顏色 self.FRAME_COLOR = self.paramDict.get("FRAME_COLOR") #邊框的線條顏色 self.GRID_COLOR = self.paramDict.get("GRID_COLOR") #格線的線條顏色 self.CROSS_LINE_COLOR = self.paramDict.get( "CROSS_LINE_COLOR") #十字線線條顏色 self.UP_DOWN_PER = self.paramDict.get("UP_DOWN_PER") #漲跌幅度 self.chartNum = self.paramDict.get("ChartNum") #時間總筆數 self.yesPrice = self.paramDict.get("YesPrice") #昨收價 self.startTime = self.paramDict.get("StartTime") #起始時間 self.endTime = self.paramDict.get("EndTime") #截止時間 self.infoFunc = self.paramDict.get("InfoFunc") #顯示訊息之函式 self.instGroup = self.paramDict.get("InstGroup", "") #InstructionGroup所使用之group值 self.minTimeList = [] #分時資料List self.volumeList = [] #成交量的List self.lastMinTime = None #最後一筆之時間 self.info_time = SLabel(text="") #時間 self.info_time.color = self.DATA_INFO_COLOR self.info_price = SLabel(text="") #成交價 self.info_vol = SLabel(text="") #成交量 self.info_vol.color = self.DATA_INFO_COLOR
def __init__(self, paramDict): super().__init__(paramDict) self.CORD_INFO_COLOR = paramDict.get("CORD_INFO_COLOR") #座標資訊的文字顏色 self.DATA_INFO_COLOR = paramDict.get("DATA_INFO_COLOR") #資訊的文字顏色 self.KLINE_COLOR = paramDict.get("KLINE_COLOR") #線條顏色 self.SOLID_COLOR = paramDict.get("SOLID_COLOR") #K線中陽線的顏色 self.VIRTUAL_COLOR = paramDict.get("VIRTUAL_COLOR") #K線中陰線的顏色 self.CROSS_LINE_COLOR = paramDict.get("CROSS_LINE_COLOR") #十字線顏色 self.info_time = SLabel(text="") #時間 self.info_time.color = self.DATA_INFO_COLOR self.info_openPrice = SLabel(text="") #開盤價 self.info_openPrice.color = self.DATA_INFO_COLOR self.info_highPrice = SLabel(text="") #最高價 self.info_highPrice.color = self.DATA_INFO_COLOR self.info_lowPrice = SLabel(text="") #最低價 self.info_lowPrice.color = self.DATA_INFO_COLOR self.info_closePrice = SLabel(text="") #收盤價 self.info_closePrice.color = self.DATA_INFO_COLOR
def _createPriceInfoObj(self, lineSetupList): if lineSetupList == None or len(lineSetupList) == 0: return self.head_layout.clear_widgets() aLabel = SLabel(text=" ", size_hint=(None, 1), width=10) aLabel.color = colorHex("#00142D") self.head_layout.add_widget(aLabel) self.priceInfoObjDict = {} for aDict in lineSetupList: aName = aDict.get("name") lwidth = schartutil.getInfoLayoutWidth( schartutil.calcCharNum(aName)) aLabel = SLabel(text=aName + " ", size_hint=(None, 1), width=lwidth) aLabel.color = aDict.get("color") self.head_layout.add_widget(aLabel) aLabel = SLabel(text="", size_hint=(None, 1), width=DEFAULT_WIDTH) aLabel.color = DEFAULT_COLOR aLabel.halign = "left" self.head_layout.add_widget(aLabel) self.priceInfoObjDict[aName] = aLabel
def showErrMsg(self, errList): filePath = os.path.join( os.path.dirname(__file__), ".." + os.sep + "conf" + os.sep + "err_explain.ini") with open(filePath, 'r', encoding='utf-8-sig') as f: lineList = f.readlines() explainStr = "" for astr in lineList: explainStr += astr explainStr += "\n\n" for astr in errList: explainStr += astr + "\n" contentLayout = BoxLayout(size_hint=(1, 1), orientation="vertical") slview = ScrollView(size_hint=(1, .92)) contentLayout.add_widget(slview) explainLayout = BoxLayout(size_hint=(1, None)) explainLayout.bind(minimum_height=explainLayout.setter('height')) explainLabel = SLabel(text=explainStr, size_hint=(1, None)) explainLabel.halign = "center" explainLabel.font_name = CONSTS.FONT_NAME explainLayout.add_widget(explainLabel) slview.add_widget(explainLayout) bottomLayout = BoxLayout(size_hint=(1, .08)) closebtn_id = SButton(text="關閉", size_hint=(1, .8)) bottomLayout.add_widget(closebtn_id) contentLayout.add_widget(bottomLayout) popup = Popup(title="錯誤格式說明", content=contentLayout, size_hint=(None, None), size=(680, 400), auto_dismiss=False) closebtn_id.bind(on_press=popup.dismiss) popup.title_font = CONSTS.FONT_NAME popup.open()
def __init__(self, paramDict, **kwargs): super(SOptionElement, self).__init__(**kwargs) optionDict = paramDict.get("OptionDict") self.formulaId = optionDict.get("FormulaID") self.paraDesc = optionDict.get("ParaDesc") self.paraDict = {} self.paraStrDict = {} self.paraList = optionDict.get("ParameterList") for aDict in self.paraList: self.paraDict[aDict.get("Name")] = aDict self._objDict = {} self.size_hint = (1, .98) self.orientation = "horizontal" self._isSelected_id = CheckBox() self._isSelected_id.active = False self._isSelected_id.size_hint = (.1, 1) self._isSelected_id.color = colorHex("#000000") self.add_widget(self._isSelected_id) self.add_widget(BoxLayout(size_hint=(.01, 1))) self.contentLayout = BoxLayout(size_hint=(.89, 1), orientation="horizontal") self.add_widget(self.contentLayout) if self.hasFunc(self.paraDesc): strList = self.paraDesc.split(" ") for astr in strList: if self.hasFunc(astr): paraName = astr[astr.find("#") + 1:] self.paraStrDict[paraName] = astr _atextInput = SOptionTextInput(paraName=paraName, size_hint=(None, 1)) _atextInput.text = self.paraDict.get(paraName).get("Def") _atextInput.width = 60 self.contentLayout.add_widget(_atextInput) self._objDict[paraName] = _atextInput else: _alabel = SLabel(text=astr, size_hint=(None, 1)) _alabel.width = self.calcStrWidth(astr) _alabel.color = colorHex("#000000") self.contentLayout.add_widget(_alabel) else: _alabel = SLabel(text=self.paraDesc, size_hint=(1, 1)) _alabel.color = colorHex("#000000") self.contentLayout.add_widget(_alabel)
def doPtradeEvent(self): contentLayout = BoxLayout() contentLayout.orientation = "vertical" contentLayout.size_hint = (1, 1) contentLabel = SLabel(text=" 交易執行中...", size_hint=(1, .8)) contentLayout.add_widget(contentLabel) sysConfDict = self.app.confDict.get(CONSTS.SYS_CONF_DICT) self.result = None self.dp_popup = Popup(title=sysConfDict.get("MSG_TITLE"), content=contentLayout, size_hint=(None, None), size=(160, 120), auto_dismiss=False) self.dp_popup.title_font = CONSTS.FONT_NAME self.dp_popup.bind(on_open=self.dp_open) Clock.schedule_once(self.doPtradeStart)
def _finishedDownload(self, gwResult): fileName = gwResult.get("FileName") fileLen = gwResult.get("FileLen") content = BoxLayout(size_hint=(1, 1), orientation="vertical") content.add_widget(BoxLayout(size_hint=(1, .05))) fileLayout = GridLayout(cols=2, spacing=2, size_hint=(1, None)) fileLayout.bind(minimum_height=fileLayout.setter('height')) fileLayout.add_widget( SLabel(text="檔案目錄:", size_hint=(.22, None), height=30)) fileLayout.add_widget( SLabel(text=download_path, size_hint=(.78, None), height=30)) fileLayout.add_widget( SLabel(text="檔案名稱:", size_hint=(.22, None), height=30)) fileLayout.add_widget( SLabel(text=fileName, size_hint=(.78, None), height=30)) fileLayout.add_widget( SLabel(text="檔案長度:", size_hint=(.22, None), height=30)) fileLayout.add_widget( SLabel(text=str(fileLen), size_hint=(.78, None), height=30)) content.add_widget(fileLayout) content.add_widget(BoxLayout(size_hint=(1, .05))) bottomLayout = BoxLayout(size_hint=(1, .1), orientation="horizontal") ensurebtn = SButton(text="確定", size_hint=(1, .8)) bottomLayout.add_widget(ensurebtn) content.add_widget(bottomLayout) self.fin_popup = Popup(title="下載完成", content=content, title_font=CONSTS.FONT_NAME, size_hint=(None, None), size=(360, 200), auto_dismiss=False) ensurebtn.bind(on_press=self.fin_popup.dismiss) self.fin_popup.open()
def showErrorView(self, isGetMsgDesc, msgCode, msgDesc=None): contentLayout = BoxLayout() contentLayout.orientation = "vertical" contentLayout.size_hint = (1, 1) if isGetMsgDesc == True: msgCodeDict = self.confDict.get(CONSTS.MSG_CODE_DICT) msgText = msgCodeDict.get(msgCode) if msgText == None: msgText = "Unknow error code->" + str(msgCode) else: msgText = str(msgCode) + "->" + msgText if msgDesc == None or msgDesc == "": contentLabel = SLabel(text=msgText, size_hint=(1, .8)) contentLabel.halign = "center" contentLayout.add_widget(contentLabel) else: titleLabel = SLabel(text=msgText, size_hint=(1, .2)) titleLabel.halign = "center" contentLayout.add_widget(titleLabel) slview = ScrollView(size_hint=(1, .6)) contentLayout.add_widget(slview) explainLayout = STableGridLayout(cols=1, spacing=1, size_hint_y=None) explainLayout.bind( minimum_height=explainLayout.setter('height')) for aStr in msgDesc: explainLabel = SLabel(text=aStr, size_hint=(1, None), height=20) explainLabel.halign = "center" explainLabel.color = colorHex("#000000") explainLabel.font_name = CONSTS.FONT_NAME explainLayout.add_widget(explainLabel) slview.add_widget(explainLayout) else: msgText = str(msgCode) + "->" + msgDesc contentLabel = SLabel(text=msgText, size_hint=(1, .8)) contentLabel.halign = "center" contentLayout.add_widget(contentLabel) sysConfDict = self.confDict.get(CONSTS.SYS_CONF_DICT) contentBtn = SButton(text=sysConfDict.get("MSG_CONFIRM"), size_hint=(1, .2)) contentLayout.add_widget(contentBtn) popup = Popup(title=sysConfDict.get("MSG_TITLE"), content=contentLayout, size_hint=(None, None), size=(200, 200), auto_dismiss=False) contentBtn.bind(on_press=popup.dismiss) popup.title_font = CONSTS.FONT_NAME popup.open()
def _queryStk(self): queryStr = self.queryStr_id.text self.resultIdNameList.clear() self.selectDict.clear() stkName = None for stkId in self.app.stkNameDict.keys(): stkName = self.app.stkNameDict.get(stkId) if stkId[2:].find(queryStr) != -1 or stkName.find(queryStr) != -1: self.resultIdNameList.append([stkId, stkName]) self.body_layout.remove_widget(self.content_layout) if self.contentView != None: self.contentView.clear_widgets() if self.pageLayout != None: self.pageLayout.clear_widgets() if self.enterPageLayout != None: self.enterPageLayout.clear_widgets() if self.nextPreLayout != None: self.nextPreLayout.clear_widgets() if len(self.resultIdNameList) == 0: return self.contentView = STableBoxLayout(size_hint=(1, 1), orientation="vertical") if len(self.resultIdNameList) > NUM_PER_PAGE: self.pageLayout = SSysBoxLayout(orientation="horizontal", size_hint=(1, None), height=30, padding=2) self.pageLayout.add_widget(BoxLayout(size_hint=(.50, 1))) self.enterPageLayout = BoxLayout(orientation="horizontal", size_hint=(.20, 1)) self.enterPageLayout.add_widget( SLabel(text="第", color=colorHex("#FFFFFF"), size_hint=(.16, 1), halign="right")) self.page_id = STextInput(text="1", multiline=False, size_hint=(.32, 1)) self.page_id.bind(on_text_validate=self._on_page_id_enter) self.enterPageLayout.add_widget(self.page_id) self.enterPageLayout.add_widget( SLabel(text="/", color=colorHex("#FFFFFF"), size_hint=(.16, 1), halign="center")) self.totalpage_id = SLabel(text="1", color=colorHex("#FFFFFF"), size_hint=(.32, 1), halign="left") self.enterPageLayout.add_widget(self.totalpage_id) self.enterPageLayout.add_widget(BoxLayout(size_hint=(.04, 1))) self.pageLayout.add_widget(self.enterPageLayout) self.nextPreLayout = BoxLayout(orientation="horizontal", size_hint=(.3, 1)) self.prepage_id = SButton(text="上一頁", size_hint=(.28, 1), halign="center", valign="middle") self.prepage_id.bind(on_release=self._onChangePage) self.nextPreLayout.add_widget(self.prepage_id) self.nextPreLayout.add_widget(BoxLayout(size_hint=(.01, 1))) self.nextpage_id = SButton(text="下一頁", size_hint=(.28, 1), halign="center", valign="middle") self.nextpage_id.bind(on_release=self._onChangePage) self.nextPreLayout.add_widget(self.nextpage_id) self.pageLayout.add_widget(self.nextPreLayout) self.contentView.add_widget(self.pageLayout) self._calcPageInfo() 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.contentView.add_widget(headLayout) slview = STableScrollView() if len(self.resultIdNameList) > NUM_PER_PAGE: slview.size_hint = (1, .95) else: slview.size_hint = (1, .95) self.gridLayout = STableGridLayout(cols=3, spacing=2, size_hint_y=None) # Make sure the height is such that there is something to scroll. self.gridLayout.bind(minimum_height=self.gridLayout.setter('height')) slview.add_widget(self.gridLayout) self.contentView.add_widget(slview) self._addContentData() self.content_layout = self.contentView self.body_layout.add_widget(self.content_layout)
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)
def mousePos(self, *args): if len(args) >= 2: key = None xcord = None if len(self.profitPerNumDict) != 0 and len(self.xcordDict) != 0: for xkey in self.xcordDict.keys(): xcord = self.xcordDict.get(xkey) if args[1][0] < (xcord + 0.5) and args[1][0] < (xcord - 0.5): key = int(xkey) break if key == None: self.clearCrossLineAndInfo() return aNum = self.profitPerNumDict.get(str(key)) if aNum == None: self.clearCrossLineAndInfo() return self.drawCrossLine(str(key)) if self.infoLayout == None: self.infoLayout = SInfoLayout(cols=1) self.infoLayout.row_force_default = True self.infoLayout.row_default_height = 20 self.infoLayout.col_force_default = True self.infoLayout.col_default_width = 110 self.infoLayout.padding = [2, 1, 2, 1] self.infoLayout.size_hint = (None, None) else: self.infoLayout.clear_widgets() if self.infoLayout.parent == None: self.add_widget(self.infoLayout) index = key - self.min_tickNum center_pos = int(self.pillarPoint / 2) if key == 0: shift_xpos = self.ycordWidth elif key > 0: shift_xpos = self.ycordWidth * 2 else: shift_xpos = 0 x1 = int(self.pos[0] + self.shift_left + index * self.pillarSumPoint + shift_xpos + center_pos) if (self.width - x1) < (self.infoLayout.width + self.shift_right): pos_x = x1 - self.infoLayout.width else: pos_x = x1 + 5 y1 = int(self.pos[1] + self.shift_bottom + aNum * self.yscale) if (self.height - y1) < (self.infoLayout.height + self.shift_top): pos_y = y1 - self.infoLayout.height else: pos_y = y1 + 5 self.infoLayout.pos = (pos_x, pos_y) self.info_tradeNum = SLabel(text="") #交易次數 self.info_tradeNum.color = self.TRADE_INFO_FGCOLOR self.info_profitPer = SLabel(text="") #獲利率 self.info_profitPer.color = self.TRADE_INFO_FGCOLOR rowNum = 1 self.infoLayout.add_widget(self.info_profitPer) self.info_profitPer.text = "獲利率:" + str(key) + "%" rowNum += 1 self.infoLayout.add_widget(self.info_tradeNum) self.info_tradeNum.text = "交易次數:" + str(aNum) self.infoLayout.size = (110, rowNum * 20)
def __init__(self, paramDict, **kwargs): super(STrendGraph, self).__init__(**kwargs) with self.canvas: Color(0, 20 / 255, 45 / 255) Rectangle(pos=self.pos, size=self.size) self.paramDict = paramDict self.btmenu = self.paramDict.get(CONSTS.S_BTMENU) self.tickNum = self.paramDict.get("ticknum") self.dataList = self.paramDict.get("datalist") if self.tickNum == 600: self.xgrid_num = 100 elif self.tickNum == 500: self.xgrid_num = 90 elif self.tickNum == 400: self.xgrid_num = 70 elif self.tickNum == 300: self.xgrid_num = 50 elif self.tickNum == 200: self.xgrid_num = 40 else: self.xgrid_num = 30 self.crossLineXIndex = -1 self.crossLineYIndex = -1 trendGraphDict = sutil.getDictFromFile( os.path.join(os.path.dirname(__file__), ".." + os.sep + "conf" + os.sep + "trend_graph.ini")) self.shift_left = int(trendGraphDict.get("SHIFT_LEFT")) self.shift_right = int(trendGraphDict.get("SHIFT_RIGHT")) self.shift_bottom = int(trendGraphDict.get("SHIFT_BOTTOM")) self.shift_top = int(trendGraphDict.get("SHIFT_TOP")) self.CORD_INFO_COLOR = colorHex(trendGraphDict.get("CORD_INFO_COLOR")) self.UP_COLOR = colorHex(trendGraphDict.get("UP_COLOR")) self.DOWN_COLOR = colorHex(trendGraphDict.get("DOWN_COLOR")) self.EQUAL_COLOR = colorHex(trendGraphDict.get("EQUAL_COLOR")) self.VOLUME_COLOR = colorHex(trendGraphDict.get("VOLUME_COLOR")) self.FRAME_COLOR = colorHex(trendGraphDict.get("FRAME_COLOR")) self.GRID_COLOR = colorHex(trendGraphDict.get("GRID_COLOR")) self.CROSS_LINE_COLOR = colorHex( trendGraphDict.get("CROSS_LINE_COLOR")) self.TRADEB_SIG_COLOR = colorHex( trendGraphDict.get("TRADEB_SIG_COLOR")) self.TRADES_SIG_COLOR = colorHex( trendGraphDict.get("TRADES_SIG_COLOR")) self.TRADE_INFO_FGCOLOR = colorHex( trendGraphDict.get("TRADE_INFO_FGCOLOR")) self.info_date = SLabel(text="") #日期 self.info_date.color = self.TRADE_INFO_FGCOLOR self.info_time = SLabel(text="") #時間 self.info_time.color = self.TRADE_INFO_FGCOLOR self.info_price = SLabel(text="") #成交價 self.info_price.color = self.TRADE_INFO_FGCOLOR self.info_vol = SLabel(text="") #成交量 self.info_vol.color = self.TRADE_INFO_FGCOLOR self.info_amt = SLabel(text="") #金額 self.info_amt.color = self.TRADE_INFO_FGCOLOR self.info_bs = SLabel(text="") #買賣訊號及買(賣)價 self.info_bs.color = self.TRADE_INFO_FGCOLOR self.calcMaxTick() self.bind(pos=self.charting) self.bind(size=self.charting) Window.bind(mouse_pos=self.mousePos)