Example #1
0
    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)
Example #2
0
 def __init__(self, **kwargs):
     super(InputsScreen, self).__init__(**kwargs)
     scroll = ScrollView()
     scroll.size_hint = (1, 1)
     self.add_widget(scroll)
     layout = GridLayout()
     layout.cols = 3
     layout.padding = '8dp'
     layout.spacing = '8dp'
     layout.size_hint_y = None
     layout.bind(minimum_height=layout.setter('height'))
     scroll.add_widget(layout)
     self.layout = layout
Example #3
0
 def build(self):
     l = BoxLayout(orientation='vertical')
     b = Button(text='Run')
     b.bind(on_press=self.btn_run)
     b.size_hint = 1, 1
     sv = ScrollView()
     sv.size_hint = 1, 10
     self.tv = TreeView(root_options=dict(text='Results'))
     self.tv.size_hint = 1, None 
     self.tv.bind(minimum_height = self.tv.setter('height')) 
     sv.add_widget(self.tv)
     l.add_widget(b)
     l.add_widget(sv)
     return l
Example #4
0
    def __init__(self, **kwargs):
        super(Literature, self).__init__(**kwargs)

        global fullapp,LitScroll
        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.scrollsize = fullapp.size[0]*0.86,fullapp.size[1]*0.6
        self.scrollpos = fullapp.size[0]*0.07,fullapp.size[1]*0.27
        self.libra = IlnessBase.Literature
        self.opened_divisions = [0 for i in range(len(self.libra.keys())+6)]

        LitScroll = ScrollView()
        LitScroll.size_hint = (None,None)
        LitScroll.pos = self.scrollpos
        LitScroll.size = self.scrollsize
        LitScroll.add_widget(self.create_literature())
        self.add_widget(LitScroll)
        self.add_widget(Label(text = '[color=000033]'+'litra.'+'[/color]',bold= True,font_size = fullapp.size[1]*0.038,pos=(0,fullapp.size[1]*0.44),markup = True))#,pos = (fullapp.size[0]*0.3,fullapp.size[1]*0.8)))
Example #5
0
    def fill_accordion_item(self, store):
        storage_butt = AccordionItem()
        storage_butt.id = str(store.id)
        storage_butt.height = 22
        storage_butt.title = str(store.name)

        scroll = ScrollView()
        scroll.do_scroll_x = False
        scroll.size_hint = (1, 1)
        scroll.bar_color = [.5, .10, .15, .8]
        scroll.bar_inactive_color = [.5, .20, .10, .5]
        scroll.scroll_type = ['bars']  # [‘bars’, ‘content’]

        tree_obj = TreeView()
        tree_obj.size_hint = (1, None)
        tree_obj.hide_root = True

        store.tree_view = WeakProxy(tree_obj)
        scroll.add_widget(tree_obj)
        storage_butt.add_widget(scroll)
        return storage_butt
def fill_menu_with_data():
	# Necesary to flush old data 
	airtable_content.clear_tabs()

	# Layout metadata to specify dimension and style
	airtable_content.orientation = "vertical"
	airtable_content.do_default_tab = False # Necesary to disable Default Tab that TabbedPanel generate automatically
	airtable_content.background_color = (0, 0, 1, .5) #50% translucent
	airtable_content.tab_width = 150

	# Trigger airtable connection and data retrieval
	# tab_headers and tab_menus have all data needed to fill airtable_content
	fetch_airtable_data()

	# Creation of each Tab and their respective items 
	for header in tab_headers:

		tab = TabbedPanelHeader(text=header)

		# Scrollview required to adequatly contain items without window or objec distortion
		# Effectively scroll through the menu effortlessly
		scroll = ScrollView()
		scroll.bar_margin = 10
		scroll.size_hint = (1, 1) # Needed to allow scrollview to fit the window regarless od size
		scroll.scroll_type = ['bars', 'content'] # allow scrolling via the bar or by draging content 
		scroll.bar_pos_y = 'left'
		scroll.bar_width = 20
		scroll.bar_color = (5, 10, 15, 0.8)
		scroll.bar_inactive_color = (5, 20, 15, 0.8)
		scroll.do_scroll_y = True # Needed for vertical scrolling
		scroll.do_scroll_x = False
		scroll.scroll_y = 1 # Scrolling speed
		
		# Adding item specifically fitted for the current tab
		scroll.add_widget(format_airtable_data(header))

		tab.content = scroll # adding scrollview with fitted items as content of the tab
		tab.content.orientation = "vertical"
		
		airtable_content.add_widget(tab) # adding the entirity of a tab page to the TabbedPanel
