Ejemplo n.º 1
0
 def __init__(self, **kwargs):
     super(SettingPos, self).__init__(**kwargs)
     self.img = Image(source=self.pic)
Ejemplo n.º 2
0
        def count_it(num):
            if num == 0:
                fbo = Fbo(size=self.stencil.size, with_stencilbuffer=True)

                with fbo:
                    ClearColor(1, 1, 1, 0)
                    ClearBuffers()
                    img2 = self.paintscreen.bg.texture
                    fbo.add(self.stencil.canvas)
                    fbo.draw()
                    img = fbo.texture
                    fbo.remove(self.stencil.canvas)
                    self.remove_widget(self.paintscreen)
                    im = np.frombuffer(img.pixels, np.uint8)
                    data = np.reshape(im, (im.shape[0], 1)).tostring()

                    data2 = str(data)
                    data2 = str.encode(data2)

                    pix = np.frombuffer(data, np.uint8)
                    a = np.empty_like(pix)
                    a[:] = pix
                    texture = Texture.create(size=self.stencil.size)

                    texture.blit_buffer(a, colorfmt='rgba', bufferfmt='ubyte')
                    self.imge = Image(pos=(0, 0),
                                      size=self.paintscreen.stencil.size,
                                      texture=texture)
                    #self.paintscreen.stencil.add_widget(self.imge)

                    #img2 = self.paintscreen.grid_layout.bg.texture
                    im2 = np.frombuffer(img2.pixels, np.uint8)
                    data = np.reshape(im2, (im2.shape[0], 1)).tostring()

                    data2 = str(data)
                    data2 = str.encode(data2)

                    pix = np.frombuffer(data, np.uint8)
                    a2 = np.empty_like(pix)
                    a2[:] = pix

                    img2 = a2
                    print(img2.shape)

                    print(img2)
                    img1 = a
                    print(img1.shape)

                    import cv2
                    #setting alpha=1, beta=1, gamma=0 gives direct overlay of two images
                    # in theory this would give a direct overlay...
                    #img3 = cv2.addWeighted(img1, 1, img2, 1, 0)
                    #print(img3.shape)

                    im = img1.reshape(1200, 1200, 4)
                    for i in range(0, 1200):
                        for j in range(0, 1200):
                            points = im[i, j, :]
                            if (
                                    points[3] == 0
                            ):  #points[0] == 255 & points[1] == 255 & points[2] == 255):
                                im[i, j, :] = [255, 255, 255, 0]
                    img_2 = img2.reshape((1200, 1200, 4))
                    for i in range(0, 1200):
                        for j in range(0, 1200):
                            points1 = im[i, j, :]
                            if (points1[3] != 0):
                                img_2[i, j, :] = im[i, j, :]

                    img3 = cv2.addWeighted(img_2, 1, im, 1, 0)
                    print(img3.shape)
                    img = PIL.Image.fromarray(im, 'RGBA')
                    img.save('img_1.png')
                    img_3 = PIL.Image.fromarray(img_2, 'RGBA')
                    img_3.save('img_3.png')
                    img3 = np.reshape(
                        img3,
                        (img3.shape[0] * img3.shape[1] * img3.shape[2], ))

                    texture = Texture.create(size=(1200, 1200))

                    texture.blit_buffer(np.reshape(img_2, (1200 * 1200 * 4, )),
                                        colorfmt='rgba',
                                        bufferfmt='ubyte')
                    #print(img3.reshape(1200,1200,4))
                    #self.grid.bg.texture = texture
                    #self.paintscreen.stencil.add_widget(Image(texture=texture,size = self.paintscreen.stencil.size))

                    self.paintscreen = PaintScreen()
                    self.add_widget(self.paintscreen)
                    self.paintscreen.bg.texture = texture
                return
            num -= 1
            self.count.text = str(num)
            Clock.schedule_once(lambda dt: count_it(num), 1)
Ejemplo n.º 3
0
            def __init__(self, **kwargs):
                super(Screen_One, self).__init__(**kwargs)
                self.name = 'One'

                #Different colors convey different chip statuses
                rimg = Image(source='red.png')
                gimg = Image(source='green.png')
                yimg = Image(source='yellow.png')
                bimg = Image(source='gray.png')
                curimg = bimg

                #Do not run test by default
                killedAlready = True

                #Checks the state of .txt file
                def docheck(obj, *args):
                    checkval = 10
                    if abs(myChip.count) < checkval or keep.active == True:
                        nonlocal curimg
                        curimg = myChip.check(rimg, gimg, yimg, bimg)
                        Fimg.clear_widgets()
                        Fimg.add_widget(begEcho)
                        Fimg.add_widget(curimg)
                    else:
                        if myChip.testtime:
                            os.system('./killall_measurements')
                            myChip.testtime = False

                #Set voltage on voltage suppl(y/ies)
                def setVoltage(obj):
                    if findByID(s1, '6state1').active:
                        mySupply.setSequence('P6V',
                                             findByID(s1, '6sup1').text,
                                             mySupply.curmax)
                        time.sleep(0.2)
                    if findByID(s1, '25state1').active:
                        mySupply.setSequence('P25V',
                                             findByID(s1, '25sup1').text,
                                             mySupply.curmax)

                #Boxes that contain voltage supply-setting elements
                class Vbox(BoxLayout):
                    def __init__(self, **kwargs):
                        # make sure we aren't overriding any important functionality
                        super(Vbox, self).__init__(**kwargs)

                        with self.canvas.before:
                            Color(
                                0, .2, .3, 1
                            )  # green; colors range from 0-1 instead of 0-255
                            self.rect = Rectangle(size=self.size, pos=self.pos)

                            self.bind(size=self._update_rect,
                                      pos=self._update_rect)

                    def _update_rect(self, instance, value):
                        self.rect.pos = instance.pos
                        self.rect.size = instance.size

                #Nested layouts
                Fouter = BoxLayout(orientation='horizontal',
                                   padding=[0, 0, 0, 0])
                Finner = BoxLayout(orientation='vertical',
                                   padding=[50, 50, 50, 50],
                                   spacing=40)
                Finner2 = BoxLayout(orientation='vertical',
                                    padding=[30, 30, 30, 30],
                                    spacing=20)
                Finner3 = BoxLayout(orientation='vertical',
                                    padding=[30, 30, 30, 30],
                                    spacing=20)
                Fvwrite = BoxLayout(orientation='horizontal',
                                    padding=[0, 0, 0, 0],
                                    spacing=0,
                                    size_hint_y=None,
                                    height=45)
                #FINNER2
                #Power supply control sections
                vlay = Vbox(orientation='vertical',
                            padding=[10, 10, 10, 10],
                            spacing=10)
                vlay2 = Vbox(orientation='vertical',
                             padding=[10, 10, 10, 10],
                             spacing=10)

                #Blit voltage-controlling elements onto the screen
                def blitVolt(vallist):
                    Finner2.remove_widget(Finner3)
                    Finner3.clear_widgets()
                    vlay.clear_widgets()
                    vlay2.clear_widgets()

                    mySupply.row1 = []
                    mySupply.row2 = []
                    mySupply.rows = [mySupply.row1, mySupply.row2]

                    #Use saved voltage values if present
                    if os.path.exists('voltagelog.txt'):
                        file1 = open('voltagelog.txt', 'r')
                        i = 0
                        for value in mySupply.values:
                            mySupply.values[i] = file1.readline().rstrip()
                            i += 1

                    #Create rows
                    mySupply.addrow('+6', 0, '6sup1', '6state1',
                                    mySupply.values[0])
                    mySupply.addrow('+25', 0, '25sup1', '25state1',
                                    mySupply.values[1])
                    mySupply.addrow('-25', 0, '-25sup1', '-25state1',
                                    mySupply.values[2])
                    mySupply.addrow('+6', 1, '6sup2', '6state2',
                                    mySupply.values[3])
                    mySupply.addrow('+25', 1, '25sup2', '25state2',
                                    mySupply.values[4])
                    mySupply.addrow('-25', 1, '-25sup2', '-25state2',
                                    mySupply.values[5])

                    #Add supply 1 rows to voltage box
                    vlay.add_widget(Label(text='Supply 1'))
                    for row in mySupply.rows[0]:
                        vlay.add_widget(row)

                    #Add supply 2 rows to voltage box
                    vlay2.add_widget(Label(text='Supply 2'))
                    for row in mySupply.rows[1]:
                        vlay2.add_widget(row)

                    #Joining sections
                    Finner3.add_widget(vlay)
                    Finner3.add_widget(vlay2)
                    Finner2.add_widget(Finner3, index=2)

                #Button to set power supply settings
                initiate = Button(size_hint_y=None,
                                  height=45,
                                  text='Set Voltages',
                                  id='initiate')
                initiate.bind(on_press=setVoltage)

                #Buttons to write and read voltage values from .txt file
                write = Button(size_hint_y=None, height=45, text='Save')
                read = Button(size_hint_y=None, height=45, text='Read')
                Fvwrite.add_widget(write)
                write.bind(on_press=mySupply.save)
                Fvwrite.add_widget(read)
                read.bind(on_press=blitVolt)

                #Joining sections
                Finner2.add_widget(Finner3)
                Finner2.add_widget(initiate)
                Finner2.add_widget(Fvwrite)

                #Run manually the first time; runs again each time the read button is pushed
                blitVolt(mySupply.values)
                #FINNER1

                #Buttons to run and kill testing script
                begEcho = Button(height=10, text='Connect to Chip', id='echo')
                kill = Button(height=10,
                              text='Kill All',
                              id='kill',
                              background_color=(1, 0, 0, 1))
                begEcho.bind(on_press=myChip.keepEcho)
                kill.bind(on_press=myChip.killer)
                choose = Button(height=10, text='Choose Chip', id='choose')
                setsup = Button(height=10, text='Set Supply', id='set')
                setsup.bind(on_press=mySupply.serialSet)

                #Run check every 1/2 sec
                Clock.schedule_interval(docheck, 0.5)

                #Checkbox Section 1
                Fbox = BoxLayout(orientation='horizontal',
                                 padding=[0, 0, 0, 0])
                ck = Label(text='Bist (Not Direct)')
                bist = Switch(active=True)
                Fbox.add_widget(ck)
                Fbox.add_widget(bist)
                Finner.add_widget(Fbox)

                #Image Section
                Fimg = BoxLayout(orientation='horizontal',
                                 padding=[0, 0, 0, 0],
                                 spacing=0)
                Fimg.add_widget(begEcho)
                Fimg.add_widget(curimg)
                Finner.add_widget(Fimg)

                #Checkbox Section 2
                Fkeep = BoxLayout(orientation='horizontal',
                                  padding=[0, 0, 0, 0],
                                  spacing=0)
                clab = Label(text='Continue echo')
                keep = Switch(active=False)
                Fkeep.add_widget(clab)
                Fkeep.add_widget(keep)
                Finner.add_widget(Fkeep)

                #Joining sections
                Finner.add_widget(kill)
                Finner.add_widget(setsup)
                Finner.add_widget(choose)
                Fouter.add_widget(Finner)
                Fouter.add_widget(Finner2)
                self.add_widget(Fouter)
Ejemplo n.º 4
0
 def build(self):
     proxyImage = Loader.image(
         'http://iftucr.org/IFT/ANL_files/artistica.jpg')
     proxyImage.bind(on_load=self._image_loaded)
     self.image = Image()
     return self.image
