Exemplo n.º 1
0
class ship(Widget):
    unit = NumericProperty(1)
    width_ship = NumericProperty()
    height_ship = NumericProperty()
    file_ship = StringProperty()
    value = NumericProperty()

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

        self._ship = ScatterLayout(size=(self.width_ship, self.height_ship),
                                   do_rotate=False,
                                   do_scale=False,
                                   do_translation=False)

        self._img_ship = Image(source=self.file_ship,
                               size=(self.width_ship, self.height_ship),
                               allow_stretch=True)

        self.add_widget(self._ship)
        self._ship.add_widget(self._img_ship)
        self.bind(pos=self._update)
        self.bind(size=self._update)
        self.bind(value=self._aniSweep)

    def _update(self, *args):
        #self._radar.pos = self.pos
        self._ship.pos = (self.x, self.y)
        self._ship.center = self._ship.center
        self._ship.size = (self.width_ship, self.height_ship)

    def _aniSweep(self, *args):
        self._ship.rotation = -float(self.value) * self.unit
Exemplo n.º 2
0
class LatexWidget(BoxLayout):
    text = StringProperty('')

    def __init__(self, **kwargs):
        self.scatterlayout = ScatterLayout(do_rotation=False,
                                           do_translation_y=False)
        super(LatexWidget, self).__init__(**kwargs)
        self.add_widget(self.scatterlayout)

    @staticmethod
    def latex_image(latex_str):
        fig, ax = pyplot.subplots()
        ax.axis('off')
        ax.text(.5,
                .5,
                latex_str,
                size=20,
                horizontalalignment='center',
                verticalalignment='center',
                bbox={})
        return FigureCanvasKivyAgg(fig)

    def on_text(self, *args):
        if self.scatterlayout.children:
            self.remove_widget(self.scatterlayout.children[0])
        im = LatexWidget.latex_image(self.text)
        self.scatterlayout.add_widget(im)
Exemplo n.º 3
0
    def __init__(self, **kwargs):
        super(radar, self).__init__(**kwargs)

        self._radar = ScatterLayout(size=(self.width_radar, self.height_radar),
                                    do_rotate=False,
                                    do_scale=False,
                                    do_translation=False)

        _img_radar = Image(source='radar_1.png',
                           size=(self.width_radar, self.height_radar),
                           allow_stretch=True)

        self._sweeperGauge = ScatterLayout(size=(self.width_radar,
                                                 self.height_radar),
                                           do_rotate=False,
                                           do_scale=False,
                                           do_translation=False)

        self._img_sweeper = Image(source='Sweeper.png',
                                  size=(self.width_radar, self.height_radar),
                                  allow_stretch=True)

        self._radar.add_widget(_img_radar)
        self.add_widget(self._radar)
        self.add_widget(self._sweeperGauge)
        self._sweeperGauge.add_widget(self._img_sweeper)
        self.bind(pos=self._update)
        self.bind(size=self._update)
        self.bind(value=self._aniSweep)
Exemplo n.º 4
0
def main_base_menu(build_place):
    scatter = ScatterLayout()
    menu = building.MenuLayout()
    inside_menu = building.InsideMenuLayout()
    main_box = BoxLayout(orientation='horizontal')
    left_box = BoxLayout(orientation='vertical', size_hint_x=.35)
    right_box = BoxLayout(size_hint_x=.65)
    icon_bottom_box = BoxLayout(size_hint=(.9, .8))
    icon_layout = BoxLayout(size_hint_y=.4)  # pos_hint=({'top': 1})

    # Вывод производства ресурсов
    stat_res = res_generation('main_base')

    # Добавление вкладок Здания
    tb = TabbedPanel(do_default_tab=False, tab_width=130)
    base_e = TabbedPanelItem(text='Энергия')
    base_e.content = base_energy()
    base_f = TabbedPanelItem(text='Пища')
    base_f.content = base_food()
    tb.add_widget(base_e)
    tb.add_widget(base_f)

    icon_bottom_box.add_widget(stat_res)
    icon_layout.add_widget(Image(source='data/images/buildings/main-base.png'))
    left_box.add_widget(icon_layout)
    left_box.add_widget(icon_bottom_box)
    right_box.add_widget(tb)
    main_box.add_widget(left_box)
    main_box.add_widget(right_box)
    inside_menu.add_widget(main_box)
    close_b = building.CloseMenuButton(build_place, scatter)
    menu.add_widget(inside_menu)
    menu.add_widget(close_b)
    scatter.add_widget(menu)
    return scatter
Exemplo n.º 5
0
class hitPin(Widget):
    width_shot = NumericProperty()
    height_shot = NumericProperty()
    file_pin = StringProperty()

    def __init__(self, **kwargs):
        super(hitPin, self).__init__(**kwargs)
        #self.animation = Clock.create_trigger(self.animateHit, 0.5)
        
            
        self._shot = ScatterLayout(
            size=(self.width_shot, self.height_shot),
            do_rotate=False, 
            do_scale=False, 
            do_translation=False
            )

        _img_shot = Image(source=self.file_pin, size=(self.width_shot, 
            self.height_shot), allow_stretch=True)


        self._shot.add_widget(_img_shot)   
        self.add_widget(self._shot)
        self.bind(pos=self._update)
        self.bind(size=self._update)
        
    def _update(self, *args):
        self._shot.pos = self.pos
        #self.cur_pos = self._shot.pos
        #self.animation()

    def animateHit(self, dt):
        self._shot.size = (self.width_shot/2, self.height_shot/2)
Exemplo n.º 6
0
 def build(self):  # pylint: disable=no-self-use; # pragma: no cover
     """Called when the app is created."""
     layout = ScatterLayout(translation_touches=2,
                            do_rotation=False,
                            scale_min=0.2,
                            scale_max=1.5)
     layout.add_widget(self._grid_widget)
     return layout
