def __init__(self, **kwargs):
        super(Gauge, self).__init__(**kwargs)

        self._gauge = Scatter(size=(self.size_gauge, self.size_gauge),
                              do_rotation=False,
                              do_scale=False,
                              do_translation=False)

        _img_gauge = Image(source=self.file_gauge,
                           size=(self.size_gauge, self.size_gauge))

        self._needle = Scatter(size=(self.size_gauge, self.size_gauge),
                               do_rotation=False,
                               do_scale=False,
                               do_translation=False)

        _img_needle = Image(source=self.file_needle,
                            size=(self.size_gauge, self.size_gauge))

        self._glab = Label(font_size=self.size_text, markup=True)
        self._progress = ProgressBar(max=100, height=20, value=self.value)

        self._gauge.add_widget(_img_gauge)
        self._needle.add_widget(_img_needle)

        self.add_widget(self._gauge)
        self.add_widget(self._needle)
        self.add_widget(self._glab)
        self.add_widget(self._progress)

        self.bind(pos=self._update)
        self.bind(size=self._update)
        self.bind(value=self._turn)
 def build(self):
     f = FloatLayout()
     s = Scatter()
     l = Label(text="Hello", font_size=150)
     f.add_widget(s)
     s.add_widget(l)
     return f
Exemple #3
0
 def build(self):
     #f= Floatlayout()
     s = Scatter()
     l = Label(text="Hello!", font_size=150)
     #f.add_widget(s)
     s.add_widget(l)
     return s
Exemple #4
0
    def __init__(self, **kwargs):
        super(Gauge, self).__init__(**kwargs)

        self._gauge = Scatter(size=(self.size_gauge, self.size_gauge),
                              do_rotation=False,
                              do_scale=False,
                              do_translation=False)

        _img_gauge = Image(source=self.file_gauge,
                           size=(self.size_gauge, self.size_gauge))

        self._needle = Scatter(size=(self.size_gauge, self.size_gauge),
                               do_rotation=False,
                               do_scale=False,
                               do_translation=False)

        _img_needle = Image(source="arrow512.png",
                            size=(self.size_gauge, self.size_gauge))

        self._gauge.add_widget(_img_gauge)
        self._needle.add_widget(_img_needle)

        self.add_widget(self._gauge)
        self.add_widget(self._needle)

        self.bind(pos=self._update)
        self.bind(size=self._update)
        self.bind(value=self._turn)
Exemple #5
0
    def __init__(self, source, **kwargs):
        super().__init__(**kwargs)
        """
        Hierarchy
        """
        self.image = Image(source=source,
                           pos_hint={
                               "center_x": 0.5,
                               "center_y": 0.5
                           })

        self.container = Scatter()
        self.container.add_widget(self.image)

        self.add_widget(self.container)
        """
        Class properties
        """
        self.source = source
        self.scale_value = 1.0
        self.initial_alpha = self.image.color[3]
        self.initial_pos = None
        self.debug = False
        self.clickable = True
        self.touched = False
        self.mouse_pos = tuple()  # mouse position (frequently updated)
        """
        Some updates per drawing
        """
        Window.bind(mouse_pos=lambda w, p: setattr(self, 'mouse_pos', p))
        Window.bind(on_draw=self.fit_image)
        Window.bind(on_dropfile=self._on_file_drop)
Exemple #6
0
    def __init__(self, source, input_data=None, **kwargs):
        self.data = input_data
        self.debug = False

        super().__init__(**kwargs)

        self.image = Image(source=source,
                           pos_hint={
                               "center_x": 0.5,
                               "center_y": 0.5
                           })
        self.container = Scatter()
        self.container.add_widget(self.image)

        self.add_widget(self.container)

        # set initial scale
        self.container.scale = 5

        # set initial transparent value
        self.initial_alpha = self.image.color[3]

        # set initial position
        self.initial_pos = None

        self.mouse_pos = tuple()  # mouse position (frequently updated)
        """
        Some updates per drawing
        """
        Window.bind(mouse_pos=lambda w, p: setattr(self, 'mouse_pos', p))
        Window.bind(on_dropfile=self._on_file_drop)
Exemple #7
0
 def __init__(self, **kwargs):
     super(Scatter_test, self).__init__(**kwargs)
     self.cols = 1
     self.scatter1 = Scatter()
     self.imag1 = Image(source="nature1.jpg")
     self.scatter1.add_widget(self.imag1)
     self.add_widget(self.scatter1)
Exemple #8
0
 def __init__(self,*args, **kwargs):
     super(ImagesCarousel, self).__init__(**kwargs)
     for image in carousel_images:
         scatter = Scatter(pos=(100,200), scale=4, do_scale=True)
         image_to_add = Image(source=images_path+image)
         scatter.add_widget(image_to_add)
         self.add_widget(scatter)
Exemple #9
0
	def on_touch_up (self, touch):
		# calls same function in it's ancestor, and slides the workspace
		Scatter.on_touch_up(self, touch)
		if not 'markerid' in touch.profile:
			return
		hand_id = int(touch.fid / self.hand_gesture_offset)
		gesture_id = touch.fid % self.hand_gesture_offset
		self.canvas.clear()
		self.draw()

		"""
		"  starts sliding  "
		"""
		if ('initial' in touch.ud) and touch.ud['initial'] != None and self.object_moving and hand_id != self.my_object.owner_id and self.x <= 0 and ((-1*self.x) % self.single_width() == 0):
			print 'about to slide'
			current = self.current_workspace()
			if touch.ud['initial'] > touch.x:
				if abs(touch.ud['initial'] - touch.x) > self.slide_threshold:
					current = current + 1
					if current >= len(self.frames):
						current = len(self.frames) - 1
					else:
						self.workspace_slide_event()
			else:
				if abs(touch.ud['initial'] - touch.x) > self.slide_threshold:
					current = current - 1
					if current < 0:
						current = 0
					else:
						self.workspace_slide_event()
			self.slide(current)
			touch.ud['initial'] = None
		return False