Ejemplo n.º 5
0
 def gameover(self, reason):
     self.main_layout.remove_widget(self.gameplay)
     if reason != TIE:
         source = WIN_IMAGE
         if reason == WHITE_WIN:
             color = BLACK_WIN
         else:
             color = WHITE_WIN
         text = ' You Lose (' + color + ') '
     else:
         source = TIE_IMAGE
         text = ' potom '
     del self.GameProcessor
     self.Gameover = FloatLayout()
     self.Gameover.add_widget(
         Image(source=source,
               size_hint=(1, 1),
               pos_hint={
                   'center_x': 0.5,
                   'center_y': 0.5
               }))
     self.Gameover.add_widget(
         LabelB(bcolor=[0, 0, 0, 0],
                text=text,
                size_hint=(0.3, 1),
                pos_hint={
                    'center_x': 0.5,
                    'center_y': 0.7
                },
                color=[1, 0, 0, 1],
                font_size=160,
                font_name=FAIL))
     self.Gameover.add_widget(
         Button(text='Restart',
                color=[0, 0, 0, 1],
                on_press=self.draw_game_screen,
                background_normal='',
                background_color=[1, 0, 0, 1],
                pos_hint={
                    'center_x': 0.20,
                    'center_y': 0.15
                },
                size_hint=(0.20, 0.15)))
     self.Gameover.add_widget(
         Button(text='Quit',
                color=[0, 0, 0, 1],
                on_press=self.leave,
                background_normal='',
                background_color=[1, 0, 0, 1],
                pos_hint={
                    'center_x': 0.80,
                    'center_y': 0.15
                },
                size_hint=(0.20, 0.15)))
     self.Gameover.add_widget(
         Button(text='Main menu',
                color=[0, 0, 0, 1],
                on_press=self.back_to_start,
                background_normal='',
                background_color=[1, 0, 0, 1],
                pos_hint={
                    'center_x': 0.5,
                    'center_y': 0.15
                },
                size_hint=(0.20, 0.15)))
     self.main_layout.add_widget(self.Gameover)
     print(reason)
Ejemplo n.º 6
0
    def __init__(self, **kwargs):
        super(MyGrid, self).__init__(**kwargs)
        self.cols = 2

        self.inside = GridLayout()
        self.inside.cols = 1

        self.inside.add_widget(Label(text="Name: "))
        self.name = TextInput(multiline=False)
        self.inside.add_widget(self.name)

        self.inside.add_widget(Label(text="Distance for each eye: "))
        self.lastName = TextInput(multiline=False)
        self.inside.add_widget(self.lastName)

        self.inside.add_widget(Label(text="Distance for Both eyes: "))
        self.email = TextInput(multiline=False)
        self.inside.add_widget(self.email)

        self.inside.add_widget(Label(text="Max X Resolution: "))
        self.xres = TextInput(multiline=False)
        self.inside.add_widget(self.xres)
        
        self.name.text = ""
        self.lastName.text = "50"
        self.email.text = "1000000"
        self.xres.text = "1280"

        self.pb = ProgressBar()
        self.inside.add_widget(self.pb)

        self.inside.add_widget(Label(text=" "))
        
        self.submit = Button(text="RUN FOR RIGHT EYE", font_size=30)
        self.submit.bind(on_press=self.pressedrunright)
        self.inside.add_widget(self.submit)

        self.submit = Button(text="RUN FOR LEFT EYE", font_size=30)
        self.submit.bind(on_press=self.pressedrunleft)
        self.inside.add_widget(self.submit)

        self.submit = Button(text="RUN FOR BOTH EYE", font_size=30)
        self.submit.bind(on_press=self.pressedrune)
        self.inside.add_widget(self.submit)
        
        self.inside.add_widget(Label(text=" "))

        self.submit = Button(text="SHOW RESULTS", font_size=20)
        self.submit.bind(on_press=self.pressresults)
        self.inside.add_widget(self.submit)

        
        self.add_widget(self.inside)
##########################################################
        self.inside2 = GridLayout()
        self.inside2.cols = 3

        self.submit = Button(text="Right eye: --<.>--", font_size=20)
        self.submit.bind(on_press=self.pressedrtw)
        self.inside2.add_widget(self.submit)
        
        self.submit = Button(text="Right eye: ----->", font_size=20)
        self.submit.bind(on_press=self.pressedrtq)
        self.inside2.add_widget(self.submit)

        self.submit = Button(text="Right eye: <-----", font_size=20)
        self.submit.bind(on_press=self.pressedrte)
        self.inside2.add_widget(self.submit)

        self.image1 = Image(source='./one/right/rightmid.jpg')
        self.image1.allow_stretch= True
        #self.image.height=5000
        self.inside2.add_widget(self.image1)

        self.image2 = Image(source='./one/right/right1.jpg')
        self.image2.allow_stretch= True
        self.inside2.add_widget(self.image2)

        self.image3 = Image(source='./one/right/right2.jpg')
        self.image3.allow_stretch= True
        self.inside2.add_widget(self.image3)

        self.inside2.add_widget(Label(text=" "))
        self.inside2.add_widget(Label(text=" "))
        self.inside2.add_widget(Label(text=" "))

        Clock.schedule_interval(self.update_pic,1)

        self.submit = Button(text="Left eye: --<.>--", font_size=20)
        self.submit.bind(on_press=self.pressedlfw)
        self.inside2.add_widget(self.submit)
        
        self.submit = Button(text="Left eye: ----->", font_size=20)
        self.submit.bind(on_press=self.pressedlfq)
        self.inside2.add_widget(self.submit)

        self.submit = Button(text="Left eye: <-----", font_size=20)
        self.submit.bind(on_press=self.pressedlfe)
        self.inside2.add_widget(self.submit)

        self.image4 = Image(source='./one/left/leftmid.jpg')
        self.inside2.add_widget(self.image4)

        self.image5 = Image(source='./one/left/left1.jpg')
        self.inside2.add_widget(self.image5)

        self.image6 = Image(source='./one/left/left2.jpg')
        self.inside2.add_widget(self.image6)

        self.inside2.add_widget(Label(text=" "))
        self.inside2.add_widget(Label(text=" "))
        self.inside2.add_widget(Label(text=" "))

        Clock.schedule_interval(self.update_pic,1)

        self.submit = Button(text="Both eyes: --<.>--", font_size=20)
        self.submit.bind(on_press=self.pressedbmd)
        self.inside2.add_widget(self.submit)
        
        self.submit = Button(text="Both eye: ----->", font_size=20)
        self.submit.bind(on_press=self.pressedbrt)
        self.inside2.add_widget(self.submit)

        self.submit = Button(text="Both eye: <-----", font_size=20)
        self.submit.bind(on_press=self.pressedblf)
        self.inside2.add_widget(self.submit)

        self.image7 = Image(source='./both/bmd.jpg')
##        self.image.size_hint_y= None
##        self.image.size_hint_x= None
##        self.image.width=100
##        self.image.height=50
##        self.image.allow_stretch= True
##        #self.image.height=5000
        self.inside2.add_widget(self.image7)

        self.image8 = Image(source='./both/brt.jpg')
        self.inside2.add_widget(self.image8)

        self.image9 = Image(source='./both/blf.jpg')
        self.inside2.add_widget(self.image9)

        Clock.schedule_interval(self.update_pic,1)
        
        self.add_widget(self.inside2)   
Ejemplo n.º 7
0
 def build(self):
     return Image(source='image.png')
Ejemplo n.º 8
0
    def build(self):
        # Label
        label = Label(text='This is Batman.',
                      font_size='20sp',
                      bold=True,
                      color=(1, 1, 1, 1))

        # ---------------------------------------------------------------------
        card = MDCard()

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

        # Button                                    widht, height
        button = Button(text='Print this',
                        size_hint=(0.15, 0.15),
                        font_size='20sp',
                        pos_hint={
                            'center_x': 0.5,
                            'center_y': 0.5
                        },
                        on_press=self.printpress,
                        on_release=self.printrelease)

        # DEFAULT: HORIZONTAL
        btn1 = Button(text='Button1')
        btn2 = Button(text='Button2')
        btn3 = Button(text='Button3')

        layout_button = BoxLayout(orientation='vertical',
                                  spacing=10,
                                  padding=10)
        layout_button.add_widget(btn1)
        layout_button.add_widget(btn2)
        layout_button.add_widget(btn3)

        return layout_button

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

        # Images + Box Layout
        img = Image(source='cute.png')
        btn_img = Button(text='Login',
                         size_hint=(None, None),
                         width=100,
                         height=50,
                         pos_hint={'center_x': 0.5})

        layout_img = BoxLayout(orientation='vertical', spacing=100, padding=50)
        layout_img.add_widget(img)
        layout_img.add_widget(btn_img)

        # return layout_img

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

        # Grid System

        layout_grid = GridLayout(cols=2,
                                 row_force_default=True,
                                 row_default_height=40)
        btn1_grid = Button(text='Hello 1',
                           size_hint=(None, None),
                           width=100,
                           height=40)
        btn2_grid = Button(text='World 1')

        btn3_grid = Button(text='Hello 2',
                           size_hint=(None, None),
                           width=100,
                           height=40)
        btn4_grid = Button(text='World 2')

        layout_grid.add_widget(btn1_grid)
        layout_grid.add_widget(btn2_grid)
        layout_grid.add_widget(btn3_grid)
        layout_grid.add_widget(btn4_grid)

        # return layout_grid

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

        # Text Input
        self.weight = TextInput(text='Enter Weight Here')
        self.height = TextInput(text='Enter Height Here')

        button_input = Button(text='Submit', on_press=self.submit)

        layout_input = GridLayout(cols=2,
                                  row_force_default=True,
                                  row_default_height=40,
                                  spacing=10,
                                  padding=20)

        layout_input.add_widget(self.weight)
        layout_input.add_widget(self.height)
        layout_input.add_widget(button_input)
Ejemplo n.º 9
0
def build_page(layout, page):
    layout.clear_widgets()
    links.clear()  # TODO: will prevent iframe functionality to work
    for id, item in page.iteritems():  # create instances (ids)
        if item['type'] == 'button':
            wgt = Button()
            if Preferences.theme != 'default':
                wgt.background_normal = os.path.join(util.dir_theme,
                                                     Preferences.theme,
                                                     'btn_normal.png')
                wgt.background_down = os.path.join(util.dir_theme,
                                                   Preferences.theme,
                                                   'btn_down.png')
                wgt.color = Preferences.foreground
                wgt.border = [0, 0, 0, 0]
        elif item['type'] == 'label':
            wgt = Label()
            if Preferences.theme != 'default':
                wgt.color = Preferences.foreground
        elif item['type'] == 'image':
            img_path = os.path.join(util.dir_img, item['source'])
            wgt = Image(source=img_path)
        elif item['type'] == 'textinput':
            wgt = TextInput()
        elif item['type'] == 'var-label':
            wgt = VariableLabel()
        elif item['type'] == 'led':
            wgt = Led()
        elif item['type'] == 'thermometer':
            wgt = Thermometer()
        elif item['type'] == 'manometer':
            wgt = Manometer()
        elif item['type'] == 'edit-grid':
            wgt = EditGrid()
            wgt.set_dimenstion(item['rows'], item['cols'])
        elif item['type'] == 'simul-grid':
            wgt = SimulGrid()
            wgt.set_dimenstion(item['rows'], item['cols'])
            wgt.build_network()
            Simulator.set_grid(wgt)
        elif item['type'] == 'graph':
            wgt = Graph()
        elif item['type'] == 'DatePicker':
            wgt = DatePicker()
        elif item['type'] == 'GraphLabel':
            wgt = GraphLabel()
        else:
            print 'Unknown component ' + item['type']
            return
        wgt.id = id
        layout.add_widget(wgt)
    for id, item in page.iteritems():  # now can use references (id)
        wgt = get_widget(id)
        if 'text' in item:
            wgt.text = item['text']
        if 'font_size' in item:
            wgt.font_size = item['font_size']
        if 'pos' in item:
            wgt.pos = eval(item['pos'])
        if 'size' in item:
            wgt.size = eval(item['size'])
        if 'pos_hint' in item:
            wgt.pos_hint = item['pos_hint']
        if 'size_hint' in item:
            wgt.size_hint = eval(item['size_hint'])
        if 'link' in item:
            links[wgt.id] = item['link']
            wgt.bind(on_press=navigate)
        if 'click' in item:
            wgt.bind(on_press=eval(item['click']))
        if 'halign' in item:
            wgt.halign = item['halign']
        if 'multiline' in item:
            wgt.multiline = item['multiline']
        if 'validate' in item:
            wgt.bind(on_text_validate=eval(item['validate']))
        if 'variable' in item:
            wgt.set_var(item['variable'])
        if 'listener' in item:
            listeners = item['listener'].split(',')
            for listener in listeners:
                wgt.append_listener(get_widget(listener.strip()))
        if 'markup' in item:
            wgt.markup = item['markup']