Exemplo n.º 7
0
 def __init__(self, **kwargs):
     ScatterLayout.__init__(self, **kwargs)
     self.FACTOR_LINE = 1.2
     self.FACTOR_TRIANGLE = .1
     with self.canvas:
         Color(0, 0, 0)
         self.rules = Line(points=[-5,-5, self.width*self.FACTOR_LINE-5,-5, -5,-5, -5, self.height*self.FACTOR_LINE-5])
     self.bind(size=self.draw_rules)
Exemplo n.º 8
0
 def __init__(self, **kwargs):
     ScatterLayout.__init__(self, **kwargs)
     self.FACTOR_LINE = 1.2
     self.FACTOR_TRIANGLE = .1
     with self.canvas:
         Color(0, 0, 0)
         self.rules = Line(points=[
             -5, -5, self.width * self.FACTOR_LINE -
             5, -5, -5, -5, -5, self.height * self.FACTOR_LINE - 5
         ])
     self.bind(size=self.draw_rules)
Exemplo n.º 9
0
class MyBigImage(FloatLayout):
    def __init__(self, **kwargs):
        super(MyBigImage, self).__init__(**kwargs)
	self.addImage("oak.jpeg")

    def addImage(self, filename):
	self.layout = ScatterLayout()
        #self.layout.scale = 1.8
        #self.layout.scale_min= 1.5
        #self.layout.scale_max= 4.5
        self.image = Image(source=filename, mipmap=True)
	self.layout.add_widget(self.image)
	self.add_widget(self.layout)
Exemplo n.º 10
0
        def build(self):
            main_widget = ScatterLayout()
            map_file_path = 'test/assets/testmap.tmx'

            def add_widgets():
                Logger.debug(
                    'TiledApp: creating tile map using map file: {}'.format(
                        map_file_path))
                tile_map = TileMap(map_file_path)

                Logger.debug('TiledApp: adding tile map to main widget')
                main_widget.add_widget(tile_map)

                Logger.debug('TiledApp: creating TileMovement widget')
                tile_movement = TileMovement(tile_map)
                tile_movement.debug()
                tile_movement.size_hint = 0.1, 0.1

                #main_widget.add_widget(tile_movement)

                def move_demo():
                    direction = tile_movement.RIGHT
                    Logger.debug('move_demo: moving {}'.format(direction))
                    tile_movement.move(direction)

                #Clock.schedule_interval(lambda *args: move_demo(), 2)

            Clock.schedule_once(lambda *args: add_widgets())
            return main_widget
    def on_touch_up(self, touch: MotionEvent):
        ScatterLayout.on_touch_up(self, touch)
        dx, dy = touch.ox - touch.x, touch.oy - touch.y

        if (graphicsConfig.getint("BaseLayout", "maximum_move_distance_for_select") * -1) <= dx <= \
                graphicsConfig.getint("BaseLayout", "maximum_move_distance_for_select") and \
                (graphicsConfig.getint("BaseLayout", "maximum_move_distance_for_select") * -1) <= dy <= \
                graphicsConfig.getint("BaseLayout", "maximum_move_distance_for_select") and not \
                touch.is_mouse_scrolling and touch.grab_current == self:

            self.log_deep_debug(
                "Touch up and within 5 of touch origin, running base layout building select"
            )
            self.base_layout_on_touch_up_function(*self.to_local(*touch.pos))

        self.fix_transform_edges(touch)
Exemplo n.º 12
0
    def build(self, testMode=True):
        """
        Initiate objects and views.
        """
        ''' init game objects '''
        self.deck = Deck()
        self.evaluator = Evaluator()

        self.player = []
        self.player.append(Player(0))
        self.player.append(Player(1))
        # board stands for public cards on board
        self.board = Board()

        # In test mode, both player select right-most cards for the turn automatically
        self.testMode = testMode
        ''' create view objects '''
        # Scatter that can be rotated to display players
        scatter_bot = ScatterLayout(do_rotation=False,
                                    do_translation=False,
                                    do_scale=False,
                                    size_hint=(1, 1),
                                    pos_hint={
                                        'x': 0,
                                        'y': 0
                                    },
                                    rotation=0)
        # For player on top, the widget rotates 180 degree
        scatter_top = ScatterLayout(do_rotation=False,
                                    do_translation=False,
                                    do_scale=False,
                                    size_hint=(1, 1),
                                    pos_hint={
                                        'x': 0,
                                        'y': 0
                                    },
                                    rotation=180)

        box = PlayerDeck()
        box2 = PlayerDeck()
        publicArea = PublicArea()
        box.build(self, "player1", 0, self.testMode)
        box2.build(self, "player2", 1, self.testMode)
        publicArea.build()

        scatter_bot.add_widget(box)
        scatter_top.add_widget(box2)

        self.add_widget(scatter_bot)
        self.add_widget(scatter_top)
        self.add_widget(publicArea)

        # register id of view objects
        self.ids[box.id] = box
        self.ids[box2.id] = box2
        self.ids[publicArea.id] = publicArea
Exemplo n.º 13
0
    def __init__(self, **kwargs):
        super(ship, self).__init__(**kwargs)

        self._ship = ScatterLayout(size=(self.width_ship, self.height_ship),
                                   do_rotate=False,
                                   do_scale=False,
                                   do_translation=False)

        self._img_ship = Image(source=self.file_ship,
                               size=(self.width_ship, self.height_ship),
                               allow_stretch=True)

        self.add_widget(self._ship)
        self._ship.add_widget(self._img_ship)
        self.bind(pos=self._update)
        self.bind(size=self._update)
        self.bind(value=self._aniSweep)
Exemplo n.º 14
0
    def addImage(self, filename):
	self.layout = ScatterLayout()
        #self.layout.scale = 1.8
        #self.layout.scale_min= 1.5
        #self.layout.scale_max= 4.5
        self.image = Image(source=filename, mipmap=True)
	self.layout.add_widget(self.image)
	self.add_widget(self.layout)