Exemple #10
0
 def build(self):
     f = FloatLayout()
     s = Scatter()
     l = Label(text="Hello World From Kivy", font_size=75)
     f.add_widget(s)
     s.add_widget(l)
     return f
Exemple #11
0
 def build(self):
     f = FloatLayout()
     s = Scatter()
     l = Label(text='Heloo World!!!')
     f.add_widget(s)
     s.add_widget(l)
     return f
    def on_touch_up(self, touch):
        """
        Defines action whe the criterion is touched up
        :param touch: the touch point (position, type of touch, ...)
        """
        if not self.destroyed:
            from ZoneUtilisateur import ZoneUtilisateur
            if self.collide_point(touch.x, touch.y) and self.parent is not None and self.support != "tablette" and not self.validated:
                for child in self.parent.children:
                    if child.__class__ == ZoneUtilisateur and child.collide_point(self.center[0], self.center[1]) and child.is_connected():
                        data = '{"Criterion" : "' + self.texte + '", "IdUser" : "' + str(
                            self.createur.identifier) + '", "TextType" : "' + self.text_type + '", "Links" : ['
                        for link in self.links:
                            data += '{ "IdImage" :"' + str(link.id_img) + '",'
                            data += '"SrcImage" : "' + self.parent.get_animal(link.id_img).src_image + '",'
                            data += '"IdUser" :"' + str(link.id_usr) + '",'
                            data += '"Distance" :"' + str(link.distance) + '",'
                            data += '"Angle" :"' + str(link.angle) + '"},'
                        if len(self.links) > 0:
                            data = data[:-1]

                        data += '], "Fusionneurs" : ['
                        for participants in self.fusionneurs:
                            data += '{"IdUser" : "' + str(participants.identifier) + '"},'
                        if len(self.fusionneurs) > 0 :
                           data = data[:-1]
                        data += ']}\n'
                        self.parent.server.send_msg(data, child.user.socket)
                        self.canvas.clear()
                        self.destroyed = True
                        self.parent.criterions.remove(self)
                        self.parent.remove_widget(self)

            Scatter.on_touch_up(self, touch)
Exemple #13
0
    def __init__(self, comicBook, **kwargs):
        super(KivyVisor, self).__init__(**kwargs)
        self.modoVisualizacion = KivyVisor.MODO_NORMAL
        self.scatter = Scatter()
        self.scatter.center = Window.center
        print("scatter center: {}".format(self.scatter.center))
        self.bind(on_touch_down=self.on_touch)
        self.comic = comicBook
        self.comic.openCbFile()
        self.imagenPagina = self.comic.getImagePage()
        self.imagenPagina.size = self.imagenPagina.texture_size
        self.imagenPagina.size_hint = (None, None)
        self.scatter.size_hint = (None, None)
        self.scatter.size = self.imagenPagina.texture_size
        self.scatter.center = Window.center
        print("image size: {}".format(self.imagenPagina.size))
        print("scatter center: {}".format(self.scatter.center))
        print("window center: {}".format(Window.center))
        self.scatter.pos_hint = (None, None)
        self.scatter.add_widget(self.imagenPagina)
        self.scatter.do_rotation = False

        self.scatter.center = (0, 0)
        self.imagenPagina.center = (0, 0)
        '''recordar que la imagen se mueve desde el centro. y la posicion es relativa al centro del contenedor en este caso es el scatter'''
        self.imagenPagina.pos = (0, Window.center[1] -
                                 self.imagenPagina.size[1] / 2)

        self.add_widget(self.scatter)
        # self.scatter.x = 1111
        print("scatter center: {}".format(self.scatter.center))
        print("scatter Heiht: {}".format(self.scatter.height))
        Window.bind(on_motion=self.on_motion)
        Window.bind(on_resize=self.on_sizeWindow)
Exemple #14
0
    def __init__(self, **kwargs):
        super(MyCarousel, self).__init__(**kwargs)
        self.in_anim = False
        global carousel
        carousel = self
        self.images = [
            Image(allow_stretch=True, size=Window.size),
            Image(allow_stretch=True, size=Window.size),
            Image(allow_stretch=True, size=Window.size),
            Image(allow_stretch=True, size=Window.size),
            Image(allow_stretch=True, size=Window.size),
        ]
        self.initialized = False
        self.default_image = Image()
        if plyer.utils.platform != "android":
            self.default_image = Image()
            self._keyboard = Window.request_keyboard(self._keyboard_closed,
                                                     self)
            self._keyboard.bind(on_key_down=self._on_keyboard_down)

        for image in self.images:
            image.displayed = None
            scatter = Scatter()
            scatter.add_widget(image)
            self.add_widget(scatter)

        self.initialized = True
        self.prev_index = self.index
        self.current_index = self.index
        self.initialize()
        self.update_images()
        self.start_automatic()
    def _add_expanded_image (self, wid):
        for child in self._expansion_cont.children:
            if type (child) == FloatLayout:
                self._expansion_cont.remove_widget (child)
        self.pre_cont = BoxLayout (size_hint = (1, 1), padding=10, orientation='horizontal')
        self.pre_cont.canvas.add (Color (0,0,0,0.75))
        self.pre_cont.canvas.add (Rectangle (size=self._expansion_cont.size))
        _handler = Scatter ()
        _image = Image (source = self._img.source,
                        keep_ratio =False, allow_stretch=True)
        _btn = Button (text='Hide', size_hint = (0.05, 1))

        def _center (wid, val):
            img_width = val[0]*0.75
            img_height = img_width / _image.image_ratio
            _image.size = (img_width, img_height)
            _image.pos = ((val[0] - img_width)/2, (val[1] - img_height) / 2)

        _handler.bind (size=_center)
        _btn.bind (on_release =self._rmv_expanded_image)
        _handler.add_widget (_image)
        self.pre_cont.add_widget (_btn)
        self.pre_cont.add_widget (_handler)

        self._expansion_cont.add_widget (self.pre_cont)
