Exemplo n.º 1
0
 def createNumfield(self):
     self.lblTextinput = OwnLabel(text='')
     self.numfieldLayout = GridLayout(cols=3)
     for i in range(1, 10):
         cur = Button(text=str(i))
         cur.bind(on_press=self.appending)
         self.numfieldLayout.add_widget(cur)
     btnDot = Button(text='.')
     btnDot.bind(on_press=self.appending)
     self.numfieldLayout.add_widget(btnDot)
     btnZero = Button(text='0')
     btnZero.bind(on_press=self.appending)
     btnDelete = Button(text='<<')
     btnDelete.bind(on_press=self.delete)
     self.numfieldLayout.add_widget(btnZero)
     self.numfieldLayout.add_widget(btnDelete)
     cur = GridLayout(cols=1)
     layout = GridLayout(cols=2, spacing=10,
                         row_force_default=True,
                         row_default_height=Design.btnHeight)
     btnOK = Button(text='ok', size_hint_y=None, height=Design.btnHeight)
     btnOK.bind(on_press=self.finished)
     btnCancel = Button(text='cancel', size_hint_y=None, 
                        height=Design.btnHeight)
     btnCancel.bind(on_press=self.cancel)
     layout.add_widget(btnOK)
     layout.add_widget(btnCancel)
     cur.add_widget(layout)
     cur.add_widget(self.lblTextinput)
     self.add_widget(cur)
     self.add_widget(self.numfieldLayout)
Exemplo n.º 2
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)
Exemplo n.º 3
0
    def build(self):
        dropdown = DropDown()

        for map in self.maps['Alarak']:
            btn = Button(text=map, size_hint_y=None, height=44)
            btn.bind(on_release=lambda btn: dropdown.select(btn.text))

            dropdown.add_widget(btn)
        mainbutton = Button(text='Map', size_hint=(None, None))

        mainbutton.bind(on_release=dropdown.open)
        dropdown.bind(
            on_select=lambda instance, x: setattr(mainbutton, 'text', x))
        mainbutton.pos = (self.w / 4, self.h - 50)
        mainbutton.size_hint = (.5, .06)

        layout = FloatLayout(size=(self.w, self.h))
        layout.add_widget(mainbutton)
        MapImg.pos = (self.w / 4 - 110, self.h - 90)
        mainbutton.add_widget(MapImg)

        for i in range(0, 10):
            self.hero_buttons.append(
                Spinner(
                    # default value shown
                    text='Player ' + str(i),
                    # available values
                    values=sorted(self.neutral),
                    # just for positioning in our example
                    size_hint=(None, None),
                    size=(90, 50),
                    pos=(5 + (self.w - 100) * int(i / 5),
                         self.h / 5 * (i % 5))))
            self.hero_buttons[i].bind(text=self.show_selected_value)
            layout.add_widget(self.hero_buttons[i])

        # spinner.bind(text=show_selected_value)

        # layout.add_widget(spinner)

        self.stack = StackLayout(size_hint=(0.7, 0.8), pos=(120, 0))
        dict_list = sorted(self.neutral, key=self.neutral.get, reverse=True)
        for hero in dict_list:
            self.stack.add_widget(
                Button(text=hero + "\n" + str(self.neutral[hero]),
                       size_hint=(0.142, 0.1),
                       halign='center'))

        layout.add_widget(self.stack)

        manager = ScreenManager()

        screen = HotsAnalyse(name='HotsAnalyse')

        screen.add_widget(layout)
        manager.add_widget(screen)

        return manager
Exemplo n.º 4
0
    def add_widget(self, widget, index=0):
        '''Add a widget.
        '''
        if isinstance(widget, Image):
            Button.add_widget(self, widget, index)
            return

        self._list_children.append((widget, index))
        if hasattr(widget, 'cont_menu'):
            widget.cont_menu = self.cont_menu
Exemplo n.º 5
0
    def add_widget(self, widget, index=0):
        '''Add a widget.
        '''
        if isinstance(widget, Image):
            Button.add_widget(self, widget, index)
            return

        self._list_children.append((widget, index))
        if hasattr(widget, 'cont_menu'):
            widget.cont_menu = self.cont_menu
Exemplo n.º 6
0
    def create_bullet(self, bt_img = None):
        bullet = Button(size_hint=size_hint, size=(self.win_height / 24, self.win_height / 24),
                        font_name=font_name, pos=(self.win_width / 2 - self.win_width / 80,
                        self.win_height / 24), background_color=bullet_color)
        if not bt_img:
            return bullet

        bbl = StackLayout(size=bullet.size, pos=bullet.pos)
        img = Image(source=bt_img)
        bbl.add_widget(img)
        bullet.add_widget(bbl)

        bullet.bind(on_press=self.help_press)
        return bullet
Exemplo n.º 7
0
 def addRouter(self, instance):
     nodeButton = Button(pos=(self.pendingNodePosY, self.pendingNodePosX),
                         size_hint=(None, None),
                         size=(40, 40))
     nodeImg = Image(source="Images/router.png")
     nodeLabel = Label()
     nodeButton.add_widget(nodeImg)
     nodeButton.add_widget(nodeLabel)
     nodeImg.center_x = nodeImg.parent.center_x
     nodeImg.center_y = nodeImg.parent.center_y + 10
     nodeLabel.center_x = nodeLabel.parent.center_x
     nodeLabel.center_y = nodeLabel.parent.center_y - 10
     nodeButton.bind(on_press=self.showNodeBubble)
     self.add_widget(nodeButton)
     self.netManager.addRouter(nodeButton)
     nodeLabel.text = self.netManager.getNodeName(nodeButton)
def buildButton(content, callback, size_hint=None):
    widgetSizeHint = (1.0, 1.0) if size_hint == None else size_hint
    widget = Button(size_hint=widgetSizeHint, padding=(10, 10))
    if isinstance(content, str):
        (col, bcol) = getColor(content)
        widget.text = content
        widget.color = col
        widget.background_normal = ''
        widget.background_color = bcol
    else:
        widget.add_widget(content)

        widget.bind(width=lambda i, value: setattr(content, 'width', value))
        widget.bind(height=lambda i, value: setattr(content, 'height', value))
        widget.bind(pos=lambda i, value: setattr(content, 'pos', value))
    widget.bind(on_press=callback)
    return widget
Exemplo n.º 9
0
    def __init__(self, **kwargs):
        super(Safhe1, self).__init__(**kwargs)

        g1 = GridLayout(rows=10, cols=10, spacing="5dp", padding="10dp")
        for i in range(1, 11):
            for j in range(1, 11):
                b = Button(text=str(i*j), on_press=self.say_hello)
                g1.add_widget(b)

        g2 = GridLayout(rows=10, cols=3, spacing="5dp", padding="10dp", size_hint_x=.3)
        for i in range(1, 11):
            for j in range(1, 4):
                b = Button(text=str(i*j), on_press=self.say_hello)
                g2.add_widget(b)

        b = BoxLayout(orientation='horizontal', spacing="5dp", padding="10dp")
        b.add_widget(g1)
        b.add_widget(g2)
        self.add_widget(b)