Ejemplo n.º 10
0
    def start(self, event):
        try:
            self.capture.release()
        except:
            pass
        self.main_layout = BoxLayout(orientation="vertical")
        self.counter = 0
        self.prev = ''
        self.net = cv2.dnn.readNet('yolov3.weights', 'yolov3.cfg')
        self.clear_widgets()
        self.title = "KivyMD Examples - Progress Loader"

        self.Start = True
        try:
            if self.find != '':
                self.find = self.find
            else:
                self.find = ''
        except:
            self.find = ''
        self.text_input = TextInput(multiline=False,
                                    size_hint=(1, 0.1 * (self.font_size / 20)),
                                    font_size=self.font_size,
                                    pos_hint={
                                        'center_x': 0.5,
                                        'center_y': 0.95
                                    })
        self.text_input.bind(text=self.on_text)
        self.text_input_1 = TextInput(multiline=False,
                                      size_hint=(1,
                                                 0.1 * (self.font_size / 20)),
                                      font_size=self.font_size,
                                      pos_hint={
                                          'center_x': 0.5,
                                          'center_y': 0.95
                                      })
        self.text_input_1.bind(text=self.on_text)
        self.text_input_2 = TextInput(multiline=False,
                                      size_hint=(1,
                                                 0.1 * (self.font_size / 20)),
                                      font_size=self.font_size,
                                      pos_hint={
                                          'center_x': 0.5,
                                          'center_y': 0.95
                                      })
        self.text_input_2.bind(text=self.on_text)
        self.text_input_4 = TextInput(multiline=False,
                                      size_hint=(1,
                                                 0.1 * (self.font_size / 20)),
                                      font_size=self.font_size,
                                      pos_hint={
                                          'center_x': 0.5,
                                          'center_y': 0.95
                                      })
        self.text_input_4.bind(text=self.on_text)
        self.second = Button(text="Second")
        self.final = Label(text="Hello World")
        self.single = False
        self.lab = 'Показывать один объект'
        self.img1 = Image(size_hint=(2, 2),
                          pos_hint={
                              'center_x': 0.5,
                              'center_y': 0.8
                          })

        self.btn = Button(text=self.translator.translate("Aloud"),
                          font_size=self.font_size,
                          background_color=(1, 1, 1, 1),
                          color=(1, 1, 1, 1),
                          size=(32, 32),
                          size_hint=(.2, .5),
                          pos=(300, 300))

        self.btn.bind(on_press=self.callback_1)

        self.btn_2 = ToggleButton(text=self.translator.translate('One'),
                                  font_size=self.font_size,
                                  background_color=(1, 1, 1, 1),
                                  color=(1, 1, 1, 1),
                                  size=(32, 32),
                                  size_hint=(.2, .5),
                                  pos=(300, 250))
        self.btn_3 = ToggleButton(text=self.translator.translate('Fast'),
                                  font_size=self.font_size,
                                  background_color=(1, 1, 1, 1),
                                  color=(1, 1, 1, 1),
                                  size=(32, 32),
                                  size_hint=(.2, .5),
                                  pos=(300, 250))
        self.fast = False
        self.btn_2.bind(on_press=self.callback_2)

        self.btn_3.bind(on_press=self.callback_3)
        self.first = Button(text=self.translator.translate("Look for"),
                            font_size=self.font_size,
                            background_color=(1, 1, 1, 1),
                            color=(1, 1, 1, 1),
                            size=(32, 32),
                            size_hint=(.2, .5),
                            pos=(20, 25))

        if self.find:
            self.btn5 = Button(text=self.translator.translate(
                'Look for {}'.format(self.find)),
                               background_color=(0, 1, 1, 1),
                               font_size=self.font_size,
                               color=(1, 1, 1, 1),
                               size_hint_y=None,
                               height=40)
        else:
            self.btn5 = Button(text=self.translator.translate('Exit'),
                               background_color=(0, 1, 1, 1),
                               color=(1, 1, 1, 1),
                               font_size=self.font_size,
                               size_hint_y=None,
                               height=40)
        self.btn5.bind(on_press=self.start)
        if self.find:
            self.btn_5 = Button(text=self.translator.translate(
                'Look for {}'.format(self.find)),
                                background_color=(0, 1, 1, 1),
                                color=(1, 1, 1, 1),
                                font_size=self.font_size,
                                size_hint_y=None,
                                height=40)
        else:
            self.btn_5 = Button(text=self.translator.translate('Exit'),
                                background_color=(0, 1, 1, 1),
                                color=(1, 1, 1, 1),
                                font_size=self.font_size,
                                size_hint_y=None,
                                height=40)
        self.btn_5.bind(on_press=self.start)
        self.first.bind(on_press=self.show_second)
        self.capture = cv2.VideoCapture(0)

        self.bind(on_load=self.cb_loaded)
        self.matches = []
        self.main_layout = BoxLayout(orientation="vertical")
        self.main_layout_1 = BoxLayout(orientation="horizontal")
        if not self.find:
            self.clear_widgets()
            self.main_layout.clear_widgets()
            self.main_layout.add_widget(self.img1)
            self.main_layout_1.add_widget(self.btn)
            self.main_layout_1.add_widget(self.btn_2)
            self.main_layout_1.add_widget(self.first)
            self.main_layout_1.add_widget(self.btn_3)
            self.main_layout.add_widget(self.main_layout_1)
            self.add_widget(self.main_layout)
            self.btn8 = Button(text=self.translator.translate('Main'),
                               background_color=(0, 1, 1, 1),
                               color=(1, 1, 1, 1),
                               size_hint_y=None,
                               height=40,
                               font_size=self.font_size)
            self.btn8.bind(on_press=self.__init__)
            self.main_layout.add_widget(self.btn8)
            Clock.schedule_interval(self.update, 1.0 / 33.0)
        else:
            if self.Start:
                self.clear_widgets()
                self.main_layout.clear_widgets()
                self.Stop = False
                self.p = 0
                self.btn_6 = Button(text=self.translator.translate('Finish'),
                                    background_color=(1, 1, 1, 1),
                                    color=(1, 1, 1, 1),
                                    font_size=self.font_size,
                                    size_hint_y=None,
                                    height=40)
                self.btn_6.bind(on_press=self.stop)
                self.net = cv2.dnn.readNet('yolov3.weights', 'yolov3.cfg')
                self.clear_widgets()
                self.main_layout.add_widget(self.img1)
                self.main_layout.add_widget(self.btn_6)
                self.add_widget(self.main_layout)
                Clock.schedule_interval(self.update, 1.0 / 33.0)
Ejemplo n.º 11
0
    def update(self, dt):
        # display image from cam in opencv window
        global counter, meme_counter, meme, alarm, lookaway, memescreen, alarm_sound, notif_sound, meme_threshold, lookaway_threshold
        ret, frame = self.capture.read()
        cv2.imshow("CV2 Image", frame)
        # convert it to texture
        buf1 = cv2.flip(frame, 0)
        buf = buf1.tostring()
        texture1 = Texture.create(size=(frame.shape[1], frame.shape[0]),
                                  colorfmt='bgr')
        texture1.blit_buffer(buf, colorfmt='bgr', bufferfmt='ubyte')
        # display image from the texture
        self.img1.texture = texture1

        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

        faces = face_cascade.detectMultiScale(gray, 1.3, 5)

        # display meme
        if (meme):
            ## load meme here
            idx = random.randint(0, 4)
            meme_src = src_path + meme_dict[idx]
            box = BoxLayout(padding=10, orientation='vertical')
            subbox1 = BoxLayout(padding=10, size_hint=(1, 0.8))
            subbox2 = BoxLayout(padding=10, size_hint=(1, 0.2))

            subbox1.add_widget(Image(source=meme_src))
            dismiss_btn = Button(text='Back to work!')

            subbox2.add_widget(dismiss_btn)

            box.add_widget(subbox1)
            box.add_widget(subbox2)
            popup = Popup(title='MEME', content=box, size=(400, 400))

            dismiss_btn.bind(on_press=popup.dismiss)
            popup.open()

            # play sound. set to repeat on half the length.
            if (notif_sound):
                notif_sound.play()
            print("meme loaded!")
            meme = False
            meme_counter = meme_counter / 2

        # play alarm noise. repeat every half length
        if (alarm):
            print("WAKE UP!")
            if (alarm_sound):
                alarm_sound.play()
            alarm = False
            counter = counter / 2

        if (lookaway):
            counter += 1
            print("lookaway:", counter)

        ## find faces. find eyes and smiles within faces.
        for (x, y, w, h) in faces:
            roi_gray = gray[y:y + h, x:x + w]
            roi_color = frame[y:y + h, x:x + w]

            eyes = eye_cascade.detectMultiScale(roi_gray)
            eyes = list(eyes)

            smile = smile_cascade.detectMultiScale(roi_gray, 1.8, 8)
            smile = list(smile)

            if (len(eyes) == 2):
                for (ex, ey, ew, eh) in eyes:
                    #print("eyes")
                    cv2.rectangle(roi_color, (ex, ey), (ex + ew, ey + eh),
                                  (0, 255, 0), 2)
                counter = 0

            if (len(smile) >= 1):
                for (sx, sy, sw, sh) in smile:
                    cv2.rectangle(roi_color, (sx, sy), (sx + sw, sy + sh),
                                  (0, 0, 255), 2)
                meme_counter = 0
                meme = False

            else:
                if (len(eyes) > 1):
                    if (memescreen):
                        print("meme counter: ", meme_counter)
                        meme_counter += 1
                    #print(meme_counter)

        if (lookaway):
            if (counter > lookaway_threshold):
                alarm = True

        if (memescreen):
            if (meme_counter > meme_threshold):
                print("Loading meme... ")
                meme = True
Ejemplo n.º 12
0
    def winner(self, obj):
        pdata = ""
        title = ""

        sound = SoundLoader.load("sound/Sax.ogg")
        box = BoxLayout(orientation="vertical")
        box.add_widget(
            Image(
                source='images/gamepad3.png',
                allow_stretch=False,
                keep_ratio=False,
            ))
        if lista == standx or listb == standx or listc == standx or listd == standx or liste == standx or listf == standx or listg == standx or listh == standx:
            pdata = "[color=00ff00]Game over[/color]: [color=0000ff] player 1 win[/color]"
            title = "Congratulations player1"
            lb1 = Label(text=pdata, markup=True, font_size=25)
            lb1.font_name = "fonts/DroidSans-Bold.ttf"
            lb1.bold = True
            butt1 = Button(text="Play Again")
            box.add_widget(lb1)
            box.add_widget(butt1)
            content2 = box
            popup = Popup(title=title,
                          content=content2,
                          size_hint=(None, None),
                          size=(400, 400))

            popup.background = "images/au.jpg"
            popup.title_size = 30

            popup.title_color = [1, 1, 0, 1]
            popup.title_font = "fonts/actionis.ttf"
            butt1.background_color = [1, 1, 0, 1]
            butt1.bind(on_release=self.reset)
            butt1.bind(on_release=popup.dismiss)

            popup.open()
            anim = Animation(x=50) + Animation(size=(300, 300), duration=2.)
            anim.start(popup)

            sound.play()
            Clock.unschedule(self.winner, .1)
            lista.clear(), listb.clear(), listc.clear(), listd.clear(
            ), liste.clear(), listf.clear(), listg.clear(), listh.clear()

        elif lista == stando or listb == stando or listc == stando or listd == stando or liste == stando or listf == stando or listg == stando or listh == stando:
            pdata = "[color=00ff00]Game over[/color]:[color=ff0000] player 2 win[/color]"
            title = "Congratulations player2"
            lb1 = Label(text=pdata, markup=True, font_size=25)
            lb1.font_name = "fonts/DroidSans-Bold.ttf"
            lb1.bold = True
            butt1 = Button(text="Play Again")
            box.add_widget(lb1)
            box.add_widget(butt1)
            content2 = box
            popup = Popup(title=title,
                          content=content2,
                          size_hint=(None, None),
                          size=(400, 400))

            popup.background = "images/au.jpg"
            popup.title_size = 30

            popup.title_color = [1, 1, 0, 1]
            popup.title_font = "fonts/actionis.ttf"
            butt1.background_color = [1, 1, 0, 1]

            butt1.bind(on_release=self.reset)
            butt1.bind(on_release=popup.dismiss)

            popup.open()
            anim = Animation(x=50) + Animation(size=(300, 300), duration=2.)
            anim.start(popup)

            sound.play()
            lista.clear(), listb.clear(), listc.clear(), listd.clear(
            ), liste.clear(), listf.clear(), listg.clear(), listh.clear()

        elif self.ids.click1.disabled == True and self.ids.click2.disabled == True and self.ids.click3.disabled == True and self.ids.click4.disabled == True and self.ids.click5.disabled == True and self.ids.click6.disabled == True and self.ids.click7.disabled == True and self.ids.click8.disabled == True and self.ids.click9.disabled == True:

            pdata = "[color=00ff00]Game over[/color]: [color=f0ff00] Drwa [/color]"
            title = "No Winner"
            lb1 = Label(text=pdata, markup=True, font_size=25)
            lb1.font_name = "fonts/DroidSans-Bold.ttf"
            lb1.bold = True
            butt1 = Button(text="Play Again")
            box.add_widget(lb1)
            box.add_widget(butt1)
            content2 = box
            popup = Popup(title=title,
                          content=content2,
                          size_hint=(None, None),
                          size=(400, 400))

            popup.background = "images/au.jpg"
            popup.title_size = 30

            popup.title_color = [1, 1, 0, 1]
            popup.title_font = "fonts/actionis.ttf"
            butt1.background_color = [1, 1, 0, 1]

            butt1.bind(on_release=self.reset)
            butt1.bind(on_release=popup.dismiss)

            popup.open()
            anim = Animation(x=50) + Animation(size=(300, 300), duration=2.)
            anim.start(popup)

            sound.play()
            lista.clear(), listb.clear(), listc.clear(), listd.clear(
            ), liste.clear(), listf.clear(), listg.clear(), listh.clear()