Exemplo n.º 15
0
class hitBang(Widget):
    width_shot = NumericProperty()
    height_shot = NumericProperty()
    file_pin = StringProperty()

    def __init__(self, **kwargs):
        super(hitBang, self).__init__(**kwargs)
        self.animation = Clock.create_trigger(self.animateHit, 0.25)
        self.cur_pos = (0.0, 0.0)
        self.ani = 0

        self._shot = ScatterLayout(size=(self.width_shot, self.height_shot),
                                   do_rotate=False,
                                   do_scale=False,
                                   do_translation=False)

        _img_shot = Image(source=self.file_pin,
                          size=(self.width_shot, self.height_shot),
                          allow_stretch=True)

        self._shot.add_widget(_img_shot)
        self.add_widget(self._shot)
        self.bind(pos=self._update)
        self.bind(size=self._update)

    def _update(self, *args):
        self._shot.pos = self.pos
        self.cur_pos = self._shot.pos
        self.animation()

    def animateHit(self, dt):
        if self.ani == 1:
            self._shot.size = (self.width_shot / 4, self.height_shot / 4)
            self._shot.pos = (self.cur_pos[0] + self.width_shot / 2.75,
                              self.cur_pos[1] + self.height_shot / 2.75)
        if self.ani == 2:
            self._shot.size = (self.width_shot / 2, self.height_shot / 2)
            self._shot.pos = (self.cur_pos[0] + self.width_shot / 4,
                              self.cur_pos[1] + self.height_shot / 4)
        if self.ani == 3:
            self._shot.size = (self.width_shot, self.height_shot)
            self._shot.pos = (self.cur_pos[0], self.cur_pos[1])
        if self.ani == 4:
            self.ani = 0
        self.ani += 1
        self.animation()
Exemplo n.º 16
0
def prod_menu(build_place):
    scatter = ScatterLayout()
    menu = MenuLayout()
    inside_menu = InsideMenuLayout()
    main_box = BoxLayout(orientation='horizontal')
    left_box = BoxLayout(orientation='vertical', size_hint_x=.35)
    right_box = BoxLayout(size_hint_x=.65)
    icon_bottom_box = BoxLayout(size_hint=(.9, .8))
    icon_layout = BoxLayout(size_hint_y=.4)  # pos_hint=({'top': 1})
    statistic_grid = GridLayout(cols=1,
                                size_hint_y=None,
                                pos_hint=({
                                    'top': .9
                                }),
                                spacing=10,
                                padding=5)
    for r in config.resources:
        res = config.resources[r]
        stat_box = BoxLayout(orientation='horizontal',
                             height=40,
                             size_hint_y=None)
        stat_box.add_widget(Image(source=res[2], size_hint_x=.2))
        stat_box.add_widget(Label(text=f'{res[0]}', size_hint_x=.8))
        statistic_grid.add_widget(stat_box)
    tb = TabbedPanel(do_default_tab=False, tab_width=130)
    ti = TabbedPanelItem(text='Улучшения')
    ti.content = prod_upgrade_content()
    tb.add_widget(ti)
    tb.add_widget(TabbedPanelItem(text='Автоматизация'))
    tb.add_widget(TabbedPanelItem(text='Статистика'))
    icon_bottom_box.add_widget(statistic_grid)
    icon_layout.add_widget(Image(source='data/images/buildings/buildings.zip'))
    left_box.add_widget(icon_layout)
    left_box.add_widget(icon_bottom_box)
    right_box.add_widget(tb)
    main_box.add_widget(left_box)
    main_box.add_widget(right_box)
    inside_menu.add_widget(main_box)
    close_b = CloseMenuButton(build_place, scatter)
    menu.add_widget(inside_menu)
    menu.add_widget(close_b)
    scatter.add_widget(menu)
    return scatter
Exemplo n.º 17
0
 def on_touch_up(self, touch):
     #clear only if we clicked in the stencil view
     CLEAR = self.parent.collide_point(*touch.pos)
     for widget in self.designer.current_template.children:
         if widget.collide_point(*widget.parent.to_widget(*touch.pos)):
             CLEAR = False
     if CLEAR:
         self.designer.selections = dict()
         self.designer.last_selected = None
     return ScatterLayout.on_touch_up(self, touch)
Exemplo n.º 18
0
 def gen_set(self):
     scatter = ScatterLayout()
     menu = building.MenuLayout()
     inside_menu = building.InsideMenuLayout()
     main_box = BoxLayout(orientation='horizontal')
     left_box = BoxLayout(orientation='vertical', size_hint_x=.35)
     right_box = BoxLayout(size_hint_x=.65)
     icon_bottom_box = BoxLayout(size_hint=(.9, .8))
     icon_layout = BoxLayout(size_hint_y=.4)  # pos_hint=({'top': 1})
     left_box.add_widget(icon_layout)
     left_box.add_widget(icon_bottom_box)
     main_box.add_widget(left_box)
     main_box.add_widget(right_box)
     inside_menu.add_widget(main_box)
     close_b = building.CloseMenuButton(self, scatter)
     menu.add_widget(inside_menu)
     menu.add_widget(close_b)
     scatter.add_widget(menu)
     return scatter