Exemplo n.º 10
0
 def __init__(self, **Kwargs):
     super(Name, self).__init__(**Kwargs)
     self.orientation = "vertical"
     S = Image(source='imagenes/fondoRojo.jpeg', allow_stretch=True)
     self.add_widget(S)  #añade la imagen al widget
     my_box1 = FloatLayout(size=(300, 300))
     #titulo
     my_label1 = Label(text='[color=ffffff][b] Centinela [/b][/color]',
                       markup=True,
                       font_size="70dp",
                       font_name="Times",
                       size_hint=(0.3, 0.3),
                       pos=(150, 420))
     #label nombre
     my_label2 = Label(
         text='[color=ffffff]  Escriba el nombre de usuario: [/color]',
         markup=True,
         font_size="40dp",
         font_name="Times",
         size_hint=(0.3, 0.3),
         pos=(200, 250))
     #input nombre
     self.my_input = TextInput(size_hint=(0.3, 0.1), pos=(130, 230))
     #Boton para ingresar al programa
     btn = Button(text="Inicio",
                  font_size=24,
                  size_hint=(0.1, 0.1),
                  background_color=[0, 1, 0.6, 0.8],
                  pos=(350, 120))
     btn.bind(on_press=self.changer)
     btnHelp = Button(font_size=24, size_hint=(0.09, 0.06), pos=(600, 500))
     btnHelp.bind(on_press=self.changerHelp)
     btnHelp.add_widget(
         Image(source='imagenes/help.jpg',
               pos=(580, 500),
               allow_stretch=True))
     my_box1.add_widget(my_label1)
     my_box1.add_widget(my_label2)
     my_box1.add_widget(self.my_input)
     my_box1.add_widget(btn)
     my_box1.add_widget(btnHelp)
     self.add_widget(my_box1)
Exemplo n.º 11
0
    def display_error_buts_deployment(self):
        cross_img = Image(source="assets/cross2.png",
                          size=(20, 20),
                          pos=(470, 370))
        cross_but = Button(size=(20, 20),
                           pos=(470, 370),
                           switch_screen='action_screen',
                           background_color=get_color_from_hex('404248'))
        cross_but.add_widget(cross_img)
        cross_but.bind(on_release=self.fast_switch_screen)

        tryagain_but = Button(
            size=(100, 30),
            pos=(200, 150),
            text="[b]TRY AGAIN[/b]",
            background_color=get_color_from_hex('FFCC00'),
            switch_screen='action_screen',
        )
        tryagain_but.bind(on_release=self.fast_switch_screen)
        self.current_screen.add_widget(cross_but)
        self.current_screen.add_widget(tryagain_but)
Exemplo n.º 12
0
    def test_get_widget_path(self):
        p = self.kv.get_widget_path
        # level 0
        float_layout = FloatLayout()
        assert_equal(p(float_layout), [])

        # level 1
        btn1 = Button()
        float_layout.add_widget(btn1)
        assert_equal(p(float_layout), [])
        assert_equal(p(btn1), [0])

        btn2 = Button()
        float_layout.add_widget(btn2)
        assert_equal(p(float_layout), [])
        assert_equal(p(btn1), [0])
        assert_equal(p(btn2), [1])

        # level 2
        btn1_btn1 = Button()
        btn1.add_widget(btn1_btn1)
        assert_equal(p(btn1_btn1), [0, 0])

        btn2_btn1 = Button()
        btn2.add_widget(btn2_btn1)
        assert_equal(p(btn2_btn1), [0, 1])

        btn2_btn2 = Button()
        btn2.add_widget(btn2_btn2)
        assert_equal(p(btn2_btn2), [1, 1])

        btn2_btn3 = Button()
        btn2.add_widget(btn2_btn3)
        assert_equal(p(btn2_btn3), [2, 1])

        # level 3

        btn2_btn3_btn1 = Button()
        btn2_btn3.add_widget(btn2_btn3_btn1)
        assert_equal(p(btn2_btn3_btn1), [0, 2, 1])
Exemplo n.º 13
0
    def on_touch_down(self, touch):
        if self.replaceable and self.collide_point(*touch.pos):
            chooser = GridLayout(rows=4, cols=4, size_hint=(1, 1))
            dummy = type("dummy", (object, ), dict(operation=None))
            popup = Popup(
                title='Replace gate',
                content=chooser,
                #auto_dismiss=False,
                size_hint=(0.4, 0.4),
                center=(self.center))
            for op in range(16):
                dummy.operation = op
                widget = get_visualization_of_bgate(dummy)
                button = Button(size_hint=(1, 1),
                                text=boolean.get_name_of_bgate(op))
                layout = FloatLayout()
                layout.add_widget(widget)
                widget.pos_hint = {"center_x": 0.5, "center_y": 0.5}
                button.add_widget(layout)
                chooser.add_widget(button)

                # def update(*largs, **kwargs):
                #     print "Updating size/pos of operation %d" % op
                #     widget.size = button.size
                #     widget.center = button.center
                # button.on_pos = button.on_size = update
                def choose_op(op=op, *largs):
                    self.op._update_table(op)
                    self.remove_widget(self.gate)
                    self.gate = get_visualization_of_bgate(self.op)
                    self.gate.size_hint = (1, 0.55)
                    self.add_widget(self.gate)
                    popup.dismiss(force=True)

                button.on_press = choose_op
            popup.attach_to = self
            popup.open()

        return super(BGate, self).on_touch_down(touch)
Exemplo n.º 14
0
    def entered(self):
        n = 0
        grid = self.children[0].children[0]
        grid.clear_widgets()
        for app in self.xml:
            n += 1

            if n % 2 == 0:
                grid.height = 200 + n * 200

            for child in app:
                if child.tag == "iconurl":
                    iconurl = child.text
                elif child.tag == "name":
                    name = child.text

            button = Button(on_press=self.goto_detail)
            button.size_hint = (None, None)
            button.size = (200, 200)

            layout = BoxLayout()
            layout.pos = (button.pos[0] + 70,
                          (grid.height - button.pos[1]) - 50 - 200)
            layout.size = button.size
            layout.orientation = "vertical"
            img = AsyncImage(source=iconurl)
            img.size_hint_x = None
            img.width = 100

            lbl = Label(text=name,
                        color=[1, 1, 1, 1],
                        size_hint=(None, None),
                        pos=(button.pos[0], button.pos[1]))
            layout.add_widget(img)
            layout.add_widget(lbl)
            button.add_widget(layout)

            self.children[0].children[0].add_widget(button)
