예제 #1
0
 def updateList(self, *args):
     if not self.searchText.text:
         return
     newCat = self.searchText.text
     self.searchText.text = ""
     try:
         self.dataLayout = BoxLayout(orientation="vertical")
         stocks = self.searchText.crossRefs[newCat]
         for stock in stocks:
             print(stock)
             abbr, name = stock
             b = Button(text=abbr + ": " + name,
                        height=Window.height * .1,
                        size_hint_max_y=Window.height * .1,
                        size_hint_min_y=Window.height * .1)
             b.abbr = abbr
             #def useRec(itself):
             #	self.text = itself.cat
             #	self.alpha.updateList()
             #b.bind(on_press = useRec)
             self.dataLayout.add_widget(b)
         self.dataLayout.size_hint_y = None
         self.dataLayout.height = Window.height * .1 * len(stocks)
         self.swap()
     except:
         print("Unga Bunga, error occured")
         return
예제 #2
0
    def updateList(self, *args):
        if not self.searchText.text:
            return
        self.newCat = self.searchText.text
        self.searchText.text = ""
        try:
            self.dataLayout = BoxLayout(orientation="vertical")
            stocks = []
            if self.newCat in self.searchText.crossRefs:
                stocks = self.downloadCat(self.newCat)
                self.titleLabel.text = self.newCat + " " + self.titleText
            for stock in reversed(stocks):
                abbr = stock[0]
                buy = stock[1]
                sell = stock[2]
                if abbr in self.crossRefs:
                    name = self.crossRefs[abbr]
                elif abbr[:-1] in self.crossRefs:
                    name = self.crossRefs[abbr[:-1]]
                else:
                    continue
                txt = (abbr + ": " + name)
                if self.sortby == 1:
                    txt += " +" + str(buy)
                if self.sortby == 2:
                    txt += " -" + str(sell)
                b = Button(text=txt,
                           height=Window.height * .1,
                           halign="center",
                           font_name="res/Aldrich",
                           font_hinting="light",
                           size_hint_max_y=Window.height * .1,
                           size_hint_min_y=Window.height * .1)
                b.text_size[0] = Window.width
                b.abbr = abbr

                def viewGraph(itself):
                    if "stats" not in self.alpha.activities:
                        self.alpha.activitySelect.makeCompareActivityExceptImAHomelessManThatDoesntKnowHowToCode(
                            itself.abbr)
                        self.alpha.activitySelect.artificialClick("stats")
                    else:
                        self.alpha.activities["stats"].artificialUpdateGraph(
                            itself.abbr)
                        self.alpha.activities["stats"].removeText()
                        self.alpha.activitySelect.artificialClick("stats")

                b.bind(on_press=viewGraph)
                self.dataLayout.add_widget(b)
            self.dataLayout.size_hint_y = None
            self.dataLayout.height = Window.height * .1 * len(stocks)
            self.swap()
        except Exception as e:
            print(e)
            return
예제 #3
0
    def autofill(self, *args):
        if args[-1]:
            self.searchRecLayout = GridLayout(cols=1,
                                              size_hint_y=None,
                                              height=Window.height * 1)
            recommend = self.searchRecs.relateItem(args[-1].upper())
            txts = []
            for r in recommend:
                cross = ""
                if r in self.crossRefs:
                    cross = self.crossRefs[r]
                abbr = cross
                name = r
                if len(r) < len(cross) or not cross:
                    abbr = r
                    name = cross
                elif len(r) == len(cross) and r < cross:
                    abbr = r
                    name = cross
                if "(the)" in name.lower(): name = "The " + name[0:-6]
                txt = abbr + ": " + name
                if txt in txts:
                    continue
                txts.append(txt)
                b = Button(text=txt,
                           height=Window.height * .1,
                           halign="center",
                           font_name="res/Aldrich",
                           font_hinting="light",
                           size_hint_max_y=Window.height * .1,
                           size_hint_min_y=Window.height * .1)
                b.text_size[0] = Window.width
                b.abbr = abbr
                b.name = name

                def useRec(itself):
                    #self.text = itself.abbr
                    self.master.master.portfolio.addStock(
                        itself.abbr, itself.name)
                    self.activity.titleLabel.text = self.master.master.portfolio.name + "'s Stocks"
                    self.activity.swap(
                        PortfolioEditorLayout(self.master.master.portfolio,
                                              self.activity))

                b.bind(on_press=useRec)
                self.searchRecLayout.add_widget(b)
            self.searchRecLayout.height = Window.height * .1 * len(recommend)
            if self.master.searchRecLayout:
                self.master.remove_widget(self.master.searchRecLayout)
            self.master.add_widget(self.searchRecLayout)
            self.master.searchRecLayout = self.searchRecLayout
예제 #4
0
    def autofill(self, *args):
        if self.searchRecLayout and args[-1]:
            self.searchRecLayout = GridLayout(cols=1,
                                              size_hint_y=None,
                                              height=Window.height * 1)
            recommend = self.searchRecs.relateItem(args[-1].upper())
            txts = []
            for r in recommend:
                cross = ""
                if r in self.crossRefs:
                    cross = self.crossRefs[r]
                abbr = cross
                name = r
                if len(r) < len(cross) or not cross:
                    abbr = r
                    name = cross
                elif len(r) == len(cross) and r < cross:
                    abbr = r
                    name = cross
                if "(the)" in name.lower(): name = "The " + name[0:-6]
                txt = abbr + ": " + name
                if txt in txts:
                    continue
                txts.append(txt)
                b = Button(text=txt,
                           height=Window.height * .1,
                           halign="center",
                           font_name="res/Aldrich",
                           font_hinting="light",
                           size_hint_max_y=Window.height * .1,
                           size_hint_min_y=Window.height * .1)
                b.text_size[0] = Window.width
                b.abbr = abbr

                def useRec(itself):
                    self.text = itself.abbr
                    self.alpha.swap()
                    self.alpha.updateLoader()

                b.bind(on_press=useRec)
                self.searchRecLayout.add_widget(b)
            self.searchRecLayout.height = Window.height * .1 * len(recommend)
            self.alpha.swap(self.searchRecLayout)