Exemplo n.º 19
0
class radar(Widget):
    unit = NumericProperty(1)
    width_radar = NumericProperty()
    height_radar = NumericProperty()
    value = NumericProperty()

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

        self._radar = ScatterLayout(size=(self.width_radar, self.height_radar),
                                    do_rotate=False,
                                    do_scale=False,
                                    do_translation=False)

        _img_radar = Image(source='radar_1.png',
                           size=(self.width_radar, self.height_radar),
                           allow_stretch=True)

        self._sweeperGauge = ScatterLayout(size=(self.width_radar,
                                                 self.height_radar),
                                           do_rotate=False,
                                           do_scale=False,
                                           do_translation=False)

        self._img_sweeper = Image(source='Sweeper.png',
                                  size=(self.width_radar, self.height_radar),
                                  allow_stretch=True)

        self._radar.add_widget(_img_radar)
        self.add_widget(self._radar)
        self.add_widget(self._sweeperGauge)
        self._sweeperGauge.add_widget(self._img_sweeper)
        self.bind(pos=self._update)
        self.bind(size=self._update)
        self.bind(value=self._aniSweep)

    def _update(self, *args):
        self._radar.pos = self.pos
        self._sweeperGauge.pos = (self.x, self.y)
        self._sweeperGauge.center = self._radar.center

    def _aniSweep(self, *args):
        self._sweeperGauge.rotation = -float(self.value) * self.unit
Exemplo n.º 20
0
    def __init__(self, **kwargs):
        super(hitBang, self).__init__(**kwargs)
        self.animation = Clock.create_trigger(self.animateHit, 0.25)
        self.cur_pos = (0.0, 0.0)
        self.ani = 0

        self._shot = ScatterLayout(size=(self.width_shot, self.height_shot),
                                   do_rotate=False,
                                   do_scale=False,
                                   do_translation=False)

        _img_shot = Image(source=self.file_pin,
                          size=(self.width_shot, self.height_shot),
                          allow_stretch=True)

        self._shot.add_widget(_img_shot)
        self.add_widget(self._shot)
        self.bind(pos=self._update)
        self.bind(size=self._update)
Exemplo n.º 21
0
 def on_touch_up(self, touch):
     #clear only if we clicked in the stencil view
     CLEAR = self.parent.collide_point(*touch.pos)
     for widget in self.designer.current_template.children:
         if widget.collide_point(*widget.parent.to_widget(*touch.pos)):
             CLEAR = False
     if CLEAR:
             self.designer.selections = dict()
             self.designer.last_selected = None
     return ScatterLayout.on_touch_up(self, touch)
    def __init__(self, **kwargs):
        super(ListScreen, self).__init__(**kwargs)
        layout = BoxLayout(orientation='vertical')
        self.add_widget(layout)
        top_buttons = BoxLayout(orientation='horizontal')
        layout.add_widget(top_buttons)
        bottom_buttons = ScatterLayout()
        layout.add_widget(bottom_buttons)

        top_buttons.add_widget(Button(text='Save'))
        top_buttons.add_widget(Button(text='Dave Doty'))
Exemplo n.º 23
0
 def open_terminal(self):
     scatter_terminal = ScatterLayout(size_hint=(.4, .5))
     terminal_lay = TerminalRelativeLayout()
     scroll_terminal = TerminalScrollView(size_hint=(.97, .87), pos_hint=({'center_x': .5, 'top': .9}))
     terminal_top = RelativeLayout(size_hint=(.97, .1), pos_hint=({'center_x': .5, 'top': 1}))
     terminal_top.add_widget(TerminalIcon(pos_hint=({'x': .005, 'top': 1}), size_hint_x=.04))
     terminal_top.add_widget(TerminalTitleLabel(text=r'C:\JARVIS\Terminal [Version 7.1.2336]',
                                                pos_hint=({'x': .05, 'top': 1}), size_hint_x=.992))
     terminal_top.add_widget(
         TerminalClose(parent_lay=self.layout, close_lay=scatter_terminal, pos_hint=({'right': .99, 'top': 1}),
                       size_hint_x=.04))
     terminal_main = TerminalGridLayout(cols=1, size_hint_y=None, padding=3, spacing=5)
     terminal_main.bind(minimum_height=terminal_main.setter('height'))
     terminal_main.add_widget(
         TerminalLabel(text='JARVIS Terminal (c) Corporation JARVIS, 2044. All rights reserved'))
     terminal_main.add_widget(TerminalTextInput(grid=terminal_main))
     terminal_lay.add_widget(terminal_top)
     scroll_terminal.add_widget(terminal_main)
     terminal_lay.add_widget(scroll_terminal)
     scatter_terminal.add_widget(terminal_lay)
     self.layout.add_widget(scatter_terminal)
    def on_touch_down(self, touch: MotionEvent):
        if touch.is_mouse_scrolling:
            # dx, dy, dz = 0, 0, 0
            # z = self.scale

            if touch.button == 'scrolldown':

                if self.scale < self.scale_max:

                    nextScale = self.scale * (1 + self.scroll_sensitivity)
                    if nextScale < self.scale_max:
                        self.scale = nextScale

                    else:
                        self.scale = self.scale_max

            elif touch.button == 'scrollup':
                if self.scale > self.scale_min:

                    nextScale = self.scale * (1 - self.scroll_sensitivity)
                    if nextScale > self.scale_min:
                        self.scale = nextScale

                    else:
                        self.scale = self.scale_min

            else:
                self.log_warning(
                    "Touch event was sent and mouse was scrolling but not up or down - ",
                    touch)

            # bdz = self.scale - z
            # self.dispatch("on_transformed", dx, dy, dz)
            self.dispatch("on_transform_with_touch", touch)
            GlobalEvents.dispatch("on_scatter_transformed")

        else:
            ScatterLayout.on_touch_down(self, touch)

        self.fix_transform_edges(touch)
Exemplo n.º 25
0
def base_window(build_place):  # Шаблон для окна
    scatter = ScatterLayout()
    menu = MenuLayout()
    inside_menu = InsideMenuLayout()
    main_box = BoxLayout(orientation='horizontal', minimum_size=(700, 400))
    left_box = BoxLayout(orientation='vertical', size_hint_x=.3)
    right_box = BoxLayout(size_hint_x=.7)
    bottom_box = BoxLayout(size_hint=(.95, .8))
    icon_box = FrameBoxLayout(orientation='vertical', size_hint_y=.4)
    statistic_grid = GridLayout(cols=1, spacing=10, padding=5)
    icon_box.add_widget(Image(source=config.empty_icon))
    left_box.add_widget(icon_box)
    bottom_box.add_widget(statistic_grid)
    left_box.add_widget(bottom_box)
    main_box.add_widget(left_box)
    main_box.add_widget(right_box)
    inside_menu.add_widget(main_box)
    close_b = CloseMenuButton(build_place, scatter)
    menu.add_widget(inside_menu)
    menu.add_widget(close_b)
    scatter.add_widget(menu)
    return scatter, icon_box, statistic_grid, right_box