Exemplo n.º 15
0
class ContactBox(Widget):
    def __init__(self, contact_name, **kwargs):
        super(ContactBox, self).__init__(**kwargs)
        self.contact_name = contact_name

        # Box button
        self.box_button = Button()
        self.box_button.size_hint = None, None
        self.box_button.width = 402
        self.box_button.height = 80

        # self.box_button.background_color = (255, 255, 255, 1)

        # Contact photo image
        self.contact_photo = Image()
        self.box_button.add_widget(self.contact_photo)
        self.contact_photo.source = ("interface/Home/contact.png")
        self.contact_photo.size_hint = (None, None)
        self.contact_photo.pos_hint = (None, None)
        self.contact_photo.size = (80, 80)
        self.contact_photo.pos = (0, 0)

        # Contact status img
        self.contact_img_status = Image()
        self.contact_img_status.source = ("interface/online.png")
        self.box_button.add_widget(self.contact_img_status)
        self.contact_img_status.size_hint = (None, None)
        self.contact_img_status.pos_hint = (None, None)
        self.contact_img_status.size = (80, 80)
        self.contact_img_status.pos = (330, self.contact_img_status.parent.y)

        # Contact name label
        self.lbl_name = Label()
        self.box_button.add_widget(self.lbl_name)
        self.lbl_name.text = self.contact_name
        self.lbl_name.size = (15, 120)
        self.lbl_name.pos = (90, self.contact_img_status.parent.y)

        self.add_widget(self.box_button)  #

    def set_status(self, contact_status):
        if self.contact_status is True:
            self.contact_img_status.source = ("interface/online.png")
        elif self.contact_status is False:
            self.contact_img_status.source = ("interface/online.png")
Exemplo n.º 16
0
 def build(self):
     """Rajoute les elements communs a tous les screens"""
     conf = Button(size_hint=(None, None), size=("50dp", "50dp"), pos=("5dp", "5dp"), on_press=self.menu)
     conf.add_widget(Image(source="Images/reglages.png", size_hint=(None, None), size=conf.size, pos=conf.pos))
     self.add_widget(conf)
     self.add_widget(self.loading)