class CustomLayout(GridLayout):
	background_image = ObjectProperty(
		Image(
			source="F:/Anaconda3/share/kivy-examples/widgets/sequenced_images/data/images/button_white_animated.zip",
			anim_delay=0.1))
Ejemplo n.º 14
0
 def on_touch_up(self, touch):
     super(OppBenchBenchPokemonInnerBoxLayout, self).on_touch_down(touch)
     self.clear_widgets()
     Board_changer.Board_CL()[Board_changer.Board_CL(
     ).board_dic.index("POKEMON_P_1"), 0] = [{
         'artist':
         'Mizue',
         'attacks': [{
             'convertedEnergyCost':
             1,
             'cost': ['Colorless'],
             'damage':
             '',
             'name':
             'Sharp Blade Quill',
             'text':
             "This attack does 20 damage to 1 of your opponent's Pokémon. (Don't apply Weakness and Resistance for Benched Pokémon.)"
         }, {
             'convertedEnergyCost':
             3,
             'cost': ['Grass', 'Colorless', 'Colorless'],
             'damage':
             '50+',
             'name':
             'Leaf Blade',
             'text':
             'Flip a coin. If heads, this attack does 20 more damage.'
         }],
         'evolvesFrom':
         'Rowlet',
         'hp':
         '80',
         'id':
         'sm1-10',
         'imageUrl':
         'https://images.pokemontcg.io/sm1/10.png',
         'imageUrlHiRes':
         'https://images.pokemontcg.io/sm1/10_hires.png',
         'name':
         'Dartrix',
         'nationalPokedexNumber':
         723,
         'number':
         '10',
         'rarity':
         'Uncommon',
         'retreatCost': ['Colorless'],
         'series':
         'Sun & Moon',
         'set':
         'Sun & Moon',
         'setCode':
         'sm1',
         'subtype':
         'Stage 1',
         'supertype':
         'Pokémon',
         'types': ['Grass'],
         'weaknesses': [{
             'type': 'Fire',
             'value': '×2'
         }]
     }]
     Board_changer.Board_CL()[Board_changer.Board_CL(
     ).board_dic.index("POKEMON_P_1"), 1] = [{
         'artist':
         'Mizue',
         'attacks': [{
             'convertedEnergyCost':
             1,
             'cost': ['Colorless'],
             'damage':
             '',
             'name':
             'Sharp Blade Quill',
             'text':
             "This attack does 20 damage to 1 of your opponent's Pokémon. (Don't apply Weakness and Resistance for Benched Pokémon.)"
         }, {
             'convertedEnergyCost':
             3,
             'cost': ['Grass', 'Colorless', 'Colorless'],
             'damage':
             '50+',
             'name':
             'Leaf Blade',
             'text':
             'Flip a coin. If heads, this attack does 20 more damage.'
         }],
         'evolvesFrom':
         'Rowlet',
         'hp':
         '80',
         'id':
         'sm1-10',
         'imageUrl':
         'https://images.pokemontcg.io/sm1/10.png',
         'imageUrlHiRes':
         'https://images.pokemontcg.io/sm1/10_hires.png',
         'name':
         'Dartrix',
         'nationalPokedexNumber':
         723,
         'number':
         '10',
         'rarity':
         'Uncommon',
         'retreatCost': ['Colorless'],
         'series':
         'Sun & Moon',
         'set':
         'Sun & Moon',
         'setCode':
         'sm1',
         'subtype':
         'Stage 1',
         'supertype':
         'Pokémon',
         'types': ['Grass'],
         'weaknesses': [{
             'type': 'Fire',
             'value': '×2'
         }]
     }]
     for i in range(
             1,
             len(Board_changer.Board_CL()[
                 Board_changer.Board_CL().board_dic.index("POKEMON_P_1")])):
         if Board_changer.Board_CL()[
                 Board_changer.Board_CL().board_dic.index("POKEMON_P_1"),
                 i] == []:
             break
         name_i = "POKEMON_P_1_" + str(i)
         box = OppBenchBenchPokemonIndividualBoxLayout(
             id=name_i,
             name=name_i,
             card_text_list=Board_changer.Board_CL()
             [Board_changer.Board_CL().board_dic.index("POKEMON_P_1"), i])
         self.add_widget(box)
         img_i = Board_changer.Board_CL()[Board_changer.Board_CL(
         ).board_dic.index("POKEMON_P_1"), i, -1, "id"] + ".png"
         self.children[i - 1].add_widget(
             Image(source=img_i, name=img_i, id=img_i))
Ejemplo n.º 15
0
 def build(self):
   return Image(source='cc-cloud.png')
Ejemplo n.º 16
0
    def build(self):
        self.first = [12, 10]
        self.second = [13, 10]
        self.sm = ScreenManager()
        screen = Screen(name="select_character")
        self.helth_1 = 5
        self.helth_2 = 5
        self.helth_1_label = Label(text="1 health: " + str(self.helth_1),
                                   pos=(0, 0),
                                   size=(200, 100))
        self.helth_2_label = Label(text="2 health: " + str(self.helth_2),
                                   pos=(1300, 0),
                                   size=(200, 100))
        self.hod = 0
        self.oh = 0
        self.prep = [[13, 12], [13, 13], [13, 14], [2, 7], [11, 20], [13, 5],
                     [14, 16], [10, 16], [12, 7], [9, 8], [11, 5], [8, 7],
                     [12, 12], [7, 6], [7, 7], [7, 8], [8, 9], [9, 8], [4, 7],
                     [14, 6], [12, 14], [6, 9], [12, 14], [14, 15], [14, 29],
                     [10, 30]]
        self.title = ""
        f = Widget()
        self.i = 0
        button = GridLayout(cols=30)
        button.size = (1500, 750)
        self.button = [0 for _ in range(450)]
        self.a = list()
        for y in range(15):
            self.a.append(list())
            for x in range(30):
                if ([y, x] in self.prep):
                    self.a[y].append(str(y * 30 + x) + "g")
                else:
                    self.a[y].append(str(y * 30 + x))
        self.mas = list()
        for i in range(450):
            t = True
            for j in self.prep:
                if (int(i / 30) == j[0] and int(i % 30) == j[1]):
                    print(1)
                    self.mas.append(
                        Button(text='',
                               on_press=self.callback_press,
                               id=str(i),
                               background_color=[0.0, 2.0, 0, 1.0]))
                    t = False
                    break
            if (t):
                self.mas.append(
                    Button(text='',
                           on_press=self.callback_press,
                           id=str(i),
                           background_color=[1.0, 0.0, 0, 1.0]))
            button.add_widget(self.mas[i])
        self.a[12][10] = "370r"
        self.a[13][10] = "400b"
        self.img = Image(source='1.jpg')
        self.img.size = (50, 50)
        self.img.pos = (10 * 50, 2 * 50)
        self.img2 = Image(source='2.jpg')
        self.img2.size = (50, 50)
        self.img2.pos = (10 * 50, 1 * 50)
        self.img_win_1 = Image(source='3.png')
        self.img_win_1.size = (1200, 600)

        self.img_win_1.pos = (1212, 1313)
        self.img_win_2 = Image(source='4.png')
        self.img_win_2.size = (1200, 600)
        self.img_win_2.pos = (1212, 1313)
        f.add_widget(button)
        f.add_widget(self.img)
        f.add_widget(self.img2)
        f.add_widget(self.img_win_1)
        f.add_widget(self.img_win_2)
        f.add_widget(self.helth_1_label)
        f.add_widget(self.helth_2_label)
        f.add_widget(screen)
        return f