Exemple #16
0
    def build(self):
        b = BoxLayout(orientation='vertical')
        t = TextInput(font_size=150,
                      size_hint_y=None,
                      height=200,
                      text='AVE Satan !')

        f = FloatLayout()
        s = Scatter()
        l = Label(text='AVE Satan !', font_size=150)

        t.bind(text=l.setter('text'))
        i = AsyncImage(source="Behemoth.jpg",
                       size_hint=(6, 6),
                       pos_hint={
                           'center_x': .5,
                           'center_y': .01
                       })

        f.add_widget(s)
        s.add_widget(l)

        b.add_widget(t)
        b.add_widget(i)
        b.add_widget(f)

        return b
    def build(self):
        layout_main = BoxLayout(
            orientation='vertical',

        )
        text_input = TextInput(
            font_size=150,
            height=200,
            size_hint_y=None,
            text='default',
        )

        layout = FloatLayout()
        scatter = Scatter()
        label = Label(
            text="default",
            font_size=150,
        )

        text_input.bind(text=label.setter('text'))

        layout.add_widget(scatter)
        scatter.add_widget(label)

        # Order is important - first is top/left
        layout_main.add_widget(text_input)
        layout_main.add_widget(layout)

        return layout_main
Exemple #18
0
    def build(self):
        # TODO:  add a layout like this (that actually works)
        #self.layout = BoxLayout(orientation='vertical', spacing=10)

        col = Widget()

        self.image = AsyncImage(allow_stretch=True,
                                keep_ratio=False,
                                size=(480, 480))

        # call this function once to load the first image
        self.nextImage(self)

        scatter = Scatter(do_rotation=False,
                          auto_bring_to_front=False,
                          size=self.image.get_norm_image_size())
        scatter.add_widget(self.image)

        col.add_widget(scatter)

        button = Button(text='Next', size_hint=(1.0, 0.1))
        button.bind(on_press=self.buttonPressed)
        button.bind(on_release=self.nextImage)
        col.add_widget(button)

        return col
Exemple #19
0
 def build(self):
     f = FloatLayout()
     s = Scatter()
     l = Label(text="Hello world")
     f.add_widget(s)
     s.add_widget(l)
     return f
Exemple #20
0
 def build(self):
     f = FloatLayout()
     s = Scatter()
     l = Label(text="Hello!", font_size=150)
     f.add_widget(s)
     s.add_widget(l)
     return f
Exemple #21
0
	def on_touch_move (self, touch):
		if self.object_moving and touch.uid == self.my_object.owner_id:
			tx = touch.x
			ty = touch.y
			tx = self.push_out_border (tx, self.single_width())
			ty = self.push_out_border (ty, self.height)
			self.my_object.relocate(tx - self.x, ty - self.y)
			"""
			"  border slide  "
			"""
			if self.enable_border_slide:
				if self.on_right_border(touch) and not self.sliding:
					self.sliding = True
					Timer(self.border_delay,self.slide_right).start()
				if self.on_left_border(touch) and not self.sliding:
					self.sliding = True
					Timer(self.border_delay,self.slide_left).start()
				if not self.on_right_border(touch) and not self.on_left_border(touch) and self.sliding:
					self.stop_slide = True
			"""
			"  highlight target  "
			"""
			if self.my_target.collide_point(touch.x-self.x, touch.y-self.y):
				self.my_target.highlight(True)
			else:
				self.my_target.highlight(False)
		if not self.object_moving or touch.uid != self.my_object.owner_id:
			Scatter.on_touch_move(self, touch)
Exemple #22
0
    def __init__(self, **kwargs):
        self.content = None

        self._flex_arrow_layout_params = None
        self._temporarily_ignore_limits = False

        self._arrow_image = Image(source=self.arrow_image,
                                  allow_stretch=False,
                                  color=self.arrow_color)
        self._arrow_image.width = self._arrow_image.texture_size[0]
        self._arrow_image.height = dp(self._arrow_image.texture_size[1])
        self._arrow_image_scatter = Scatter(
            size_hint=(None, None),
            do_scale=False,
            do_rotation=False,
            do_translation=False,
        )
        self._arrow_image_scatter.add_widget(self._arrow_image)
        self._arrow_image_scatter.size = self._arrow_image.texture_size
        self._arrow_image_scatter_wrapper = BoxLayout(size_hint=(None, None), )
        self._arrow_image_scatter_wrapper.add_widget(self._arrow_image_scatter)
        self._arrow_image_layout = RelativeLayout()
        self._arrow_image_layout.add_widget(self._arrow_image_scatter_wrapper)

        self._arrow_layout = None

        super().__init__(**kwargs)
        self.reposition_inner_widgets()