Exemplo n.º 17
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)
Exemplo n.º 18
0
class Interface(Widget):
    def __init__(self):
        super().__init__()
        self.app = App.get_running_app()
        self.folder_popup()

    def folder_popup(self, *args):
        pop_layout = BoxLayout(orientation='vertical', spacing=20, padding=10)
        label = Label(
            text=
            'Set folder to scan for gifs/webms\n(defaults to $HOME/Pictures folder if non specified)',
            halign='center',
            size_hint_y=None)
        self.txt_input = TextInput(multiline=False,
                                   hint_text='eg. /home/user/gifs',
                                   size_hint_y=None,
                                   height=Window.height / 20,
                                   focus=False)
        btn = Button(text='Continue',
                     size_hint_y=None,
                     height=Window.height / 15)
        btn.bind(on_press=self.btn_press)

        pop_layout.add_widget(label)
        pop_layout.add_widget(self.txt_input)
        pop_layout.add_widget(btn)

        self.popup = Popup(title='Select Folder',
                           content=pop_layout,
                           size_hint=(0.5, 0.5))
        self.popup.auto_dismiss = True if 'not first' in args else False
        self.popup.open()

    # on_press event triggers callback passed with parameter - instance of btn here
    def btn_press(self, instance):
        self.popup.dismiss()
        try:
            self.app.root.remove_widget(self.app.root.ids.open_popup)
        except Exception as e:
            print('\n\n\n' + str(e) + '\n\n\n')

        dirName = os.environ['HOME']+'/Pictures' if self.txt_input.text == '' \
           else self.txt_input.text

        Clock.schedule_once(lambda dt: self.load_layout(dirName, 'first run'),
                            0.13)

    def back_btn_setup(self, instance):
        previous_dir = self.dirNames[0]
        del self.dirNames[0]
        if len(self.dirNames) == 0:
            self.load_layout(previous_dir)
        else:
            self.load_layout(previous_dir, 'subdir')

    def about_dialog(self, instance):
        label = Label(
            text=
            '''vieW is a webm viewer - select your folder and all\n webms present within will be watchable.\n  vieW was developed using Kivy and Python3,\n by a novice fellow \nseeking to further their programming \'expertise\' \n Work is still in progress :) \n\n[i]Copyright © 2018  [b]noTthis?[/b]\nLicensed under GPLv3[/i]''',
            halign='center',
            markup=True)
        popup = Popup(title='About vieW?', content=label, size_hint=(0.5, 0.5))
        popup.open()

    def load_layout(self, dir, *args):
        self.dir = dir

        ##########################################################
        ###################### base layout ############################

        try:
            if len(self.app.root.children
                   ) > 0:  # has stack_layout been been instantiated before?
                for widget in self.app.root.children:
                    self.app.root.remove_widget(widget)
                    self.app.root.canvas.clear()
        except Exception as e:
            print(e)

        # navbar canvas objects load on next frame(s) load_button() after attributes have loaded
        self.navbar = Widget(size_hint=(None, None), pos_hint={'y': 0.932})
        self.app.root.add_widget(self.navbar)

        if 'subdir' in args:
            self.back_btn = Button(size_hint=(None,None), size=(80,30), \
                    pos_hint={'x': 0.009,'center_y': 0.963})
            img = Image(source='img/alpha.png',
                        allow_stretch=True,
                        size=(80, 34))
            self.back_btn.bind(on_release=self.back_btn_setup)
            self.back_btn.add_widget(img)
            self.app.root.add_widget(self.back_btn)
        else:
            about_btn = Button(size_hint=(None,None), size=(80,30), \
                    pos_hint={'x': 0.009,'center_y': 0.963}, text='About?')
            about_btn.background_normal = 'img/alpha.png'
            about_btn.bind(on_release=self.about_dialog)
            self.app.root.add_widget(about_btn)

        # img source is alpha until interface loaded otherwise img visibile at 0,0
        self.folder_btn = Button(size_hint=(None,None), size=(80,30), \
                 pos_hint={'x': 0.89,'center_y': 0.963})
        img = Image(source='img/alpha.png', allow_stretch=True, size=(80, 24))
        self.folder_btn.bind(
            on_release=lambda instance: self.folder_popup('not first'))
        self.folder_btn.add_widget(img)
        self.app.root.add_widget(self.folder_btn)

        self.search_btn = Button(size_hint=(None,None), size=(60,30), \
                 pos_hint={'x':0.8,'center_y':0.963})
        img = Image(source='img/alpha.png', size=(60, 30))
        self.search_btn.bind(on_release=self.btn_search)
        self.search_btn.add_widget(img)
        self.app.root.add_widget(self.search_btn)

        self.scroll_layout = ScrollView(pos_hint={
            'center_x': 0.5,
            'center_y': 0.42
        })
        self.stack_layout = StackLayout(padding=12, \
                    spacing=(12,30), \
                    size_hint_y=None)

        self.scroll_layout.add_widget(self.stack_layout)
        self.app.root.add_widget(self.scroll_layout)

        #######################################################

        # delete ',gif_cache' dir from previous run from cwd and all subdirs
        # in case changes have been made since then
        if 'first run' in args:
            for directory, subdir, files in os.walk(self.dir):
                subprocess.call(['rm', '-rf', directory + '/.gif_cache'])
            self.dirNames = [
            ]  # when subdir is entered parent dir added to index 0,
            #when back pressed & parent dir entered, index 0 is removed so new index 0 is new parent dir

        # if not first time going through dir no need to recreate thumbnails
        if '.gif_cache' not in os.listdir(
                self.dir):  # if first time going through directory
            self.first = True
            # loading screen
            self.progress = ProgressBar(max=sum([
                1 if (fn[-4:] == 'webm') or (
                    os.path.isdir(''.join([self.dir, '/', fn]))) else 0
                for fn in os.listdir(self.dir)
            ]))
            self.loading_popup = Popup(title='Loading thumbnails..', \
                     content=self.progress, \
                     size_hint=(0.4,0.3), \
                     auto_dismiss=False)
            self.loading_popup.open()
            os.mkdir(self.dir + '/' + '.gif_cache')
        else:
            self.first = False

        self.ctr = 0
        self.fNames_url = []
        self.fNames = []
        self.fns = os.listdir(self.dir)
        Clock.schedule_interval(lambda dt: self.load_thumbnails(), 0)

    def load_thumbnails(self):
        if self.ctr == len(
                self.fns):  # if we have gone through all files in current dir
            try:
                self.loading_popup.dismiss()
            except Exception as e:  # if self.first=False
                print('\n\n\n' + str(e) + '\n\n\n')

            # relate stack_layout height to number of children - to allow scroll child must be larger than scroll
            self.stack_layout.height = sum(
                [100 / 4.5 for child in self.stack_layout.children])

            Clock.schedule_once(
                self.load_buttons
            )  # next frame - required for widgets to update attributes
            return False  # cancels clock event

        if self.ctr == 0:  # if first execution
            # update widget properties
            with self.navbar.canvas.before:
                Color(92 / 360, 92 / 360, 92 / 360, 1)
                Rectangle(pos=self.navbar.pos, size=(self.app.root.width, 40))
            # navbar btn child images property updates
            self.folder_btn.children[0].source = 'img/folder.png'
            self.folder_btn.children[0].x = self.folder_btn.x
            self.folder_btn.children[
                0].y = self.folder_btn.y + 4  # img extends beyond len specified by placeholder widget?
            self.search_btn.children[0].source = 'img/search.png'
            self.search_btn.children[0].x = self.search_btn.x + 2
            self.search_btn.children[0].y = self.search_btn.y + 1
            try:
                self.back_btn.children[0].source = 'img/back.png'
                self.back_btn.children[0].pos = self.back_btn.pos
            except Exception as e:  # if not a 'subdir'
                print('\n\n\n' + str(e) + '\n\n\n')

        # slice filename str if too long to fit in label optimally
        if len(self.fns[self.ctr]) >= 11:
            label_fn = self.fns[self.ctr][:10] + '..'
        else:
            label_fn = self.fns[self.ctr]

        if self.fns[self.ctr][-4:] == 'webm':
            # if folder contents change while program is running, self.ctr may not refer to the thumbnail produced
            thumbnail_fn = self.dir + '/' + '.gif_cache' + '/' + str(
                self.ctr) + 'img.jpg'
            if self.first:  # create thumbnails
                # get first frame of webm
                subprocess.call([
                    'ffmpeg', '-i', self.dir + '/' + self.fns[self.ctr], '-ss',
                    '00:00:00.0', '-vframes', '1', thumbnail_fn
                ])
                self.progress.value += 1

            self.fNames_url.append('{}/{}'.format(self.dir,
                                                  self.fns[self.ctr]))
            self.thumbnail = Image(source=thumbnail_fn,
                                   size_hint=(None, None),
                                   allow_stretch=True,
                                   keep_ratio=False)
            label = Label(text=label_fn, text_size=(100, None))

        elif os.path.isdir(self.dir + '/' + self.fns[self.ctr]):
            if self.fns[
                    self.ctr] == '.gif_cache':  # config folder not for viewing
                self.ctr += 1
                return
            if self.first:
                self.progress.value += 1

            self.fNames_url.append('{}/{}'.format(self.dir,
                                                  self.fns[self.ctr]))
            self.thumbnail = Image(source='img/System-folder-icon.png',
                                   size_hint=(None, None),
                                   allow_stretch=True,
                                   keep_ratio=False)
            label = Label(text=label_fn, text_size=(100, None))

        else:
            self.ctr += 1
            return

        # thumb_layout size defaults to 100,100 so all children will extend past layout without increasing size
        thumb_layout = BoxLayout(orientation='vertical',
                                 size_hint=(None, None),
                                 spacing=15)
        thumb_layout.add_widget(self.thumbnail)
        thumb_layout.add_widget(label)

        self.fNames.append(self.fns[self.ctr])
        self.stack_layout.add_widget(
            thumb_layout,
            index=len(self.stack_layout.children))  # add widgets to end
        self.ctr += 1

    def load_buttons(self, dt):
        for layout in self.stack_layout.children:  # images are children to boxlayouts which are child to stacklayout
            image = layout.children[1]  # widgets are added to index 0
            btn = Button(background_normal='img/alpha.png',
                         pos=(image.x, image.y))
            btn.bind(on_release=self.gif_press)
            image.add_widget(btn)

    def gif_press(self, instance):
        for i in range(len(self.stack_layout.children)):
            # since self.stack_layout children & fNames_url[] were created in tandem,
            # image child of 'i'th item in self.stack_layout points to relevant url in fNames_url[i]
            if instance == self.stack_layout.children[i].children[1].children[
                    0]:
                if os.path.isdir(self.fNames_url[i]):
                    self.dirNames.insert(
                        0, self.dir
                    )  # self.dir is cwd - when going back will be parent(s) to subdir(s)
                    self.load_layout(self.fNames_url[i], 'subdir')
                else:
                    GifPopup(self.fNames_url[i], self.fNames_url)
                return

    def btn_search(self, instance):
        SearchPopup(self.fNames_url, self.fNames, self.dir)
    def rebuild_set(self, instance):
        try:
            self.clear_all()
            global do_par, di_par, ai_par, hr_par, send_info
            b2 = BoxLayout(orientation='vertical')
            b3 = BoxLayout(orientation='horizontal', size_hint=(1, 0.08))

            g1 = GridLayout(cols=2,
                            spacing=30,
                            padding=25,
                            size_hint=(1, .175))
            g2 = GridLayout(cols=2,
                            spacing=30,
                            padding=25,
                            size_hint=(1, .175))
            g3 = GridLayout(cols=2,
                            spacing=30,
                            padding=25,
                            size_hint=(1, .175))
            g4 = GridLayout(cols=2,
                            spacing=30,
                            padding=25,
                            size_hint=(1, .175))

            g1.add_widget(
                Label(text='Количество',
                      font_size=20,
                      halign='left',
                      size_hint=(.2, .1),
                      color=[0, 0, 0, 1]))
            self.do_num = (TextInput(text=do_par.split(', ')[2],
                                     multiline=False,
                                     font_size=20))
            g1.add_widget(self.do_num)
            g1.add_widget(
                Label(text='Адрес',
                      font_size=20,
                      halign='left',
                      size_hint=(.2, .1),
                      color=[0, 0, 0, 1]))
            self.do_adr = (TextInput(text=do_par.split(', ')[1],
                                     multiline=False,
                                     font_size=20))
            g1.add_widget(self.do_adr)

            g2.add_widget(
                Label(text='Количество',
                      font_size=20,
                      halign='left',
                      size_hint=(.2, .1),
                      color=[0, 0, 0, 1]))
            self.di_num = (TextInput(text=di_par.split(', ')[2],
                                     multiline=False,
                                     font_size=20))
            g2.add_widget(self.di_num)
            g2.add_widget(
                Label(text='Адрес',
                      font_size=20,
                      halign='left',
                      size_hint=(.2, .1),
                      color=[0, 0, 0, 1]))
            self.di_adr = (TextInput(text=di_par.split(', ')[1],
                                     multiline=False,
                                     font_size=20))
            g2.add_widget(self.di_adr)

            g3.add_widget(
                Label(text='Количество',
                      font_size=20,
                      halign='left',
                      size_hint=(.2, .1),
                      color=[0, 0, 0, 1]))
            self.ai_num = (TextInput(text=ai_par.split(', ')[2],
                                     multiline=False,
                                     font_size=20))
            g3.add_widget(self.ai_num)
            g3.add_widget(
                Label(text='Адрес',
                      font_size=20,
                      halign='left',
                      size_hint=(.2, .1),
                      color=[0, 0, 0, 1]))
            self.ai_adr = (TextInput(text=ai_par.split(', ')[1],
                                     multiline=False,
                                     font_size=20))
            g3.add_widget(self.ai_adr)

            g4.add_widget(
                Label(text='Количество',
                      font_size=20,
                      halign='left',
                      size_hint=(.2, .1),
                      color=[0, 0, 0, 1]))
            self.hr_num = (TextInput(text=hr_par.split(', ')[2],
                                     multiline=False,
                                     font_size=20))
            g4.add_widget(self.hr_num)
            g4.add_widget(
                Label(text='Адрес',
                      font_size=20,
                      halign='left',
                      size_hint=(.2, .1),
                      color=[0, 0, 0, 1]))
            self.hr_adr = (TextInput(text=hr_par.split(', ')[1],
                                     multiline=False,
                                     font_size=20))
            g4.add_widget(self.hr_adr)

            but_back = Button(on_release=self.save_set,
                              font_size=24,
                              background_color=[0, 0.6, 0, 1],
                              background_normal='',
                              size_hint=(0.2, 1))
            I1 = Image(source='E:\images\menu2.png')
            but_back.add_widget(I1)
            b3.add_widget(but_back)
            b3.add_widget(
                Button(text='Настройки',
                       bold=True,
                       font_size=28,
                       background_color=[0, 0.6, 0, 1],
                       background_normal='',
                       background_down=''))
            b3.add_widget(
                Button(font_size=28,
                       background_color=[0, 0.6, 0, 1],
                       background_normal='',
                       background_down='',
                       size_hint=(0.2, 1)))

            b2.add_widget(b3)
            b2.add_widget(
                Label(text='Цифровые выходы:',
                      font_size=24,
                      halign='center',
                      size_hint=(1, 0.05),
                      color=[0, 0, 0, 1]))
            b2.add_widget(g1)
            b2.add_widget(
                Label(text='Цифровые входы:',
                      font_size=24,
                      halign='center',
                      size_hint=(1, 0.05),
                      color=[0, 0, 0, 1]))
            b2.add_widget(g2)
            b2.add_widget(
                Label(text='Аналоговые входы:',
                      font_size=24,
                      halign='center',
                      size_hint=(1, 0.05),
                      color=[0, 0, 0, 1]))
            b2.add_widget(g3)
            b2.add_widget(
                Label(text='Регистры временного хранения информации:',
                      font_size=24,
                      halign='center',
                      size_hint=(1, 0.05),
                      color=[0, 0, 0, 1]))
            b2.add_widget(g4)

            I1.x = 0 - I1.width * 0.125
            I1.y = Window.height - I1.height * 0.9
            self.root.add_widget(b2)
        finally:
            pass
    def rebuild(self):
        self.clear_all()
        b2 = BoxLayout(orientation='horizontal', size_hint=(1, 0.1))
        b3 = BoxLayout(orientation='horizontal', size_hint=(1, 0.1))

        but_off = Button(font_size=24,
                         background_color=[0, 0.6, 0, 1],
                         background_normal='',
                         size_hint=(0.2, 1),
                         on_release=self.restart)
        I1 = Image(source='E:\images\off2.png')
        but_off.add_widget(I1)
        b2.add_widget(but_off)
        self.titl = Button(text='Индикация параметров',
                           halign='left',
                           bold=True,
                           font_size=24,
                           background_color=[0, 0.6, 0, 1],
                           background_normal='',
                           background_down='')
        b2.add_widget(self.titl)

        but_set = Button(on_release=self.rebuild_set,
                         font_size=24,
                         background_color=[0, 0.6, 0, 1],
                         background_normal='',
                         size_hint=(0.2, 1))
        I2 = Image(source='E:\images\set2.png')
        but_set.add_widget(I2)
        b2.add_widget(but_set)

        self.list_button = self.list_but
        self.list_adapter = ListAdapter(data=[],
                                        cls=self.list_button,
                                        allow_empty_selection=False)

        self.list_view = ListView(adapter=self.list_adapter)
        self.list_button.background_color = [1, 1, 1, 1]
        self.list_button.background_normal = ''
        self.list_button.on_release = self.show_popup
        self.list_view.container.spacing = 10
        self.list_button.font_size = 24
        self.list_button.font_name = 'arialbd'
        self.list_button.bold = True
        self.list_button.color = [0, 0, 0, 1]
        self.list_button.padding = 30
        self.list_button.halign = 'left'
        self.list_button.text_size = (Window.width, 0)
        self.list_adapter.data = []

        I1.x = 0 - I2.width * 0.125
        I1.y = Window.height - I2.height * 0.9
        I2.x = Window.width - I2.width * 0.9
        I2.y = Window.height - I2.height * 0.9
        self.root.add_widget(b2)
        self.root.add_widget(self.list_view)

        self.but_0x = Button(on_release=self.do_set,
                             text='0x',
                             bold=True,
                             font_size=28,
                             background_color=[0, 0.6, 0, 1],
                             background_normal='')

        self.but_1x = Button(on_release=self.di_set,
                             text='1x',
                             bold=True,
                             font_size=28,
                             background_color=[0, 0.6, 0, 1],
                             background_normal='')

        self.but_3x = Button(on_release=self.ai_set,
                             text='3x',
                             bold=True,
                             font_size=28,
                             background_color=[0, 0.6, 0, 1],
                             background_normal='')

        self.but_4x = Button(on_release=self.hr_set,
                             text='4x',
                             bold=True,
                             font_size=28,
                             background_color=[0, 0.6, 0, 1],
                             background_normal='')
        b3.add_widget(self.but_0x)
        b3.add_widget(self.but_1x)
        b3.add_widget(self.but_3x)
        b3.add_widget(self.but_4x)
        self.root.add_widget(b3)
        self.hr_set()
        Clock.schedule_interval(self.update, 1)