Ejemplo n.º 17
0
    def build(self):
        img = Image(source='kivy.jpg',
                    size_hint=(1, .5),
                    pos_hint={'center_x':.5, 'center_y':.5})
 
        return img
    def __init__(self, resultado: LineaResultado, fase, nrodefase: Fase,
                 **kwargs):
        super(TabbedPanelItemResultados, self).__init__(**kwargs)
        self.text = f"Fase {nrodefase}"
        content = BoxLayout(padding=gridpadding)
        # content = BoxLayout(halign='left', valign="middle")
        content.orientation = 'vertical'
        content.add_widget(
            Label(text=f"{fase.nombre}", size_hint=(1.0, None), height=20))
        content.add_widget(
            Label(text="Captura de usuario:", size_hint=(1.0, None),
                  height=20))

        grid = GridLayout(
            cols=2,
            row_force_default=True,
            row_default_height=40,
            size_hint=(1.0, None),
            height=240,
            spacing=5,
            padding=gridpadding,
        )
        label = Label(text="Rostro", size_hint=(None, 1), width=100)
        with label.canvas.before:
            Color(firstrowcolor[0], firstrowcolor[1], firstrowcolor[2])
            label.rect = Rectangle(size=self.size, pos=self.pos)
        label.bind(pos=WidgetCreator.update_rect,
                   size=WidgetCreator.update_rect)
        grid.add_widget(label)

        rostro = BoxLayout(orientation='horizontal')
        rostro.add_widget(Label(text=resultado.captura.rostro.name))
        rostro.add_widget(
            Image(size_hint=(None, 0.9),
                  width=40,
                  source=SelectorDeIconos.iconoderostro(
                      resultado.captura.rostro)))
        with rostro.canvas.before:
            Color(firstrowcolor[0], firstrowcolor[1], firstrowcolor[2])
            rostro.rect = Rectangle(size=self.size, pos=self.pos)
        rostro.bind(pos=WidgetCreator.update_rect,
                    size=WidgetCreator.update_rect)
        grid.add_widget(rostro)

        label = Label(text="Mirada", size_hint=(None, 1), width=100)
        with label.canvas.before:
            Color(secondrowcolor[0], secondrowcolor[1], secondrowcolor[2])
            label.rect = Rectangle(size=self.size, pos=self.pos)
        label.bind(pos=WidgetCreator.update_rect,
                   size=WidgetCreator.update_rect)
        grid.add_widget(label)

        mirada = BoxLayout(orientation='horizontal')
        mirada.add_widget(Label(text=resultado.captura.mirada.name))
        mirada.add_widget(
            Image(size_hint=(None, 0.9),
                  width=40,
                  source=SelectorDeIconos.iconodemirada(
                      resultado.captura.mirada)))
        with mirada.canvas.before:
            Color(secondrowcolor[0], secondrowcolor[1], secondrowcolor[2])
            mirada.rect = Rectangle(size=self.size, pos=self.pos)
        mirada.bind(pos=WidgetCreator.update_rect,
                    size=WidgetCreator.update_rect)
        grid.add_widget(mirada)

        label = Label(text="Cabeza", size_hint=(None, 1), width=100)
        with label.canvas.before:
            Color(firstrowcolor[0], firstrowcolor[1], firstrowcolor[2])
            label.rect = Rectangle(size=self.size, pos=self.pos)
        label.bind(pos=WidgetCreator.update_rect,
                   size=WidgetCreator.update_rect)
        grid.add_widget(label)

        cabeza = BoxLayout(orientation='horizontal')
        cabeza.add_widget(Label(text=resultado.captura.cabeza.name))
        cabeza.add_widget(
            Image(size_hint=(None, 0.9),
                  width=40,
                  source=SelectorDeIconos.iconodecabeza(
                      resultado.captura.cabeza)))
        with cabeza.canvas.before:
            Color(firstrowcolor[0], firstrowcolor[1], firstrowcolor[2])
            cabeza.rect = Rectangle(size=self.size, pos=self.pos)
        cabeza.bind(pos=WidgetCreator.update_rect,
                    size=WidgetCreator.update_rect)
        grid.add_widget(cabeza)

        label = Label(text="Brazos", size_hint=(None, 1), width=100)
        with label.canvas.before:
            Color(secondrowcolor[0], secondrowcolor[1], secondrowcolor[2])
            label.rect = Rectangle(size=self.size, pos=self.pos)
        label.bind(pos=WidgetCreator.update_rect,
                   size=WidgetCreator.update_rect)
        grid.add_widget(label)

        brazos = BoxLayout(orientation='horizontal')
        brazos.add_widget(Label(text=resultado.captura.posicionbrazos.name))
        brazos.add_widget(
            Image(size_hint=(None, 0.9),
                  width=40,
                  source=SelectorDeIconos.iconodebrazos(
                      resultado.captura.posicionbrazos)))
        with brazos.canvas.before:
            Color(secondrowcolor[0], secondrowcolor[1], secondrowcolor[2])
            brazos.rect = Rectangle(size=self.size, pos=self.pos)
        brazos.bind(pos=WidgetCreator.update_rect,
                    size=WidgetCreator.update_rect)
        grid.add_widget(brazos)

        label = Label(text="Volumen de Voz", size_hint=(None, 1), width=100)
        with label.canvas.before:
            Color(firstrowcolor[0], firstrowcolor[1], firstrowcolor[2])
            label.rect = Rectangle(size=self.size, pos=self.pos)
        label.bind(pos=WidgetCreator.update_rect,
                   size=WidgetCreator.update_rect)
        grid.add_widget(label)

        volumen = BoxLayout(orientation='horizontal')
        volumen.add_widget(Label(text=str(resultado.captura.volumendevoz)))
        volumen.add_widget(
            Image(size_hint=(None, 0.9),
                  width=40,
                  source=SelectorDeIconos.iconodevolumen(
                      resultado.captura.volumendevoz)))
        with volumen.canvas.before:
            Color(firstrowcolor[0], firstrowcolor[1], firstrowcolor[2])
            volumen.rect = Rectangle(size=self.size, pos=self.pos)
        volumen.bind(pos=WidgetCreator.update_rect,
                     size=WidgetCreator.update_rect)
        grid.add_widget(volumen)

        label = Label(text="Palabras por minuto",
                      size_hint=(None, 1),
                      width=100)
        with label.canvas.before:
            Color(secondrowcolor[0], secondrowcolor[1], secondrowcolor[2])
            label.rect = Rectangle(size=self.size, pos=self.pos)
        label.bind(pos=WidgetCreator.update_rect,
                   size=WidgetCreator.update_rect)
        grid.add_widget(label)

        velocidad = BoxLayout(orientation='horizontal')
        velocidad.add_widget(
            Label(text=str(resultado.captura.palabrasporsegundo)))
        velocidad.add_widget(
            Image(size_hint=(None, 0.9),
                  width=40,
                  source=SelectorDeIconos.iconodevelocidad(
                      resultado.captura.palabrasporsegundo)))
        with velocidad.canvas.before:
            Color(secondrowcolor[0], secondrowcolor[1], secondrowcolor[2])
            velocidad.rect = Rectangle(size=self.size, pos=self.pos)
        velocidad.bind(pos=WidgetCreator.update_rect,
                       size=WidgetCreator.update_rect)
        grid.add_widget(velocidad)

        content.add_widget(grid)

        box = BoxLayout()
        box.add_widget(
            Label(text=f"Interpretación: {resultado.interpretacion.lectura}",
                  size_hint=(1.0, None),
                  height=20))
        content.add_widget(box)

        scrollableInfo = ScrollView(size_hint=(1.0, 1.0))
        scrollableInfo.add_widget(
            Label(text=f"{resultado.interpretacion.masinfo}"))
        content.add_widget(scrollableInfo)
        self.add_widget(content)
Ejemplo n.º 19
0
 def build(self):
     print('Building main view')
     self.title = 'Persimmon'
     self.background = Image(source='persimmon/background.png').texture