Exemple #23
0
	def on_touch_down (self, touch):
		if not 'markerid' in touch.profile:
			return
		hand_id = int(touch.fid / self.hand_gesture_offset)
		gesture_id = touch.fid % self.hand_gesture_offset
		if not self.object_moving and gesture_id == self.grab_gesture:
			self.canvas.clear()
			self.draw()
			self.canvas.add(Ellipse(pos=(touch.x-self.x, touch.y-self.y), size=(30,30)))
			"""
			"  grab  "
			"""
			if self.my_object.collide_point(touch.x-self.x, touch.y-self.y):
				self.play_grab_sound()
				# does not seem necessary
				# self.my_object.dispatch('on_touch_down', touch)
				self.object_moving = True
				self.my_object.owner_id = hand_id
				self.object_grabbed_event()
				return True

		# keeps x-location of touch, to use for sliding the workspace later
		"""
		"  sense sliding  "
		"""
		if self.object_moving and hand_id != self.my_object.owner_id:
			touch.ud['initial'] = touch.x
			print 'started sliding'

		# calls same function in it's ancestor
		Scatter.on_touch_down(self, touch)
Exemple #24
0
    def set_background(self):
        graphics_widget = FloatLayout()

        for td in self.textures_data:
            filename,xpos,ypos,width,height = td.split(":")
            xpos = float(xpos)
            ypos = float(ypos)
            image = MyImage(keep_ratio=True, allow_stretch=False, color=(0,0,0,0))
            image.set_shadow(False)
            with image.canvas:
                Rectangle(texture=self.textures[filename].texture, size=(float(width) * X_BLOCK, float(height) * Y_BLOCK))
            scatter = Scatter(do_rotation=False, do_scale=False, do_translation=False)
            scatter.pos = (xpos * X_BLOCK, ypos * Y_BLOCK)
            scatter.add_widget(image)
            graphics_widget.add_widget(scatter)

        #for td in self.sprites_data:
        #    filename,xpos,ypos,width,height = td.split(":")
        #    xpos = float(xpos)
        #    ypos = float(ypos)
        #    image = MyImage(texture = self.sprites[filename].texture, keep_ratio=True, allow_stretch=False)
        #    image.set_shadow(False)
        #    scatter = Scatter(do_rotation=False, do_scale=False, do_translation=False)
        #    scatter.pos = (xpos * X_BLOCK, (ypos + 4) * Y_BLOCK / 2)
        #    scatter.add_widget(image)
        #    graphics_widget.add_widget(scatter)
        #    scatter.scale = 6 -  ypos * 1.5

        return graphics_widget
Exemple #25
0
 def build(self):  # 7 Создаем метод build
     #return Button() # 8 Пустая кнопка
     """9 при вводе мы получаем уже кнопку,занимающая ввесь экран, который при клике на экран меняет цвет, Здесь можно получить инфу:
     https://kivy.org/doc/stable/api-kivy.uix.button.html?highlight=uix#module-kivy.uix.button"""
     #return CodeInput(Lexer=HtmlLexer())# 17 на экране будет поле, в котором можно написать например html код
     s = Scatter()  # 24
     fl = FloatLayout(size=(300, 300))  # 21
     s.add_widget(fl)  # 25
     """return Button(text="eto moiya pervaiya knopka", 
             font_size=30,
             on_press=self.btn_press,
             background_color=[1,0,0,1], 
             background_normal='') # 10 Добавим текст и чтоб было какое-то событие у кнопки красно яркого цвета"""
     fl.add_widget(
         Button(text="eto moiya pervaiya knopka",
                font_size=16,
                on_press=self.btn_press,
                background_color=[1, 0, 0, 1],
                background_normal='',
                size_hint=(.5, .25),
                pos=(640 / 2 - 160, 480 / 2 - (480 * .25 / 2))))
     # 22 позиция кнопки
     #return fl
     return s
     """Сolor mainya proga kotoraya otvechet za cvet"""
Exemple #26
0
 def show_images(self):
     # image_list must always contain camera_icon, otherwise image_list[0] in <Images> fails
     copy_list = [im for im in app.daten.image_list if not im[0].endswith(utils.camera_icon)]
     l = len(copy_list)
     if l == 0:
         app.do_capture()
         return
     elif l == 1:
         t = copy_list[0]
         if t[1] is None:
             self.show_single_image(t[0])
         else:
             maxdim = self.app.getConfigValue("maxdim", 1024)
             if self.app.useGoogle:
                 im = self.app.gphoto.getImage(t[1], maxdim)
             else:
                 im = self.app.serverIntf.getImage(t[1], maxdim)
             if im is None:
                 self.app.message("Kann Bild nicht laden")
             else:
                 self.show_single_image(im)
         return
     self.bl.clear_widgets()
     for i, cp in enumerate(copy_list):
         im = AsyncImage(source=cp[0], on_touch_down=self.show_single_image)
         im.size = app.root.sm.size
         im.mediaId = cp[1]
         im.number = i
         # without auto_bring_to_front=False the boxlayout children are reshuffled
         sc = Scatter(do_rotation=False, do_translation=False, do_scale=False, size=im.size,
                      auto_bring_to_front=False, size_hint=(None, None))
         sc.add_widget(im)
         self.bl.add_widget(sc)
Exemple #27
0
    def build(self):
        main_widget = BoxLayout(orientation='horizontal')

        ####### chat #######
        chat = BoxLayout(orientation='vertical')
        t = TextInput(text='default',
                      font_size=15,
                      size_hint_y=0.15,
                      height=100)
        f = FloatLayout()
        s = Scatter()
        l = Label(text='Hello!', font_size=20, size_hint_y=0.85)

        t.bind(text=l.setter('text'))

        f.add_widget(s)
        s.add_widget(l)
        chat.add_widget(f)
        chat.add_widget(t)
        ####### end chat #######

        ####### dummy #######
        carte = BoxLayout(orientation='vertical')
        dummy_label = Label(text='Je suis un label', font_size=20)
        carte.add_widget(dummy_label)
        ####### end dummy #######

        main_widget.add_widget(chat)
        main_widget.add_widget(carte)
        return main_widget