Exemplo n.º 26
0
def menu_content(build_place):
    tb = TabbedPanel(do_default_tab=False, tab_width=150)
    tab_all = TabbedPanelHeader(text='Все')
    tab_war = TabbedPanelHeader(text='Военные')
    tab_prod = TabbedPanelItem(text='Производственные')
    tab_social = TabbedPanelHeader(text='Социальные')
    scatter = ScatterLayout(id='scatter_layout')  # size_hint_max=(1000, 800)
    name_label = PlaceLabel(text=f'Место для строительства: {build_place.id}')
    menu = MenuLayout()
    inside_menu = InsideMenuLayout()
    tb.add_widget(tab_all)
    tb.add_widget(tab_war)
    tb.add_widget(tab_social)
    tb.add_widget(tab_prod)
    for tab in tb.tab_list:
        tab.content = create_building_list(tab.text, build_place, scatter)
    inside_menu.add_widget(tb)
    menu.add_widget(inside_menu)
    menu.add_widget(name_label)
    close_b = CloseMenuButton(build_place, scatter)
    menu.add_widget(close_b)
    scatter.add_widget(menu)
    return scatter
    def __init__(self, **kwargs):
        # 父类构造方法
        super().__init__(**kwargs)

        # 设置背景颜色(可忽略)
        with self.canvas:
            # 背景颜色
            Color(1, 1, 1, 1)
            # 浮动布局矩形 = 矩形(位置=布局位置,大小=布局大小)
            self.rect = Rectangle(pos=self.pos, size=self.size)
            # 浮动布局绑定(位置=布局矩形位置,大小=设置背景尺寸)
            self.bind(pos=self.update_rect, size=self.update_rect)

        # 缩放布局
        scatter_layout = ScatterLayout()

        # 异步图片
        image = AsyncImage(source='http://sck.rjkflm.com/images/logo1.png')

        # 布局加组件(异步图片)
        scatter_layout.add_widget(image)

        # 布局加组件(缩放布局)
        self.add_widget(scatter_layout)
Exemplo n.º 28
0
proglabel = Label(text="None\nDeveloper",color=(1,1,1,0),font_size="13sp")
#proglabel.pos_hint_x = .2
#proglabel.pos_hint_y = 0
proglabel.pos_hint = {"x":.25,"y":-.4}
progimg = Image(source="loadingmat.gif",keep_ratio=False,allow_stretch=True,anim_delay=0.05)
progimg.size_hint = .14,.75
progimg.pos_hint ={"x":1.1,"y":.1}
progbg = RootWidget()
progbg.setbg(progbg,(1,1,1,1))
progbg.size_hinz = .15, 1
progbg.pos_hint = {"x":.85,"y":0}
titlebar.add_widget(progbg)
titlebar.add_widget(progimg)
titlebar.add_widget(proglabel)
titlelab.pos_hint = {"x":-.1,"y":0}
titlescat = ScatterLayout()
titlescat.size_hint = None,None
sidebar = RootWidget()
sidebar.setbg(sidebar,(.8,.8,.8,1))
sidebar.size_hint = .8,.9
sidebar.pos_hint = {"x":-.8,"y":0}
exitbt = Button(text="Beenden",background_color=(0,1,1,1))
exitbt.size_hint = 1,.1
exitbt.pos_hint = {"x":0,"y":0}
exitbt.bind(on_release=exitapp)
sidebar.add_widget(exitbt)
secbt = Button(text="Entwickler - Bereich",background_color=(0,0,0,1))
secbt.size_hint = 1,.1
secbt.pos_hint = {"x":0,"y":.8}
sm.add_widget(secac)
secbt.bind(on_release=goto_secure)
Exemplo n.º 29
0
 def __init__(self, **kwargs):
     self.scatterlayout = ScatterLayout(do_rotation=False,
                                        do_translation_y=False)
     super(LatexWidget, self).__init__(**kwargs)
     self.add_widget(self.scatterlayout)
 def __init__(self, **kwargs):
     ScatterLayout.__init__(self, **kwargs)
     BetterLogger.__init__(self)