Ejemplo n.º 20
0
    def set_page(self, task, result, result_type='text', footer='time'):
        '''Creates a :mod:`main.PageBox` for a result. The header consists of the
        :ref:`task`'s name, the footer is by default the time when the result
        was created and the content depends on `result_type` which can be -
        text, image(path to image) or widget. If `result_type == 'widget'`,
        result has to be an instance of a widget (obviously containing the
        output), e.g.::

            b = Button(text='my output')
            set_page('MyTask', b, result_type='widget')

        .. note:: When exporting pages, everything is converted into images
           (pngs), therefore making fancy behaving widgets is irrelevant.

        .. versionadded:: 0.2.0

        .. versionchanged:: 0.3.2
           Added tables as a result type.
        '''
        page = PageBox()
        head = PaperLabel(text=task, size_hint_y=None, height='30dp')

        if result_type == 'text':
            content = PaperLabel(text=result)
        elif result_type in ['image', 'import']:
            content = Image(source=result)
        elif 'table' in result_type:
            # result == list of values
            box = BoxLayout(orientation='vertical')
            grid = ResultGrid(cols=int(result_type.strip('table')),
                              padding=1, spacing=1, size_hint=[0.95, None],
                              pos_hint={'center_x': 0.5})
            grid.bind(minimum_height=grid.setter('height'))

            for value in result:
                if isinstance(value, (float, int)):
                    val = repr(value)
                else:
                    val = str(value)
                grid.add_widget(Wrap(text=val, color=[0, 0, 0, 1],
                                     background_color=[1, 1, 1, 1],
                                     padding_x=3))

            box.add_widget(Widget())
            box.add_widget(grid)
            box.add_widget(Widget())
            content = box

        elif result_type == 'widget':
            content = result

        # turn off with footer=None
        if result_type == 'import':
            pass
        elif not footer:
            foot = PaperLabel(size_hint_y=None, height='30dp')
        else:
            if footer == 'time':
                t = strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())
                foot = PaperLabel(text=t,
                                  size_hint_y=None,
                                  height='30dp')
            else:
                foot = PaperLabel(text=footer, size_hint_y=None,
                                  height='30dp')

        if not result_type == 'import':
            page.add_widget(head)
            page.add_widget(content)
            page.add_widget(foot)
        else:
            page.add_widget(content)
        self.ids.results.add_widget(page, 1)

        panel = self.ids.resultspanel
        if panel.width == panel.min_size:
            panel.width = panel.max_size
    def __init__(self, **kwargs):
        super().__init__()

        self.app = MDApp.get_running_app()

        self.mapview = MapView(lat=19.60389,
                          lon=-99.01260,
                          zoom=10
                          )

        self.marcadoresches = []
        self.marcadoressor = []
        self.marcadorescomer = []
        self.marcadoreshbe = []
        self.marcadoresbusqueda = []
        self.tipocomercio = ''

        self.datoshbe = {
            'hbe1': {'direccion': 'HDA. CERRO GORDO ',
                    'colonia': 'Balcones Campestre',
                    'lat': 21.156959409958873,
                    'lon': -101.70300001710274,
                    'tel': '8181531100',
                    'cp': '37150',
                    'municipio': 'Leon, Guanajuato'
                    },

            'hbe2': {'direccion': 'BLVD. ADOLFO LÓPEZ MATEOS 2102',
                     'colonia': 'Jardines del Moral',
                     'lat': 21.146246179033383,
                     'lon': -101.68449454293152,
                     'tel': '4777198103',
                     'cp': '37160',
                     'municipio': 'Leon, Guanajuato'
                     },

            'hbe3': {'direccion': 'BLVD. ADOLFO LOPEZ MATEOS 2102',
                     'colonia': 'Jardines del Moral',
                     'lat': 21.146236158514455,
                     'lon': -101.6846125617232,
                     'tel': '4777198103',
                     'cp': '37160',
                     'municipio': 'Leon, Guanajuato'
                     },

            'hbe4': {'direccion': 'AV. Guerrero 2415',
                     'colonia': 'Terracota',
                     'lat':  20.695401634729016,
                     'lon': -101.35843141409075,
                     'tel': '4621190160',
                     'cp': '36620',
                     'municipio': 'Irapuato, Guanajuato'
                     },
        }
        
        
        

        self.datosches = {
            'che1': {'direccion': '4TA. AVENIDA NO. 257 LOTE 1',
                     'colonia': 'Fracc Rey Neza',
                     'lat': 19.40068,
                     'lon': -98.98720,
                     'tel': '54412720',
                     'cp': '57000',
                     'municipio': 'Nezahualcoyotl'
                     },

            'che2': {'direccion': 'AV. TEXCOCO NO. 292',
                     'colonia': 'Pavón',
                     'lat': 19.396626,
                     'lon': -99.048428,
                     'tel': '11038000 ext 37140',
                     'cp': '57610',
                     'municipio': 'Nezahualcoyotl'
                     },

            'che3': {'direccion': 'AV. RIO DE LA LOZA NO. 4 ',
                     'colonia': 'San Miguel Chalma',
                     'lat': 19.545221,
                     'lon': -99.152201,
                     'tel': '11038000 ext 37130',
                     'cp': '07160',
                     'municipio': 'Tlalnepantla'
                     },

            'che4': {'direccion': 'AV. INSURGENTES SIN NUMERO',
                     'colonia': 'Calvario',
                     'lat': 19.60237,
                     'lon': -99.05572,
                     'tel': 'Sin tel',
                     'cp': '55020',
                     'municipio': 'Ecatepec de Morelos'
                     },

            'che5': {'direccion': 'AV ALFREDO DEL MAZO NO. 705',
                     'colonia': 'Tlacopa',
                     'lat': 19.309995,
                     'lon': -99.635682,
                     'tel': '017222379445',
                     'cp': '50100',
                     'municipio': 'Toluca de Lerdo'
                     },

            'che6': {'direccion': 'PROL. GUADALUPE VICTORIA NO. 471',
                     'colonia': 'La Purisima',
                     'lat': 19.258697,
                     'lon': -99.628197,
                     'tel': '017222127113',
                     'cp': '52140',
                     'municipio': 'Metepec'
                     },

            'che7': {'direccion': 'BLVRD JUAN HERRERA Y PIÑA 7',
                     'colonia': 'Barrio Otumba',
                     'lat': 19.204049,
                     'lon': -100.125421,
                     'tel': '7262626942',
                     'cp': '51200',
                     'municipio': 'Valle de Bravo'
                     },

            'che8': {'direccion': 'BLVD. MANUEL AVILA CAMACHO 5',
                     'colonia': 'Lomas de Sotelo',
                     'lat': 19.454290,
                     'lon': -99.219101,
                     'tel': '7262626942',
                     'cp': '53390',
                     'municipio': 'Naucalpan de Juárez'
                     },

            'che9': {'direccion': 'AV. DE LOS BOSQUES NO. 128',
                     'colonia': 'Lomas de Tecamachalco',
                     'lat': 19.411133,
                     'lon': -99.250840,
                     'tel': '5555967887',
                     'cp': '52780',
                     'municipio': 'Huixquilucan'
                     },
            'che10': {'direccion': 'AV. CENTRAL ESQ. AV JARDINES DE MORELOS S/N',
                      'colonia': 'Jardínes de Morelos',
                      'lat': 19.603457,
                      'lon': -99.013337,
                      'tel': '5558371634',
                      'cp': '55065',
                      'municipio': 'Ecatepec de Morelos'
                      },
            'che11': {'direccion': 'AV.AQUILES SERDAN 360',
                      'colonia': 'El Mirador',
                      'lat': 19.257597,
                      'lon': -99.022525,
                      'tel': '5525942726',
                      'cp': '16740',
                      'municipio': 'Xochimilco'
                      },

            'che12': {'direccion': 'CTRA. A SANTIAGO TEPELCATLALPAN 400',
                      'colonia': 'Santiago Tepalcatlalpan',
                      'lat': 19.257736,
                      'lon': -99.122394,
                      'tel': '5555557600',
                      'cp': '16210',
                      'municipio': 'Xochimilco'
                      },

            'che13': {'direccion': 'AV. UNIVERSIDAD 740',
                      'colonia': 'Sta Cruz Atoyac',
                      'lat': 19.373194,
                      'lon': -99.162387,
                      'tel': '8005632222',
                      'cp': '03310',
                      'municipio': 'Benito Juárez'
                      },

            'che14': {'direccion': 'VASCO DE QUIROGA 3800',
                      'colonia': 'Lomas de Santa Fe',
                      'lat': 19.359963,
                      'lon': -99.274583,
                      'tel': '5521678307',
                      'cp': '05348',
                      'municipio': 'Cuajimalpa'
                      },

            'che15': {'direccion': 'AV. BENITO JUAREZ NO. 39 MZ 36',
                      'colonia': 'Presidentes',
                      'lat': 19.376661,
                      'lon': -99.223099,
                      'tel': '5511038000',
                      'cp': '01290',
                      'municipio': 'Álvaro Obregón'
                      },

            'che16': {'direccion': 'AV. CANAL DE TEZONTLE 1512',
                      'colonia': 'Área Federal Central de Abastos',
                      'lat': 19.384808,
                      'lon': -99.082368,
                      'tel': '5511038000',
                      'cp': '09020',
                      'municipio': 'Iztapalapa'
                      },

            'che17': {'direccion': 'BUEN TONO NO. 8',
                      'colonia': 'Centro',
                      'lat': 19.428273,
                      'lon': -99.143175,
                      'tel': '5555124069',
                      'cp': '06070',
                      'municipio': 'Cuahtémoc'
                      },

            'che18': {'direccion': 'BLVD. MIGUEL DE CERVANTES SAAVEDRA 397',
                      'colonia': 'Irrigación',
                      'lat': 19.441866,
                      'lon': -99.206946,
                      'tel': '5555803422',
                      'cp': '11579',
                      'municipio': 'Miguel Hidalgo'
                      },

            'che19': {'direccion': 'AV. CUAUTEPEC NO. 117',
                      'colonia': 'Jorge Negrete',
                      'lat': 19.526125,
                      'lon': -99.141422,
                      'tel': '8009251111',
                      'cp': '07280',
                      'municipio': 'Gustavo A. Madero'
                      },

            'che20': {'direccion': 'AV. FORTUNA 334',
                      'colonia': 'Magdalena de las Salinas',
                      'lat': 19.482093,
                      'lon': -99.130347,
                      'tel': '8009251111',
                      'cp': '07760',
                      'municipio': 'Gustavo A. Madero'
                      },
        }

        self.datossor = {
            'sor1': {'direccion': 'CTRA. MEXICO-TEPEXPAN ESQ. LOS REYES TEXCOCO NO. 8',
                     'colonia': 'San Isidro Atlautenco',
                     'lat': 19.620721,
                     'lon': -98.997171,
                     'tel': '8007074262',
                     'cp': '55064',
                     'municipio': 'Ecatepec de Morelos'
                     },

            'sor2': {'direccion': 'LA PURISIMA NO. 5',
                     'colonia': 'San Cristóbal Lejipaya',
                     'lat': 19.602854,
                     'lon': -98.946640,
                     'tel': '5949569566',
                     'cp': '55800',
                     'municipio': 'Atenco'
                     },

            'sor3': {'direccion': 'AV. CENTRAL 65',
                     'colonia': '1ro de Agosto',
                     'lat': 19.551379,
                     'lon': -99.018549,
                     'tel': '8002201234',
                     'cp': '55100',
                     'municipio': 'Ecatepec de Morelos'
                     },

            'sor4': {'direccion': 'MEXICO NO. 5',
                     'colonia': 'Cd. López Mateos',
                     'lat': 19.568340,
                     'lon': -99.250645,
                     'tel': '5558225029',
                     'cp': '52960',
                     'municipio': 'Atizapán'
                     },

            'sor5': {'direccion': 'AV. 16 DE SEPTIEMBRE 34',
                     'colonia': 'Paraiso II',
                     'lat': 19.631577,
                     'lon': -99.119169,
                     'tel': '8007074262',
                     'cp': '55700',
                     'municipio': 'Coacalco'
                     },

            'sor6': {'direccion': 'AV. CUITLAHUAC 372',
                     'colonia': 'Cuitlahuac',
                     'lat': 19.471089,
                     'lon': -99.170700,
                     'tel': '8002201234',
                     'cp': '02530',
                     'municipio': 'Azcapotzalco'
                     },

            'sor7': {'direccion': 'AV. TOLTECAS S/N',
                     'colonia': 'Hab. Los Reyes',
                     'lat': 19.53765,
                     'lon': -99.189802,
                     'tel': '5516659002',
                     'cp': '54090',
                     'municipio': 'Tlalnepantla'
                     },

            'sor8': {'direccion': 'AV. GUSTAVO BAZ PRADA 250',
                     'colonia': 'Bosques de Echegaray',
                     'lat': 19.491437,
                     'lon': -99.227430,
                     'tel': '5553736844',
                     'cp': '53300',
                     'municipio': 'Naucalpan'
                     },

            'sor9': {'direccion': 'CALLE MEXIQUENSE 31',
                     'colonia': 'Los Héroes Tecámac',
                     'lat': 19.633013,
                     'lon': -99.033405,
                     'tel': '5558369960',
                     'cp': '55765',
                     'municipio': 'Tecámac'
                     },

            'sor10': {'direccion': 'CTRA. MEX-QRT KM 36.8',
                      'colonia': 'Reforma Política',
                      'lat': 19.650797,
                      'lon': -99.195386,
                      'tel': '8002201234',
                      'cp': '54700',
                      'municipio': 'Cuautitlán Izcalli'
                      },

            'sor11': {'direccion': 'AV. STA. FE 46',
                      'colonia': 'Lomas de Santa Fe',
                      'lat': 19.357175,
                      'lon': -99.273897,
                      'tel': 'Sin info',
                      'cp': '01219',
                      'municipio': 'Cuajimalpa'
                      },

            'sor12': {'direccion': 'AV. IMAN 550',
                      'colonia': 'Pedregal de Carrasco',
                      'lat': 19.306898,
                      'lon': -99.164659,
                      'tel': '5555288345',
                      'cp': '04700',
                      'municipio': 'Coyoacán'
                      },

            'sor13': {'direccion': 'ERMITA IZTAPALAPA 3016',
                      'colonia': 'Reforma Politica',
                      'lat': 19.344716,
                      'lon': -99.027594,
                      'tel': '8183299252',
                      'cp': '09730',
                      'municipio': 'Iztapalapa'
                      },

            'sor14': {'direccion': 'CALZ. DE LA VIGA 1805',
                      'colonia': 'Mexicaltzingo',
                      'lat': 19.360090,
                      'lon': -99.123618,
                      'tel': '8183299252',
                      'cp': '09080',
                      'municipio': 'Iztapalapa'
                      },

            'sor15': {'direccion': 'AV. REVOLUCION 780',
                      'colonia': 'San Juan',
                      'lat': 19.379381,
                      'lon': -99.185600,
                      'tel': '5555655046',
                      'cp': '03730',
                      'municipio': 'Benito Juárez'
                      },

            'sor16': {'direccion': 'OBRERO MUNDIAL 320',
                      'colonia': 'Piedad Narvarte',
                      'lat': 19.402383,
                      'lon': -99.154002,
                      'tel': '5583299000',
                      'cp': '03000',
                      'municipio': 'Benito Juárez'
                      },

            'sor17': {'direccion': 'AV. EL ROSARIO 901',
                      'colonia': 'El Rosario',
                      'lat': 19.504132,
                      'lon': -99.200933,
                      'tel': '8007074262',
                      'cp': '02100',
                      'municipio': 'Azcapotzalco'
                      },

            'sor18': {'direccion': 'CALZ. DE LOS MISTERIOS 62',
                      'colonia': 'Tepeyac Insurgentes',
                      'lat': 19.489655,
                      'lon': -99.119282,
                      'tel': '8002201234',
                      'cp': '07020',
                      'municipio': 'Gustavo A. Madero'
                      },

            'sor19': {'direccion': 'AV. EJERCITO NACIONAL 769',
                      'colonia': 'Granada',
                      'lat': 19.439809,
                      'lon': -99.199979,
                      'tel': '5591260960',
                      'cp': '11520',
                      'municipio': 'Miguel Hidalgo'
                      },

            'sor20': {'direccion': 'AV JARDIN 330',
                      'colonia': 'Col del Gas',
                      'lat': 19.468902,
                      'lon': -99.159565,
                      'tel': '8002201234',
                      'cp': '02970',
                      'municipio': 'Azcapotzalco'
                      },
        }

        self.datoscomer = {
            'comer1': {'direccion': 'CALZ DEL HUESO 530',
                       'colonia': 'Fracc. Los Girasoles',
                       'lat': 19.305154,
                       'lon': -99.126231,
                       'tel': '01 800 3777 333',
                       'cp': '4929',
                       'municipio': 'Coyoacan'
                       },

            'comer2': {'direccion': 'ATENAS 6',
                       'colonia': 'Fracc. Valle Dorado',
                       'lat': 19.551346,
                       'lon': -99.209801,
                       'tel': '01 800 3777 333',
                       'cp': '54020',
                       'municipio': 'Tlalnepantla'
                       },

            'comer3': {'direccion': 'BLVD MANUEL AVILA CAMACHO 3228',
                       'colonia': 'Boulevares',
                       'lat': 19.498145,
                       'lon': -99.237891,
                       'tel': '01 800 3777 333',
                       'cp': '53100',
                       'municipio': 'Naucalpan de Juárez'
                       },

            'comer4': {'direccion': 'PLAZUELA DE LA FAMA 1',
                       'colonia': 'La Fama',
                       'lat': 19.288794,
                       'lon': -99.179277,
                       'tel': '01 800 3777 333',
                       'cp': '14410',
                       'municipio': 'Tlalpan'
                       },

            'comer5': {'direccion': 'CIRCUITO MEDICOS 35',
                       'colonia': 'Ciudad Satélite',
                       'lat': 19.509474,
                       'lon': -99.232960,
                       'tel': '01 800 3777 333',
                       'cp': '53100',
                       'municipio': 'Naucalpan de Juárez'
                       },

            'comer6': {'direccion': 'NOGAL 212',
                       'colonia': 'Santa María La Ribera',
                       'lat': 19.451636,
                       'lon': -99.163952,
                       'tel': '01 800 3777 333',
                       'cp': '6400',
                       'municipio': 'Cuauhtémoc'
                       },

            'comer7': {'direccion': 'CTRA A CELAYA 2',
                       'colonia': 'Fracc. La Lejona 2da Sección',
                       'lat': 20.897708,
                       'lon': -100.752716,
                       'tel': '01 800 3777 333',
                       'cp': '37765',
                       'municipio': 'San Miguel Allende'
                       },

            'comer8': {'direccion': 'AV DE LAS TORRES 446',
                       'colonia': 'San José del Olivar',
                       'lat': 19.334798,
                       'lon': -99.227121,
                       'tel': '01 800 3777 333',
                       'cp': '1770',
                       'municipio': 'Álvaro Obregón'
                       },

            'comer9': {'direccion': 'AV MAGNOCENTRO LT 1 MZ 2',
                       'colonia': 'San Fernando Huixquilucan',
                       'lat': 19.399401,
                       'lon': -99.276681,
                       'tel': '01 800 3777 333',
                       'cp': '52796',
                       'municipio': 'Huixquilucan'
                       },

            'comer10': {'direccion': 'XOCHIMILCO 343',
                        'colonia': 'Anahuac',
                        'lat': 19.438072,
                        'lon': -99.179588,
                        'tel': '01 800 3777 333',
                        'cp': '11320',
                        'municipio': 'Miguel Hidalgo'
                        },

            'comer11': {'direccion': 'BOSQUES DE MOCTEZUMA 1B',
                        'colonia': 'Fracc. La Herradura',
                        'lat': 19.416958,
                        'lon': -99.249047,
                        'tel': '01 800 3777 333',
                        'cp': '53920',
                        'municipio': 'Huixquilucan'
                        },

            'comer12': {'direccion': 'CALZ ERMITA IZTAPALAPA 3865',
                        'colonia': 'Santa María Aztahuacán',
                        'lat': 19.351905,
                        'lon': -99.012747,
                        'tel': '01 800 3777 333',
                        'cp': '9730',
                        'municipio': 'Iztapalapa'
                        },

            'comer13': {'direccion': 'PERPETUA 35',
                        'colonia': 'San José Insurgentes',
                        'lat': 19.366372,
                        'lon': -99.182357,
                        'tel': '01 800 3777 333',
                        'cp': '3900',
                        'municipio': 'Benito Juárez'
                        },

            'comer14': {'direccion': 'MIGUEL ANGEL DE QUEVEDO 443',
                        'colonia': 'Romero de Terreros',
                        'lat': 19.345040,
                        'lon': -99.171795,
                        'tel': '01 800 3777 333',
                        'cp': '4310',
                        'municipio': 'Coyoacán'
                        },

            'comer15': {'direccion': 'BOSQUE DE ARRAYAN MZ 5 LT 1',
                        'colonia': 'Fracc. Conjunto Urbano Bosque Esmeralda',
                        'lat': 19.548925,
                        'lon': -99.287349,
                        'tel': '01 800 3777 333',
                        'cp': '52973',
                        'municipio': 'Atizapán de Zaragoza'
                        },

            'comer16': {'direccion': 'AV DE LAS FUENTES 190',
                        'colonia': 'Lomas de Tecamachalco',
                        'lat': 19.421845,
                        'lon': -99.237988,
                        'tel': '01 800 3777 333',
                        'cp': '53950',
                        'municipio': 'Naucalpán de Juárez'
                        },

            'comer17': {'direccion': 'PROLONGACION BOSQUES DE REFORMA 1813',
                        'colonia': 'Vista Hermosa',
                        'lat': 19.382919,
                        'lon': -99.267804,
                        'tel': '01 800 3777 333',
                        'cp': '5109',
                        'municipio': 'Cuajimalpa'
                        },

            'comer18': {'direccion': 'AV. JESUS DEL MONTE 271',
                        'colonia': 'Jesús del Monte',
                        'lat': 19.388758,
                        'lon': -99.293395,
                        'tel': '01 800 3777 333',
                        'cp': '52764',
                        'municipio': 'Huixquilucan'
                        },

            'comer19': {'direccion': 'AV. MIGUEL ANGEL DE QUEVEDO 1144',
                        'colonia': 'Parque San Andrés',
                        'lat': 19.342817,
                        'lon': -99.146703,
                        'tel': 'Sin Datos',
                        'cp': '4040',
                        'municipio': 'Coyoacan'
                        },

            'comer20': {'direccion': 'AV. DEL CARMEN 335',
                        'colonia': 'Fracc. Avandaro',
                        'lat': 19.164580,
                        'lon': -100.125154,
                        'tel': 'Sin Datos',
                        'cp': '51200',
                        'municipio': 'Valle de Bravo'
                        },
        }

        self.entradafield = MDTextFieldRect(pos_hint={"x": .05, "y":.93},
                                        hint_text = "Buscar por Municipio, Colonia, Calle",
                                        size_hint = (.6, .060),
                                        height = "30dp"
                                        )

        self.borramarcador = MDIconButton(pos_hint={"x": .80, "y":.9},
                                                   icon = "map-marker-off",
                                                   user_font_size = "32sp",
                                    )
        self.botonbusqueda = MDIconButton(pos_hint={"x": .65, "y": .9},
                                          icon="magnify",
                                          user_font_size="32sp",
                                          )


        self.botongps = MDIconButton(pos_hint={"x": .75, "y": .03},
                                     icon = "crosshairs-gps",
                                     user_font_size = "32sp"
                                     )

        self.botonayuda = MDIconButton(pos_hint={"x": .75, "y": .13}, #falta agregar funcion para mostrar
                                       icon="help-box",
                                       user_font_size="32sp"
                                       )

        self.botonche = MDFillRoundFlatButton(pos_hint={"x": .1, "y": .05},
                                              size_hint=(.25, .07),
                                              text = "Chedraui",
                                              )
        self.mr = Image(source="imagenes/pinrojo.png",
                        pos_hint={"x": -.385, "y": -.41})

        self.botonhbe = MDFillRoundFlatButton(pos_hint={"x": .5, "y": .05},
                                              size_hint=(.25, .07),
                                              text="HEB"
                                              )
        self.mg = Image(source="imagenes/pingris.png",
                        pos_hint={"x": .013, "y": -.41})

        self.botoncomer = MDFillRoundFlatButton(pos_hint={"x": .1, "y": .15},
                                              size_hint=(.25, .07),
                                              text="La Comer"
                                              )
        self.mv = Image(source="imagenes/pinverde.png",
                        pos_hint={"x": -.385, "y": -.31})

        self.botonsor = MDFillRoundFlatButton(pos_hint={"x": .5, "y": .15},
                                              size_hint=(.25, .07),
                                              text="Soriana"
                                              )
        self.ma = Image(source="imagenes/pinazul.png",
                        pos_hint={"x": .013, "y": -.31})

        self.botongps.bind(on_press=lambda x: self.ActivaGPS())
        self.botonayuda.bind(on_press=lambda x: self.AyudaMapa())
        self.botonche.bind(on_press=lambda x: self.Consulta_Che())
        self.botonsor.bind(on_press=lambda x: self.Consulta_Sor())
        self.botoncomer.bind(on_press=lambda x: self.Consulta_Comer())
        self.botonhbe.bind(on_press=lambda x: self.Consulta_HBE())
        self.borramarcador.bind(on_press=lambda x: self.BorraMarcador())
        self.botonbusqueda.bind(on_press=lambda x: self.Consulta_Busqueda())

        self.add_widget(self.mapview) # Se agrega el mapa en la "capa inferior"
        #self.add_widget(self.botongps) # En una "capa" posterior se agrega el boton para que se vea
        self.add_widget(self.botonbusqueda)
        self.add_widget(self.entradafield)

        self.add_widget(self.botonche)
        self.add_widget(self.botonhbe)
        self.add_widget(self.botoncomer)
        self.add_widget(self.botonsor)
        self.add_widget(self.botonayuda)
        self.add_widget(self.borramarcador)
        self.add_widget(self.mr)
        self.add_widget(self.mv)
        self.add_widget(self.mg)
        self.add_widget(self.ma)