Exemple #28
0
 def __init__(self, *args, **kwargs):
     super(ImagesCarousel, self).__init__(**kwargs)
     for image in carousel_images:
         scatter = Scatter(pos=(100, 200), scale=4, do_scale=True)
         image_to_add = Image(source=images_path + image)
         scatter.add_widget(image_to_add)
         self.add_widget(scatter)
Exemple #29
0
 def input_menu(self):
     ''' create containers for menu gui '''
     main_layout = BoxLayout(orientation='vertical', size_hint=(None, None), size=(400,200))     
     button_layout = BoxLayout(orientation='horizontal')
     
     # add transparent background
     with main_layout.canvas.before:
         Color(.5, .5, .5, .2) 
         self.rect = Rectangle(size=main_layout.size, pos=main_layout.pos)
         
     # create components
     label = Label(font_size=25, text='Enter Username')
     done_button = Button(font_size=25, text='Done')
     exit_button = Button(font_size=25, text='Exit')
     
     # button events
     done_button.bind(on_release=self.get_flickr_images)
     exit_button.bind(on_release=self.exit_application)
     
     # add components to containers
     main_layout.add_widget(label)
     main_layout.add_widget(textbox)
     button_layout.add_widget(done_button)
     button_layout.add_widget(exit_button)
     main_layout.add_widget(button_layout)
     
     s = Scatter(size_hint=(None, None), size=(450,250), pos=(300, 300), do_rotation=False, do_scale=False)
     s.add_widget(main_layout)
     self.root.add_widget(s)
    def on_touch_move(self, touch):
        """
        Update the distance and angle between the animal and each of his links and set the user touching the animal
        :param touch: the position of the touch
        """
        from main import Tablette
        if self.collide_point(touch.x, touch.y) and self.parent is not None:
            for criterion in self.parent.criterions:
                value = criterion.has_link(self.identifier)
                if value != -1:
                    criterion.update_link(value, self.center)

            for child in self.parent.children:
                if child.__class__ == ZoneUtilisateur and child.collide_point(self.center[0], self.center[1]):
                    if self.current_user is None or self.current_user.identifier != child.user.identifier:
                        self.parent.server.send_msg(
                            '{"Image" : "' + str(self.src_image) + '", "ID" : "' + str(self.identifier) + '"}\n',
                            child.user.socket)
                        self.set_user(child.user)

        if self.parent.__class__.__name__ == Tablette.__name__:
            if touch.y > self.parent.height - 40:
                self.parent.client.send_msg('{"Animal" : "' + str(self.identifier) + '"}')
                self.parent.remove_animal(self)

        Scatter.on_touch_move(self, touch)
Exemple #31
0
    def build(self):
        b = BoxLayout(orientation='vertical')
        f = FloatLayout()
        s = Scatter()

        t = TextInput(font_size=150,
                      size_hint_y=None,
                      height=200,
                      text='default')
        l = Label(text="default", font_size=150)

        t.bind(text=l.setter('text'))

        f.add_widget(s)
        s.add_widget(l)

        b.add_widget(t)
        b.add_widget(f)
        button1 = Button(text="Send",
                         background_color=(0.572, 0.45, 0.65, 1),
                         font_size=80,
                         size_hint_y=None,
                         height=100)
        b.add_widget(button1)

        return b
Exemple #32
0
 def __init__(self, **kwargs):
     super(ImagesCarousel, self).__init__(**kwargs)
     for image in carousel_images:
         scatter = Scatter()
         image_to_add = Image(source=mypath+image)
         scatter.add_widget(image_to_add)
         self.add_widget(scatter)
    def on_touch_down(self, touch):
        """
        Defines actions to perform when the criterion is touched up
        :param touch: the touch point (position, type of touch, ...)
        """
        if not self.destroyed:
            if self.collide_point(touch.x, touch.y):
                Scatter.on_touch_down(self, touch)

                if touch.is_double_tap and self.support != "tablette":
                    if self.zoom_mode:
                        self.size = (120,120)
                        self.zoom_mode = False
                    else:
                        self.size = (400, 400)
                        self.zoom_mode = True
                    self.remove_widget(self.label_question)
                    self.remove_widget(self.label_text)
                    self.label_text_pos = [5, 5 + self.size[1] / 5]
                    self.label_text_size = [self.size[0] - 10, self.size[1] - 30 - 2 * self.size[1] / 5]
                    self.label_question_pos = [5, self.size[1] - self.size[1] / 5 - 25]
                    self.label_question_size = [self.size[0] - 10, 20]

                    self.label_question = Label(text=self.text_type, text_size=self.label_question_size,
                                                pos=self.label_question_pos, halign="left", valign='top',
                                                size=self.label_question_size)
                    self.label_text = Label(text=self.text, text_size=self.label_text_size, pos=self.label_text_pos,
                                            valign='top', halign="left", size_hint_y=None, multiline=True,
                                            size=self.label_text_size)
                    self.add_widget(self.label_question)
                    self.add_widget(self.label_text)
Exemple #34
0
 def __init__(self):
     super(Simulation, self).__init__()
     self.scatter = Scatter()
     self.b1 = Button(text="Button 1")
     self.label1 = Label(text=print_message())
     self.add_widget(self.scatter)
     self.scatter.add_widget(self.label1)
Exemple #35
0
 def build(self):
     f = FloatLayout()
     s = Scatter()
     l = Label(text="hi there!", font_size=200)
     f.add_widget(s)
     s.add_widget(l)
     return f
