Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
    def __init__(self, paramDict, **kwargs):
        super(SStrategy, self).__init__(**kwargs)
        
        self.paramDict = paramDict
        self.app = self.paramDict.get(CONSTS.S_APP)        

        self.size_hint = (1, 1)
        self.orientation = "vertical"

        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=(.6, 1))
        headLabel.halign: 'center'
        headLabel.valign: 'middle'
        headLayout.add_widget(headLabel)
        headLabel = SHeadLabel(text="檔案名稱", size_hint=(.25, 1))
        headLabel.halign: 'center'
        headLabel.valign: 'middle'
        headLayout.add_widget(headLabel)
        self.add_widget(headLayout)
        
        gapLayout = STableBoxLayout(size_hint=(1, None), height=2)
        self.add_widget(gapLayout)
        
        self.maxIndex = 0
        self.def_ids = {}
        
        slview = STableScrollView()
        slview.size_hint = (1, None)
        slview.size = (540, 350)
        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'))
        
        filePath = os.path.join(os.path.dirname(__file__), ".." + os.sep + "conf" + os.sep + "strategy.ini")
        if not os.path.exists(filePath):
            with open(filePath, 'w'): pass        
            
        alist = sutil.getListFromFile(filePath)
        for astr in alist:
            tmpList = astr.strip().split(",")
            if len(tmpList) < 2:
                continue
            self.addListRow(tmpList, False)
            self.maxIndex += 1            

        self.addInsertRow(str(self.maxIndex))
        slview.add_widget(self.contentLayout)
        
        self.add_widget(slview)
        
        closeLayout = BoxLayout(size_hint=(1, None), height=36)
        self.closebtn_id = SButton(text="關閉", size_hint=(1, 1))
        closeLayout.add_widget(self.closebtn_id)
        self.add_widget(closeLayout)
Ejemplo n.º 3
0
    def __init__(self, refDict, **kwargs):
        super(SOptionSelect, self).__init__(**kwargs)

        self.app = refDict.get(CONSTS.S_APP)
        self.sysConfDict = self.app.confDict.get(CONSTS.SYS_CONF_DICT)
 
        slview = STableScrollView()
        slview.size_hint = (1, 1)
        self.stgLayout = STableGridLayout(cols=1, spacing=2, size_hint_y=None)
        # Make sure the height is such that there is something to scroll.
        self.stgLayout.bind(minimum_height=self.stgLayout.setter('height'))
        slview.add_widget(self.stgLayout)
        
        self.contentLayout_id.add_widget(slview)
        
        self._doQueryFormulaId()
Ejemplo n.º 4
0
    def _finishedSelectStock(self, gwResult):

        self.result = gwResult
        dataFields = gwResult.get("DataFields")
        headNum = len(dataFields)
        
        self.currentHeadIndex = 0
        self.sortedDirection = 1
        self.headButtonList = []
        headLayout = STableGridLayout(cols=headNum, rows=1, spacing=2, size_hint=(1, None), height=30)
        headIndex = -1
        for field in dataFields:            
            headIndex += 1
            headButton = SHeadSortedButton(headText = field, headIndex = headIndex, text = field, size_hint = (1.0 / headNum, 1))
            if headIndex == 0:
                headButton.text = field + " ▼"
            headButton.bind(on_release=self._sortedData)
            headLayout.add_widget(headButton)
            self.headButtonList.append(headButton)
        self.add_widget(headLayout)
        
        gapLayout = STableBoxLayout(size_hint=(1, None), height=2)
        self.add_widget(gapLayout)

        slview = STableScrollView()
        slview.size_hint = (1, .9)
        self.contentLayout = STableGridLayout(cols=headNum, 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'))
        
        stockData = gwResult.get("StockData")
        self.currStockDataList = stockData.split(";")
        self._addStockData()

        slview.add_widget(self.contentLayout)
        
        self.add_widget(slview)
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
    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)