Exemplo n.º 21
0
def build(app):
    # Here, you must return a root widget that will be used for app
    # You also have app instance in parameter.

    # -------------------------------------------------------------------------
    # Our root widget
    root = FloatLayout()

    app.should_display_images_by_default = True

    root.scroller = scroller = ScrollView(size_hint=(None, None),
                                          size=(1920, 1080),
                                          pos_hint={
                                              'center_x': .5,
                                              'center_y': .5
                                          },
                                          do_scroll_x=False)
    root.add_widget(scroller)

    def rotate_window(but):
        but.background_color = bluergb
        but.children[0].color = (1, 1, 1, 1)
        if Window.rotation == 180:
            Window.rotation = 0
        else:
            Window.rotation = 180

    def on_press_button(but):
        but.background_color = (1, 1, 1, 1)
        but.children[0].color = bluergb

    but = Button(size=(72, 71),
                 size_hint=(None, None),
                 pos=(Window.width - 72 + 10, Window.height / 2 - 71 / 2),
                 background_color=bluergb,
                 background_normal='widgets/picto-background.png',
                 background_down='widgets/picto-background.png')

    img = Image(source='widgets/picto-reverse.png',
                size=(40, 40),
                pos=(but.x + (but.width - 40) / 2,
                     but.y + (but.height - 40) / 2),
                color=(1, 1, 1, 1))
    but.add_widget(img)
    but.bind(on_press=on_press_button)
    but.bind(on_release=rotate_window)

    but2 = Button(size=(72, 71),
                  size_hint=(None, None),
                  pos=(0 - 10, Window.height / 2 - 71 / 2),
                  background_color=bluergb,
                  background_normal='widgets/picto-background.png',
                  background_down='widgets/picto-background.png')

    img = Image(source='widgets/picto-reset.png',
                size=(40, 40),
                pos=(but2.x + (but2.width - 40) / 2,
                     but2.y + (but2.height - 40) / 2),
                color=(1, 1, 1, 1))
    but2.add_widget(img)

    def add_buttons(dt):
        root.add_widget(but)
        root.add_widget(but2)

    Clock.schedule_once(add_buttons, .5)

    scroller.layout = layout = GridLayout(cols=8,
                                          col_force_default=True,
                                          row_force_default=True,
                                          col_default_width=223,
                                          row_default_height=252,
                                          padding=15,
                                          spacing=15,
                                          size_hint=(None, None),
                                          width=1920)
    layout.bind(minimum_height=layout.setter('height'))

    scroller.add_widget(layout)

    panel = WidgetsPanel(app=app)
    app.panel = panel
    root.add_widget(panel)

    def clear_panel(but):
        but.background_color = bluergb
        but.children[0].color = (1, 1, 1, 1)
        panel.clear_panel()
        app.root_images.clear_widgets()
        panel.close_panel()

    but2.bind(on_press=on_press_button)
    but2.bind(on_release=clear_panel)

    def feed_scroll(defs):
        source = defs['source']
        if source not in app.images_displayed:
            return
        current_images = [x.source for x in app.root.scroller.layout.children]
        if source in current_images:
            return

        item = ScrollItem(**defs)
        app.root.scroller.layout.add_widget(item)

    def my_show_objects(objects):
        self = app
        root = self.root
        selected_authors = self.author_widget.selected_keywords
        selected_titles = self.title_widget.selected_keywords
        # selected_titles = [x.upper() for x in selected_titles]

        for item in objects[:]:
            # Filtering authors and titles
            if item.nom not in selected_titles and len(selected_titles) > 0:
                objects.remove(item)
                continue

            if item.freefield not in selected_authors and len(
                    selected_authors) > 0:
                objects.remove(item)
                continue

        panel.result_sentence.text = "J'ai trouvé [font=fonts/proximanova-bold-webfont.ttf][size=28]" + str(
            len(objects)) + " [/size][/font]livres!"

        if isinstance(self.root_images.x, (int, long)):
            if root.type_expo == 'normal':
                images = [x.source for x in self.root.scroller.layout.children]

                images_to_add = []
                images_displayed = []
                for item in objects:
                    # is the current filename is already showed ?
                    filename = item.filename
                    if filename in images:
                        images.remove(filename)
                        continue

                    image = dict(source=filename,
                                 size_hint=(1, 1),
                                 item=item,
                                 app=self)
                    images_to_add.append(image)
                    images_displayed.append(filename)
                self.images_displayed = images_displayed
                self.delayed_work(feed_scroll, images_to_add)

                # remove all the previous images
                for child in self.root.scroller.layout.children[:]:
                    for filename in images:
                        if filename == child.source:
                            self.root.scroller.layout.remove_widget(child)

    app.show_objects = my_show_objects

    app.trigger_objects_filtering()

    def on_touch_window(touch):
        return True

    # Window.on_touch_down = on_touch_window

    # def on_value(widget, value):
    #     print 'relou' , value
    # app.bind(items_to_add=on_value)

    #### LAISSER CETTE PARTIE SINON CRASH -> variable app.basket appellée dans imageitem
    # -------------------------------------------------------------------------
    # Create a basket widget
    # This button is on the bottom/left part of the screen
    kwargs = {
        'pos_hint': {
            'right': 1,
            'top': 1
        },
        'size_hint': (None, None),
        'size': (64, 64),
        'border': (0, 0, 0, 0),
        'color': (0, 0, 0, 1),
        'bold': True
    }
    #active to False disables the basket
    #email_send to True activates sending the url of the basket by email
    #url_send to True activates sending the url of the basket to a specific url
    app.basket = basket = Basket(
        active=False,
        background_normal='widgets/corner_topright.png',
        background_down='widgets/corner_topright_down.png',
        email_send=True,
        url_send=False,
        url_send_url='http://urltest.lapin.be?url=',
        app=app,
        **kwargs)
    if basket.active:
        #do not offer a basket on tablets, only on tables
        if platform() not in ('android'):
            root.add_widget(basket)

    # -------------------------------------------------------------------------

    return root