Exemple #36
0
    def build(self):

        s = Scatter()
        fl = FloatLayout(size=(200, 200))

        s.add_widget(fl)
        fl.add_widget(
            Button(text="Это кнопка",
                   font_size=15,
                   on_press=self.btn_press,
                   background_color=[1, 1, 0, 1],
                   background_normal='',
                   size_hint=(.5, .25),
                   pos=(10, 80)))

        fl.add_widget(
            Button(text="Это кнопка2",
                   font_size=15,
                   on_press=self.btn_press2,
                   background_color=[1, 0, 0, 1],
                   background_normal='',
                   size_hint=(.5, .25),
                   pos=(10, 20)))

        return s
Exemple #37
0
    def build(self):
        f = FloatLayout()
        b = Button(pos_hint={'x': 0.5, 'center_y': .5},text='Hello world', font_size=14)
        s = Scatter()
        l = Label(text="Hello!",font_size=150)
        
        def select_to(*args):
            try:
                print args[1][0]
            except:
                pass
    
        fi = FileChooserIconView()

        f.add_widget(s)        
        s.add_widget(l)
        l.add_widget(b)
        
        def callback(instance):
            print('The button <%s> is being pressed' % instance.text)
            
            f.add_widget(fi)
        b.bind(on_press=callback)
        fi.bind(on_selection=select_to)
        return f
Exemple #38
0
 def build(self):
     f=FloatLayout()
     s=Scatter()
     l=Label(text='Hello World',font_size=12)
     f.add_widget(s)
     s.add_widget(l)
     return f
Exemple #39
0
 def build(self):
     f = FloatLayout()
     s = Scatter()
     l = Label(text="Arbind Mehta", font_size=100)
     f.add_widget(s)
     s.add_widget(l)
     return f
Exemple #40
0
    def __init__(self, **kwargs):
        self.showMeasurements = False  #true-> shows gyro and acceleration false -> show gauge

        super(SensorManager, self).__init__(**kwargs)
        sensorSubscriber = SensorSubscriber()
        self.jsonVar = sensorSubscriber.getDummyMsg()
        sensorSubscriber.setMsgCallBackFcn(self.callBackFnct)
        self.label = Label()
        self.add_widget(self.label)

        self.opfer = time.time()
        self.updateLabel()

        self.cadran = Image(source="cadran.png", size_hint=(0, 0))

        self.add_widget(self.cadran)

        self.upsidedown = Image(source="upsidedowncar.jpg", size_hint=(0, 0))

        self.add_widget(self.upsidedown)

        self.lowbattery = Image(source="lowbattery.jpg", size_hint=(0, 0))
        self.add_widget(self.lowbattery)

        self.widgetSize = Window.size
        self.container = Scatter(size=self.widgetSize)
        self.needle = Image(source="needle.png", size=(0, 0))
        self.container.add_widget(self.needle)
        self.add_widget(self.container)

        self.colorflag = 1
Exemple #41
0
class layout(FloatLayout):
    def __init__(self, **kwargs):
        super(layout, self).__init__(**kwargs)
        self.widgetSize = Window.size
        self.cadran = Image(source="cadran.png")
        self.add_widget(self.cadran)

        self.container = Scatter(
            size=self.widgetSize,
            do_rotation=False,
            do_scale=False,
            do_translation=False,
        )
        self.needle = Image(source="needle.png", size=self.widgetSize)
        self.container.add_widget(self.needle)
        self.add_widget(self.container)

        Clock.schedule_interval(self.move, 1)

    def move(self, dt):
        print(self.container.center, self.cadran.center, self.needle.center)
        # self.container.center=self.cadran.center
        #self.container.rotation=45
        self.container.pos_hint = {"center": (.5, .5)}
        self.rotateNeedle(int(time.time()) % 21 * 5)

    def rotateNeedle(self, speed):
        """rotates the value to something between minValue (mapped to 0°) to maxValue (mapped to 180°)"""
        minValue = 0
        maxValue = 100
        if speed < minValue or speed > maxValue:
            raise ValueError("can only display values between {} and {}",
                             minValue, maxValue)
        self.container.size = Window.size
        self.container.rotation = speed / (maxValue - minValue) * 180 - 90
Exemple #42
0
    def __init__(self, **kwargs):
        super(AnalogeGauge, self).__init__(**kwargs)
        self._gauge_widget = Widget()
        self._gauge = self._gauge_widget

        self._needle_widget_safe = Widget()
        self._needle_widget = self._needle_widget_safe

        self._form_processor_constants()

        self._needle = Scatter(size=self.size,
                               do_rotation=False,
                               do_scale=False)

        self._background_widget = Widget()
        self._background = Scatter(size=self.size,
                                   do_rotation=False,
                                   do_scale=False)

        self._glab = Label(font_size=self.size_text,
                           markup=True,
                           font_name='digital')

        self._needle.add_widget(self._needle_widget)

        self.add_widget(self._background)
        self.add_widget(self._gauge)
        self.add_widget(self._glab)
        self.add_widget(self._needle)

        self.bind(pos=self._update)
        self.bind(size=self._update)
        self.bind(value=self._turn)

        self.bind(file_gauge=self._reform_widget_graphics)
        self.bind(file_needle=self._reform_widget_graphics)
        self.bind(file_background=self._reform_widget_graphics)

        self.bind(min_value=self._form_processor_constants)
        self.bind(rotate_clock=self._form_processor_constants)
        self.bind(max_value=self._form_processor_constants)
        self.bind(start_angle=self._form_processor_constants)
        self.bind(angle_width=self._form_processor_constants)

        self.bind(mark_color=self._create_gaudge)
        self.bind(mark_sub_color=self._create_gaudge)
        self.bind(mark_mid_color=self._create_gaudge)
        self.bind(show_middle_marks=self._create_gaudge)
        self.bind(show_middle_marks=self._create_gaudge)
        self.bind(mark_count=self._create_gaudge)
        self.bind(mark_sub_count=self._create_gaudge)

        self.bind(needle_color=self._create_needle)

        self.bind(padding=self._update)

        self._update()
        self._reform_widget_graphics()
        self._turn()
