def __init__(self,**kwargs): super(Medicine,self).__init__(**kwargs) self.active_checkboxes = [] self.checkboxeslist = [] self.scrollsize = fullapp.size[0]*0.86,fullapp.size[1]*0.57 self.scrollpos = fullapp.size[0]*0.07,fullapp.size[1]*0.34 self.canvas.add(Rectangle(size=fullapp.size,pos=fullapp.pos,source="MainBackgroundWhiter.png")) self.add_widget(MenuButton()) rect = Rectangle(size=(fullapp.size[0],fullapp.size[1]*0.236),pos=fullapp.pos,source='FrontForScroll.png') self.canvas.add(rect) self.canvas.add(Color(0.5,0.5,0.5,1)) self.canvas.add(Rectangle(size=self.scrollsize,pos=self.scrollpos)) MedScroll = ScrollView() MedScroll.size_hint = (None,None) MedScroll.size = self.scrollsize MedScroll.pos = self.scrollpos MedBox = Widget() MedBox.size_of_drug = (self.scrollsize[0],fullapp.size[1]*0.1) MedBox.spacing = fullapp.size[1]*0.01 MedBox.size = (self.scrollsize[0],(MedBox.spacing+MedBox.size_of_drug[1])*len(IlnessBase.Medicine)-MedBox.spacing) MedBox.size_hint_y = None for i in range(len(IlnessBase.Medicine)): text = Label(color=(1,1,1,1),markup=True) text.text = IlnessBase.Medicine[i][:IlnessBase.Medicine[i].find(':')] + ' ' + '[i][size=11][color=272727]' + 'ATX num ' + IlnessBase.Medicine[i][IlnessBase.Medicine[i].find(':')+1:] + '[/i][/size][/color]' text.text_size = MedBox.size_of_drug text.text_size[0] -= MedBox.size_of_drug[1] text.halign = 'left' text.valign = 'middle' text.pos = (MedBox.size_of_drug[0]/4.3,i*(MedBox.spacing+MedBox.size_of_drug[1])-MedBox.size_of_drug[1]/2) b = Button(size=MedBox.size_of_drug,pos=(0,i*(MedBox.spacing+MedBox.size_of_drug[1]))) b.bind(on_press=self.on_button) b.add_widget(text) checkbox = CheckBox(size=(MedBox.size_of_drug[1],MedBox.size_of_drug[1]),pos = (MedBox.size_of_drug[0]-MedBox.size_of_drug[1],i*(MedBox.spacing+MedBox.size_of_drug[1]))) checkbox.num = i checkbox.bind(active=self.on_checkbox) b.add_widget(checkbox) self.checkboxeslist.append(checkbox) b.ATXNum = IlnessBase.Medicine[i][IlnessBase.Medicine[i].find(':')+1:] MedBox.add_widget(b) TopLabel = Label(bold=True,size_hint=(None,None),text='check prep:',font_size=fullapp.size[1]*0.036,color = (0,0,0,1),pos = (fullapp.size[0]*0.34,fullapp.size[1]*0.85)) self.SomeWidget = Widget(pos=(0,0),size_hint=(None,None),size = fullapp.size) CancelButton = Button(text = 'exit',font_size=fullapp.size[1]*0.022,size_hint=(None,None),size=(MedBox.size_of_drug[0]/2.01,fullapp.size[1]*0.05), pos = (self.scrollpos[0],self.scrollpos[1]-fullapp.size[1]*0.05-1),background_color = (0.3,0.3,0.9,1),on_press=self.on_cancel) OkButton = Button(text = 'chose',font_size=fullapp.size[1]*0.022,size_hint=(None,None),size=(MedBox.size_of_drug[0]/2.01,fullapp.size[1]*0.05), pos = (self.scrollpos[0]+MedBox.size_of_drug[0]/2+1,self.scrollpos[1]-fullapp.size[1]*0.05-1),background_color = (0.3,0.3,0.9,1),on_press=self.on_choose) self.SomeWidget.add_widget(CancelButton) self.SomeWidget.add_widget(OkButton) self.SomeWidget.opacity=0 MedScroll.add_widget(MedBox) self.add_widget(self.SomeWidget) self.add_widget(MedScroll) self.add_widget(TopLabel)
def disrupt_game_popUp(self): myBox = BoxLayout() myBox.orientation = 'vertical' myLabel = Label() myLabel.text = 'This will quit the current game.\nAre you sure?' button1 = Button() button1.text = 'Yes' button1.size_hint_y = 0.2 button2 = Button() button2.text = 'No' button2.size_hint_y = 0.2 bar = Widget() bar.size_hint_y = 0.02 myBox.add_widget(myLabel) myBox.add_widget(button1) myBox.add_widget(bar) myBox.add_widget(button2) popUp = Popup() popUp.title = 'Stop the game?' popUp.content = myBox popUp.size_hint = (0.9, 0.8) popUp.auto_dismiss = False #button.bind(on_release=popUp.dismiss) button1.bind(on_release=self.disrupt_yes) button2.bind(on_release=self.disrupt_no) return popUp
def are_you_sure_exit(self): myBox = BoxLayout() myBox.orientation = 'vertical' myLabel = Label() myLabel.text = 'Are you sure\nyou wanna exit the game?' button = Button() button.text = 'No' button.size_hint_y = 0.2 button1 = Button() button1.text = 'Yes' button1.size_hint_y = 0.2 bar = Widget() bar.size_hint_y = 0.02 myBox.add_widget(myLabel) myBox.add_widget(button1) myBox.add_widget(bar) myBox.add_widget(button) popUp = Popup() popUp.title = 'Exiting the game' popUp.content = myBox popUp.size_hint = (0.8, 0.8) button.bind(on_release=popUp.dismiss) button1.bind(on_release=self.exit_application) return popUp
def view_art_popUp(self): myBox = BoxLayout() myBox.orientation = 'vertical' myLabel = Label() if self.critical: myLabel.text = 'You have completed the puzzle!\n\nNote: You must win with timer\nto unlock next level' else: myLabel.text = 'You have completed the puzzle!' if self.artist != None and self.artist != 'flickr': button = Button() button.text = 'More arts by ' + self.artist button.size_hint_y = 0.2 button.bind(on_release=self.open_fanpage) button1 = Button() button1.text = 'View full image' button1.size_hint_y = 0.2 button2 = Button() button2.text = 'Replay' button2.size_hint_y = 0.2 bar = Widget() bar.size_hint_y = 0.02 bar2 = Widget(size_hint_y=0.02) myBox.add_widget(myLabel) myBox.add_widget(button1) myBox.add_widget(bar) if self.artist != None and self.artist != 'flickr': myBox.add_widget(button) myBox.add_widget(bar2) myBox.add_widget(button2) popUp = Popup() popUp.title = 'You won!' popUp.content = myBox popUp.size_hint = (0.9, 0.8) popUp.auto_dismiss = False #button.bind(on_release=popUp.dismiss) button1.bind(on_release=self.view_image) button2.bind(on_release=self.re_play) return popUp
def set_widget_size(w: Widget, x: int, y: int): if x <= 1 and x > 0: w.size_hint_x = x elif x > 1: w.size_hint_x = None w.width = x else: pass if y <= 1 and y > 0: w.size_hint_x = x elif y > 1: w.size_hint_y = None w.height = y else: pass
def create_literature(self): global fullapp,butsize,chartsize,spacing butsize = (self.scrollsize[0],fullapp.size[1]*0.1) spacing = fullapp.size[1]*0.03 chartsize = (fullapp.size[0]*0.68,fullapp.size[1]*0.1) symbols_to_fill = 50 image = Widget() image.size = (fullapp.size[0]*0.68,self.find_height(len(self.opened_divisions))+self.find_chartsize(self.opened_divisions[-1])[1]*self.opened_divisions[-1]) image.size_hint_y = None for i in range(len(self.opened_divisions)): CurBaseElement = copy.copy(IlnessBase.Literature[IlnessBase.LiteratureKeys[i]]) CurSource = 'ButtonForLiterature.png' if (self.opened_divisions[i] == 0) else 'ButtonForLiteratureClicked.png' image.canvas.add(Rectangle(size = butsize,pos = (0,image.size[1] - self.find_height(i+1)),source = CurSource)) label = Label(text = '[color=ffffff]'+str(IlnessBase.LiteratureKeys[i])+'[/color]', markup = True, bold =True, italic = True, font_size = fullapp.size[1]*0.04) label.text_size=butsize label.halign = 'left' label.pos = (fullapp.size[0]*0.32,image.size[1] - self.find_height(i+1) - fullapp.size[1]*0.02) image.add_widget(label) button = Button(size = butsize,pos = (0,image.size[1] - self.find_height(i+1)),background_color = (1,1,1,0)) button.num = i button.bind(on_press = self.on_button) image.add_widget(button) if(self.opened_divisions[i] == 1): rectpos = (fullapp.size[0]*0.13,image.size[1] - self.find_height(i+1) - self.find_chartsize(i)[1]) image.canvas.add(Rectangle(size = self.find_chartsize(i),pos = rectpos,source = 'GreySquare.png')) for j in range(len(CurBaseElement)): if(len(CurBaseElement[j]) < symbols_to_fill/1.4): CurBaseElement[j] = CurBaseElement[j][:CurBaseElement[j].find(':')] + ':' +' '*20 + CurBaseElement[j][CurBaseElement[j].find(':')+1:] ChartLabel = Label(text='* ' + CurBaseElement[j][:CurBaseElement[j].find(':')] + '[i]'+CurBaseElement[j][CurBaseElement[j].find(':'):] + '[/i]', text_size = (chartsize[0]*1,chartsize[1]),font_size=chartsize[1]/3.36,markup = True,color = (0.17,0.17,0.17,1), pos = (chartsize[0]/2-fullapp.size[0]*0.017,image.size[1] - self.find_height(i+1)-chartsize[1]*(j+1.4))) image.add_widget(ChartLabel) return image
def collide_customed(self, widget): ''' Function which implement custom collision between 2 widgets This function draw a square with center (self.center_x, self.center_y) and size = ( widget.size - self.size)/2 (1 if res <0) :param Widget: the widget to test collision with self :type widget = Widget, we will use center_x,center_y and size :return Return true is self's custom zone is in collision with widget ''' #Calcul of radius size = ((widget.size_hint_x - self.size_hint_x) / 4) # if r <=0, the test will be done with a point if (size <= 0): size = 1 #Creation of the zone zone = Widget() zone.center_x = widget.center_x zone.center_y = widget.center_y zone.size_hint_x = size zone.size_hint_y = size #Test the collision return (self.collide_widget(zone))
def collide_customed(self, widget): ''' Fonction which implement custom collision between 2 widgets This function draw a square with center (self.center_x, self.center_y) and size = ( widget.size - self.size)/2 (1 if res <0) :param Widget: the widget to test collision with self :type widget = Widget, we will use center_x,center_y and size :return Return true is self's custom zone is in collision with widget ''' #Calcul of radius size = ((widget.size_hint_x - self.size_hint_x)/4) # if r <=0, the test will be done with a point if (size<=0): size = 1 #Creation of the zone zone = Widget() zone.center_x = widget.center_x zone.center_y = widget.center_y zone.size_hint_x = size zone.size_hint_y = size #Test the collision return(self.collide_widget(zone))
def notify(self): def exit(instance): self.remove_widget(NotePopup) self.scrollsize = fullapp.size[0]*0.8,fullapp.size[1]*0.6 self.scrollpos = fullapp.size[0]*0.095,fullapp.size[1]*0.185 self.size_of_note = (self.scrollsize[0],fullapp.size[1]*0.25) NotePopup = Popup(size_hint=(None,None),size=(fullapp.size[0]*0.9,fullapp.size[1]*0.8)) NotePopup.pos = (fullapp.size[0]/2 - NotePopup.size[0]/2,fullapp.size[1]/2 - NotePopup.size[1]/2) NotePopup.title = 'view pushers.' NotePopup.title_align = 'center' NotePopup.separator_color = (0.3,0.3,1,1) NotePopup.title_size = fullapp.size[1]*0.03 NoteScroll = ScrollView() NoteScroll.size_hint = (None,None) NoteScroll.size = self.scrollsize NoteScroll.pos =self.scrollpos NoteBox = Widget() NoteBox.size_of_note = self.size_of_note NoteBox.spacing = fullapp.size[1]*0.006 NoteBox.size = (self.scrollsize[0],(NoteBox.spacing+NoteBox.size_of_note[1])*len(fullapp.notes)-NoteBox.spacing) NoteBox.size_hint_y = None for i in range(len(fullapp.notes)): b = Button(size=self.size_of_note,pos=(-2,i*(NoteBox.spacing+NoteBox.size_of_note[1]))) if(fullapp.notes[i]['type'] == 'request'): b.add_widget(Label(markup=True,text='[color=cccccc]'+'ok request number '+ '[b][/color]' + str(fullapp.notes[i]['idnum']) + '[/b]',font_size=fullapp.size[1]*0.03,color=(1,1,1,1),pos=(fullapp.size[0]*0.19,fullapp.size[1]*0.126+i*(NoteBox.spacing+NoteBox.size_of_note[1])))) if(fullapp.notes[i]['undertype']=='med'): preparate = IlnessBase.Medicine[fullapp.notes[i]['idinIlnessBase']] print(preparate) b.add_widget(Label(text_size=(self.size_of_note[0]*0.97,self.size_of_note[1]*0.7),markup=True,text='to adding preparate '+ '[b][i]' + preparate[:preparate.find(':')]\ + '[/b][/i]'+' seems ' + '[b][i]' + preparate[preparate.find(':')+1:] + '[/b][/i]'+' by systemATX.',font_size=fullapp.size[1]*0.03,color=(1,1,1,1),pos=(fullapp.size[0]*0.244,fullapp.size[1]*0.086+i*(NoteBox.spacing+NoteBox.size_of_note[1])))) if(fullapp.notes[i]['state']=='inprogress'): b.add_widget(Label(text='[color=cccccc]Poss: [/color][b][color=adaddf]cheking[/color][b]',font_size=fullapp.size[1]*0.03,markup=True,pos=(fullapp.size[0]*0.184,-fullapp.size[1]*0.046+i*(NoteBox.spacing+NoteBox.size_of_note[1])))) b.add_widget(Label(text='[color=353535]from '+ fullapp.notes[i]['date'],markup=True,font_size=fullapp.size[1]*0.025,pos=(fullapp.size[0]*0.384,-fullapp.size[1]*0.076+i*(NoteBox.spacing+NoteBox.size_of_note[1])))) elif(fullapp.notes[i]['undertype']=='ser'): service = fullapp.notes[i]['name'] print(service) b.add_widget(Label(text_size=(self.size_of_note[0],self.size_of_note[1]*0.7),markup=True,text='To add new usluga '+ '[b][i]' + service\ + '[/b][/i]'+ '[/b][/i]'+'. Check info to usluga.',font_size=fullapp.size[1]*0.03,color=(1,1,1,1),pos=(fullapp.size[0]*0.244,fullapp.size[1]*0.056+i*(NoteBox.spacing+NoteBox.size_of_note[1])))) if(fullapp.notes[i]['state']=='inprogress'): b.add_widget(Label(text='[color=cccccc]Statust: [/color][b][color=adaddf]checking[/color][b]',font_size=fullapp.size[1]*0.03,markup=True,pos=(fullapp.size[0]*0.184,-fullapp.size[1]*0.046+i*(NoteBox.spacing+NoteBox.size_of_note[1])))) b.add_widget(Label(text='[color=353535]from '+ fullapp.notes[i]['date'],markup=True,font_size=fullapp.size[1]*0.025,pos=(fullapp.size[0]*0.384,-fullapp.size[1]*0.076+i*(NoteBox.spacing+NoteBox.size_of_note[1])))) NoteBox.add_widget(b) DefendWidget = Widget(size=fullapp.size,pos=fullapp.pos,size_hint=(None,None)) NoteScroll.add_widget(NoteBox) DefendWidget.add_widget(NoteScroll) DefendWidget.add_widget(Button(size_hint=(None,None),pos=(fullapp.size[0]*0.11,fullapp.size[1]*0.13),size=(25,25),background_normal='47.png',on_press=exit)) if(len(fullapp.notes)==0): DefendWidget.add_widget(Label(text='Non pushers',pos=(self.scrollpos[0]+self.scrollsize[0]/3.6,self.scrollpos[1]+self.scrollsize[1]/2),font_size=fullapp.size[1]*0.04)) else: DefendWidget.add_widget(Label(text_size=(fullapp.size[0]*0.7,100),text='[color=010101]view in [b] http://www.sechenovclinic.ru/[/color][/b]',font_size=fullapp.size[1]*0.02,pos=(self.scrollpos[0]+self.scrollsize[0]/2.7,self.scrollpos[1]-fullapp.size[1]*0.047),markup=True)) NotePopup.add_widget(DefendWidget) self.add_widget(NotePopup)
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])