Exemplo n.º 22
0
        def __init__(self, ms, **kwargs):
            super(MasterClient.Home, self).__init__(**kwargs)

            self.ms = ms

            # Float Layout Top Bar
            self.float_layout = FloatLayout()
            self.float_layout.size_hint = (None, None)
            # self.float_layout.pos_hint = (None, None) # Não pode definir no FloatLayout
            self.float_layout.size = (402, 85)
            self.float_layout.y = 630

            # Top Bar image
            self.top_bar = Image()
            self.float_layout.add_widget(self.top_bar)
            self.top_bar.source = ("interface/Home/top_bar1.png")
            self.top_bar.y = 630

            # AddContact button
            self.add_contact_btn = Button()
            self.float_layout.add_widget(self.add_contact_btn)
            self.add_contact_btn.size_hint = (None, None)
            self.add_contact_btn.size = (40, 40)
            self.add_contact_btn.pos = (345, 643)
            self.add_contact_btn.background_color = (1.0, 1.0, 1.0, 0)
            self.add_contact_btn.on_press = self.press_add_contact_button

            # Switch status button
            self.switch_status = Button()
            self.float_layout.add_widget(self.switch_status)
            self.switch_status.size_hint = (None, None)
            self.switch_status.size = (43, 24)
            self.switch_status.pos = (20, 651)
            self.switch_status.background_color = (1.0, 1.0, 1.0, 0)
            self.switch_status.on_press = self.press_switch_status

            # Switch status image
            self.switch_img = Image()
            self.add_widget(self.float_layout)
            self.switch_status.add_widget(self.switch_img)
            self.switch_img.source = ("interface/Home/switch_on.png")
            self.switch_img.size = (43, 24)
            self.switch_img.pos = (20, 651)

            # Scroll View
            self.scroll_view = ScrollView()
            self.add_widget(self.scroll_view)
            self.scroll_view.size_hint = (None, None)
            self.scroll_view.size = (402, 630)
            self.scroll_view.y = self.scroll_view.parent.x
            self.scroll_view.orientation = "vertical"
            self.scroll_view.background_color = (255, 0, 0, 1)

            # Box View chats
            self.box = BoxLayout()
            self.scroll_view.add_widget(self.box)
            self.box.id = "box"
            self.box.orientation = "vertical"
            self.box.size_hint_y = None
            self.box.bind(minimum_height=self.box.setter("height"))
            self.box.y = self.box.parent.y

            print(len(contacts))
            for contact in contacts:
                print("entrei aqui no coisa do bicho do negoço")
                print(contact)
                ###
                # Box button
                box_button = Button()
                self.box.add_widget(box_button)

                box_button.size_hint = (None, None)
                box_button.width = 402
                box_button.height = 80
                #box_button.background_color = (255, 255, 255, 1)

                # Contact photo image
                contact_photo = Image()
                box_button.add_widget(contact_photo)
                contact_photo.source = ("interface/Home/contact.png")
                contact_photo.size_hint = (None, None)
                contact_photo.pos_hint = (None, None)
                contact_photo.size = (80, 80)
                contact_photo.pos = (0, 0)

                # Contact status img
                contact_img_status = Image()
                box_button.add_widget(contact_img_status)
                contact_img_status.source = ("interface/online.png")
                contact_img_status.size_hint = (None, None)
                contact_img_status.pos_hint = (None, None)
                contact_img_status.size = (80, 80)
                contact_img_status.pos = (330, contact_img_status.parent.y)

                # Contact name label
                lbl_name = Label()
                box_button.add_widget(lbl_name)
                lbl_name.text = contact_name
                lbl_name.size = (15, 120)
                lbl_name.pos = (90, contact_img_status.parent.y)