def create_controller():
	#create controller for swiping and pinching in the center

	# few parameters for scaling

	# this defines the active area of dragging/zooming
	normal_scale = 4.5
	# amount of pinch for zoom in and out
	zoom_in_scale = 5.5
	zoom_out_scale = 3.5
	# distance to drag in x and y direction for action
	x_sensitive= Window.center[0]/3
	y_sensitive = Window.center[1]/3


	# Controller(scatter object) that can be scaled and translate
	controller = Scatter(size_hint = (None,None), do_rotation=False, do_translation=True,
	do_scale=True, scale = normal_scale,
	scale_min= zoom_out_scale, scale_max=zoom_in_scale, center = Window.center)

	# a reference object to show the active area
	#control_object = Image()
	#controller.add_widget(control_object)

	#create microscope control parts
	microscope_control = microscope_controller()
	mc.step = 100

# this provides actions when moving and zooming the scatter objects
	def control_feedback(arg1, arg2):
		'the callback functions for controller scatter object'

		if controller.center[0] - Window.center[0] > x_sensitive:
			microscope_control.drag_right()

		elif controller.center[0] - Window.center[0] < -1* x_sensitive:
			microscope_control.drag_left()

		elif controller.center[1] - Window.center[1] > y_sensitive:
			microscope_control.drag_top()

		elif controller.center[1] - Window.center[1] < -1*y_sensitive:
			microscope_control.drag_bot()

		elif controller.scale < zoom_out_scale*1.1:
			microscope_control.pinch_out()

		elif controller.scale > zoom_in_scale*0.9:
			microscope_control.pinch_in()

		'after taking actions, reset scatter location and scale'
		controller.center = Window.center
		controller.scale = normal_scale


	# bind a function to controller when release touch
	controller.bind(on_touch_up = control_feedback)

	return controller
Exemple #44
0
    def build(self):
        f = FloatLayout()
        s = Scatter()
        l = Label(text="Jai Radhekrishna", font_size=12)

        f.add_widget(s)
        s.add_widget(l)
        return f
Exemple #45
0
 def build(self):
     f = FloatLayout()
     s = Scatter()
     l = Label(text='Merhaba \nEfendim!',
               font_size=150)
     f.add_widget(s)
     s.add_widget(l)
     return f
Exemple #46
0
    def build(self):
        l = Label(text='Hola!!',  font_size=160)
        f = FloatLayout()
        s = Scatter()

        f.add_widget(s)
        s.add_widget(l)
        return f
    def build(self):
        myFloatLayout = FloatLayout()
        myScatter = Scatter()
        myLabel = Label(text="Welcome", font_size=110)

        myFloatLayout.add_widget(myScatter)
        myScatter.add_widget(myLabel)
        return myFloatLayout
Exemple #48
0
 def on_touch_down(self, touch):
     #if touch.is_double_tap:
     x = Label(text = "HI!",
           font_size=150)
     s = Scatter(size_hint=(None, None), size=(150,150), pos=(300, 300), do_rotation=False, do_scale=False)
     s.add_widget(x)
     self.root.add_widget(s)
     return s
Exemple #49
0
	def on_touch_move (self, touch):
		# will not work with simple touch anymore
		if not 'markerid' in touch.profile:
			return
		hand_id = int(touch.fid / self.hand_gesture_offset)
		gesture_id = touch.fid % self.hand_gesture_offset

		if self.object_moving and hand_id == self.my_object.owner_id:
			tx = touch.x
			ty = touch.y
			tx = self.push_out_border (tx, self.single_width())
			ty = self.push_out_border (ty, self.height)
			self.my_object.relocate(tx - self.x, ty - self.y)
			"""
			"  border slide  "
			"""
			if self.enable_border_slide:
				if self.on_right_border(touch) and not self.sliding:
					self.sliding = True
					Timer(self.border_delay,self.slide_right).start()
				if self.on_left_border(touch) and not self.sliding:
					self.sliding = True
					Timer(self.border_delay,self.slide_left).start()
				if not self.on_right_border(touch) and not self.on_left_border(touch) and self.sliding:
					self.stop_slide = True

			"""
			"  highlighting target  "
			"""
			if self.my_target.collide_point(touch.x-self.x, touch.y-self.y):
				self.my_target.highlight(True)
			else:
				self.my_target.highlight(False)

			"""
			"  release  "
			"""
			if gesture_id == self.release_gesture and ((-1*self.x) % self.single_width() == 0):
				self.object_moving = False
				self.object_released_event()
				self.play_release_sound()
				"""
				"  collide  "
				"""
				if self.my_target.collide_point(touch.x-self.x, touch.y-self.y):
					self.object_collide_event()
					self.swap_object_target()
					self.play_collide_sound()

		"""
		"  show cursor  "
		"""
		if not self.object_moving or touch.ud != self.my_object.owner_id:
			Scatter.on_touch_move(self, touch)
			self.canvas.clear()
			self.draw()
			self.canvas.add(Color(0,0,0))
			self.canvas.add(Ellipse(pos=(touch.x-self.x, touch.y-self.y), size=(30,30)))