Example #7
0
	def render_builder(self,tab):
		self.MainBx=BoxLayout(orientation='vertical')
		self.MainBx.size_hint=( 1, 1)
		UpBx=BoxLayout()

		UpBx.padding=10
		UpBx.spacing=10
		UpBx.size_hint = (1,.99)

		btnBuild=Button(text='Build',size_hint=(1, 1))
		btnBuild.bind(on_press=self.start_build)
		btnInstall=Button(text='Install',size_hint=(1,1))
		btnInstall.bind(on_press=self.start_install)
		btnInstall.bind(on_release=self.install_prj)
		btnInstall.disabled=False

		BtnBx=BoxLayout()
		BtnBx.size_hint = (1,.1)
		BtnBx.add_widget(btnBuild)
		BtnBx.add_widget(btnInstall)

		self.MainBx.add_widget(UpBx)
		self.MainBx.add_widget(BtnBx)


		DxBox=BoxLayout(orientation='vertical')
		DxBox.padding=5
		DxBox.spacing=5

		ProojIntBx = GridLayout(cols=2) #init
		ProojIntBx.size_hint = (1, 0.3)
		vl=Label(text=u'Version')
		vl.text_size=(self.width, None)
		self.vt=TextInput()
		self.vt.multiline=False
		pnl=Label(text=u'Project Name')
		self.pnt=TextInput()
		self.pnt.multiline=False
		pkgl=Label(text=u'Base Package Name')
		self.pkgt=TextInput()
		self.pkgt.multiline=False
		ProojIntBx.add_widget(vl)
		ProojIntBx.add_widget(self.vt)
		ProojIntBx.add_widget(pnl)
		ProojIntBx.add_widget(self.pnt)
		ProojIntBx.add_widget(pkgl)
		ProojIntBx.add_widget(self.pkgt)

		FileBx=BoxLayout() #add file search and list permission
		FileBx.size_hint = (1, 0.95)
		self.prj_path=FileChooserListView(path=self.prj_load_path)
		self.prj_path.size_hint = (1, 1)
		FileBx.add_widget(self.prj_path)


		ActionOptBx = GridLayout(cols=4) #debug install ....
		ActionOptBx.padding=10
		ActionOptBx.spacing=10
		ActionOptBx.size_hint = (1, 0.1)
		DebugBox=BoxLayout()
		DebugBox.add_widget(Label(text='Debug'))
		self.chkDebug=CheckBox()
		DebugBox.add_widget(self.chkDebug)
		DebugBox.add_widget(Label(text='Release'))
		self.chkRelease=CheckBox()
		DebugBox.add_widget(self.chkRelease)
		ActionOptBx.add_widget(DebugBox)
		DxBox.add_widget(ProojIntBx)
		DxBox.add_widget(FileBx)
		DxBox.add_widget(ActionOptBx)

		#dxbox -> second in up box
		PermissionBx=BoxLayout(orientation='vertical') #treeviw pwrmission
		PermissionBx.padding=5
		PermissionBx.spacing=5
		PermissionBx.pos=(10, 0)

		#~ PermissionBx.size_hint = (1, 1)
		layouttv = GridLayout(cols=1, spacing=5, size_hint_y=None,pos=(0,10))
		layouttv.bind(minimum_height=layouttv.setter('height'))
		for x in self.obj_builder.permissions_list:
			btn = ToggleButton(text=x, size_hint_y=None, height=40)
			btn.bind(state=self.add_remove_permission)
			layouttv.add_widget(btn)

		root = ScrollView(size_hint=(None, None), size=(400, 500))
		root.size_hint = (1, .9)

		root.add_widget(layouttv)
		PermissionBx.add_widget(root)

		#reder all
		UpBx.add_widget(DxBox)
		UpBx.add_widget(PermissionBx)

		#add all in tab item
		tab.add_widget(self.MainBx)