Exemplo n.º 23
0
class GifPopup(Widget):
    def __init__(self, source, fNames_url):
        self.fNames_url = fNames_url

        relative_layout = RelativeLayout()
        self.popup = Popup(title=source,
                           size_hint=(0.9, 0.95),
                           content=relative_layout,
                           auto_dismiss=False)

        self.gif = Video(source=source, volume=0, state='play', anim_loop=0, \
              allow_stretch=True, size_hint=(1,0.9),  pos_hint={'y':0.09})
        self.close_btn = Button(text='close [x]', size_hint=(None,None), size=(70,20), \
                 pos_hint={'x':0.003,'y':0.003}, background_normal='img/alpha.png')
        self.close_btn.bind(on_release=self.close_btn_press)

        self.mute_btn = Button(text='mute [x]', size_hint=(None,None), size=(70,20), \
                 pos_hint={'x':0.004,'y':0.04}, background_normal='img/alpha.png')
        self.mute_btn.bind(on_release=self.mute_btn_press)

        self.prev_btn = Button(text='[<-] previous', size_hint=(None,None), pos_hint={'x':0.2, 'y':0.003},  \
                size=(100,28), background_normal='img/alpha.png')
        self.prev_btn.bind(on_release=self.prev_btn_press)

        self.next_btn = Button(text='next [->]', size_hint=(None,None), pos_hint={'x':0.88 , 'y':0.003}, \
                size=(70, 28), background_normal='img/alpha.png')
        self.next_btn.bind(on_release=self.next_btn_press)

        self.play_pause_btn = Button(size_hint=(None,None), pos_hint={'center_x':0.57, 'y':0.03}, \
                    size=(57,30), background_normal='img/alpha.png')
        self.play_pause_btn.bind(on_release=self.play_pause_btn_press)
        self.play_pause_img = Image(source='img/pause.png', size=(35, 35))
        self.play_pause_label = Label(text='playing', size_hint=(None,None), size=(70,20), \
                   pos_hint={'center_x':0.57,'center_y':0.017})
        self.dot_dot_label = Label(text='',size_hint=(None,None), size=(20,20), \
                  pos_hint={'x':0.599, 'center_y':0.017})
        self.play_pause_btn.add_widget(self.play_pause_img)

        self.label_updating = Clock.schedule_interval(self.update_label, 0.5)

        for i in [self.gif, self.close_btn, self.mute_btn, self.prev_btn, self.dot_dot_label, \
           self.next_btn, self.play_pause_btn, self.play_pause_label]:
            relative_layout.add_widget(i)

        Clock.schedule_once(self.update_properties, 0)
        self.popup.open()

    def update_properties(self, instance):
        # center play/pause image
        self.play_pause_img.center_x = self.play_pause_img.parent.x + (
            self.play_pause_img.parent.width / 2)
        self.play_pause_img.center_y = self.play_pause_img.parent.y + (
            self.play_pause_img.parent.height / 2)

    def close_btn_press(self, instance):
        self.popup.dismiss()
        self.gif.state = 'stop'
        self.label_updating.cancel()

    def mute_btn_press(self, instance):
        if self.gif.volume == 1:
            self.gif.volume = 0
            instance.text = 'mute [x]'
        else:
            self.gif.volume = 1
            instance.text = 'mute [ ]'

    def prev_btn_press(self, instance):
        for i in range(len(self.fNames_url) - 1):
            if self.gif.source == self.fNames_url[i]:
                self.gif.source = self.fNames_url[i + 1]  # prev gif
                self.popup.title = self.fNames_url[i + 1]
                self.gif.state = 'play'
                self.play_pause_btn.children[0].source = 'img/pause.png'
                self.play_pause_label.text = 'playing'
                return

    def next_btn_press(self, instance):
        for i in range(1, len(self.fNames_url)):
            if self.gif.source == self.fNames_url[i]:
                self.gif.source = self.fNames_url[i - 1]
                self.popup.title = self.fNames_url[i - 1]
                self.gif.state = 'play'
                self.play_pause_btn.children[0].source = 'img/pause.png'
                self.play_pause_label.text = 'playing'
                return

    def play_pause_btn_press(self, instance):
        if instance.children[
                0].source == 'img/pause.png':  # if pause was visible aka gif playing
            instance.children[0].source = 'img/play.png'
            self.play_pause_label.text = 'paused'
            self.gif.state = 'pause'
        elif instance.children[0].source == 'img/play.png':
            instance.children[0].source = 'img/pause.png'
            self.play_pause_label.text = 'playing'
            self.gif.state = 'play'

    def update_label(self, dt):
        self.dot_dot_label.text = '' if self.gif.state=='stop' or self.gif.state=='pause' \
                  else self.dot_dot_label.text
        if self.gif.state == 'play':
            if self.dot_dot_label.text == '':
                self.dot_dot_label.text = '.'
            elif self.dot_dot_label.text == '.':
                self.dot_dot_label.text = '..'
            elif self.dot_dot_label.text == '..':
                self.dot_dot_label.text = ''
        elif self.gif.state == 'stop':  # end of gif?
            self.play_pause_btn.children[0].source = 'img/play.png'
            self.play_pause_label.text = 'paused'