Exemple #50
0
	def on_touch_up (self, touch):
		# calls same function in it's ancestor, and slides the workspace
		Scatter.on_touch_up(self, touch)
		"""
		"  starts sliding  "
		"""
		if ('initial' in touch.ud) and touch.ud['initial'] != None and (not self.object_moving or touch.uid != self.my_object.owner_id) and self.x <= 0 and ((-1*self.x) % self.single_width() == 0) and self.enable_slide:
			current = self.current_workspace()
			# self.current_trial.ws_switch += 1
			#if self.x <= 0 and (-1*self.x) % self.single_width() != 0:
			if touch.ud['initial'] > touch.x:
				if abs(touch.ud['initial'] - touch.x) > self.slide_threshold:
					current = current + 1
					if current >= len(self.frames):
						current = len(self.frames) - 1
					else:
						self.workspace_slide_event()
			else:
				if abs(touch.ud['initial'] - touch.x) > self.slide_threshold:
					current = current - 1
					if current < 0:
						current = 0
					else:
						self.workspace_slide_event()
			self.slide(current)
			touch.ud['initial'] = None
		# if touch lefts from a target trigger that target
		"""
		"  release  "
		"""
		if self.sliding and self.object_moving and touch.uid == self.my_object.owner_id:
				self.stop_slide = True
		if self.object_moving and touch.uid == self.my_object.owner_id and ((-1*self.x) % self.single_width() == 0):
			self.object_moving = False
			self.play_release_sound()
			tx = touch.x
			ty = touch.y
			tx = self.push_out_border (tx, self.single_width())
			ty = self.push_out_border (ty, self.height)
			self.my_object.relocate(tx - self.x, ty - self.y)
			self.object_released_event()
			# if object is released on target, swap them and make a new target
			if self.my_target.collide_point(touch.x-self.x, touch.y-self.y):
				"""
				"  collide  "
				"""
				self.object_collide_event()
				self.swap_object_target()
				self.play_collide_sound()
			else:
				self.my_object.move_back()
			self.my_object.owner_id = None

		# TODO no idea about this - to be removed
		if self.my_target != None and self.my_target.collide_point(touch.x-self.x, touch.y-self.y):
			self.my_target.dispatch('on_touch_up', touch)
			return True
		return False
Exemple #51
0
	def __init__(self):
		Scatter.__init__(self, pos=(200,200), size=(300,300))
		layout = BoxLayout(pos=(50, 50), size=(200,200))
		btn1 = Button(text='Hello')
		btn2 = Button(text='World')
		layout.add_widget(btn1)
		layout.add_widget(btn2)
		self.add_widget(Image(source='img/background.jpg', size=(300,300)))
		self.add_widget(layout)
Exemple #52
0
class Scatter_test(GridLayout):

    def __init__(self, **kwargs):
        super(Scatter_test, self).__init__(**kwargs)
        self.cols = 1
        self.scatter1 = Scatter()
        self.imag1 = Image(source="nature1.jpg")
        self.scatter1.add_widget(self.imag1)
        self.add_widget(self.scatter1)
Exemple #53
0
    def build(self):
        f = FloatLayout()
        s = Scatter()
        l = Label(text="Jai Radhekrishna",
                  font_size=12)

        f.add_widget(s)
        s.add_widget(l)
        return f
Exemple #54
0
 def build(self):
     root = FloatLayout()
     size = (1024, 768)
     for url in urls:
         scatter = Scatter(size=size)
         bk = berkelium.Webbrowser(url=url, size=size)
         scatter.add_widget(bk)
         root.add_widget(scatter)
     return root
 def __init__(self,post,sourcepos,**kw):
     self.downloader=None
     self.post= post 
     self.download('preview')
     Scatter.__init__(self,**kw)
     self.back_animation=Animation(pos=sourcepos,scale=1.2, rotation=0.0)
     self.center_animation=Animation(pos=(0,0),scale=10.0, rotation=0.0)        
     self.next_animation=Animation(pos=(2000,sourcepos[1]),scale=0.1)
     self.prev_animation=Animation(pos=(-1000,sourcepos[1]),scale=0.1)
     self.touches=set()
Exemple #56
0
    def build(self):
        # return a Button() as a root widget
        f = FloatLayout()
        s = Scatter()
        l = Label(text="Hello",
        	font_size=150)

        f.add_widget(s)
        s.add_widget(l)
        return f
Exemple #57
0
	def build(self):
         f = FloatLayout()
         s = Scatter()
         l = Label(text="Hello World!",
				   font_size=50,
                   pos=(200,200))
              
         f.add_widget(s)
         s.add_widget(l)
         return f
    def build(self):
        layout = FloatLayout()
        scatter = Scatter()
        label = Label(text="Hello world!",
                      font_size=150)

        layout.add_widget(scatter)
        scatter.add_widget(label)

        return layout
Exemple #59
0
class TopDisplay(RelativeLayout):
    def on_parent(self, *args):
        self.population_data = json_load('county_population.json')
        self.map_view = Scatter(scale=.7)
        self.map_view.x += 400
        self.map_view.y += 100
        county_data = json_load('counties.json')
        for county, data in county_data.iteritems():
            data['population'] = self.population_data[county]
            self.map_view.add_widget(County(**data))
        self.add_widget(self.map_view)
Exemple #60
0
 def build(self):
     if len(argv) > 1:
         filename = argv[1]
     else:
         curdir = dirname(__file__)
         filename = join(curdir, 'softboy.avi')
     video = Video(source=filename, play=True)
     scatter = Scatter()
     video.bind(texture_size=scatter.setter('size'))
     scatter.add_widget(video)
     return scatter