Example #8
0
    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)
Example #9
0
    def new_back(self):
        # Popup for changing backgrounds
        val = '180dp'
        self.popup = Popup(title='Choose background',
                           auto_dismiss=True,
                           size_hint=(0.95, 0.62),
                           separator_color=(0, 0, 1, 1),
                           title_align='center',
                           title_color=(1, 1, 1, 1),
                           title_size='16sp',
                           title_font='fonts/Fcarbim.ttf')

        scroll = ScrollView()
        scroll.size_hint = (1, 1)
        scroll.do_scroll_x = False
        scroll.do_scroll_y = True

        grd = GridLayout(cols=3, spacing='3dp')
        grd.size_hint = (1, None)
        grd.bind(minimum_height=grd.setter('height'))

        but1 = ImageButton(
            source='boc/BackOfCards.png',
            on_release=lambda x: self.receive('boc/BackOfCards.png'),
            size_hint=(1, None),
            height=val)
        but2 = ImageButton(
            source='boc/BackOfCards1.png',
            on_release=lambda x: self.receive('boc/BackOfCards1.png'),
            size_hint=(1, None),
            height=val)
        but3 = ImageButton(
            source='boc/BackOfCards2.png',
            on_release=lambda x: self.receive('boc/BackOfCards2.png'),
            size_hint=(1, None),
            height=val)
        but4 = ImageButton(
            source='boc/BackOfCards3.png',
            on_release=lambda x: self.receive('boc/BackOfCards3.png'),
            size_hint=(1, None),
            height=val)
        but5 = ImageButton(
            source='boc/BackOfCards4.png',
            on_release=lambda x: self.receive('boc/BackOfCards4.png'),
            size_hint=(1, None),
            height=val)
        but6 = ImageButton(
            source='boc/BackOfCards5.png',
            on_release=lambda x: self.receive('boc/BackOfCards5.png'),
            size_hint=(1, None),
            height=val)

        grd.add_widget(but1)
        grd.add_widget(but2)
        grd.add_widget(but3)
        grd.add_widget(but4)
        grd.add_widget(but5)
        grd.add_widget(but6)

        scroll.add_widget(grd)
        self.popup.add_widget(scroll)
        self.popup.open()