Exemplo n.º 31
0
    def build(self):
        sl = ScatterLayout()
        al = AnchorLayout()
        bl = BoxLayout(orientation='vertical', padding=[.05, .05], spacing=2)
        bl1 = BoxLayout(orientation='horizontal', spacing=0)
        bl2 = BoxLayout(orientation='horizontal', spacing=0)
        bl3 = BoxLayout(orientation='horizontal', spacing=0)
        bl4 = BoxLayout(orientation='horizontal', spacing=0)
        bl5 = BoxLayout(orientation='horizontal', spacing=0)
        bl6 = BoxLayout(orientation='horizontal', spacing=0)
        bl7 = BoxLayout(orientation='horizontal', spacing=0)
        bl8 = BoxLayout(orientation='horizontal', spacing=0)
        bl9 = BoxLayout(orientation='horizontal',
                        spacing=0,
                        size_hint=(1, .5),
                        padding=[0])

        self.lab1 = Label(text='Зона №1')
        self.lab1.bind(size=self._update_rect1, pos=self._update_rect1)
        with self.lab1.canvas.before:
            Color(0, 43, 230, 255)
            self.rect1 = Rectangle(size=self.lab1.size, pos=self.lab1.pos)
        self.bt1 = Button(text='Вкл', size_hint=(.2, 1))
        self.bt1.bind(on_press=self.pressing1)

        self.lab2 = Label(text='Зона №2')
        self.lab2.bind(size=self._update_rect2, pos=self._update_rect2)
        with self.lab2.canvas.before:
            Color(0, 43, 230, 255)  # green; colors range from 0-1 not 0-255
            self.rect2 = Rectangle(size=self.lab2.size, pos=self.lab2.pos)
        self.bt2 = Button(text='Вкл', size_hint=(.2, 1))
        self.bt2.bind(on_press=self.pressing2)

        self.lab3 = Label(text='Зона №3')
        self.lab3.bind(size=self._update_rect3, pos=self._update_rect3)
        with self.lab3.canvas.before:
            Color(0, 43, 230, 255)  # green; colors range from 0-1 not 0-255
            self.rect3 = Rectangle(size=self.lab3.size, pos=self.lab3.pos)
        self.bt3 = Button(text='Вкл', size_hint=(.2, 1))
        self.bt3.bind(on_press=self.pressing3)

        self.lab4 = Label(text='Зона №4')
        self.lab4.bind(size=self._update_rect4, pos=self._update_rect4)
        with self.lab4.canvas.before:
            Color(0, 43, 230, 255)  # green; colors range from 0-1 not 0-255
            self.rect4 = Rectangle(size=self.lab4.size, pos=self.lab4.pos)
        self.bt4 = Button(text='Вкл', size_hint=(.2, 1))
        self.bt4.bind(on_press=self.pressing4)

        self.lab5 = Label(text='Зона №5')
        self.lab5.bind(size=self._update_rect5, pos=self._update_rect5)
        with self.lab5.canvas.before:
            Color(0, 43, 230, 255)  # green; colors range from 0-1 not 0-255
            self.rect5 = Rectangle(size=self.lab5.size, pos=self.lab5.pos)
        self.bt5 = Button(text='Вкл', size_hint=(.2, 1))
        self.bt5.bind(on_press=self.pressing5)

        self.lab6 = Label(text='Зона №6')
        self.lab6.bind(size=self._update_rect6, pos=self._update_rect6)
        with self.lab6.canvas.before:
            Color(0, 43, 230, 255)  # green; colors range from 0-1 not 0-255
            self.rect6 = Rectangle(size=self.lab6.size, pos=self.lab6.pos)
        self.bt6 = Button(text='Вкл', size_hint=(.2, 1))
        self.bt6.bind(on_press=self.pressing6)

        self.lab7 = Label(text='Зона №7')
        self.lab7.bind(size=self._update_rect7, pos=self._update_rect7)
        with self.lab7.canvas.before:
            Color(0, 43, 230, 255)  # green; colors range from 0-1 not 0-255
            self.rect7 = Rectangle(size=self.lab7.size, pos=self.lab7.pos)
        self.bt7 = Button(text='Вкл', size_hint=(.2, 1))
        self.bt7.bind(on_press=self.pressing7)

        self.lab8 = Label(text='Зона №8')
        self.lab8.bind(size=self._update_rect8, pos=self._update_rect8)
        with self.lab8.canvas.before:
            Color(0, 43, 230, 255)  # green; colors range from 0-1 not 0-255
            self.rect8 = Rectangle(size=self.lab8.size, pos=self.lab8.pos)
        self.bt8 = Button(text='Вкл', size_hint=(.2, 1))
        self.bt8.bind(on_press=self.pressing8)

        self.lab9 = Label()
        self.bt9 = Button(text='Подключиться', size_hint=(1, 1))
        self.bt9.bind(on_press=self.pressing9)
        self.lab10 = Label()

        sl.add_widget(al)
        al.add_widget(bl)
        bl.add_widget(bl1)
        bl1.add_widget(self.lab1)
        bl1.add_widget(self.bt1)
        bl.add_widget(bl2)
        bl2.add_widget(self.lab2)
        bl2.add_widget(self.bt2)
        bl.add_widget(bl3)
        bl3.add_widget(self.lab3)
        bl3.add_widget(self.bt3)
        bl.add_widget(bl4)
        bl4.add_widget(self.lab4)
        bl4.add_widget(self.bt4)
        bl.add_widget(bl5)
        bl5.add_widget(self.lab5)
        bl5.add_widget(self.bt5)
        bl.add_widget(bl6)
        bl6.add_widget(self.lab6)
        bl6.add_widget(self.bt6)
        bl.add_widget(bl7)
        bl7.add_widget(self.lab7)
        bl7.add_widget(self.bt7)
        bl.add_widget(bl8)
        bl8.add_widget(self.lab8)
        bl8.add_widget(self.bt8)
        bl.add_widget(bl9)
        bl9.add_widget(self.lab9)
        bl9.add_widget(self.bt9)
        bl9.add_widget(self.lab10)

        self.data1 = '0'
        self.data2 = '0'
        self.data3 = '0'
        self.data4 = '0'
        self.data5 = '0'
        self.data6 = '0'
        self.data7 = '0'
        self.data8 = '0'
        return sl