Exemplo n.º 24
0
    def entered(self):
        grid = self.children[0].children[0]
        grid.clear_widgets()

        self.books = []
        self.book_filepaths = [
            helper.get_resources_path() + "/books/" + b
            for b in os.listdir(helper.get_resources_path() + "/books/")
        ]
        self.titles = []
        if self.book_filepaths == []:
            grid.add_widget(Label(text="No books found :("))

        n = 0
        for b in self.book_filepaths:
            n += 1
            if n % 2 == 0:
                grid.height = 200 + n * 200

        n = 0
        for b in self.book_filepaths:
            n += 1

            button = Button(on_press=self.goto_read)
            button.size_hint = (None, None)
            button.size = (200, 200)
            self.children[0].children[0].add_widget(button)

            layout = BoxLayout()
            button.add_widget(layout)
            x = ((1 - (n % 2)) * 240) + 70
            y = grid.height - ((((n - 1) / 2) -
                                (((n - 1) / 2) % 1)) * 240) - 250
            layout.pos = (x, y)
            layout.size = button.size
            layout.orientation = "vertical"

            self.book_filename = b.split("/")[-1].split(".")[0]
            book = EPUBEE(b)
            cover = book.get_cover()

            if cover != "":
                cover_path = helper.get_app_path(
                ) + APP_NAME + "/covers/" + self.book_filename + ".jpeg"
                cover.save(cover_path)
                self.books.append(book)

                img = Image(source=cover_path)
                img.size_hint_x = None
                img.width = 100
                img.height = 100

            if len(book.title) > 18:
                text = book.title[:15] + "..."
            else:
                text = book.title
            self.titles.append(text)

            lbl = Label(text=text,
                        color=[.5, .5, .5, 1],
                        size_hint=(None, None),
                        pos=(button.pos[0], button.pos[1]))
            if cover != "":
                layout.add_widget(img)
                print("adding")

            layout.add_widget(lbl)
Exemplo n.º 25
0
Arquivo: test.py Projeto: yaOwner/test
class Gex(Widget):
    def __init__(self, **kwargs):
        super(Gex, self).__init__(**kwargs)
        self.name_one = TextInput(multiline=False,
                                  pos=(275, 325),
                                  size=(200, 60))
        self.add_widget(self.name_one)

        self.name_two = TextInput(multiline=False,
                                  pos=(275, 265),
                                  size=(200, 60))
        self.add_widget(self.name_two)

        self.name_three = TextInput(multiline=False,
                                    pos=(275, 205),
                                    size=(200, 60))
        self.add_widget(self.name_three)

        self.name_four = TextInput(multiline=False,
                                   pos=(275, 145),
                                   size=(200, 60))
        self.add_widget(self.name_four)

        self.wid = Widget()
        self.wid.add_widget(
            Button(text='Играть',
                   size=(140, 40),
                   pos=(305, 0),
                   on_press=self.play))
        self.add_widget(self.wid)

    def play(self, instance):
        anim = Animation(x=275, y=800, duration=0)
        anim.start(self.name_one)

        anim_two = Animation(x=275, y=800, duration=0.2)
        anim_two.start(self.name_two)

        anim_three = Animation(x=275, y=800, duration=0.2)
        anim_three.start(self.name_three)

        anim_four = Animation(x=275, y=800, duration=0.2)
        anim_four.start(self.name_four)

        anim_five = Animation(x=305, y=800, size=(140, 60), duration=0.2)
        anim_five.start(instance)

        instance.add_widget(
            Button(text='Правда или Действие?',
                   pos=(260, 235),
                   size=(200, 60),
                   on_press=self.upd))

        self.text_scrolls = []
        self.q = deque()
        while True:
            self.q.append(self.name_one.text)
            self.q.append(self.name_two.text)
            self.q.append(self.name_three.text)
            self.q.append(self.name_four.text)

    def upd(self, instance):
        self.ids['fer'].text = str(self.q.popleft())

        play = ['Правда', 'Действие']
        start = random.choice(play)
        instance.text = start

        if (start == 'Действие'):
            for i in range(1):
                self.wid = Button(text='Вопросы для действия',
                                  pos=(160, 180),
                                  size=(400, 55),
                                  on_press=self.questionAction,
                                  font_size=13)
                self.add_widget(self.wid)

        if (start == 'Правда'):
            for i in range(1):
                self.wid = Button(text='Вопросы для правды',
                                  pos=(160, 180),
                                  size=(400, 55),
                                  on_press=self.questionTruth,
                                  font_size=13)
                self.add_widget(self.wid)

    def questionAction(self, instance):
        pass

    def questionTruth(self, instance):
        pass