Example #10
0
    def setMenu(self, menuNum, *largs):

        self.menu = menuNum
        print("menu is now: " + str(menuNum))

        # Undo the previous menu
        self.clear_widgets()

        if self.menu == 0:

            # Add the start button
            self.startLayout = AnchorLayout(anchor_x='center',
                                            anchor_y='center')
            self.startLayout.size = Window.size
            self.startLayout.center = Window.center
            startButton = Button(text="Start")
            startButton.size_hint = 0.5, 0.2
            startButton.font_size = 35
            buttonEvent = partial(self.setMenu, 1)
            startButton.bind(on_press=buttonEvent)
            self.startLayout.add_widget(startButton)

            # Add the settings button
            self.settingsLayout = AnchorLayout(anchor_x='left',
                                               anchor_y='bottom')
            self.settingsLayout.size = Window.size
            self.settingsLayout.center = Window.center
            settingsButton = Button(text="")
            settingsButton.size_hint = None, None
            settingsButton.size = 50, 50
            settingsButton.font_size = 15
            buttonEvent = partial(self.setMenu, 3)
            settingsButton.bind(on_press=buttonEvent)
            self.settingsLayout.add_widget(settingsButton)

            # Add the layouts to the main widget
            self.add_widget(self.startLayout)
            self.add_widget(self.settingsLayout)

        elif self.menu == 1:

            # Add the back button
            self.backLayout = AnchorLayout(anchor_x='center', anchor_y='top')
            self.backLayout.size_hint = None, None
            self.backLayout.size = Window.size[0], Window.size[1] * 0.95
            self.backLayout.center = Window.center
            btn = Button(text="back",
                         size_hint=(None, None),
                         size=(Window.width / 1.1, Window.height / 10.0),
                         font_size=fs)
            btn.bind(on_press=partial(self.setMenu, 0))
            self.backLayout.add_widget(btn)

            # Set up the centered drinks list
            self.mainLayout = AnchorLayout(anchor_x='center',
                                           anchor_y='bottom')
            self.mainLayout.size_hint = None, None
            self.mainLayout.size = Window.size[0], Window.size[1]
            self.mainLayout.center = Window.center
            layout = GridLayout(cols=1, spacing=30, size_hint_y=None)
            layout.size_hint_x = 0.8
            layout.bind(minimum_height=layout.setter('height'))

            # Add all the different drinks
            for i in range(len(drinksList)):
                if drinksList[i]["canMake"]:
                    btn = Button(text=str(drinksList[i]["name"]))
                    btn.font_size = 25
                    btn.size_hint_y = None
                    btn.height = 60
                    btn.bind(on_press=partial(self.setDrink, drinksList[i]))
                    layout.add_widget(btn)

            # Add some spacing at the end
            lbl = Label(text="", height=60)
            layout.add_widget(lbl)

            # Set up scrolling of the main list
            scrolling = ScrollView(size_hint=(None, None),
                                   size=(Window.width, Window.height))
            scrolling.add_widget(layout)
            scrolling.size_hint = None, None
            scrolling.size = self.mainLayout.size[
                0] * 0.75, self.mainLayout.size[1] * 0.83
            scrolling.center = self.mainLayout.center
            scrolling.bar_width = 30
            scrolling.bar_margin = 0
            scrolling.bar_inactive_color = [.7, .7, .7, .9]
            scrolling.scroll_type = ["bars"]
            layout.center = scrolling.center
            self.mainLayout.add_widget(scrolling)

            # Add the various sections to the root widget
            self.add_widget(self.mainLayout)
            self.add_widget(self.backLayout)

        elif self.menu == 2:

            # Add the back button
            self.backLayout = AnchorLayout(anchor_x='center', anchor_y='top')
            self.backLayout.size_hint = None, None
            self.backLayout.size = Window.size[0], Window.size[1] * 0.95
            self.backLayout.center = Window.center
            btn = Button(text="back",
                         size_hint=(None, None),
                         size=(Window.width / 1.1, Window.height / 10.0),
                         font_size=fs)
            buttonEvent = partial(self.setMenu, 1)
            btn.bind(on_press=buttonEvent)
            self.backLayout.add_widget(btn)

            # Add the make button
            self.makeLayout = AnchorLayout(anchor_x='center',
                                           anchor_y='bottom')
            self.makeLayout.size_hint = None, None
            self.makeLayout.size = Window.size[0], Window.size[1] * 0.95
            self.makeLayout.center = Window.center
            btn = Button(id="btnmake",
                         text="make",
                         size_hint=(None, None),
                         size=(Window.width / 1.1, Window.height / 10.0),
                         font_size=fs)
            buttonEvent = partial(self.makeDrink)
            btn.bind(on_press=buttonEvent)
            self.makeLayout.add_widget(btn)

            # Make the central layout
            self.drinkLayout = AnchorLayout(anchor_x='center',
                                            anchor_y='bottom')
            self.drinkLayout.size_hint = None, None
            self.drinkLayout.size = Window.size[0], Window.size[1]
            self.drinkLayout.center = Window.center

            for ing in self.currentDrink["ingredients"]:
                if ing["name"] not in self.settings["liquidsAvail"]:
                    print("substituting " + ing["name"] + " for " +
                          getLiquid(ing["name"])["subs"])
                    ing["oldName"] = ing["name"]
                    ing["name"] = getLiquid(ing["name"])["subs"]

            # Add the drop down boxes to the info
            self.drinkInfo = GridLayout(cols=4,
                                        spacing=15,
                                        size_hint=(None, None))
            for index, ing in enumerate(self.currentDrink["ingredients"]):
                if "oldName" in ing.keys():
                    spinner = Label(text=ing["oldName"] + "\n(" + ing["name"] +
                                    ")",
                                    size_hint=(None, None),
                                    size=(190, 50),
                                    font_size=fs)
                else:
                    spinner = Label(text=ing["name"],
                                    size_hint=(None, None),
                                    size=(190, 50),
                                    font_size=fs)
                spinner.ind = index

                self.drinkInfo.add_widget(spinner)
                btn = Button(text="-",
                             size_hint=(None, None),
                             height=50,
                             width=50,
                             font_size=fs)
                btn.bind(on_press=partial(self.changeDrink, index, -25))
                self.drinkInfo.add_widget(btn)
                lbl = Label(id="lbl" + str(index),
                            text=str(ing["ml"]) + " ml",
                            size_hint=(None, None),
                            height=50,
                            width=80,
                            font_size=fs)
                self.drinkInfo.add_widget(lbl)
                btn = Button(text="+",
                             size_hint=(None, None),
                             height=50,
                             width=50,
                             font_size=fs)
                btn.bind(on_press=partial(self.changeDrink, index, 25))
                self.drinkInfo.add_widget(btn)

            # Set up the scrolling list of ingredients
            self.scrollingDrinks = ScrollView(size_hint=(None, None),
                                              size=(Window.width,
                                                    Window.height))
            self.scrollingDrinks.size_hint = None, None
            self.scrollingDrinks.size = self.drinkLayout.size[
                0] * 0.85, self.drinkLayout.size[1] * 0.85
            self.scrollingDrinks.center = self.drinkLayout.center
            self.scrollingDrinks.add_widget(self.drinkInfo)
            self.drinkLayout.add_widget(self.scrollingDrinks)

            # Add the various sections to the root widget
            self.add_widget(self.backLayout)
            self.add_widget(self.drinkLayout)
            self.add_widget(self.makeLayout)

            self.checkDrink()

        elif self.menu == 3:

            # Add the back button
            self.backLayout = AnchorLayout(anchor_x='center', anchor_y='top')
            self.backLayout.size_hint = None, None
            self.backLayout.size = Window.size[0], Window.size[1] * 0.95
            self.backLayout.center = Window.center
            btn = Button(text="back",
                         size_hint=(None, None),
                         size=(Window.width / 1.1, Window.height / 10.0),
                         font_size=fs)
            buttonEvent = partial(self.setMenu, 0)
            btn.bind(on_press=buttonEvent)
            self.backLayout.add_widget(btn)

            # Create the keypad
            self.keypadWrapper = AnchorLayout(anchor_x='center',
                                              anchor_y='center')
            self.keypadWrapper.size_hint = None, None
            self.keypadWrapper.size = Window.size[0], Window.size[1]
            self.keypadWrapper.center = Window.center
            self.keypadLayout = GridLayout(cols=3)
            self.keypadLayout.size_hint = None, None
            self.keypadLayout.size = Window.size[0] * 0.5, Window.size[1] * 0.5
            self.keypadLayout.center = Window.center
            for i in range(9):
                btn = Button(size_hint=(None, None),
                             size=(80, 80),
                             font_size=fs)
                buttonEvent = partial(self.enterCode, i + 1)
                btn.bind(on_press=buttonEvent)
                self.keypadLayout.add_widget(btn)
            self.keypadWrapper.add_widget(self.keypadLayout)

            # Add the various sections to the root widget
            self.add_widget(self.backLayout)
            self.add_widget(self.keypadWrapper)

        elif self.menu == 4:

            # Add the back button
            self.backLayout = AnchorLayout(anchor_x='center', anchor_y='top')
            self.backLayout.size_hint = None, None
            self.backLayout.size = Window.size[0], Window.size[1] * 0.95
            self.backLayout.center = Window.center
            btn = Button(text="back",
                         size_hint=(None, None),
                         size=(Window.width / 1.1, Window.height / 10.0),
                         font_size=fs)
            buttonEvent = partial(self.setMenu, 0)
            btn.bind(on_press=buttonEvent)
            self.backLayout.add_widget(btn)

            self.controlLayout = AnchorLayout(anchor_x='center',
                                              anchor_y='bottom')
            self.controlLayout.size_hint = None, None
            self.controlLayout.size = Window.size[0] * 0.9, Window.size[
                1] * 0.80
            self.controlLayout.center = (Window.center[0],
                                         Window.center[1] - 50)

            # Set up the wrapper grid
            self.wrapperGrid = GridLayout(cols=1,
                                          spacing=15,
                                          size_hint=(None, None))
            self.wrapperGrid.size = (self.controlLayout.size[0] * 0.99,
                                     self.controlLayout.size[1] * 0.99)
            self.wrapperGrid.center = self.controlLayout.center

            # Set up the liquid list grid
            self.liquidGrid = GridLayout(cols=2,
                                         spacing=15,
                                         size_hint=(None, None))
            self.liquidGrid.size = (self.wrapperGrid.size[0] * 0.9,
                                    self.wrapperGrid.size[1] * 0.5)
            self.liquidGrid.center = (self.wrapperGrid.center[0],
                                      self.wrapperGrid.center[1])
            for index, liq in enumerate(self.settings["liquidsAvail"]):
                spinner = Spinner(text=liq,
                                  id="sd" + str(index),
                                  values=liquidNameList,
                                  size_hint=(None, None),
                                  size=(200, 60),
                                  font_size=fs,
                                  pos_hint=(None, None))
                spinner.bind(text=self.change_avail_drink)
                self.liquidGrid.add_widget(spinner)

            # Add the settings layout
            self.controlGrid = GridLayout(cols=4,
                                          spacing=15,
                                          size_hint=(None, None))
            self.controlGrid.size = (self.wrapperGrid.size[0] * 0.9,
                                     self.wrapperGrid.size[1] * 0.30)
            self.controlGrid.center = self.wrapperGrid.center

            # Add a value setting
            lbl = Label(text="maxBooze",
                        size_hint=(None, None),
                        height=50,
                        width=180,
                        font_size=fs)
            self.controlGrid.add_widget(lbl)
            btn = Button(text="-",
                         size_hint=(None, None),
                         height=50,
                         width=50,
                         font_size=fs)
            btn.bind(on_press=partial(self.changeSetting, "maxBooze", -25))
            self.controlGrid.add_widget(btn)
            lbl = Label(id="maxBooze",
                        text=str(self.settings["maxBooze"]),
                        size_hint=(None, None),
                        height=50,
                        width=80,
                        font_size=fs)
            self.controlGrid.add_widget(lbl)
            btn = Button(text="+",
                         size_hint=(None, None),
                         height=50,
                         width=50,
                         font_size=fs)
            btn.bind(on_press=partial(self.changeSetting, "maxBooze", 25))
            self.controlGrid.add_widget(btn)

            # Add a value setting
            lbl = Label(text="maxVol",
                        size_hint=(None, None),
                        height=50,
                        width=180,
                        font_size=fs)
            self.controlGrid.add_widget(lbl)
            btn = Button(text="-",
                         size_hint=(None, None),
                         height=50,
                         width=50,
                         font_size=fs)
            btn.bind(on_press=partial(self.changeSetting, "maxVol", -25))
            self.controlGrid.add_widget(btn)
            lbl = Label(id="maxVol",
                        text=str(self.settings["maxVol"]),
                        size_hint=(None, None),
                        height=50,
                        width=80,
                        font_size=fs)
            self.controlGrid.add_widget(lbl)
            btn = Button(text="+",
                         size_hint=(None, None),
                         height=50,
                         width=50,
                         font_size=fs)
            btn.bind(on_press=partial(self.changeSetting, "maxVol", 25))
            self.controlGrid.add_widget(btn)

            # Add a value setting
            lbl = Label(text="maxChange",
                        size_hint=(None, None),
                        height=50,
                        width=180,
                        font_size=fs)
            self.controlGrid.add_widget(lbl)
            btn = Button(text="-",
                         size_hint=(None, None),
                         height=50,
                         width=50,
                         font_size=fs)
            btn.bind(on_press=partial(self.changeSetting, "maxChange", -25))
            self.controlGrid.add_widget(btn)
            lbl = Label(id="maxChange",
                        text=str(self.settings["maxChange"]),
                        size_hint=(None, None),
                        height=50,
                        width=80,
                        font_size=fs)
            self.controlGrid.add_widget(lbl)
            btn = Button(text="+",
                         size_hint=(None, None),
                         height=50,
                         width=50,
                         font_size=fs)
            btn.bind(on_press=partial(self.changeSetting, "maxChange", 25))
            self.controlGrid.add_widget(btn)

            # Add buttons to change active solenoid setting
            lbl = Label(text="selectedDrink",
                        size_hint=(None, None),
                        height=50,
                        width=180,
                        font_size=fs)
            self.controlGrid.add_widget(lbl)
            btn = Button(text="-",
                         size_hint=(None, None),
                         height=50,
                         width=50,
                         font_size=fs)
            btn.bind(
                on_press=partial(self.changeSetting, "selectedSetting", -1))
            self.controlGrid.add_widget(btn)
            lbl = Label(id="selectedSetting",
                        text=str(self.settings["selectedSetting"]),
                        size_hint=(None, None),
                        height=50,
                        width=80,
                        font_size=fs)
            self.controlGrid.add_widget(lbl)
            btn = Button(text="+",
                         size_hint=(None, None),
                         height=50,
                         width=50,
                         font_size=fs)
            btn.bind(
                on_press=partial(self.changeSetting, "selectedSetting", 1))
            self.controlGrid.add_widget(btn)

            # Add a value setting
            lbl = Label(text="milliPer25",
                        size_hint=(None, None),
                        height=50,
                        width=180,
                        font_size=fs)
            self.controlGrid.add_widget(lbl)
            btn = Button(text="-",
                         size_hint=(None, None),
                         height=50,
                         width=50,
                         font_size=fs)
            btn.bind(on_press=partial(self.changeSetting, "milliPer25", -5,
                                      self.settings["selectedSetting"]))
            self.controlGrid.add_widget(btn)
            lbl = Label(id="milliPer25",
                        text=str(self.settings["milliPer25"][
                            self.settings["selectedSetting"] - 1]),
                        size_hint=(None, None),
                        height=50,
                        width=80,
                        font_size=fs)
            self.controlGrid.add_widget(lbl)
            btn = Button(text="+",
                         size_hint=(None, None),
                         height=50,
                         width=50,
                         font_size=fs)
            btn.bind(on_press=partial(self.changeSetting, "milliPer25", 5))
            self.controlGrid.add_widget(btn)

            # Add the various sections to the root widget
            self.add_widget(self.backLayout)
            self.wrapperGrid.add_widget(self.liquidGrid)
            self.wrapperGrid.add_widget(self.controlGrid)
            self.controlLayout.add_widget(self.wrapperGrid)
            self.add_widget(self.controlLayout)