Ejemplo n.º 22
0
 def __init__(self, **kw):
     super(ProcessFlow, self).__init__(**kw)
     app = App.get_running_app()
     self.texture = Image(source=app.path + '/data/grid.png').texture
     self.texture.wrap = 'repeat'
Ejemplo n.º 23
0
    def draw_game_screen(self, button):
        self.main_layout.remove_widget(self.main_layout.children[0])
        if self.game_type == '1 Player':
            self.game_mode = ONEPLAYER
        else:
            self.game_mode = TWOPLAYERS
        self.GameProcessor = GameProcessor()
        self.GameProcessor.savelog(self.savelog)
        self.Algorithm = GameBrains(BLACK)
        self.Orienteer = Orienteer()
        self.clicks = 0

        self.gameplay = FloatLayout(size_hint=[0.5, 1],
                                    pos_hint={
                                        'center_x': 0.5,
                                        'center_y': 0.5
                                    })

        self.gameplay.add_widget(
            Image(source=GAME_BACKGROUND,
                  size_hint=[2, 2],
                  pos_hint={
                      'center_x': 0.5,
                      'center_y': 0.5
                  },
                  allow_stretch=True))

        self.gameplay.add_widget(
            Button(text='Quit',
                   on_press=self.leave,
                   size_hint=[0.35, 0.1],
                   pos_hint={
                       'center_x': 1.25,
                       'center_y': 0.66
                   },
                   background_color=GAME_BUTTON_COLOR,
                   background_normal=''))

        self.gameplay.add_widget(
            Button(text='Restart',
                   on_press=self.draw_game_screen,
                   size_hint=[0.35, 0.1],
                   pos_hint={
                       'center_x': 1.25,
                       'center_y': 0.90
                   },
                   background_color=GAME_BUTTON_COLOR,
                   background_normal=''))
        self.gameplay.add_widget(
            Button(text='Main menu',
                   on_press=self.back_to_main_menu,
                   size_hint=[0.35, 0.1],
                   pos_hint={
                       'center_x': 1.25,
                       'center_y': 0.78
                   },
                   background_color=GAME_BUTTON_COLOR,
                   background_normal=''))
        self.move_label = LabelB(text='',
                                 bcolor=GAME_BUTTON_COLOR,
                                 size_hint=[.35, .1],
                                 pos_hint={
                                     'center_x': -0.25,
                                     'center_y': 0.9
                                 })
        self.gameplay.add_widget(self.move_label)
        self.gameplay.add_widget(
            Button(text='Cancel selection',
                   on_press=self.cancel_move,
                   size_hint=[0.35, 0.1],
                   pos_hint={
                       'center_x': -0.25,
                       'center_y': 0.66
                   },
                   background_color=GAME_BUTTON_COLOR,
                   background_normal=''))
        self.gameplay.add_widget(
            Button(text='Make movement',
                   on_press=self.commit_move,
                   size_hint=[0.35, 0.1],
                   pos_hint={
                       'center_x': -0.25,
                       'center_y': 0.78
                   },
                   background_color=GAME_BUTTON_COLOR,
                   background_normal=''))
        #FIXME Make some grouped separate procedure.
        self.start = None
        self.end = None

        self.Orienteer.invert()
        self.board = BoardWidget(
            self.Orienteer.oriented_board(self.get_board()), self.input_move)
        self.gameplay.add_widget(self.board)
        self.main_layout.add_widget(self.gameplay)
Ejemplo n.º 24
0
    def __init__(self, **kw):
        self.picture_taken_callback = kw.pop('picture_taken_callback', None)
        self.cancel_callback = kw.pop('cancel_callback', None)
        self.picture_filepath = kw.pop('picture_filepath', None)
        self.image_width = kw.pop('image_width', 640)
        self.image_height = kw.pop('image_height', 480)
        super(CameraTakePictureScreen, self).__init__(**kw)

        self.container = FloatLayout(
            size_hint=(
                None,
                None,
            ),
            pos_hint={
                'center_x': 0.5,
                'center_y': 0.5,
            },
            width=self.image_width,
            height=self.image_height,
        )
        self.add_widget(self.container)

        self.camera_texture = Image(
            id='camera_texture',
            size_hint=(
                1,
                1,
            ),
            allow_stretch=True,
            keep_ratio=True,
            pos_hint={
                'center_x': 0.5,
                'center_y': 0.5,
            },
        )
        self.container.add_widget(self.camera_texture)

        btn1 = RoundedButton(
            id='take_picture_button',
            size_hint=(
                None,
                None,
            ),
            pos_hint={
                "center_x": 0.5,
                "y": 0.0,
            },
            width=dp(50),
            height=dp(50),
            text=fa_icon('camera'),
            on_release=self.on_capture,
        )
        self.container.add_widget(btn1)

        btn2 = CloseButton(
            id='cancel_button',
            pos_hint={
                "right": 1,
                "top": 1,
            },
            text=fa_icon('window-close'),
            on_release=self.on_cancel_button_clicked,
        )
        self.container.add_widget(btn2)

        self.camera_capture = cv2.VideoCapture(0)  # @UndefinedVariable
        self.camera_capture.set(cv2.CAP_PROP_FRAME_WIDTH,
                                self.image_width)  # @UndefinedVariable
        self.camera_capture.set(cv2.CAP_PROP_FRAME_HEIGHT,
                                self.image_height)  # @UndefinedVariable
        self.fps = self.camera_capture.get(
            cv2.CAP_PROP_FPS)  # @UndefinedVariable

        if self.fps == 0 or self.fps == 1:
            self.fps = 1.0 / 10
        elif self.fps > 1:
            self.fps = 1.0 / (self.fps / 2.0)

        self.camera_task = Clock.schedule_interval(self.on_camera_update,
                                                   1.0 / 20)