Exemplo n.º 32
0
    def play_solid_scene(self, data, *args):

        # print " "
        # print "BUILDING SCENE", data
        # print " "

        if platform == 'ios' or platform == 'android':
            self.app.appix_base.clear_all_labels()
            self.app.appix_base.event_manager.sports_manager.stop_sports_scene()
        else:
            try:
                self.window_width = self.app.main_stage.ids["content_stencil"].width
                self.window_height = self.app.main_stage.ids["content_stencil"].height
            except AttributeError:
                pass

        # print "BPM ----------> ", self.bpm

        # if platform == 'ios' or platform == 'android':
            # self.app.appix_base.clear_all_labels()

        self.scene_playing = True   # Needed for labels on phone

        scene_num = int(data['scene_num'])

        if self.layers[scene_num]:
            self.stop_solid_scene(data)

        element_layout = ScatterLayout(do_rotation=False, do_translation=False, do_scale=False)
        element_layout.auto_bring_to_front = False
        element_layout.width = self.window_width   # * element_settings['size_x']
        element_layout.height = self.window_height  # * element_settings['size_y']
        self.layers[scene_num] = element_layout

        gradient_cycles, blink_cycles, full_duration = self.calculate_loop_extensions(data)

        if len(data["color_ids"]) == 1:
            color = self.rendered_color(data["color_ids"][0])
            color_key_frames = [KeyFrame(at=0, rgba=color),
                                KeyFrame(at=full_duration, rgba=color)]
        else:
            original_color_length = len(data["color_ids"])
            color_key_frames = self.build_gradient_parameters(data, original_color_length, gradient_cycles, full_duration)


        if data["blink_speed"]:
            blink_key_frames, blink_random_offset = self.build_blink_parameters(data, blink_cycles)
        else:
            blink_key_frames = [KeyFrame(at=0, opacity=1), KeyFrame(at=full_duration, opacity=1)]
            blink_random_offset = 0
        # TODO: END BLINK CODE HERE


        track = (ColorTrack(
            RectangleTrack(
                KeyFrame(at=0., pos=Expr("widget.pos"), size=Expr("widget.size")),
                KeyFrame(at=full_duration, pos=Expr("widget.x, widget.y")),
                canvas="before"
            ),

            *color_key_frames,
            canvas="before"
        ),
            RelativeAttributeTrack(
                *blink_key_frames
            ),
        )

        # Offset the start time
        # TODO: this will also offset the start of the gradients animation - probably don't want this?
        # Clock.schedule_once(partial(self.start_animation, track, scene_num), blink_random_offset)
        self.start_animation(track, scene_num)