Example #11
0
    def __init__(self, paramDateText, **kwargs):
        super(SDatePicker, self).__init__(**kwargs)
        
        self.element_height = 28

        self.orientation = "vertical"

        self.date_text = paramDateText
        if paramDateText != None:
            self.date_text = paramDateText
        else:
            self.date_text = time.strftime(format('%Y%m%d'))
        self.yearInt = int(int(self.date_text) / 10000)
        self.monthInt = int(int(self.date_text) % 10000 / 100)
        self.dayInt = int(self.date_text) % 100

        yearMonthLayout = BoxLayout(size_hint=(1, None), orientation="horizontal", height=self.element_height)
        
        yearMonthLayout.add_widget(BoxLayout(size_hint=(.11, 1))) #左邊間隙
        
        yearLeftBtn = SLRButton(text="<", size_hint=(.08, .8)) #年<
        yearLeftBtn.bind(on_press=self.yearLeftEvent)
        yearMonthLayout.add_widget(yearLeftBtn)
        yearMonthLayout.add_widget(BoxLayout(size_hint=(.01, 1))) #間隔
        self.yearLabel = Label(text=str(self.yearInt), size_hint=(.2, 1)) #西元年的數字
        yearMonthLayout.add_widget(self.yearLabel)
        alabel = Label(text="年", size_hint=(.05, 1)) #年
        alabel.font_name = CONSTS.FONT_NAME
        yearMonthLayout.add_widget(alabel)
        yearMonthLayout.add_widget(BoxLayout(size_hint=(.01, 1))) #間隔
        yearRightBtn = SLRButton(text=">", size_hint=(.08, .8)) #年>
        yearRightBtn.bind(on_press=self.yearRightEvent)
        yearMonthLayout.add_widget(yearRightBtn)
        yearMonthLayout.add_widget(BoxLayout(size_hint=(.03, 1))) #年月之間隔
        monthLeftBtn = SLRButton(text="<", size_hint=(.08, .8)) #月<
        monthLeftBtn.bind(on_press=self.monthLeftEvent)
        yearMonthLayout.add_widget(monthLeftBtn)
        self.monthLabel = Label(text=str(self.monthInt), size_hint=(.1, 1)) #月的數字
        yearMonthLayout.add_widget(self.monthLabel)
        alabel = Label(text="月", size_hint=(.05, 1)) #月
        alabel.font_name = CONSTS.FONT_NAME
        yearMonthLayout.add_widget(alabel)
        yearMonthLayout.add_widget(BoxLayout(size_hint=(.01, 1))) #間隔
        monthRightBtn = SLRButton(text=">", size_hint=(.08, .8)) #月>
        monthRightBtn.bind(on_press=self.monthRightEvent)
        yearMonthLayout.add_widget(monthRightBtn)
        yearMonthLayout.add_widget(BoxLayout(size_hint=(.11, 1))) #右邊間隙
        
        self.add_widget(yearMonthLayout)
        
        self.add_widget(BoxLayout(size_hint=(1, .01)))
        
        self.addWeekHead()
        
        self.add_widget(BoxLayout(size_hint=(1, .01)))
        
        self.selectDateDict = {}
        for i in range(1, 32):
            self.selectDateDict[i] = SDayButton(text=str(i), size_hint=(.14, None), height=self.element_height)
            self.selectDateDict[i].bind(on_release=self.dateSelectEvent)
        self.dateSelectEvent(self.selectDateDict[self.dayInt])
        
        slview = ScrollView()
        slview.size_hint = (1, .8)
        self.contentLayout = GridLayout(cols=7, 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'))

        self.addContent()

        slview.add_widget(self.contentLayout)
        
        self.add_widget(slview)