Ejemplo n.º 25
0
    def build(self):
        self.savelog = False
        self.start_screen = FloatLayout(size_hint=(1, 1),
                                        pos_hint={
                                            'center_x': 0.5,
                                            'center_y': 0.5
                                        })

        background_image = Image(source=INITIAL_BACKGROUND,
                                 size_hint=[1, 1],
                                 pos_hint={
                                     'center_x': 0.5,
                                     'center_y': 0.5
                                 },
                                 allow_stretch=True)

        game_label = LabelB(text='Chess game',
                            size_hint=[0.15, 0.1],
                            pos_hint={
                                'center_x': 0.7,
                                'center_y': 0.8
                            },
                            color=[0, 0, 0, 1],
                            bcolor=[0, 0, 0, 0],
                            font_name=FONT,
                            font_size=100)

        self.buttons = BoxLayout(orientation='vertical',
                                 spacing=10,
                                 size_hint=(0.3, 0.4),
                                 pos_hint={
                                     'center_x': 0.7,
                                     'center_y': 0.4
                                 })

        start_game_button = Button(text='Start game',
                                   on_press=self.c_game_mode,
                                   background_normal='',
                                   background_color=INITIAL_BUTTON_COLOR,
                                   color=[0, 0, 0, 1])

        settings_button = Button(text='Settings',
                                 on_press=self.show_settings,
                                 background_normal='',
                                 background_color=INITIAL_BUTTON_COLOR,
                                 color=[0, 0, 0, 1])

        exit_button = Button(text='Quit',
                             on_press=self.leave,
                             background_normal='',
                             background_color=INITIAL_BUTTON_COLOR,
                             color=[0, 0, 0, 1])

        self.buttons.add_widget(start_game_button)
        self.buttons.add_widget(settings_button)
        self.buttons.add_widget(exit_button)

        self.start_screen.add_widget(background_image)
        self.start_screen.add_widget(game_label)

        self.start_screen.add_widget(self.buttons)
        self.main_layout = FloatLayout()
        self.main_layout.add_widget(self.start_screen)

        return self.main_layout
Ejemplo n.º 26
0
 def soon():
     content = Image(source="images/soon.jpg")
     popup = Popup(title="Soon", content=content, size_hint=(None, None), size=(230, 200))
     popup.open()
Ejemplo n.º 27
0
Archivo: main.py Proyecto: puneetp/GPIS
 def display_image(self, next_num):
     self.current_image = Image(source = self.grasps[next_num].image, pos_hint = {'top': .75, 'x': .5}, size_hint = (.4,.4))
     self.root.add_widget(self.current_image)
     self.next_grasp += 1
Ejemplo n.º 28
0
class DatasetApp(App):
    img1 = Image(source = 'main.png')
    layout = BoxLayout(orientation='vertical')
    img1.pos = (0,layout.height)
    img_vector = []
    proporcao = 0
    dropped = False
    count = 0
    tl = []
    br = []
    labels = []
    save_result = {}
    the_path = 0
    ipt1 = TextInput(size_hint_y=None,
                         height = 40,
                         font_size = 25)
    btn1 = Button(text="Pular Imagem", height=40, size_hint_y=None)
    btn2 = Button(text="Save", height=40, size_hint_y = None)
    btn3 = Button(text="Voltar", height=40, size_hint_y = None)
    First = True

    def build(self):
        Window.bind(on_dropfile=self._on_file_drop)
        Window.bind(on_motion=self.on_motion)
        self.btn1.bind(on_press=self._update_image)
        self.btn2.bind(on_press=self.save)
        self.btn3.bind(on_press=self.volta)

        h, w, channels = scipy.ndimage.imread('main.png').shape
        ratio = w/h
        Window.size = (ratio*500, 500 + _DOWN_)

        self.layout.add_widget(self.img1)
        self.layout.add_widget(self.ipt1)
        self.layout.add_widget(self.btn1)
        self.layout.add_widget(self.btn3)
        self.layout.add_widget(self.btn2)
        return self.layout

    def _on_file_drop(self, window, file_path):
        self.count = 0
        path = file_path.decode("utf-8")
        self.the_path = path
        for filename in os.listdir(path):
            if filename.endswith(".jpg"):
                self.img_vector.append(path+'/'+filename)
        self.dropped = True
        if os.path.isfile(path+'/labels.txt'):
            with open(path+'/img_vector.txt', "rb") as input:
                self.img_vector = pickle.load(input)
            with open(path+'/labels.txt', "rb") as input:
                self.labels = pickle.load(input)
            with open(path+'/tl.txt', "rb") as input:
                self.tl = pickle.load(input)
            with open(path+'/br.txt', "rb") as input:
                self.br = pickle.load(input)
            self.count = len(self.labels)
            print(self.count, self.labels, self.tl, self.br, self.img_vector)
        self._update_image()
        return

    def _update_image(self, *args):
        if(self.count <= len(self.img_vector) and self.dropped):
            if (self.count < len(self.img_vector)):
                self.img1.source = self.img_vector[self.count]

                h, w, channels = scipy.ndimage.imread(self.img_vector[self.count]).shape
                ratio = w/h
                Window.size = (ratio*500, 500 + _DOWN_)
                self.proporcao = h/500

            if self.First:
                self.First = False
            else:
                if (len(self.tl) < self.count):
                    self.tl.append((0,0))
                    self.br.append((0,0))
                    self.labels.append(0)

            self.count = self.count+1
            print(self.count)
        else:
            print("Cabou imagens!")
        return

    def on_motion(self, etype, motionevent, *args):
        if((etype.mouse_pos[1] >= _DOWN_) and not self.First):
            x = etype.mouse_pos[0]
            y = etype.mouse_pos[1] - _DOWN_

            if (motionevent == 'begin'):
                self.tl.append((int(x*self.proporcao), int(y*self.proporcao)))
            if (motionevent == 'end'):
                self.br.append((int(x*self.proporcao), int(y*self.proporcao)))
                self.labels.append(self.ipt1.text)
                self._update_image()
                print("DEU BOM!")
        return

    def save(self, *args):
        print(self.img_vector, self.labels, self.tl, self.br)
        for i in range(len(self.labels)):
            save = {i: {'location':self.img_vector[i],'label': self.labels[i], 'topleft': {'x': self.tl[i][0], 'y': self.tl[i][1]}, 'bottomright': {'x': self.br[i][0], 'y': self.br[i][1]}} }
            self.save_result.update(save)
        with open(self.the_path+'/img_vector.txt', 'wb') as f:
            pickle.dump(self.img_vector, f)
        with open(self.the_path+'/labels.txt', 'wb') as f:
            pickle.dump(self.labels, f)
        with open(self.the_path+'/tl.txt', 'wb') as f:
            pickle.dump(self.tl, f)
        with open(self.the_path+'/br.txt', 'wb') as f:
            pickle.dump(self.br, f)
        pp = pprint.PrettyPrinter(indent=4)
        pp.pprint(self.save_result)
        return

    def volta(self, *args):
        self.count = self.count - 2
        self._update_image()
        self.img_vector.insert(self.count, self.img_vector[self.count-1])
        self.count = self.count + 1
        return
Ejemplo n.º 29
0
    def __init__(self, name, **kwargs):
        super(profileScreen, self).__init__(**kwargs)
        self.name = name

        self.background_image = Image(
            source='./data/images/background-profile.png')
        self.add_widget(self.background_image)

        self.label_choose_name = Label(
            text="ENTER YOUR TEAM'S NAME",
            font_size='20sp',
            font_name='./data/fonts/H.H. Samuel-font-defharo.ttf',
            color=(1, 1, 1, 1))
        self.label_choose_name.pos = (0, 300)

        self.input_name = nameInput(
            height=34,
            font_size=36,
            font_name='./data/fonts/H.H. Samuel-font-defharo.ttf',
            foreground_color=(0.43, 0.57, 0.71, 1),
            multiline=False,
            padding=[155, -6, 0, -6])  #[80,-6,0,-6])
        self.input_name.h_align = 'center'
        self.input_name.pos = (25, 566)
        self.input_name.size_hint = (None, None)
        self.input_name.size = (310, 36)
        self.input_name.background_normal = './data/images/interface-input-name.png'
        self.input_name.background_active = './data/images/interface-input-name.png'

        self.label_choose_crest = Label(
            text="CHOOSE YOUR TEAM'S CREST",
            font_size='20sp',
            font_name='./data/fonts/H.H. Samuel-font-defharo.ttf',
            color=(1, 1, 1, 1))
        self.label_choose_crest.pos = (0, 228)

        self.crest_chooser = crestChooser(position=(25, 440))

        brown = (0.22, 0.46, 0.03, 1.0)
        dark_gray = (0.4, 0.4, 0.4, 1.0)

        self.label_fans = Label(
            text="17.812 FANS (LV 3)",
            font_size='20sp',
            font_name='./data/fonts/H.H. Samuel-font-defharo.ttf',
            color=dark_gray,
            pos=(0, 10))
        self.label_big_brag = Label(
            text="37% WINS",
            font_size='38sp',
            font_name='./data/fonts/H.H. Samuel-font-defharo.ttf',
            color=dark_gray,
            pos=(0, -29))
        self.label_small_brag = Label(
            text="OUT OF A TOTAL OF 21 MATCHES",
            font_size='20sp',
            font_name='./data/fonts/H.H. Samuel-font-defharo.ttf',
            color=dark_gray,
            pos=(0, -63))

        self.label_3rd_count = Label(
            text="x0",
            font_size='20sp',
            font_name='./data/fonts/H.H. Samuel-font-defharo.ttf',
            color=dark_gray,
            pos=(-108, -158))
        self.label_2nd_count = Label(
            text="x0",
            font_size='20sp',
            font_name='./data/fonts/H.H. Samuel-font-defharo.ttf',
            color=dark_gray,
            pos=(-55, -158))
        self.label_1st_count = Label(
            text="x0",
            font_size='20sp',
            font_name='./data/fonts/H.H. Samuel-font-defharo.ttf',
            color=dark_gray,
            pos=(0, -158))
        self.label_premiere_count = Label(
            text="x0",
            font_size='20sp',
            font_name='./data/fonts/H.H. Samuel-font-defharo.ttf',
            color=dark_gray,
            pos=(55, -158))
        self.label_world_count = Label(
            text="x0",
            font_size='20sp',
            font_name='./data/fonts/H.H. Samuel-font-defharo.ttf',
            color=dark_gray,
            pos=(108, -158))

        self.commit_button = Button(size_hint=(None, None),
                                    size=(90, 90),
                                    pos=(180 - 45, 20))
        self.commit_button.background_normal = './data/images/btn-profile-return.png'
        self.commit_button.background_down = './data/images/btn-profile-return-press.png'
        self.commit_button.bind(on_release=self.return_to_title)

        self.add_widget(self.label_choose_name)
        self.add_widget(self.input_name)
        self.add_widget(self.label_choose_crest)
        self.add_widget(self.crest_chooser)
        self.add_widget(self.label_fans)
        self.add_widget(self.label_big_brag)
        self.add_widget(self.label_small_brag)
        self.add_widget(self.label_3rd_count)
        self.add_widget(self.label_2nd_count)
        self.add_widget(self.label_1st_count)
        self.add_widget(self.label_premiere_count)
        self.add_widget(self.label_world_count)
        self.add_widget(self.commit_button)
Ejemplo n.º 30
0
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.checkbox import CheckBox
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.image import Image
from kivy.uix.label import Label
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.slider import Slider
from kivy.uix.spinner import Spinner

import ImageProcessor as ip

# Static variables
imageProcessor = ip.ImageProcessor()
chosenImage = Image(source='images/hand.jpg', pos=(500, 200), size=(200, 200))
drawingImage = Image(source='drawing.png', pos=(500, 200), size=(200, 200))
widthCropSlider = Slider(min=10,
                         max=(chosenImage._coreimage._size[0] / 100 * 90),
                         value=(chosenImage._coreimage._size[0] / 100 * 90),
                         steps=1)
heightCropSlider = Slider(min=10,
                          max=(chosenImage._coreimage._size[1] / 100 * 90),
                          value=(chosenImage._coreimage._size[1] / 100 * 90),
                          steps=1)
xCropSlider = Slider(min=0,
                     max=(chosenImage._coreimage._size[0]),
                     value=0,
                     steps=1)
yCropSlider = Slider(min=0,
                     max=(chosenImage._coreimage._size[1]),