Beispiel #1
0
    def add_unit(self,num):
        print('fffffffffff')
        self.QuestionList.append(BoxLayout())
        self.QuestionList[-1].orientation = 'vertical'
        self.QuestionList[-1].size_hint = (None,None)
        self.QuestionList[-1].size = self.unitSize
        self.QuestionList[-1].center_x = self.center_x
        self.QuestionList[-1].canvas.add(Color(0.5,0.5,0.5))
        self.QuestionList[-1].rect = Rectangle(size=self.unitSize,pos=(self.padding[0],self.top-self.padding[1]-len(self.QuestionList)*self.unitheight-(len(self.QuestionList)-1)*self.spacing[1]))
        self.QuestionList[-1].canvas.add(self.QuestionList[-1].rect)
        self.QuestionList[-1].opacity = 0.01
        self.QuestionList[-1].chagingopacity = 1
        self.QuestionList[-1].opacitypace = 2/fps

        BaseElement = self.BaseSearch(num)
        CurNum = str(self.QuestionCounter)
        self.QuestionList[-1].CurNum = self.QuestionCounter
        self.QuestionList[-1].IdInBase = num
        self.QuestionCounter += 1
        TextNumberLabel = Label()
        TextNumberLabel.italic = True
        TextNumberLabel.markup = True
        TextNumberLabel.text = str("[color=292929]Question  [/color]" + CurNum + ".") if BaseElement['isQuest'] else str("Diag")
        TextNumberLabel.color = (0,0,0,0.2) if BaseElement['isQuest'] else (0.5,0,0.08,0.6)
        TextNumberLabel.bold = False if BaseElement['isQuest'] else True
        TextNumberLabel.font_size = Window.size[1]*0.025
        self.QuestionList[-1].TextNumberLabel = TextNumberLabel
        self.QuestionList[-1].add_widget(TextNumberLabel)

        QuestLabel = Label()
        QuestLabel.text = self.BaseSearch(num)['text'] if BaseElement['isQuest'] else '                                                              '+self.BaseSearch(num)['text']
        QuestLabel.color = (1,1,1,0.9)
        QuestLabel.font_size = Window.size[1]*0.03
        QuestLabel.text_size = (self.unitwidth*0.9,None)
        QuestLabel.size_hint_y = 0.9 if BaseElement['isQuest'] else 0.1
        QuestLabel.bold = False if BaseElement['isQuest'] else True
        self.QuestionList[-1].QuestLabel = QuestLabel
        self.QuestionList[-1].add_widget(QuestLabel)

        JustBlueLine = Widget()
        JustBlueLine.size_hint_y = 1 if BaseElement['isQuest'] else 1
        self.QuestionList[-1].bluelinerect = Rectangle(size=(self.unitwidth*0.98,self.unitheight*0.025),pos=(self.padding[0]+self.unitwidth*0.01,self.QuestionList[-1].rect.pos[1]+self.unitheight*0.28))
        JustBlueLine.canvas.add(Color(0.26, 0.63, 0.75))
        JustBlueLine.canvas.add(self.QuestionList[-1].bluelinerect)
        self.QuestionList[-1].JustBlueLine = JustBlueLine
        self.QuestionList[-1].add_widget(JustBlueLine)

        FakeWidget = Widget(size_hint_y = 0.5)
        self.QuestionList[-1].add_widget(FakeWidget)


        if(BaseElement['isQuest'] == True):
            CheckBoxGroup=BoxLayout(size_hint_y=1.4)
            CheckBoxGroup.orientation = "horizontal"
            CheckBoxGroup.id = "checkgroup"
            CheckBoxGroup.IdInBase = num
            CheckBoxYes = CheckBox(group="ilness"+CurNum)
            CheckBoxYes.bind(active=self.MakeChoice)
            CheckBoxYes.type = 'yes'
            CheckBoxNo = CheckBox(group="ilness"+CurNum)
            CheckBoxNo.bind(active=self.MakeChoice)
            CheckBoxNo.type = 'no'
            CheckBoxNotStated = CheckBox(group="ilness"+CurNum)
            CheckBoxNotStated.bind(active=self.MakeChoice)
            CheckBoxNotStated.type = 'notstated'
            CheckBoxFlaseWidget = Widget()  
            CheckBoxGroup.add_widget(CheckBoxYes)
            CheckBoxGroup.add_widget(Label(text="Yes.",color = (1,1,1,0.6),font_size=Window.size[1]*0.026,bold=True,halign='left'))
            CheckBoxGroup.add_widget(copy.copy(CheckBoxFlaseWidget))
            CheckBoxGroup.add_widget(CheckBoxNo)
            CheckBoxGroup.add_widget(Label(text="No.",color = (1,1,1,0.6),font_size=Window.size[1]*0.026,bold=True))
            CheckBoxGroup.add_widget(copy.copy(CheckBoxFlaseWidget))
            CheckBoxGroup.add_widget(CheckBoxNotStated)
            CheckBoxGroup.add_widget(Label(text="NaN",color = (1,1,1,0.5),font_size=Window.size[1]*0.026,bold=False,size_hint_x=2))
            CheckBoxGroup.add_widget(Widget(size_hint_x=0.4))
            self.QuestionList[-1].add_widget(CheckBoxGroup)

        else:
            a = self.unitSize
            ButtonGroup = BoxLayout(orientation='horizontal',spacing=self.unitwidth*0.1,padding=(a[0]*0.05,a[1]*0.05,a[0]*0.05,a[1]*0.05))
            BackToMenu = Button()
            BackToMenu.text = "main"
            BackToMenu.color = (0,0,0,1)
            BackToMenu.font_size = fullapp.size[1]*0.025
            BackToMenu.italic = True
            BackToMenu.on_press = self.MenuButton.return_menu
            RestartSearch = Button()
            RestartSearch.text = 'exit'
            RestartSearch.color = (0,0,0,1)
            RestartSearch.font_size = fullapp.size[1]*0.025
            RestartSearch.italic = True
            RestartSearch.on_press = self.restart

            ButtonGroup.add_widget(BackToMenu)
            ButtonGroup.add_widget(RestartSearch)
            self.QuestionList[-1].add_widget(ButtonGroup)

        self.add_widget(self.QuestionList[-1])