Exemplo n.º 33
0
    def building_content(self, build_place, build):
        building = config.buildings[build]
        scatter = ScatterLayout(id='town_hall_scatter')
        name_label = PlaceLabel(text=f'{build}, id: {build_place.id}')
        menu = MenuLayout()
        inside_menu = InsideMenuLayout()
        top_layout = BoxLayout(orientation='horizontal', size_hint_y=.3)
        bottom_layout = BoxLayout(orientation='vertical', size_hint_y=.3)
        right_layout = BoxLayout(orientation='vertical')
        upgrade_layout = BoxLayout(orientation='horizontal', size_hint_y=.3)
        description_layout = BoxLayout(size_hint_y=.7)
        description_label = Label(text='Описание здания')
        description_layout.add_widget(description_label)
        icon_rel = BoxLayout(size_hint_x=.3)
        icon = Image(source=building[3])
        icon_rel.add_widget(icon)
        upgrade_label = Label(text=f'{building[1]} сек', size_hint_x=.9)
        upgrade_res_layout = BoxLayout(orientation='horizontal')
        for i, res_cost in enumerate(building[2]):
            if res_cost > 0:
                res_box = BoxLayout(orientation='horizontal', size_hint_x=.5)
                help_lay_res = RelativeLayout()
                help_lay_res.add_widget(
                    Image(source=f'{config.resources[res_list[i]][2]}',
                          size=(25, 25),
                          pos_hint=({
                              'right': 1
                          }),
                          size_hint=(None, 1)))
                add_lay = GridLayout(cols=2,
                                     size_hint=(1, 1),
                                     pos_hint=({
                                         'center_x': .5,
                                         'center_y': .5
                                     }))
                add_lay.add_widget(help_lay_res)
                add_lay.add_widget(BuildResLabel(text=f'{res_cost}'))
                res_box.add_widget(add_lay)
                upgrade_res_layout.add_widget(res_box)
        upgrade_button = Button(text='Up', size_hint_x=.1)
        upgrade_layout.add_widget(upgrade_button)
        upgrade_layout.add_widget(upgrade_label)
        upgrade_layout.add_widget(upgrade_res_layout)
        right_layout.add_widget(upgrade_layout)
        right_layout.add_widget(description_layout)
        top_layout.add_widget(icon_rel)
        top_layout.add_widget(right_layout)
        middle_lay = BoxLayout(size_hint_y=.4)
        slider_layout = BoxLayout(orientation='vertical', size_hint_y=.7)
        input_layout = BoxLayout(orientation='horizontal',
                                 size_hint=(.3, 1),
                                 pos_hint=({
                                     'right': 1
                                 }))
        text_input = UnitTextInput(text='0',
                                   size_hint_y=.9,
                                   pos_hint=({
                                       'center_y': .5
                                   }),
                                   multiline=False)
        total_res_layout = BoxLayout(orientation='horizontal',
                                     size_hint_x=.65,
                                     padding=5)
        self.slider = UnitSlider(text_input, size_hint_y=.55, padding=10)
        total_inside = TotalInsideLayout(orientation='horizontal',
                                         slider=self.slider)
        time_label = TotalTimeLabel(size_hint_y=.3, halign='left')
        total_res_label = TotalResLabel(text='Стоимость:', size_hint_x=.35)
        text_input.slider = self.slider
        self.slider.total_inside = total_inside
        self.slider.time_label = time_label
        self.slider.total_res_label = total_res_label
        hire_button = HireUnitsButton(text='Нанять',
                                      disabled=True,
                                      slider=self.slider,
                                      build_root=self)
        count_box = BoxLayout(orientation='vertical',
                              size_hint_x=.25,
                              padding=1,
                              spacing=1)
        up_button = UpButton(opacity=0, slider=self.slider)
        down_button = DownButton(opacity=0, slider=self.slider)
        bottom_slider_lay = BoxLayout(orientation='horizontal',
                                      size_hint_y=.45)
        scroll_unit = ScrollView(do_scroll_x=False,
                                 scroll_distance=50,
                                 size_hint_y=.8,
                                 pos_hint=({
                                     'center_y': .5
                                 }))
        butt_list = [up_button, down_button]
        self.unit_grid = GridLayout(cols=1,
                                    padding=5,
                                    spacing=5,
                                    size_hint_y=None,
                                    opacity=0)
        self.unit_grid.bind(minimum_height=self.unit_grid.setter('height'))
        self.available_list = []
        checkbox_group_list = []

        for unit_name in building[5]:
            unit = config.units[unit_name]
            checkbox = UnitCheckBox(group='units',
                                    size_hint_x=.05,
                                    slider=self.slider,
                                    txt_inp=text_input,
                                    unit=unit_name,
                                    hb=hire_button,
                                    bl=butt_list,
                                    trl=total_res_label,
                                    tl=time_label)
            checkbox.bind(active=on_checkbox_active)
            checkbox_group_list.append(checkbox)
            grid_layout = UnitGridLayout(cols=6,
                                         size_hint_y=None,
                                         height=40,
                                         checkbox=checkbox)
            unit_icon = Image(source=unit[3], size_hint_x=.05)
            unit_name_label = Label(text=f'{unit_name}', size_hint_x=.2)
            unit_cost = BoxLayout(orientation='horizontal', size_hint_x=.45)
            for i, res_cost in enumerate(unit[2]):
                if res_cost > 0:
                    res_box = BoxLayout(orientation='horizontal',
                                        size_hint_x=.5)
                    help_lay_res = RelativeLayout()
                    help_lay_res.add_widget(
                        Image(source=f'{config.resources[res_list[i]][2]}',
                              size=(25, 25),
                              pos_hint=({
                                  'right': 1
                              }),
                              size_hint=(None, 1)))
                    add_lay = GridLayout(cols=2,
                                         size_hint=(1, 1),
                                         pos_hint=({
                                             'center_x': .5,
                                             'center_y': .5
                                         }))
                    add_lay.add_widget(help_lay_res)
                    add_lay.add_widget(BuildResLabel(text=f'{res_cost}'))
                    res_box.add_widget(add_lay)
                    unit_cost.add_widget(res_box)
            unit_time = Label(text=f'{unit[1]} сек', size_hint_x=.15)
            how_many_lay = BoxLayout(orientation='horizontal', size_hint_x=.1)
            available_label = Label(text='8',
                                    size_hint_y=.8,
                                    pos_hint=({
                                        'center_y': .5
                                    }))
            checkbox.available_label = available_label
            self.available_list.append(available_label)
            all_button = AllUnitButton(text='All',
                                       size_hint_y=.6,
                                       pos_hint=({
                                           'center_y': .5
                                       }),
                                       checkbox=checkbox)
            how_many_lay.add_widget(all_button)
            how_many_lay.add_widget(available_label)
            grid_layout.add_widget(checkbox)
            grid_layout.add_widget(unit_icon)
            grid_layout.add_widget(unit_name_label)
            grid_layout.add_widget(unit_cost)
            grid_layout.add_widget(unit_time)
            grid_layout.add_widget(how_many_lay)
            self.unit_grid.add_widget(grid_layout)

        self.slider.group_list = checkbox_group_list
        scroll_unit.add_widget(self.unit_grid)
        count_box.add_widget(up_button)
        count_box.add_widget(down_button)
        input_layout.add_widget(count_box)
        input_layout.add_widget(text_input)
        input_layout.add_widget(hire_button)
        slider_layout.add_widget(self.slider)
        total_res_layout.add_widget(total_res_label)
        total_res_layout.add_widget(total_inside)
        bottom_slider_lay.add_widget(total_res_layout)
        bottom_slider_lay.add_widget(input_layout)
        slider_layout.add_widget(bottom_slider_lay)
        middle_lay.add_widget(scroll_unit)
        bottom_layout.add_widget(slider_layout)
        bottom_layout.add_widget(time_label)
        inside_menu.add_widget(top_layout)
        inside_menu.add_widget(middle_lay)
        inside_menu.add_widget(bottom_layout)
        menu.add_widget(inside_menu)
        menu.add_widget(name_label)
        close_b = CloseMenuButton(self, scatter)
        menu.add_widget(close_b)
        scatter.add_widget(menu)
        self.update_available_units()
        anim_opacity_up.start(self.unit_grid)
        return scatter
Exemplo n.º 34
0
    def build(self):
        appLayout = FloatLayout(size=(800, 600))

        bg = Image(source='Images/Metal2.jpg', pos=(0, 0), size=(1500, 840))

        g1 = Gauge()
        g1s = ScatterLayout(scale=0.5, size=g1.size, pos=(30, 80))
        g1s.add_widget(g1)

        g2 = Gauge()
        g2s = ScatterLayout(scale=0.5, size=g1.size, pos=(200, 80))
        g2s.add_widget(g2)

        g3 = Gauge()
        g3s = ScatterLayout(scale=0.5, size=g1.size, pos=(300, 80))
        g3s.add_widget(g3)

        head = Header()
        headscat = Scatter(size=head.size, pos=(0, 530), do_translation=False)
        headscat.add_widget(head)

        foot = Footer()
        Footer.updatedate(foot)
        #Clock.schedule_interval(foot.updatetime, 1)
        Clock.schedule_interval(partial(Footer.updatetime, foot), 1)
        Clock.schedule_interval(partial(Footer.updatedate, foot), 3600)
        #footscat = Scatter(size=foot.size, pos=(0,-10), do_translation=False)
        #footscat.add_widget(foot)

        appLayout.add_widget(bg)
        appLayout.add_widget(g1s)
        appLayout.add_widget(g2s)
        appLayout.add_widget(g3s)
        appLayout.add_widget(headscat)
        appLayout.add_widget(foot)

        Window.size = (800, 600)
        return appLayout
 def on_touch_move(self, touch: MotionEvent):
     ScatterLayout.on_touch_move(self, touch)
     self.fix_transform_edges(touch)