Esempio n. 1
0
    def _refresh(self, _dt=0):
        game = self.katrain.game
        thresholds = self.katrain.config("trainer/eval_thresholds")

        sum_stats, histogram, player_ptloss = game_report(
            game, depth_filter=self.depth_filter, thresholds=thresholds)
        labels = [
            f"≥ {pt}" if pt > 0 else f"< {thresholds[-2]}" for pt in thresholds
        ]

        table = GridLayout(cols=3, rows=6 + len(thresholds))
        colors = [
            [cp * 0.75 for cp in col[:3]] + [1]
            for col in Theme.EVAL_COLORS[self.katrain.config("trainer/theme")]
        ]

        table.add_widget(
            TableHeaderLabel(text="", background_color=Theme.BACKGROUND_COLOR))
        table.add_widget(
            TableHeaderLabel(text=i18n._("header:keystats"),
                             background_color=Theme.BACKGROUND_COLOR))
        table.add_widget(
            TableHeaderLabel(text="", background_color=Theme.BACKGROUND_COLOR))

        for i, (label, fmt, stat, scale, more_is_better) in enumerate([
            ("accuracy", "{:.1f}", "accuracy", 100, True),
            ("meanpointloss", "{:.1f}", "mean_ptloss", 5, False),
            ("aitopmove", "{:.1%}", "ai_top_move", 1, True),
            ("aitop5", "{:.1%}", "ai_top5_move", 1, True),
        ]):

            statcell = {
                bw: TableStatLabel(
                    text=fmt.format(sum_stats[bw][stat])
                    if stat in sum_stats[bw] else "",
                    side=side,
                    value=sum_stats[bw].get(stat, 0),
                    scale=scale,
                    bar_color=Theme.STAT_BETTER_COLOR if
                    (sum_stats[bw].get(stat, 0) <
                     sum_stats[Move.opponent_player(bw)].get(stat, 0))
                    ^ more_is_better else Theme.STAT_WORSE_COLOR,
                    background_color=Theme.BOX_BACKGROUND_COLOR,
                )
                for (bw, side) in zip("BW", ["left", "right"])
            }
            table.add_widget(statcell["B"])
            table.add_widget(
                TableCellLabel(text=i18n._(f"stat:{label}"),
                               background_color=Theme.BOX_BACKGROUND_COLOR))
            table.add_widget(statcell["W"])

        table.add_widget(
            TableHeaderLabel(text=i18n._("header:num moves"),
                             background_color=Theme.BACKGROUND_COLOR))
        table.add_widget(
            TableHeaderLabel(text=i18n._("stats:pointslost"),
                             background_color=Theme.BACKGROUND_COLOR))
        table.add_widget(
            TableHeaderLabel(text=i18n._("header:num moves"),
                             background_color=Theme.BACKGROUND_COLOR))

        for i, (col, label, pt) in enumerate(
                zip(colors[::-1], labels[::-1], thresholds[::-1])):
            statcell = {
                bw: TableStatLabel(
                    text=str(histogram[i][bw]),
                    side=side,
                    value=histogram[i][bw],
                    scale=len(player_ptloss[bw]) + 1e-6,
                    bar_color=col,
                    background_color=Theme.BOX_BACKGROUND_COLOR,
                )
                for (bw, side) in zip("BW", ["left", "right"])
            }
            table.add_widget(statcell["B"])
            table.add_widget(TableCellLabel(text=label, background_color=col))
            table.add_widget(statcell["W"])

        self.stats.clear_widgets()
        self.stats.add_widget(table)

        for bw, player_info in self.katrain.players_info.items():
            self.player_infos[bw].player_type = player_info.player_type
            self.player_infos[bw].captures = ""  # ;)
            self.player_infos[bw].player_subtype = player_info.player_subtype
            self.player_infos[bw].name = player_info.name
            self.player_infos[bw].rank = (
                player_info.sgf_rank if player_info.player_type == PLAYER_HUMAN
                else rank_label(player_info.calculated_rank))

        # if not done analyzing, check again in 1s
        if not self.katrain.engine.is_idle():
            Clock.schedule_once(self._refresh, 1)
Esempio n. 2
0
    def build(self):
        layout = GridLayout(cols=3)

        # create renderer
        self.renderer = Renderer(size_hint=(5, 5))
        self.renderer.set_clear_color(
            (0.1, 0.1, 0.1, 1)
        )  # rgba

        # create scene
        scene = Scene()
        self.cubes = []

        # create cubes for scene
        #
        # default pure green cube
        cube_geo = BoxGeometry(.3, .3, .3)
        cube_mat = Material(
            color=(0, 0.5, 0)  # base color
        )
        self.cubes.append(Mesh(
            geometry=cube_geo,
            material=cube_mat
        ))  # default pos == (0, 0, 0)
        self.cubes[0].pos.z = -5
        self.cubes[0].pos.x = 1
        self.cubes[0].pos.y = 0.8
        self.cubes[0].rotation.x = 45

        # black cube, red shadow, half-transparent
        cube_geo = BoxGeometry(.3, .3, .3)
        cube_mat = Material(
            transparency=0.5,
            color=(0, 0, 0),  # base color
            diffuse=(10, 0, 0),  # color of "shadows"
            specular=(0, 0, 0)  # mirror-like reflections
        )
        self.cubes.append(Mesh(
            geometry=cube_geo,
            material=cube_mat
        ))  # default pos == (0, 0, 0)
        self.cubes[1].pos.z = -5
        self.cubes[1].pos.x = -1
        self.cubes[1].pos.y = 0.8
        self.cubes[1].rotation.y = 45

        # default pure green cube with red reflections
        cube_geo = BoxGeometry(.3, .3, .3)
        cube_mat = Material(
            transparency=1,
            color=(0, 0.5, 0),  # base color
            diffuse=(0, 0, 0),  # color of "shadows"
            specular=(10, 0, 0)  # mirror-like reflections
        )
        self.cubes.append(Mesh(
            geometry=cube_geo,
            material=cube_mat
        ))  # default pos == (0, 0, 0)
        self.cubes[2].pos.z = -5
        self.cubes[2].pos.x = 1
        self.cubes[2].pos.y = -0.8
        self.cubes[2].rotation.z = 45

        # black cube with red reflections
        # and half-transparent
        cube_geo = BoxGeometry(.3, .3, .3)
        cube_mat = Material(
            transparency=0.5,
            color=(0, 0, 0),  # base color
            specular=(10, 0, 0)  # mirror-like reflections
        )
        self.cubes.append(Mesh(
            geometry=cube_geo,
            material=cube_mat
        ))  # default pos == (0, 0, 0)
        self.cubes[3].pos.z = -5
        self.cubes[3].pos.x = -1
        self.cubes[3].pos.y = -0.8
        self.cubes[3].rotation.x = 45

        cube_geo = BoxGeometry(.3, .3, .3)
        cube_mat = Material(
            transparency=0.5,
            color=(0, 0, 0),  # base color
            specular=(10, 0, 0)
        )
        self.main_cube = Mesh(
            geometry=cube_geo,
            material=cube_mat
        )  # default pos == (0, 0, 0)
        self.main_cube.rotation.x = 45
        self.main_cube.rotation.y = 45
        self.main_cube.pos.z = -5
        scene.add(self.main_cube)

        planes = [
            ((0, 0, -10), (0, 0, 0)),
            ((-10, 0, 0), (0, -90, 0)),
            ((10, 0, 0), (0, 90, 0)),
            ((0, 0, 10), (0, 180, 0))
        ]  # position and rotation changes
        for plane in planes:
            geo = BoxGeometry(5, 5, .1)
            mat = Material(
                color=(1, 1, 1)
            )
            mesh = Mesh(
                geometry=geo,
                material=mat
            )
            mesh.pos.x += plane[0][0]
            mesh.pos.y += plane[0][1]
            mesh.pos.z += plane[0][2]
            mesh.rot.x += plane[1][0]
            mesh.rot.y += plane[1][1]
            mesh.rot.z += plane[1][2]
            scene.add(mesh)

        # create camera for scene
        self.camera = PerspectiveCamera(
            fov=75,    # distance from the screen
            aspect=0,  # "screen" ratio
            near=.1,    # nearest rendered point
            far=1000     # farthest rendered point
        )

        # start rendering the scene and camera
        for cube in self.cubes:
            scene.add(cube)
        self.renderer.render(scene, self.camera)

        # set renderer ratio is its size changes
        # e.g. when added to parent
        self.renderer.bind(size=self._adjust_aspect)

        layout.add_widget(Factory.CamRot())
        layout.add_widget(Factory.LightPanel())
        layout.add_widget(Factory.CamStrafe())
        layout.add_widget(Widget())

        layout.add_widget(self.renderer)

        layout.add_widget(Label(text='+\n\nY\n\n-'))
        layout.add_widget(Factory.CamNav())
        layout.add_widget(Label(text='-      X      +'))
        layout.add_widget(Factory.ObjNav())

        Clock.schedule_interval(self.rotate_cube, .01)
        Clock.schedule_interval(self.scale_cube, 1)

        # keyboard listener
        Listener()
        return layout
Esempio n. 3
0
    def _handle_keyboard(self, window, key, *largs):
        if key == 27 and self.auto_dismiss:
            self.dismiss()
            return True


if __name__ == '__main__':
    from kivy.base import runTouchApp
    from kivy.uix.button import Button
    from kivy.uix.label import Label
    from kivy.uix.gridlayout import GridLayout
    from kivy.core.window import Window

    # add view
    content = GridLayout(cols=1)
    content.add_widget(Label(text='This is a hello world'))
    view = ModalView(size_hint=(None, None),
                     size=(256, 256),
                     auto_dismiss=True)
    view.add_widget(content)

    def open_view(btn):
        view.open()

    layout = GridLayout(cols=3)
    for x in range(9):
        btn = Button(text='click me %s' % x)
        btn.bind(on_release=view.open)
        layout.add_widget(btn)
    Window.add_widget(layout)
Esempio n. 4
0
    def build(self):
        layout = GridLayout(cols=3,
                            row_force_default=True,
                            row_default_height=40,
                            spacing=5,
                            padding=10)
        btn1 = Button(text="SkyMatix YouTube (Zibo)")
        btn1.bind(on_press=any_Function)

        btn2 = Button(
            text="South African Flight Simmers\nRequires Join Invitation (FB)")
        btn2.bind(on_press=any_Function1)

        btn3 = Button(text="X-Aviation")
        btn3.bind(on_press=any_Function2)

        btn4 = Button(text="NaviGraph (Account)")
        btn4.bind(on_press=any_Function3)

        btn5 = Button(text="Xplane Org")
        btn5.bind(on_press=any_Function4)

        btn6 = Button(text="Prepar 3D Home")
        btn6.bind(on_press=any_Function5)

        btn7 = Button(text="RexTexture Direct Pre 3D")
        btn7.bind(on_press=any_Function6)

        btn8 = Button(text="Threshold")
        btn8.bind(on_press=any_Function7)

        btn9 = Button(text="MicroSoft Flight Simulator Home")
        btn9.bind(on_press=any_Function8)

        btn10 = Button(text="Orbex (Airports & Scenery)")
        btn10.bind(on_press=any_Function9)

        btn11 = Button(text="Ortho4XP & Pre3D (Scenery)\nYouTube")
        btn11.bind(on_press=any_Function10)

        btn12 = Button(text="SimMarket")
        btn12.bind(on_press=any_Function11)

        btn13 = Button(text="Air Manager")
        btn13.bind(on_press=any_Function12)

        btn14 = Button(text="NMG Simulations")
        btn14.bind(on_press=any_Function13)

        btn15 = Button(text="X-Pilot.com")
        btn15.bind(on_press=any_Function14)

        btn16 = Button(text="Ixeg 733 Liveries")
        btn16.bind(on_press=any_Function15)

        btn17 = Button(text="GAFFER Simulations")
        btn17.bind(on_press=any_Function16)

        btn18 = Button(text="The X-Plane Scenery Gateway")
        btn18.bind(on_press=any_Function17)

        btn19 = Button(text="Prepard3d Scenery\nLibrary Instillation")
        btn19.bind(on_press=any_Function18)

        btn20 = Button(text="CaptainSim")
        btn20.bind(on_press=any_Function19)

        btn21 = Button(text="JustFlight")
        btn21.bind(on_press=any_Function20)

        btn22 = Button(text="Fsx & Pre3d Scenery's")
        btn22.bind(on_press=any_Function21)

        btn23 = Button(text="SimTool Kit Pro")
        btn23.bind(on_press=any_Function22)

        btn24 = Button(text="SimBrief")
        btn24.bind(on_press=any_Function23)

        btn25 = Button(text="Little Nav Map")
        btn25.bind(on_press=any_Function24)

        btn26 = Button(text="Join Fs")
        btn26.bind(on_press=any_Function25)

        btn27 = Button(text="Xplane First Officer")
        btn27.bind(on_press=any_Function26)

        btn28 = Button(text="Pre3D Share Cockpit")
        btn28.bind(on_press=any_Function27)

        btn29 = Button(text="Pre3d Multi crew Copilot")
        btn29.bind(on_press=any_Function28)

        btn30 = Button(text="Avsim")
        btn30.bind(on_press=any_Function29)

        btn31 = Button(text="Pre3d Vehicle Addons")
        btn31.bind(on_press=any_Function30)

        btn32 = Button(text="Smart Co-pilot Xplane 11")
        btn32.bind(on_press=any_Function31)

        btn33 = Button(text="Fly With Lua ")
        btn33.bind(on_press=any_Function32)

        btn34 = Button(text="Python")
        btn34.bind(on_press=any_Function33)

        btn35 = Button(text="JarDesigns")
        btn35.bind(on_press=any_Function34)

        btn36 = Button(text="WorldEditor")
        btn36.bind(on_press=any_Function35)

        btn37 = Button(text="OpenScenery")
        btn37.bind(on_press=any_Function36)

        btn38 = Button(text="Airport Navigator Xplane 11")
        btn38.bind(on_press=any_Function37)

        btn39 = Button(text="GOOGLE Search")
        btn39.bind(on_press=any_Function38)

        btn40 = Button(text="Data Ref Xplane 11")
        btn40.bind(on_press=any_Function39)

        btn41 = Button(text="App Designed By:\[email protected]")

        layout.add_widget(btn1)
        layout.add_widget(btn2)
        layout.add_widget(btn3)
        layout.add_widget(btn4)
        layout.add_widget(btn5)
        layout.add_widget(btn6)
        layout.add_widget(btn7)
        layout.add_widget(btn8)
        layout.add_widget(btn9)
        layout.add_widget(btn10)
        layout.add_widget(btn11)
        layout.add_widget(btn12)
        layout.add_widget(btn13)
        layout.add_widget(btn14)
        layout.add_widget(btn15)
        layout.add_widget(btn16)
        layout.add_widget(btn17)
        layout.add_widget(btn18)
        layout.add_widget(btn19)
        layout.add_widget(btn20)
        layout.add_widget(btn21)
        layout.add_widget(btn22)
        layout.add_widget(btn23)
        layout.add_widget(btn24)
        layout.add_widget(btn25)
        layout.add_widget(btn26)
        layout.add_widget(btn27)
        layout.add_widget(btn28)
        layout.add_widget(btn29)
        layout.add_widget(btn30)
        layout.add_widget(btn31)
        layout.add_widget(btn32)
        layout.add_widget(btn33)
        layout.add_widget(btn34)
        layout.add_widget(btn35)
        layout.add_widget(btn36)
        layout.add_widget(btn37)
        layout.add_widget(btn38)
        layout.add_widget(btn39)
        layout.add_widget(btn40)
        layout.add_widget(btn41)

        return layout
Esempio n. 5
0
    def update(self, day, month, year):
        lunar_day, lunar_month, lunar_year = self.lunarDay(day, month, year)
        solar_day = datetime.date(year, month, day)
        dayOfMonth = solar_day.day
        dayOfWeek = self.day_of_week[solar_day.weekday()]
        month = solar_day.month
        year = solar_day.year
        event_text = self.getEvent(day, month, year)
        self.layout = RelativeLayout()
        box = BoxLayout(orientation='vertical')

        solar_layout = RelativeLayout(size_hint=(1, 3))
        solar_box = BoxLayout(spacing=2, padding=2, orientation='vertical')
        solar_background_image = Image(
            source='Image/Calendar/Background/Calendar/snow.png',
            allow_stretch=True,
            keep_ratio=False)

        monthYear_lbl = Label(
            text='[color=ffffff][b]Tháng %s Năm %s[/b][/color]' %
            (month, year),
            size_hint=(1, .3),
            font_size=20,
            valign='top',
            halign='center',
            markup=True)
        day_lbl = Label(
            text=
            '[color=000000][b][size=150]%s[/size]\n[size=35]%s[/size][/b][/color]'
            % (dayOfMonth, dayOfWeek),
            size_hint=(1, 3),
            valign='top',
            halign='center',
            markup=True)

        event_lbl = AutoLineBreakLabel(
            text='[color=%s][b][size=13]%s[/size][/b][/color]' % event_text,
            width=320,
            valign='middle',
            halign='center')
        solar_box.add_widget(Label(size_hint=(1, .2)))
        solar_box.add_widget(monthYear_lbl)
        solar_box.add_widget(day_lbl)
        solar_box.add_widget(event_lbl)

        solar_layout.add_widget(solar_background_image)
        solar_layout.add_widget(solar_box)

        lunar_canChi_layout = RelativeLayout(size_hint=(1, 1))
        lunar_canChi_box = GridLayout(spacing=2, padding=2, cols=4)

        lunar_lbl_background = 'Image/Calendar/Button/button_default.png'
        self.lunar_time_lbl = Button(
            text='[size=15][b]Giờ[/b][/size]\n[color=ff0000]%s[/color]' %
            self.get_time(),
            markup=True,
            background_normal=lunar_lbl_background,
            background_down=lunar_lbl_background,
            valign='middle',
            halign='center',
        )

        lunar_day_lbl = Button(
            text='[size=15][b]Ngày[/b][/size]\n[color=ff0000]%s[/color]' %
            lunar_day,
            markup=True,
            background_normal=lunar_lbl_background,
            background_down=lunar_lbl_background,
            valign='middle',
            halign='center',
        )

        lunar_month_lbl = Button(
            text='[size=15][b]Tháng[/b][/size]\n[color=ff0000]%s[/color]' %
            (lunar_month),
            markup=True,
            background_normal=lunar_lbl_background,
            background_down=lunar_lbl_background,
            valign='middle',
            halign='center')

        lunar_year_lbl = Button(
            text='[size=15][b]Năm[/b][/size]\n[color=ff0000]%s[/color]' %
            (lunar_year),
            markup=True,
            background_normal=lunar_lbl_background,
            background_down=lunar_lbl_background,
            valign='middle',
            halign='center')

        self.canChi_time_lbl = Button(
            text='[color=ff0000]%s[/color]' % self.get_canchi_time_by_day(),
            markup=True,
            background_normal=lunar_lbl_background,
            background_down=lunar_lbl_background,
            valign='middle',
            halign='center',
        )

        canChi_day_lbl = Button(
            text='[color=ff0000]%s[/color]' % self.getCanChiDay(solar_day),
            markup=True,
            background_normal=lunar_lbl_background,
            background_down=lunar_lbl_background,
            valign='middle',
            halign='center',
        )

        canChi_month_lbl = Button(
            text='[color=ff0000]%s %s[/color]' %
            (self.getCanChiMonth(lunar_month, lunar_year)),
            markup=True,
            background_normal=lunar_lbl_background,
            background_down=lunar_lbl_background,
            valign='middle',
            halign='center')

        canChi_year_lbl = Button(text='[color=ff0000]%s %s[/color]' %
                                 (self.getCanChiYear(lunar_year)),
                                 markup=True,
                                 background_normal=lunar_lbl_background,
                                 background_down=lunar_lbl_background,
                                 valign='middle',
                                 halign='center')

        lunar_canChi_box.add_widget(self.lunar_time_lbl)
        lunar_canChi_box.add_widget(lunar_day_lbl)
        lunar_canChi_box.add_widget(lunar_month_lbl)
        lunar_canChi_box.add_widget(lunar_year_lbl)
        lunar_canChi_box.add_widget(self.canChi_time_lbl)
        lunar_canChi_box.add_widget(canChi_day_lbl)
        lunar_canChi_box.add_widget(canChi_month_lbl)
        lunar_canChi_box.add_widget(canChi_year_lbl)
        lunar_canChi_box.add_widget(Label(size_hint=(1, .8)))

        lunar_canChi_layout.add_widget(lunar_canChi_box)

        box.add_widget(solar_layout)
        box.add_widget(lunar_canChi_layout)

        background_image = Image(
            source=
            'Image/Calendar/Background/Calendar/background_lunar_calendar.png',
            allow_stretch=True,
            keep_ratio=False)

        self.layout.add_widget(background_image)
        self.layout.add_widget(box)
        self.add_widget(self.layout)
        self.getAllCanChiDay()
Esempio n. 6
0
    def build(self):
        self.theflag = 0
        self.theflag0 = 0
        self.distan = 1000  # дистанция до начальной точки (0,0,-50) что бы ничего не было за экраном (надо будет выстваить на изменение)
        bl = BoxLayout(orientation='vertical',
                       size_hint=(.15, 1),
                       spacing=10,
                       padding=10)  # левая панель
        al = AnchorLayout(anchor_x='left',
                          anchor_y='center')  # основная система интерфейса
        layout = GridLayout(cols=2, spacing=3,
                            size_hint=(1, 1))  #сетка для кнопок поворота

        matrix = np.load('matrix0.npy', allow_pickle=True)
        counter = int(int(matrix.size) / 2)
        x = np.zeros(counter)
        y = np.zeros(counter)
        z = np.zeros(counter)
        soe = np.zeros((counter, counter))

        for i in range(2):
            if (i == 0):
                for j in range(counter):
                    for k in range(3):
                        a = matrix[i, j]
                        if (k == 0):
                            x[j] = a[k] * 10
                        elif (k == 1):
                            y[j] = a[k] * 10
                        else:
                            z[j] = a[k] * 10
            else:
                for j in range(counter):
                    a = matrix[i, j]
                    for k in range(counter):
                        soe[j][k] = a[k]
        print(x, y, z)
        print(soe)
        # кнопка загрузки координат
        loader = Button(text='Load', on_press=self.load)
        bl.add_widget(loader)

        #starter = Button(text='Построить', on_press = self.letstart)
        #bl.add_widget(starter)

        bl.add_widget(Widget())
        # create renderer
        self.renderer = Renderer()

        # create scene
        scene = Scene()

        #lines
        k0 = 0
        k1 = 0
        lines_list = []
        for i in soe:
            for j in i:
                if (j == 1):
                    line0_geo = BoxGeometry(
                        1,
                        int(((y[k0] - y[k1])**2 + (x[k0] - x[k1])**2 +
                             (z[k0] - z[k1])**2)**0.5), 1)
                    #print(int(((abs(x[k0]-x[k1]) + abs(y[k0]-y[k1])+ abs(z[k0]-z[k1]))**0.5)),'length')
                    #print(int(abs(y[k0]-y[k1]) + abs(x[k0]-x[k1])+ abs(z[k0]-z[k1])))
                    line0_mat = Material()
                    self.line0 = Mesh(
                        geometry=line0_geo,
                        material=line0_mat)  # default pos == (0, 0, 0)
                    self.line0.pos.x = int((x[k0] + x[k1]) / 2)
                    self.line0.pos.y = int((y[k0] + y[k1]) / 2)
                    self.line0.pos.z = int((z[k0] + z[k1]) / 2) - self.distan
                    if y[k0] - y[k1] == 0 and x[k0] - x[
                            k1] == 0 and z[k0] - z[k1] != 0:
                        self.line0.rotation.x = 90
                    elif y[k0] - y[k1] == 0 and x[k0] - x[k1] != 0 and z[
                            k0] - z[k1] == 0:
                        self.line0.rotation.z = 90
                    elif y[k0] - y[k1] != 0 and x[k0] - x[k1] == 0 and z[
                            k0] - z[k1] == 0:
                        ###
                        fff = 0
                    elif y[k0] - y[k1] != 0 and x[k0] - x[k1] != 0 and z[
                            k0] - z[k1] == 0:
                        self.line0.rotation.z = math.atan(
                            (x[k0] - x[k1]) / (y[k0] - y[k1])) / math.pi * 180
                    elif y[k0] - y[k1] != 0 and x[k0] - x[
                            k1] == 0 and z[k0] - z[k1] != 0:
                        #self.line0.rotation.x = math.atan((z[k0]-z[k1])/(y[k0]-y[k1]))/math.pi*180
                        self.line0.rotation.x = math.acos(
                            abs(y[k0] - y[k1]) /
                            ((x[k0] - x[k1])**2 + (y[k0] - y[k1])**2 +
                             (z[k0] - z[k1])**2)**0.5) / math.pi * 180
                        #print()
                    elif y[k0] - y[k1] == 0 and x[k0] - x[k1] != 0 and z[
                            k0] - z[k1] != 0:
                        self.line0.rotation.z = math.atan(
                            (x[k0] - x[k1]) /
                            (z[k0] - z[k1])) / math.pi * 180 * -1
                        self.line0.rotation.x = 90

                    ###
                    elif y[k0] - y[k1] != 0 and x[k0] - x[k1] != 0 and z[
                            k0] - z[k1] != 0:
                        if ((x[k0] < x[k1] and y[k0] < y[k1])
                                or (x[k0] > x[k1] and y[k0] > y[k1])):
                            #self.line0.rotation.z = math.atan((abs(z[k0]-z[k1]))/1.5/(abs(y[k0]-y[k1])))/math.pi*180
                            self.line0.rotation.z = math.acos(
                                abs(y[k0] - y[k1]) /
                                ((x[k0] - x[k1])**2 + (y[k0] - y[k1])**2 +
                                 (0)**2)**0.5) / math.pi * 180 * -1
                            #проблема
                        else:
                            self.line0.rotation.z = math.acos(
                                abs(y[k0] - y[k1]) /
                                ((x[k0] - x[k1])**2 + (y[k0] - y[k1])**2 +
                                 (0)**2)**0.5) / math.pi * 180
                        #self.line0.rotation.x = math.atan((1.25*abs(x[k0]-x[k1]))/(abs(y[k0]-y[k1])))/math.pi*180*-1
                        if ((z[k0] < z[k1] and y[k0] < y[k1])
                                or (z[k0] > z[k1] and y[k0] > y[k1])):
                            self.line0.rotation.x = math.acos(
                                abs(y[k0] - y[k1]) /
                                ((0)**2 + (y[k0] - y[k1])**2 +
                                 (z[k0] - z[k1])**2)**0.5) / math.pi * 180
                            #проблема
                        else:
                            self.line0.rotation.x = math.acos(
                                abs(y[k0] - y[k1]) /
                                ((0)**2 + (y[k0] - y[k1])**2 +
                                 (z[k0] - z[k1])**2)**0.5) / math.pi * 180 * -1

                        #self.line0.rotation.x = math.acos(abs(y[k0]-y[k1])/((0)**2+(y[k0]-y[k1])**2+(z[k0]-z[k1])**2)**0.5)/math.pi*180*-1#there
                        print(self.line0.rotation.z)
                        print(self.line0.rotation.x)
                    lines_list.append(self.line0)
                k1 += 1
            k0 += 1
            k1 = 0
        line0_geo = BoxGeometry(1, y[1] - y[0], 1)
        line0_mat = Material()
        self.line0 = Mesh(geometry=line0_geo,
                          material=line0_mat)  # default pos == (0, 0, 0)
        self.line0.pos.z = int(z[0]) - self.distan

        #self.line3.rotation.x = 90

        #points
        point_list = []
        sumx = 0
        sumy = 0
        sumz = 0
        sumcount = 0
        loader = OBJLoader()

        for i in range(counter):
            point_geom = SphereGeometry(1.1)
            point_mat = Material()
            self.point0 = Mesh(geometry=point_geom, material=point_mat)
            self.point0.pos.x = int(x[i])
            self.point0.pos.y = int(y[i])
            self.point0.pos.z = int(z[i]) - self.distan
            self.point0.scale = (1, 1, 1)
            point_list.append(self.point0)
            sumx += self.point0.pos.x
            sumy += self.point0.pos.y
            sumz += self.point0.pos.z
            sumcount += 1
            #scene.add(self.point0)

        point_geom = SphereGeometry()
        point_mat = Material()
        self.point1 = Mesh(geometry=point_geom, material=point_mat)
        self.point1.pos.x = sumx / sumcount
        self.point1.pos.y = sumy / sumcount
        self.point1.pos.z = sumz / sumcount
        self.point1.scale = (1, 1, 1)
        #scene.add(self.point1)
        self.camera = PerspectiveCamera(
            fov=100,  # размер окна т.е. чем больше фов тем больше масштаб
            aspect=0,  # "screen" ratio
            near=1,  # рендер от
            far=10000  # дистанция рендера
        )

        k0 = 0
        self.ll = []
        for i in soe:
            for j in i:
                if (j == 1):
                    self.ll.append(lines_list[k0])
                    scene.add(lines_list[k0])
                    k0 += 1

        for i in range(counter):
            scene.add(point_list[i])
            pass

        self.pp = point_list
        self.renderer.render(scene, self.camera)
        self.renderer.bind(size=self._adjust_aspect)
        al.add_widget(self.renderer)
        bl.add_widget(Factory.Fov())
        bl.add_widget(Factory.CamNav())
        al.add_widget(bl)
        return al
 def build(self):
     return GridLayout()
Esempio n. 8
0
	def __init__(self):
		#rate of intrest
		self.roi=0
		#declaring dates
		self.date_today=time.strftime('%d-%m-%Y')
		self.name='1st'
		super(first_screen,self).__init__()
		#main gird consists of all the 14 horizental layouts
		self.main_grid=GridLayout(rows=16,padding=10,spacing=10)

		#adding company name--Garuda.inc to the app
		self.Title=Label(text='~  [b]Garuda.inc[/b]',size_hint=[1,0.25],font_name='Montez-Regular',markup=True)
		self.main_grid.add_widget(self.Title)
		
		#adding selection of toggle buttons for intrest selection
		intrest_box=BoxLayout()
		self.gold=ToggleButton(text='Gold',state='down',group='intrest',background_normal='button-on.jpeg',background_down='button-down.jpeg',on_press=lambda a:self.intrest_action(1))
		self.silver=ToggleButton(text='Silver',group='intrest',background_normal='button-on.jpeg',background_down='button-down.jpeg',on_press=lambda a:self.intrest_action(2))
		self.other=ToggleButton(text='Other',group='intrest',background_normal='button-on.jpeg',background_down='button-down.jpeg',on_press=lambda a:self.intrest_action(3))
		intrest_box.add_widget(self.gold)
		intrest_box.add_widget(self.silver)
		intrest_box.add_widget(self.other)
		self.main_grid.add_widget(intrest_box)

		#adding selection of months for intrest calculation
		month_box=BoxLayout()
		self.month_minus=ToggleButton(text='0',group='months',background_normal='button-on.jpeg',background_down='button-down.jpeg',on_press=lambda a:self.month_action(1))
		self.month_plus=ToggleButton(text='1',state='down',group='months',background_normal='button-on.jpeg',background_down='button-down.jpeg',on_press=lambda a:self.month_action(2))
		self.month=ToggleButton(text='exjact',group='months',background_normal='button-on.jpeg',background_down='button-down.jpeg',on_press=lambda a:self.month_action(3))
		month_box.add_widget(self.month_minus)
		month_box.add_widget(self.month_plus)
		month_box.add_widget(self.month)
		self.main_grid.add_widget(month_box)

		#adding label to enter money
		entry_money=Label(text='[b]enter amount [/b]',markup=True)
		self.main_grid.add_widget(entry_money)

		#taking input amount from user
		self.amount=TextInput(text='',input_type='number',multiline=False)
		self.main_grid.add_widget(self.amount)

		#adding label to take date and changing date button 
		date_panel=BoxLayout()
		enter_date=Label(text='[b]Enter Date[/b]',markup=True)
		self.change_date=Button(text=self.date_today,markup=True,size_hint=[0.5,1],background_normal='button-on.jpeg',background_down='button-down.jpeg',on_press=lambda a:self.date_popup())
		date_panel.add_widget(enter_date)
		date_panel.add_widget(self.change_date)
		self.main_grid.add_widget(date_panel)

		#adding a inputs to take date
		date_box=BoxLayout(spacing=10,padding=10)
		self.datei=TextInput(multiline=False,input_type='number',text='')
		self.monthi=TextInput(multiline=False,input_type='number',text='')
		self.yeari=TextInput(multiline=False,input_type='number',text='',size_hint=[1.7,1])
		date_box.add_widget(self.datei)
		date_box.add_widget(self.monthi)
		date_box.add_widget(self.yeari)
		self.main_grid.add_widget(date_box)

		#select the condition
		self.main_grid.add_widget(BoxLayout(size_hint=[1,0.1]))
		sixm=BoxLayout(size_hint=(1,0.5))
		self.sixc1=CheckBox(group='term',size_hint=[0.1,1],state='down',on_press=lambda a:self.term_action(1))
		sixt=Label(text='[b] with compond  intrest \'6\' month                      [/b]',markup=True)
		sixm.add_widget(self.sixc1)
		sixm.add_widget(sixt)
		simm=BoxLayout(size_hint=(1,0.5))
		self.simc2=CheckBox(group='term',size_hint=[0.1,1],on_press=lambda a:self.term_action(2))
		simt=Label(text='[b]only simple intrest every month                    [/b]',markup=True)
		simm.add_widget(self.simc2)
		simm.add_widget(simt)
		self.main_grid.add_widget(sixm)
		self.main_grid.add_widget(simm)
		self.main_grid.add_widget(BoxLayout(size_hint=[1,0.1]))

		#ok button
		ok=Button(text='ok',background_normal='button-on.jpeg',background_down='button-down.jpeg',on_press=lambda a:self.intrest_cal())
		self.main_grid.add_widget(ok)

		#displaying the date
		see_date=Label(text='[b]the total number of days is[/b]',markup=True)
		self.dateo=TextInput(text='',font_name='fff',hint_text_color=[0,1,0.5,1],readonly=True,markup=True,foreground_color=[1,0,0,1])
		self.main_grid.add_widget(see_date)
		self.main_grid.add_widget(self.dateo)

		#displaying the amount
		see_amount=BoxLayout()
		amountt=Label(text='[b]the total amount is[/b]',markup=True)
		details=Button(text='full',size_hint=[0.4,1],background_normal='button-on.jpeg',background_down='button-down.jpeg',on_press=lambda a:popu2().open())
		see_amount.add_widget(amountt)
		see_amount.add_widget(details)
		self.main_grid.add_widget(see_amount)
		self.amounto=TextInput(text='',font_name='fff',hint_text_color=[0,1,0.5,1],readonly=True,markup=True,foreground_color=[1,0,0,1])
		self.main_grid.add_widget(self.amounto)

       	
        
		#side-hidden panel
		#to add this all to have to add main panel and the side panel to navigationdrawer
		navigationdrawer = NavigationDrawer()                
		navigationdrawer.anim_type = 'fade_in'    
		self.side_panel=BoxLayout(orientation='vertical')        
		value=['vijayawada','guntur','hyderabad','rajahmundry','nellore','visakhapatnam','kakinada','warangal','proddatur','bangalore','delhi','chennai','mumbai','kolkata']        
		
		s1=Spinner(text='vijayawada',values=value,size_hint_y=None,sync_height = True,background_normal='button-on.jpeg',background_down='button-down.jpeg')     
		tex1=Label(text='gold price in the city is')        
		self.rateo1=TextInput(readonly=True,font_name='fff',markup=True,foreground_color=[1,0,0,1])
		ok1=Button(text='ok',size_hint=[0.4,1],readonly=True,background_normal='button-on.jpeg',background_down='button-down.jpeg',on_press=lambda a:self.dis(s1.text,1))
		box1=BoxLayout()
		box1.add_widget(self.rateo1)
		box1.add_widget(ok1)
        
		s2=Spinner(text='guntur',values=value,size_hint_y=None,sync_height = True,background_normal='button-on.jpeg',background_down='button-down.jpeg')        
		tex2=Label(text='gold price in the city is')        
		self.rateo2=TextInput(readonly=True,font_name='fff',markup=True,foreground_color=[1,0,0,1])
		ok2=Button(text='ok',size_hint=[0.4,1],readonly=True,background_normal='button-on.jpeg',background_down='button-down.jpeg',on_press=lambda a:self.dis(s2.text,2))
		box2=BoxLayout()
		box2.add_widget(self.rateo2)
		box2.add_widget(ok2)
        
		tex3=Label(text='silver price in India(1KG)')        
		rateo3=TextInput(readonly=True,font_name='fff',markup=True,foreground_color=[1,0,0,1])
       
		but1=Button(text='about',background_normal='button-on.jpeg',background_down='button-down.jpeg')        
		self.side_panel.add_widget(s1)        
		self.side_panel.add_widget(tex1)        
		self.side_panel.add_widget(box1)        
		self.side_panel.add_widget(BoxLayout())        
		self.side_panel.add_widget(s2)        
		self.side_panel.add_widget(tex2)        
		self.side_panel.add_widget(box2)        
		self.side_panel.add_widget(BoxLayout())        
		self.side_panel.add_widget(tex3)        
		self.side_panel.add_widget(rateo3)        
		self.side_panel.add_widget(but1)
       
		navigationdrawer.add_widget(self.side_panel)
		navigationdrawer.add_widget(self.main_grid)

		#adding the complete grid to screen
		
		self.add_widget(navigationdrawer)
Esempio n. 9
0
    def build(self):
        wid = Widget()

        self.buttons = []

        main_layout = BoxLayout(orientation='vertical')

        main_layout.add_widget(
            Label(text='Make a summ!', font_size=self.font_size))

        layout = GridLayout(cols=10, size_hint=(1, 1))

        for j in range(2):
            for i in range(10):
                self.buttons.append(Button(text='', on_press=self.react))
                layout.add_widget(self.buttons[-1])

        main_layout.add_widget(layout)

        main_layout.add_widget(
            Label(text='Of following numbers:', font_size=self.font_size))

        args = BoxLayout()

        self.arg1 = Spinner(text='First\nnumber',
                            values=('0', '1', '2', '3', '4', '5', '6', '7',
                                    '8', '9'),
                            font_size=self.font_size,
                            color=first_arg_color,
                            on_text=self.reset_indication)
        self.arg1.bind(text=self.reset_indication)
        args.add_widget(self.arg1)

        args.add_widget(Label(text='+', font_size=self.font_size))

        self.arg2 = Spinner(text='Second\nnumber',
                            values=('0', '1', '2', '3', '4', '5', '6', '7',
                                    '8', '9'),
                            font_size=self.font_size,
                            color=second_arg_color,
                            on_text=self.reset_indication)
        self.arg2.bind(text=self.reset_indication)
        args.add_widget(self.arg2)

        main_layout.add_widget(args)

        main_layout.add_widget(Label(text='=', font_size=self.font_size))

        answer = BoxLayout()

        self.answer1 = Spinner(text='',
                               values=('', '0', '1', '2', '3', '4', '5', '6',
                                       '7', '8', '9'),
                               font_size=self.font_size)
        answer.add_widget(self.answer1)

        self.answer2 = Spinner(text='',
                               values=('', '0', '1', '2', '3', '4', '5', '6',
                                       '7', '8', '9'),
                               font_size=self.font_size)
        answer.add_widget(self.answer2)

        answer.size_hint = (0.2, None)
        answer.pos_hint = {'center_x': 0.5}

        main_layout.add_widget(answer)

        self.check_button = Button(text='', on_press=self.check_answer)

        main_layout.add_widget(
            Label(text='And check the result!',
                  font_size=self.font_size,
                  color=neutral_color))
        main_layout.add_widget(self.check_button)

        # reward =)
        self.reward_layout = GridLayout(cols=10)
        main_layout.add_widget(self.reward_layout)

        main_layout.size_hint = (1.0, 1.0)

        return main_layout
Esempio n. 10
0
            rgb: self.colors
        Rectangle:
            pos: root.pos
            size: root.size

""")

Window.size = (700, 700)


class Dummy:
    colors = (0, 0, 0, 0)

    def __init__(self, colors):
        self.colors = colors


class Button1(Button, Dummy):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)


layout = GridLayout(cols=8)
for i in range(8):
    for j in range(8):
        clr = (i + j + 1) % 2
        btn = Button1(colors=(clr, clr, clr))
        layout.add_widget(btn)

runTouchApp(layout)
Esempio n. 11
0
    def build(self):
        self.title = 'Exchange Rates To AMD'
        bl = BoxLayout(orientation="vertical")
        bl2 = BoxLayout(orientation="horizontal")
        gl = GridLayout(cols=1, spacing=3)
        gl2 = GridLayout(cols=2, spacing=1)
        self.lbl = Label(text="- - - - - - - - -", font_size=20)

        btn_usd = Button(text='USD', size_hint_y=None, height=44)
        btn_usd.bind(on_release=lambda btn: dropdown.select(btn_usd.text))
        btn_eur = Button(text='EUR', size_hint_y=None, height=44)
        btn_eur.bind(on_release=lambda btn: dropdown.select(btn_eur.text))
        btn_rub = Button(text='RUB', size_hint_y=None, height=44)
        btn_rub.bind(on_release=lambda btn: dropdown.select(btn_rub.text))
        btn_uah = Button(text='UAH', size_hint_y=None, height=44)
        btn_uah.bind(on_release=lambda btn: dropdown.select(btn_uah.text))
        btn_amd = Button(text='AMD', size_hint_y=None, height=44)
        btn_amd.bind(on_release=lambda btn: dropdown.select(btn_amd.text))

        dropdown.add_widget(btn_usd)
        dropdown.add_widget(btn_eur)
        dropdown.add_widget(btn_rub)
        dropdown.add_widget(btn_uah)
        dropdown.add_widget(btn_amd)

        btn_usd2 = Button(text='USD', size_hint_y=None, height=44)
        btn_usd2.bind(on_release=lambda btn: dropdown2.select(btn_usd2.text))
        btn_eur2 = Button(text='EUR', size_hint_y=None, height=44)
        btn_eur2.bind(on_release=lambda btn: dropdown2.select(btn_eur2.text))
        btn_rub2 = Button(text='RUB', size_hint_y=None, height=44)
        btn_rub2.bind(on_release=lambda btn: dropdown2.select(btn_rub2.text))
        btn_uah2 = Button(text='UAH', size_hint_y=None, height=44)
        btn_uah2.bind(on_release=lambda btn: dropdown2.select(btn_uah2.text))
        btn_amd2 = Button(text='AMD', size_hint_y=None, height=44)
        btn_amd2.bind(on_release=lambda btn: dropdown2.select(btn_amd2.text))

        dropdown2.add_widget(btn_usd2)
        dropdown2.add_widget(btn_eur2)
        dropdown2.add_widget(btn_rub2)
        dropdown2.add_widget(btn_uah2)
        dropdown2.add_widget(btn_amd2)

        self.mainbutton = Button(text="From", size_hint=(1, .5))
        self.mainbutton2 = Button(text="To", size_hint=(1, .5))

        self.mainbutton.bind(on_release=dropdown.open)
        self.mainbutton2.bind(on_release=dropdown2.open)

        dropdown.bind(
            on_select=lambda instance, x: setattr(self.mainbutton, 'text', x))
        dropdown2.bind(
            on_select=lambda instance, x: setattr(self.mainbutton2, 'text', x))
        """
        bl.add_widget(self.lbl)
        bl.add_widget( Button(text="Get Rate", on_press=self.get_rate) )
        bl2.add_widget(self.mainbutton)
        bl2.add_widget(self.mainbutton2)
        bl.add_widget(bl2)
        return bl
        """
        gl.add_widget(self.lbl)
        gl2.add_widget(self.mainbutton)
        gl2.add_widget(self.mainbutton2)
        gl.add_widget(gl2)
        gl.add_widget(
            Button(text="Get Rate", on_press=self.get_rate,
                   size_hint=(.4, .5)))
        return gl
Esempio n. 12
0
    def update_plants(self, *args):
        try:
            self.remove_widget(self.grid_layout)
        except:
            pass

        grid_layout = GridLayout(cols=2)

        # left side of display
        layout_left = FloatLayout()

        # colored background for left side of main menu
        layout_left.canvas.add(brown_color)
        layout_left.canvas.add(
            Rectangle(pos=(0, 0),
                      size=(screen_width / 2, screen_height),
                      orientation='horizontal'))
        layout_left.add_widget(
            Label(
                text="[b][size=42][color=#5C4940]PLANTHING[/color][/size][/b]",
                markup=True,
                size_hint=(.5, .5),
                pos_hint={
                    'x': .25,
                    'y': .4
                }))

        # reading humidity and temp using sensors.get_humidity_temp()
        temp_humidity = sensors.get_humidity_temp(
        )  #{'temperature': 0, 'humidity': 0 }

        temperature_string = "[b][size=18][color=#5C4940]Temperature: {0} C[/color][/size][/b]".format(
            temp_humidity["temperature"])
        humidity_string = "[b][size=18][color=#5C4940]Humidity: {0}%[/color][/size][/b]".format(
            temp_humidity["humidity"])

        # temperature display
        self.temperature_widget = Label(text=temperature_string,
                                        markup=True,
                                        size_hint=(.5, .05),
                                        pos_hint={
                                            'x': .25,
                                            'y': 0.2
                                        })
        layout_left.add_widget(self.temperature_widget)

        # humidity display
        self.humidity_widget = Label(text=humidity_string,
                                     markup=True,
                                     size_hint=(.5, .05),
                                     pos_hint={
                                         'x': .25,
                                         'y': 0.15
                                     })
        layout_left.add_widget(self.humidity_widget)

        # four plants on display
        layout_right = FloatLayout(cols=2,
                                   row_force_default=True,
                                   row_default_height=screen_height / 2)
        layout_right.canvas.add(Color(1, 1, 1))
        layout_right.canvas.add(
            Rectangle(pos=(screen_width / 2, 0),
                      size=(screen_width / 2, screen_height),
                      orientation='horizontal'))

        # initialize the plants
        plant_size = 0.3  # plant image width is 30% of width
        plant_padding = (0.5 -
                         plant_size) / 2  # total space for each plant is 50%
        positions = [(plant_padding, 0.5 + plant_padding),
                     (0.5 + plant_padding, 0.5 + plant_padding),
                     (plant_padding, plant_padding),
                     (0.5 + plant_padding, plant_padding)]

        total_plants = 4
        for i in range(total_plants):
            # Position of this button
            (x, y) = positions[i]

            # Add brown background for each plant
            layout_right.canvas.add(brown_color)
            layout_right.canvas.add(
                Rectangle(
                    pos=(screen_width / 2 + (x - 0.035) * screen_width / 2,
                         (y - 0.08) * screen_height),
                    size=(150, 210),
                    orientation='horizontal'))

            # If plant exists, add it
            if i < len(plants):
                plant = plants[i]

                # each plant icon is a button
                plant_button = ImageButton(source=plant["plant_image"],
                                           on_press=partial(
                                               self.view_detail,
                                               plant_id=plant["plant_id"]),
                                           size_hint=(plant_size, plant_size),
                                           pos_hint={
                                               'x': x,
                                               'y': y
                                           })

                layout_right.add_widget(plant_button)

                # adding in names of plants
                plant_text = "[b][color=#5C4940]{0}[/color][/b]".format(
                    plant['name'])
                label_height = 0.05
                label_offset = 0.09
                layout_right.add_widget(
                    Label(text=plant_text,
                          markup=True,
                          size_hint=(plant_size, label_height),
                          pos_hint={
                              'x': x,
                              'y': y - plant_size / 2 + label_offset
                          }))
            else:
                # Plant doesn't exist, allow users to add new plant
                plant_button = Button(
                    text=
                    "[b][size=18][color=#5C4940]Add Plant[/color][/size][/b]",
                    markup=True,
                    background_color=[0, 0, 0, 0],
                    on_press=self.add_plant,
                    size_hint=(plant_size, plant_size),
                    pos_hint={
                        'x': x,
                        'y': y - 0.035
                    })
                layout_right.add_widget(plant_button)
                plant_background = Rectangle(pos=(x, y),
                                             size=(plant_size, plant_size),
                                             orientation='horizontal')
                layout_right.canvas.add(plant_background)

        # add left and right screens
        grid_layout.add_widget(layout_left)
        grid_layout.add_widget(layout_right)

        self.add_widget(grid_layout)
        self.grid_layout = grid_layout
Esempio n. 13
0
    def __init__(self, **kwargs):
        super(Detail, self).__init__(**kwargs)  # detail superclass
        grid_layout = GridLayout(cols=2)

        self.mainMenu = kwargs['main']

        self.plant = None

        # left side
        left_layout = FloatLayout()

        # background colour
        left_layout.canvas.add(brown_color)
        left_layout.canvas.add(
            Rectangle(pos=(0, 0),
                      size=(screen_width / 2, screen_height),
                      orientation='horizontal'))

        # plant image
        plant_size = 0.6
        self.plant_image = Image(source="",
                                 size_hint=(plant_size, plant_size),
                                 pos_hint={
                                     'x': (1 - plant_size) / 2,
                                     'y': (1 - plant_size) / 2
                                 })
        left_layout.add_widget(self.plant_image)

        left_layout.add_widget(
            Button(text="Back",
                   on_press=self.back,
                   background_color=brown_button_background,
                   size_hint=(1, .05),
                   pos_hint={
                       'x': 0,
                       'y': 0.95
                   }))

        # plant name and owner labels
        self.plant_name_label = Label(
            text="[b][size=18][color=#5C4940]Name: Plant[/color][/size][/b]",
            markup=True,
            size_hint=(1, 0.1),
            pos_hint={
                'x': 0,
                'y': 0.05
            })
        self.owner_name_label = Label(
            text=
            "[b][size=18][color=#5C4940]Owned By: Person[/color][/size][/b]",
            markup=True,
            size_hint=(1, 0.1),
            pos_hint={
                'x': 0,
                'y': 0
            })
        left_layout.add_widget(self.plant_name_label)
        left_layout.add_widget(self.owner_name_label)

        # right side
        right_layout = FloatLayout()

        # background colour
        right_layout.canvas.add(Color(1, 1, 1))
        right_layout.canvas.add(
            Rectangle(pos=(screen_width / 2, 0),
                      size=(screen_width / 2, screen_height),
                      orientation='horizontal'))

        # Water and fertilizer buttons
        btn_size = .3
        btn_gap = 0.05

        self.water_btn = ImageButton(source="Graphics/water_btn.png",
                                     size_hint=(btn_size, btn_size),
                                     pos_hint={
                                         'x': 0.5 - btn_gap / 2 - btn_size,
                                         'y': 0.2
                                     },
                                     on_press=self.water)
        self.fertilizer_btn = ImageButton(source="Graphics/fertilizer_btn.png",
                                          size_hint=(btn_size, btn_size),
                                          pos_hint={
                                              'x': 0.5 + btn_gap / 2,
                                              'y': 0.2
                                          },
                                          on_press=self.fertilize)

        right_layout.add_widget(self.water_btn)
        right_layout.add_widget(self.fertilizer_btn)

        progress_start_y = 0.8
        progress_bar_height = 0.1

        # temperature bar
        right_layout.add_widget(
            ImageButton(source="Graphics/light_icon.png",
                        size_hint=(0.1, progress_bar_height),
                        pos_hint={
                            'x': 0.2,
                            'y': progress_start_y
                        }))
        self.temperature_bar = ProgressBar(max=100,
                                           size_hint=(0.3,
                                                      progress_bar_height),
                                           pos_hint={
                                               'x': 0.5,
                                               'y': progress_start_y
                                           })
        right_layout.add_widget(self.temperature_bar)

        # water bar
        right_layout.add_widget(
            ImageButton(source="Graphics/water_icon.png",
                        markup=True,
                        size_hint=(0.1, progress_bar_height),
                        pos_hint={
                            'x': 0.2,
                            'y': progress_start_y - progress_bar_height
                        }))
        self.water_bar = ProgressBar(max=100,
                                     size_hint=(0.3, progress_bar_height),
                                     pos_hint={
                                         'x':
                                         0.5,
                                         'y':
                                         progress_start_y - progress_bar_height
                                     })
        right_layout.add_widget(self.water_bar)

        # fertilizer bar
        right_layout.add_widget(
            ImageButton(source="Graphics/fertilizer_icon.png",
                        markup=True,
                        size_hint=(0.1, progress_bar_height),
                        pos_hint={
                            'x': 0.2,
                            'y': progress_start_y - 2 * progress_bar_height
                        }))
        self.fertilizer_bar = ProgressBar(max=100,
                                          size_hint=(0.3, progress_bar_height),
                                          pos_hint={
                                              'x':
                                              0.5,
                                              'y':
                                              progress_start_y -
                                              2 * progress_bar_height
                                          })
        right_layout.add_widget(self.fertilizer_bar)

        # delete button
        right_layout.add_widget(
            ImageButton(source="Graphics/delete.png",
                        on_press=self.remove_plant,
                        markup=True,
                        size_hint=(0.25, progress_bar_height),
                        pos_hint={
                            'x': 0.5 - 0.25 / 2,
                            'y': 0.05
                        }))

        grid_layout.add_widget(left_layout)
        grid_layout.add_widget(right_layout)
        self.add_widget(grid_layout)
Esempio n. 14
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
Esempio n. 15
0
    def __init__(self, **kwargs):
        super(NewCatScreen, self).__init__(**kwargs)
        self.DB = PGConnection()
        self.expense_list = self.DB.get_expenses()
        self.revenue_list = self.DB.get_revenues()
        self.maingrid = GridLayout()
        self.maingrid.rows = 4
        self.maingrid.cols = 1

        # Colour
        self.expensesText = (1, 1, 1, 1)
        self.expensesBG = (0.04, 0.12, 0.4, 1)
        self.revenueText = (1, 1, 1, 1)
        self.revenueBG = (0.6, 0, 0, 1)
        self.changeBtnBG = (0.5, 0.5, 0.5, 1)

        def submita(self, instance):
            pass

        def switch_main(instance):
            self.manager.transition.direction = 'right'
            self.manager.current = "mainscreen"

        def submit_cat(instance):
            value = self.catInput.text
            print(value)
            showPopup = Pop()
            self.popup_window = Popup(title="Confirm submission?",
                                      content=showPopup,
                                      size=(300, 100),
                                      size_hint=(None, None))
            showPopup.cnclBtn.bind(on_release=self.popup_window.dismiss)
            # showPopup.cnfmBtn.bind(on_release=self.submita)
            self.popup_window.open()

        # Change to revenue
        self.catBox = GridLayout(size_hint=(0.3, 0.1))
        self.catBox.cols = 2
        self.catText = Label(text="New category:")
        self.catInput = TextInput(multiline=False)
        self.catBox.add_widget(self.catText)
        self.catBox.add_widget(self.catInput)

        # Category switch
        self.changeFlow = GridLayout(size_hint=(0.3, 0.1))
        self.changeFlow.cols = 1
        self.switchLabel = Label(text="Type:")
        self.switch = Switch(active=False)
        self.changeFlow.add_widget(self.switchLabel)
        self.changeFlow.add_widget(self.switch)

        # Submit button
        self.submitBtn = GridLayout(size_hint=(0.3, 1))
        self.submitBtn.rows = 1
        submit_btn = Button(text="Submit", background_color=(1, 1, 1, 1))
        submit_btn.bind(on_release=submit_cat)
        self.submitBtn.add_widget(submit_btn)

        # Back to main menu
        self.backBtn = GridLayout(size_hint=(0.3, 1))
        self.backBtn.rows = 1
        new_category_btn = Button(pos_hint={'top': 0.5},
                                  text="Back",
                                  background_color=(1, 1, 1, 1))
        new_category_btn.bind(on_release=switch_main)
        self.backBtn.add_widget(new_category_btn)

        self.maingrid.add_widget(self.catBox)
        self.maingrid.add_widget(self.changeFlow)
        self.maingrid.add_widget(self.submitBtn)
        self.maingrid.add_widget(self.backBtn)
        self.add_widget(self.maingrid)
Esempio n. 16
0
    def __init__(self, **kwargs):
        super(DisguiseLayout, self).__init__(**kwargs)
        self.disguise_size = {
            'hair': (200, 100),
            'eyes': (200, 67),
            'nose': (200, 44),
            'mouth': (200, 44),
            'body': (200, 200)
        }

        self.left_panel = GridLayout(cols=1,
                                     pos_hint=({
                                         'center_x': 0.5,
                                         'center_y': 0.5
                                     }))
        self.right_panel = ScrollView(effect_cls=ScrollEffect)

        for id, typ in enumerate(self.disguise_size.keys()):
            but = DisguiseTypeButton(
                typ=typ, source=os.path.join('data', 'but_{}.png'.format(typ))
            )  #, size_hint=(1,0.3))#, size=(50,50), pos_hint={'x':0, 'center_y':0.3+0.1*id})
            but.bind(on_release=self.show_hide_list)
            self.left_panel.add_widget(but)

        self.add_widget(self.left_panel)
        self.add_widget(self.right_panel)

        #self.disguise_size={'hair':(200,100),'eyes':(200,67),'nose':(200,44),'mouth':(200,44),'body':(200,200)}
        self.disguise_size = {
            'hair': (300, 150),
            'eyes': (300, 100),
            'nose': (300, 67),
            'mouth': (300, 67),
            'body': (300, 300)
        }

        self.scroll_views = {}
        self.max_texture_size = 0
        for typ, siz in self.disguise_size.items():
            gridlayout = GridLayout(cols=1,
                                    spacing=10,
                                    padding=10,
                                    size_hint=(1, None))
            gridlayout.bind(minimum_height=gridlayout.setter('height'))

            for filename in os.listdir('data'):
                if filename.startswith('id_{}'.format(typ)):
                    id_trash, type_trash, name = filename.split('_')
                    name = name.replace('.png', '')
                    btn = DisguiseButton(typ=typ,
                                         name=name,
                                         size_hint=(None, None),
                                         size=siz,
                                         background_normal=os.path.join(
                                             'data', filename))
                    btn.bind(on_release=self.pick_from_list)
                    gridlayout.add_widget(btn)

                    img_size = Image(
                        source=os.path.join('data', filename)).texture_size
                    if img_size > self.max_texture_size:
                        self.max_texture_size = img_size

            self.scroll_views[typ] = ScrollView(effect_cls=ScrollEffect)
            self.scroll_views[typ].add_widget(gridlayout)
            gridlayout.bind(
                minimum_width=self.scroll_views[typ].setter('width'))
Esempio n. 17
0
    def build(self):
        self.anx = AnchorLayout()

        self.osn = Image(source='Fonn.jpg')
        self.anx.add_widget(self.osn)
        self.bl = BoxLayout(orientation='vertical',
                            padding=[15, 10],
                            spacing=5)

        self.gll = GridLayout(minimum_height=20,
                              cols=1,
                              size_hint=(1, None),
                              height=100)
        self.gll.bind(minimum_height=self.gll.setter('height'))

        self.scrol = ScrollView(
            bar_width=10,
            bar_color=[1, 0, 0, 1],
            effect_cls="ScrollEffect",
            scroll_type=['bars'],
            size_hint=(1, None),
            do_scroll_y=True,
        )

        self.pcontactim = contactim()
        self.pcontactem = contactem()

        for x in range(0, len(self.pcontactim)):
            self.gll.add_widget(
                Label(text=self.pcontactim[x] + ":   " + self.pcontactem[x],
                      height=40,
                      halign="right",
                      size_hint=(1, None),
                      font_size=20))

        self.scrol.add_widget(self.gll)

        self.gl = GridLayout(rows=2,
                             spacing=3,
                             size_hint=(1, None),
                             width=0,
                             row_default_height=10)

        self.bl.add_widget(
            Label(text="Список контактов", font_size='50sp',
                  size_hint=(1, .5)))  # назв

        self.bl.add_widget(self.scrol)  # списки

        self.bl.add_widget(
            Label(text="Добавить контакт", font_size='40sp',
                  size_hint=(1, .5)))

        self.txima = TextInput(hint_text="имя", height=60)
        self.txema = TextInput(hint_text="@email", height=60)
        self.btn = Button(text="Сохранить",
                          on_press=self.soxrcont,
                          background_color=[0.2, .8, 0.3, 1],
                          background_normal='')

        self.gl.add_widget(self.txima)
        self.gl.add_widget(self.txema)
        self.gl.add_widget(Label(text="       "))
        self.gl.add_widget(self.btn)
        self.bl.add_widget(self.gl)

        self.bl.add_widget(BoxLayout())
        self.anx.add_widget(self.bl)
        return self.anx
Esempio n. 18
0
    def __init__(self, **kwargs):
        super(box, self).__init__(**kwargs)
        self.main_box = BoxLayout(size=Window.size)
        self.main_box.orientation = 'vertical'
        self.anim_type = 'slide_above_simple'
        ###############################################################################3
        act_current_dir = os.getcwd()
        #os.chdir(r'/home/nagendra/test_folder')
        os.chdir(r'/storage/emulated/0/New kivy/My_app/New_music_code')
        current_dir = os.getcwd()
        os.chdir(act_current_dir)
        print('current_dirrrr = ', current_dir)
        #######################################################################
        self.lyt_image = main_lyt_image(self)
        self.nav_lyt = navigator_lyt(self,
                                     self.main_box)  # for navigation layout
        self.nav_lyt.bind(on_press=partial(open_filemanager, music_app,
                                           self.main_box, current_dir))
        self.nav_lyt.bind(on_release=lambda x: self.toggle_nav_drawer())
        ####################################################################
        gridlayout = GridLayout(cols=1, size_hint_y=None, spacing=1)
        gridlayout.bind(minimum_height=gridlayout.setter('height'))
        ##################################################################33#########
        print('current_di = ', current_dir)
        index = 0
        ## r'/storage/emulated/0/New kivy/My_app/New_music_code/songs/'
        SD_CARD = primary_external_storage_path()
        request_permissions([
            Permission.READ_EXTERNAL_STORAGE, Permission.WRITE_EXTERNAL_STORAGE
        ])

        for dirpath, dir_name, filename in os.walk(SD_CARD):
            ##print('dir_pathh = ',dirpath)
            for fn in glob(dirpath + '/*.mp3'):
                print('fn_list= ', fn)
                #                song_text = fn.split('/')[-1:][0][:-4]
                #################################################
                song_name, btn_image, song_length = data_extract(fn)

                if (float(song_length) < 100.0):
                    continue
                print('son_len = ', str(song_length))
                ###################################################
                song_button = tbtn_new()
                song_button.bind(
                    on_press=partial(self.gonext, index, self.main_box))
                song_button.text = song_name

                songlist[index] = [fn, song_button]
                #                song_button.canvas.before.children[0].rgba = [1,1,1,0.15] # Background color of button
                ##################################################
                song_btn_image(song_button, btn_image)  ## Image of button
                ####################################################################
                gridlayout.add_widget(song_button)
                index += 1
        #txtfile.close()
        scrollview = ScrollView()
        scrollview.add_widget(gridlayout)
        self.main_box.add_widget(scrollview)

        self.add_widget(self.main_box)
Esempio n. 19
0
    def __init__(self, app, dict):
        super(QuestionsForm, self).__init__()
        self.the_app = app
        with self.canvas.before:
            self.rect = Rectangle(source='back4.png')
            self.bind(size=self._update_rect, pos=self._update_rect)

        self.answers = {}
        self.questions = dict['ques']
        num_questions = len(dict['ques'].keys())

        layoutup = BoxLayout(orientation='vertical')
        layoutup.add_widget(BoxLayout(size_hint_y=0.7))
        layoutup.add_widget(
            Label(text=dict['qu_title'],
                  font_size=50,
                  font_name="fonts/the_font.ttf",
                  halign='right',
                  size_hint_y=0.4,
                  size_hint_x=1.5,
                  color=[0, 0, 0, 1]))
        layoutup.add_widget(BoxLayout(size_hint_y=0.1))
        layoutup.add_widget(
            Label(text=dict['qu_description']['d1'],
                  font_name="fonts/the_font.ttf",
                  font_size=36,
                  halign='right',
                  size_hint_y=0.15,
                  color=[0, 0, 0, 1]))
        layoutup.add_widget(
            Label(text=dict['qu_description']['d2'],
                  font_name="fonts/the_font.ttf",
                  font_size=36,
                  halign='right',
                  size_hint_y=0.15,
                  color=[0, 0, 0, 1]))
        layoutup.add_widget(
            Label(text=dict['qu_description']['d3'],
                  font_name="fonts/the_font.ttf",
                  font_size=36,
                  halign='right',
                  size_hint_y=0.15,
                  color=[0, 0, 0, 1]))
        layoutup.add_widget(BoxLayout(size_hint_y=0.2))

        # question matrix
        layout = GridLayout(cols=len(dict['ans']) + 2,
                            rows=len(dict['ques']) + 1,
                            row_default_height=400 / num_questions)

        dict['ques'] = collections.OrderedDict(sorted(dict['ques'].items()))

        q_counter = 0
        for ques, values in dict['ques'].items():
            layout.add_widget(BoxLayout(size_hint_x=0.05))
            q_counter += 1
            if q_counter == 1:
                for ans in dict['ans']:
                    layout.add_widget(
                        Label(size_hint_x=0.1,
                              text=dict['ans'][ans],
                              font_name="fonts/the_font.ttf",
                              font_size=25,
                              halign='right',
                              color=[0, 0, 0, 1]))
                layout.add_widget(
                    Label(text="תולאש",
                          font_name="fonts/the_font.ttf",
                          font_size=42,
                          halign='right',
                          orientation='vertical',
                          color=[0, 0, 0, 1]))
                layout.add_widget(BoxLayout(size_hint_x=0.1))

            for ans in dict['ans']:
                ab = AnswerButton(size_hint_x=0.15,
                                  text="",
                                  group=str(q_counter))
                ab.name = str(ques) + "," + str(ans)
                ab.question = ques
                ab.answer = ans
                ab.form = self
                self.ans_button.append(ab)
                layout.add_widget(ab)

            # CHECK ID AND KEEP THE CLICK VALUE
            layout.add_widget(
                Label(halign='right',
                      text=dict['ques'][ques],
                      font_name="fonts/the_font.ttf",
                      orientation='vertical',
                      font_size=36,
                      color=[0, 0, 0, 1]))

        layoutup.add_widget(layout)
        layoutup.add_widget(BoxLayout())
        layoutbuttons = BoxLayout(size_hint_y=0.2)
        self.next_button = Button(on_press=self.next,
                                  background_color=(0, 0.71, 1., 1),
                                  background_normal="",
                                  size_hint_x=0.3,
                                  text=dict['next_button'],
                                  font_name="fonts/the_font",
                                  font_size=20,
                                  disabled=True)

        layoutbuttons.add_widget(BoxLayout(size_hint_x=0.2))
        layoutbuttons.add_widget(self.next_button)
        layoutbuttons.add_widget(BoxLayout())
        layoutbuttons.add_widget(BoxLayout(size_hint_x=0.7))

        layoutup.add_widget(layoutbuttons)
        layoutup.add_widget(BoxLayout(size_hint_y=0.1))
        self.add_widget(layoutup)
Esempio n. 20
0
    def build(self):
        root = BoxLayout(orientation='vertical')
        self.abon_name = TextInput(text=RECEPIENT_NAME,
                                   readonly=False,
                                   font_size=20,
                                   size_hint=[1, .1],
                                   background_color=[1, 1, 1, .8])
        self.abon_mail = TextInput(text="",
                                   readonly=False,
                                   font_size=20,
                                   size_hint=[1, .1],
                                   background_color=[1, 1, 1, .8])
        self.abon_login = TextInput(text="",
                                    readonly=False,
                                    font_size=20,
                                    size_hint=[1, .1],
                                    background_color=[1, 1, 1, .8])
        self.abon_password = TextInput(text="",
                                       readonly=False,
                                       font_size=20,
                                       size_hint=[1, .1],
                                       background_color=[1, 1, 1, .8])
        self.sender_name = TextInput(text=SENDER_NAME,
                                     readonly=False,
                                     font_size=20,
                                     size_hint=[1, .1],
                                     background_color=[.3, 1, .7, .8])
        self.sender_mail = TextInput(text=SENDER_EMAIL,
                                     readonly=False,
                                     font_size=20,
                                     size_hint=[1, .1],
                                     background_color=[.3, 1, .7, .8])
        self.sender_password = TextInput(text=SENDER_PASSWORD,
                                         readonly=False,
                                         font_size=20,
                                         size_hint=[1, .1],
                                         background_color=[.3, 1, .7, .8])

        root.add_widget(Label(text="Абонент ", size_hint=[1, .2]))

        abon = GridLayout(cols=2)
        abon.add_widget(Label(text="Имя: ", size_hint=[.4, .1]))
        abon.add_widget(self.abon_name)
        abon.add_widget(Label(text="Почта: ", size_hint=[.4, .1]))
        abon.add_widget(self.abon_mail)
        abon.add_widget(Label(text="Логин: ", size_hint=[.4, .1]))
        abon.add_widget(self.abon_login)
        abon.add_widget(Label(text="Пароль: ", size_hint=[.4, .1]))
        abon.add_widget(self.abon_password)
        root.add_widget(abon)

        root.add_widget(Label(text="Отправитель ", size_hint=[1, .2]))

        sender = GridLayout(cols=2, size_hint=[1, .7])
        sender.add_widget(Label(text="Имя: ", size_hint=[.4, .1]))
        sender.add_widget(self.sender_name)
        sender.add_widget(Label(text="Почта: ", size_hint=[.4, .1]))
        sender.add_widget(self.sender_mail)
        sender.add_widget(Label(text="Пароль: ", size_hint=[.4, .1]))
        sender.add_widget(self.sender_password)
        root.add_widget(sender)

        btn1 = Button(text='Отправить',
                      size_hint=[1, .25],
                      on_press=self.send_mail)
        root.add_widget(btn1)

        return root
Esempio n. 21
0
    def __init__(self, app, **kwargs):
        super(ManualScreen, self).__init__(**kwargs)
        layout = FloatLayout(
        )  #FloatLayout(orientation='vertical', padding=20, spacing=5)
        self.add_widget(layout)
        self.app = app

        with self.canvas.before:
            Color(0.9, 0.9, 0.9, 1)
            self.rect = Rectangle(size=(75, 50),
                                  pos=(800 - 75, 0),
                                  rgb=(1, 1, 1),
                                  source='Datas/irisib.png')

        box_Gauges = GridLayout(rows=3,
                                cols=2,
                                col_default_width=150,
                                col_force_default=True,
                                row_default_height=150,
                                row_force_default=True,
                                pos=(10, -20))
        gaugesize = 150
        fontSize = 20
        self.gaugeU_Motor = Gauge(value=0,
                                  size_gauge=gaugesize,
                                  size_text=fontSize,
                                  text_desc="U Motor",
                                  size_desc=15)
        self.gaugeI_Motor = Gauge(value=0,
                                  size_gauge=gaugesize,
                                  size_text=fontSize,
                                  text_desc="I Motor",
                                  size_desc=15)
        self.gaugeU_Brake = Gauge(value=0,
                                  size_gauge=gaugesize,
                                  size_text=fontSize,
                                  text_desc="U Brake",
                                  size_desc=15)
        self.gaugeI_brake = Gauge(value=0,
                                  size_gauge=gaugesize,
                                  size_text=fontSize,
                                  text_desc="I Brake",
                                  size_desc=15)
        self.gauge_Speed = Gauge(value=0,
                                 size_gauge=gaugesize,
                                 size_text=fontSize,
                                 text_desc="Speed",
                                 size_desc=15)
        self.gauge_Couple = Gauge(value=0,
                                  size_gauge=gaugesize,
                                  size_text=fontSize,
                                  text_desc="Couple",
                                  size_desc=15)

        box_Gauges.add_widget(self.gaugeU_Motor)
        box_Gauges.add_widget(self.gaugeI_Motor)
        box_Gauges.add_widget(self.gaugeU_Brake)
        box_Gauges.add_widget(self.gaugeI_brake)
        box_Gauges.add_widget(self.gauge_Speed)
        box_Gauges.add_widget(self.gauge_Couple)

        settings_layout = GridLayout(rows=3,
                                     cols=2,
                                     col_default_width=150,
                                     col_force_default=True,
                                     row_default_height=30,
                                     row_force_default=True,
                                     pos=(400, -20),
                                     spacing=[5, 10])

        self.btnSetSpeed = Button(
            text="Set Speed",
            on_release=self.btnSetting_Release)  #"TC_Set_Speed")
        self.btnSetSpeed.id = "TC_Set_Speed"
        self.btnSetUmotor = Button(text="Set Umotor",
                                   on_release=self.btnSetting_Release)
        self.btnSetUmotor.id = "TC_Set_Umotor"
        self.btnSetCouple = Button(text="Set Couple",
                                   on_release=self.btnSetting_Release)
        self.btnSetCouple.id = "TC_Set_Couple"
        self.txtbxSetSpeed = TextInput(text='0', input_filter='float')
        self.txtbxSetUmotor = TextInput(text='0', input_filter='float')
        self.txtbxSetCouple = TextInput(text='0', input_filter='float')

        settings_layout.add_widget(self.txtbxSetSpeed)
        settings_layout.add_widget(self.btnSetSpeed)
        settings_layout.add_widget(self.txtbxSetUmotor)
        settings_layout.add_widget(self.btnSetUmotor)
        settings_layout.add_widget(self.txtbxSetCouple)
        settings_layout.add_widget(self.btnSetCouple)

        layout.add_widget(settings_layout)
        layout.add_widget(box_Gauges)
Esempio n. 22
0
 def __init__(self, **kwargs):
     self._element = GridLayout(**kwargs)
Esempio n. 23
0

def minus(hello=0):
    m_s = my_matrix.get_mat_size()[0]
    my_matrix.set_mat_size([m_s - 1, m_s - 1])


def get_matrix(hello=0):
    print(my_matrix.get_matrix())


def set_matrix(hello=0):
    my_matrix.set_matrix([[1, 2, 3], [3, 4, 5], [1, 2, 3]])


gl = GridLayout(cols=1)
gl2 = GridLayout(cols=2)

but1 = Button(text='+', on_press=plus)
but2 = Button(text='-', on_press=minus)
but3 = Button(text='get matrix', on_press=get_matrix)
but4 = Button(text='set matrix', on_press=set_matrix)

gl.add_widget(my_matrix)
gl.add_widget(gl2)
gl.add_widget(but3)
gl.add_widget(but4)

gl2.add_widget(but1)
gl2.add_widget(but2)
Esempio n. 24
0
    def __init__(self, **kwargs):
        super(Layout, self).__init__(**kwargs)

        self.cols = 2
        self.model_path = '/Users/willroper/Documents/University/SimFarm2030/SimFarm2030/cultivar_models/'
        self.model_files = os.listdir(self.model_path)

        for mfile in iter(self.model_files):
            print(mfile)
            if mfile == '.DS_Store':
                self.model_files.remove(mfile)

        self.cultivar_dict = {}

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

        self.inside.dropdown = DropDown()

        for model_file in self.model_files:

            print(model_file)

            if os.path.isdir(model_file) or model_file == '.DS_Store':
                print(model_file)
                continue

            # Get the name of this cultivar from the model file name
            cultivar_name = model_file.split('_')[0]

            with open(self.model_path + model_file, 'rb') as pfile1:
                self.cultivar_dict[cultivar_name] = pickle.load(pfile1)

            btn = Button(text=cultivar_name, size_hint_y=None, height=44)

            btn.bind(on_release=self.change_model)

            self.inside.dropdown.add_widget(btn)

        # Get the name of this cultivar from the model file name
        cultivar_name = self.model_files[0].split('_')[0]
        self.current_model = self.cultivar_dict[cultivar_name]

        self.current_cultivar = cultivar_name

        # create a big main button
        self.inside.dropbutton = Button(text='Cultivar Models',
                                        size_hint=(None, None))
        self.inside.dropbutton.bind(on_release=self.inside.dropdown.open)
        self.inside.add_widget(self.inside.dropbutton)

        self.meant_label = Label(text=r'Mean Temperature Modifier: ')
        self.inside.add_widget(self.meant_label)
        self.mean_t_slider = Slider(min=-10,
                                    max=10,
                                    value=0,
                                    value_track=True,
                                    value_track_color=[1, 0, 0, 1])
        self.inside.add_widget(self.mean_t_slider)
        self.meant_label.text = r'Mean Temperature Modifier: ' + str(
            round(self.mean_t_slider.value, 2))
        self.mean_t_slider.bind(value=self.onSliderValueChange)

        self.meanp_label = Label(text=r'Mean Precipitation Modifier: ')
        self.inside.add_widget(self.meanp_label)
        self.mean_p_slider = Slider(min=-100,
                                    max=100,
                                    value=0,
                                    value_track=True,
                                    value_track_color=[1, 0, 0, 1])
        self.inside.add_widget(self.mean_p_slider)
        self.meanp_label.text = r'Mean Precipitation Modifier: ' + str(
            round(self.mean_p_slider.value, 2))
        self.mean_p_slider.bind(value=self.onSliderValueChange)

        self.t_label = Label(text=r'Temperature Modifier: ')
        self.inside.add_widget(self.t_label)
        self.t_slider = Slider(min=-10,
                               max=10,
                               value=0,
                               value_track=True,
                               value_track_color=[1, 0, 0, 1])
        self.inside.add_widget(self.t_slider)
        self.t_label.text = r'Temperature Modifier: ' + str(
            round(self.t_slider.value, 2))
        self.t_slider.bind(value=self.onSliderValueChange)

        self.p_label = Label(text=r'Precipitation Modifier: ')
        self.inside.add_widget(self.p_label)
        self.p_slider = Slider(min=-100,
                               max=100,
                               value=0,
                               value_track=True,
                               value_track_color=[1, 0, 0, 1])
        self.inside.add_widget(self.p_slider)
        self.p_label.text = r'Precipitation Modifier: ' + str(
            round(self.p_slider.value, 2))
        self.p_slider.bind(value=self.onSliderValueChange)

        self.year_label = Label(text='Year: ')
        self.inside.add_widget(self.year_label)
        self.year_slider = Slider(min=2002,
                                  max=2017,
                                  value=2002,
                                  step=1,
                                  value_track=True,
                                  value_track_color=[1, 0, 0, 1])
        self.inside.add_widget(self.year_slider)
        self.year_label.text = r'Year: ' + str(round(self.year_slider.value))
        self.year_slider.bind(value=self.onSliderValueChange)

        self.update_button = Button(text='Update', font_size=40)
        self.update_button.bind(on_press=self.compute_image)
        self.inside.add_widget(self.update_button)

        self.current_model.country_predict(self.year_slider.value,
                                           self.t_slider.value,
                                           self.p_slider.value,
                                           self.mean_t_slider.value,
                                           self.mean_p_slider.value,
                                           self.current_cultivar)
        self.country_image = Image(
            source='country_predictions/prediction_country_map_' +
            self.current_cultivar + '_' + str(round(self.year_slider.value)) +
            '_' + str(round(self.mean_t_slider.value, 3)) + '_' +
            str(round(self.mean_p_slider.value, 3)) + '_' +
            str(round(self.t_slider.value, 3)) + '_' +
            str(round(self.p_slider.value, 3)) + '.png')
        self.add_widget(self.country_image)

        self.add_widget(self.inside)
Esempio n. 25
0
 def filesync(self):
     """Callback when the user presses the Sync button. This relies on keyless ssh working, and does most of the work in shell scripts."""
     Logger.info('Config: filesync')
     # set up a popup containing a scrollview to contain stdout output
     layout = GridLayout(cols=1, spacing=1, padding=1, size_hint_y=None)
     layout.bind(minimum_height=layout.setter('height'))
     popup = Popup(title='Sync', size_hint=(0.8, 1))
     sv = ScrollView(size_hint=(1, 1))
     sv.add_widget(layout)
     popup = Popup(title='Sync', content=sv, size_hint=(0.8, 1))
     popup.open()
     # temp file for the rsync, probably a better way to do this
     # this file describes exactly what songs should exist on the host, no more, no less
     tpath = os.path.join(self.config.get('paths', 'tmppath'), "rsync.inc")
     # look in the ini file for all the relevant paths
     synchost = self.config.get('sync', 'synchost')
     syncbasepath = self.config.get('sync', 'syncmusicpath')
     syncfanartpath = self.config.get('sync', 'syncfanartpath')
     basepath = self.config.get('paths', 'musicpath')
     fanartpath = self.config.get('paths', 'fanartpath')
     Logger.info('Filesync: Copying rsync file to carpi')
     # TODO: figure out why this doesn't show up on the screen until after the os.walk has completed
     l = OutlineLabel(text='Copying rsync file to carpi',
                      size_hint=(None, None),
                      font_size='12sp',
                      halign='left')
     l.bind(texture_size=l.setter('size'))
     layout.add_widget(l)
     sv.scroll_to(l)
     # copy the rsync file from the synchost
     # TODO: implement this using python instead of call
     call(["scp", synchost + ":rsync.inc", tpath])
     filelist = {}
     # use codecs.open to ensure the file is read as utf8, otherwise special chars can be mangled
     with codecs.open(tpath, 'r', 'utf-8') as f:
         for line in f:
             # add each filename to a dict for easy searching later
             filelist[Helpers.decodeFileName(line.rstrip())] = True
     Logger.info('Filesync: Removing old files from carpi')
     # TODO: figure out why this doesn't show up on the screen until after the os.walk has completed
     l = OutlineLabel(text='Removing old files from carpi',
                      size_hint=(None, None),
                      font_size='12sp',
                      halign='left')
     l.bind(texture_size=l.setter('size'))
     layout.add_widget(l)
     sv.scroll_to(l)
     # this whole block walks the filesystem and deletes any file that is not in the rsync file
     # the sync operation is split up into a delete and a copy because that was the only way I could get
     # rsync to work correctly, it was always copying/deleting the wrong things otherwise
     for dirpath, dirnames, filenames in os.walk(
             Helpers.decodeFileName(basepath)):
         if len(filenames) > 0:
             rpath = dirpath[len(basepath + os.sep):]
             for filename in filenames:
                 fpath = os.path.join(Helpers.decodeFileName(rpath),
                                      Helpers.decodeFileName(filename))
                 apath = os.path.join(Helpers.decodeFileName(dirpath),
                                      Helpers.decodeFileName(filename))
                 if fpath not in filelist:
                     Logger.debug("Filesync: Deleting " + apath)
                     os.remove(Helpers.decodeFileName(apath))
     # TODO: somehow do this all in python instead of shell script, it's ugly
     # also, if the host somehow has tmppath mounted with the no-execute bit set, this will fail
     with open(os.path.join(self.config.get('paths', 'tmppath'), 'sync.sh'),
               'w') as sfile:
         sfile.write("#!/bin/bash\n")
         # delete all empty directories
         sfile.write('find "' + basepath +
                     '" -type d -empty -delete 2>/dev/null\n')
         # copy/update only the files that exist in the rsync file
         sfile.write('rsync -vruxhm --files-from="' + tpath + '" ' +
                     synchost + ':"' + syncbasepath + '"/ "' + basepath +
                     '"\n')
         # copy the car sticker database to the synchost
         sfile.write('scp /var/lib/mpd/sticker.sql ' + synchost + ':' +
                     self.config.get('sync', 'synctmppath') + '\n')
         # build a secondary shell script to perform the sticker update on the synchost
         with open(
                 os.path.join(self.config.get('paths', 'tmppath'), 'scmd'),
                 'w') as f:
             # attach the copied database and merge sticker data from it to update ratings user has added in the car
             # not using os.path.join here since who knows what os the synchost uses...use linux
             f.write("attach database \"" +
                     self.config.get('sync', 'synctmppath') +
                     "/sticker.sql\" as carpi;\n")
             f.write("replace into sticker select * from carpi.sticker;\n")
             f.write(
                 "replace into carpi.sticker select * from sticker where name='rating';\n"
             )
             f.write(".quit\n")
         # copy secondary script to synchost and run it
         sfile.write(
             'scp ' +
             os.path.join(self.config.get('paths', 'tmppath'), 'scmd') +
             ' ' + synchost + ':' + self.config.get('sync', 'synctmppath') +
             '\n')
         # not using os.path.join here since who knows what os the synchost uses...use linux
         sfile.write('ssh -t ' + synchost +
                     ' sudo sqlite3 /var/lib/mpd/sticker.sql < ' +
                     self.config.get('sync', 'synctmppath') + '/scmd\n')
         # copy the now updated sticker database back from the synchost
         # not using os.path.join here since who knows what os the synchost uses...use linux
         sfile.write('scp ' + synchost + ':' +
                     self.config.get('sync', 'synctmppath') +
                     '/sticker.sql ' + self.config.get('paths', 'tmppath') +
                     '\n')
         # build a secondary shell script to perform the sticker update on the host
         with open(
                 os.path.join(self.config.get('paths', 'tmppath'), 'scmd'),
                 'w') as f:
             # attach the copied database and merge sticker data from it to update ratings user has added at home
             f.write("attach database \"" + os.path.join(
                 self.config.get('paths', 'tmppath'), "sticker.sql") +
                     "\" as carpi;\n")
             f.write("replace into sticker select * from carpi.sticker;\n")
             f.write(".quit\n")
         # run the secondary script
         sfile.write(
             'cat ' +
             os.path.join(self.config.get('paths', 'tmppath'), 'scmd') +
             ' | sudo sqlite3 /var/lib/mpd/sticker.sql\n')
         # rsync over all the fanart
         sfile.write('rsync -vruxhm ' + synchost + ':"' + syncfanartpath +
                     '"/ "' + fanartpath + '"\n')
         # tell mpd about any changes
         sfile.write("mpc update\n")
     # make the shell script executable
     os.chmod(
         os.path.join(self.config.get('paths', 'tmppath'), 'sync.sh'),
         os.stat(
             os.path.join(self.config.get('paths', 'tmppath'),
                          'sync.sh')).st_mode | 0111)
     # queue for holding stdout
     q = Queue()
     # create a subprocess for the shell script and capture stdout
     p = Popen(
         [os.path.join(self.config.get('paths', 'tmppath'), 'sync.sh')],
         stdout=PIPE,
         bufsize=1,
         close_fds=True)
     # check the stdout queue every .1 seconds and write lines to the scrollview if there is output
     event = Clock.schedule_interval(
         partial(self.write_queue_line, q, layout, sv), 0.1)
     # run all this crap in a separate thread to be non-blocking
     t = Thread(target=self.enqueue_output,
                args=(p.stdout, q, event, popup, tpath, synchost, layout,
                      sv))
     t.daemon = True
     t.start()
Esempio n. 26
0
    def show_property(self, instance, value, key=None, index=-1, *l):
        # normal call: (tree node, focus, )
        # nested call: (widget, prop value, prop key, index in dict/list)
        if value is False:
            return

        content = None
        if key is None:
            # normal call
            nested = False
            widget = instance.widget
            key = instance.key
            prop = widget.property(key)
            value = getattr(widget, key)
        else:
            # nested call, we might edit subvalue
            nested = True
            widget = instance
            prop = None

        dtype = None

        if isinstance(prop, AliasProperty) or nested:
            # trying to resolve type dynamicly
            if type(value) in (str, str):
                dtype = 'string'
            elif type(value) in (int, float):
                dtype = 'numeric'
            elif type(value) in (tuple, list):
                dtype = 'list'

        if isinstance(prop, NumericProperty) or dtype == 'numeric':
            content = TextInput(text=str(value) or '', multiline=False)
            content.bind(
                text=partial(self.save_property_numeric, widget, key, index))
        elif isinstance(prop, StringProperty) or dtype == 'string':
            content = TextInput(text=value or '', multiline=True)
            content.bind(
                text=partial(self.save_property_text, widget, key, index))
        elif (isinstance(prop, ListProperty)
              or isinstance(prop, ReferenceListProperty)
              or isinstance(prop, VariableListProperty) or dtype == 'list'):
            content = GridLayout(cols=1, size_hint_y=None)
            content.bind(minimum_height=content.setter('height'))
            for i, item in enumerate(value):
                button = Button(text=repr(item), size_hint_y=None, height=44)
                if isinstance(item, Widget):
                    button.bind(
                        on_release=partial(self.highlight_widget, item, False))
                else:
                    button.bind(on_release=partial(self.show_property, widget,
                                                   item, key, i))
                content.add_widget(button)
        elif isinstance(prop, OptionProperty):
            content = GridLayout(cols=1, size_hint_y=None)
            content.bind(minimum_height=content.setter('height'))
            for option in prop.options:
                button = ToggleButton(
                    text=option,
                    state='down' if option == value else 'normal',
                    group=repr(content.uid),
                    size_hint_y=None,
                    height=44)
                button.bind(
                    on_press=partial(self.save_property_option, widget, key))
                content.add_widget(button)
        elif isinstance(prop, ObjectProperty):
            if isinstance(value, Widget):
                content = Button(text=repr(value))
                content.bind(on_release=partial(self.highlight_widget, value))
            elif isinstance(value, Texture):
                content = Image(texture=value)
            else:
                content = Label(text=repr(value))

        elif isinstance(prop, BooleanProperty):
            state = 'down' if value else 'normal'
            content = ToggleButton(text=key, state=state)
            content.bind(on_release=partial(self.save_property_boolean, widget,
                                            key, index))

        self.content.clear_widgets()
        if content:
            self.content.add_widget(content)
Esempio n. 27
0
    def getcheckboxes_active(self, *arg):
        username = "******"
        password = "******"  # Here enter your API password
        authServiceUrl = "https://sandbox-authservice.priaid.ch"  # Be aware that sandbox link is for testing pourpose (not real data) once you get live access you shold use https://authservice.priaid.ch/login
        healthServiceUrl = "https://sandbox-healthservice.priaid.ch"  # Be aware that sandbox link is for testing pourpose (not real data) once you get live access you shold use https://healthservice.priaid.ch
        language = "en-gb"
        gender = "male"
        yearOfBirth = "1996"
        '''how to get the active state of all checkboxed created in def show'''
        # Iterate over the dictionary storing the CheckBox widgets
        selected_symptoms = []
        for idx, wgt in self.check_ref.items():
            #print(wgt.active)
            if wgt.active == True:
                #print(idx)
                selected_symptoms.append(idx)
        #print(selected_symptoms)

        selectedSymptoms = []
        if self.connection_check():
            for person in self.loadsymptoms:
                #print(person)
                for k, v in person.items():
                    #print('{}: {}'.format(k, v))
                    #print(v)
                    if v in selected_symptoms:
                        selectedSymptoms.append(person['ID'])
        else:
            return self.connection_popup()

        #print(selectedSymptoms)

        load = DiagnosisClient(username, password, authServiceUrl,
                               healthServiceUrl, language)
        self.diagnose = load.loadDiagnosis(selectedSymptoms, Gender.Male, 1996)

        #print(self.diagnose)

        self.diagnose_list = []
        for person in self.diagnose:
            #print(person)
            for k, v in person.items():
                #print(person['Issue']['Name'])

                self.diagnose_list.append(person['Issue']['Name'])

        #print(diagnose_list)

        layout = GridLayout(cols=1,
                            padding=10,
                            size_hint_y=None,
                            row_force_default=True,
                            row_default_height='30dp')
        layout.bind(minimum_height=layout.setter("height"))
        for each in range(len(self.diagnose_list)):

            layout3 = BoxLayout(padding=[0, 0, 30, 0],
                                orientation="horizontal")
            label1 = Button(color=(0, 0, 0, 1),
                            font_size=15,
                            background_normal="",
                            background_color=(1, 1, 1, 1),
                            text=self.diagnose_list[each],
                            halign='left',
                            markup=True)
            chckbox = CheckBox(color=(0, 0, 0, 1))
            #chckbox.bind(active=self.getcheckboxes_active)

            # Stores a reference to the CheckBox instance
            #self.check_ref[chckbox] = prods[each]
            self.check_ref[str(self.diagnose_list[each])] = chckbox

            layout3.add_widget(chckbox)
            layout3.add_widget(label1)
            layout.add_widget(layout3)

        if len(self.diagnose_list) > 0:
            self.diagnosis_box.clear_widgets()
            self.diagnosis_box.add_widget(layout)
        else:
            #print('empty')

            self.diagnosis_box.clear_widgets()
            self.diagnosis_box.add_widget(
                Label(
                    text='No diagnosis found!',
                    color=(0, 0, 0, 1),
                ))
Esempio n. 28
0
class SkillsScreen(Screen):
    root_obj = ObjectProperty()
    app_obj = ObjectProperty()
    selected_student = ObjectProperty()
    selected_skill = ObjectProperty()
    student_review = ObjectProperty(GridLayout())
    confirm_popup = ObjectProperty()

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.bind(selected_student=self.display_stud_skills)
        self.bind(selected_skill=self.display_stud_skills)

    def open_student_popup(self):
        args = {
            'item': self.selected_student,
            'item_list': self.root_obj.active_students,
            'attribute': 'surname',
            'callback': self.select_student,
            'title': 'Choisissez un élève',
            'size_hint_y': 1
        }
        return self.root_obj.open_choice_popup(**args)

    def _on_answer(self, func, instance, answer):
        self.confirm_popup.dismiss()
        if answer == 'yes':
            return func()
        else:
            return

    def select_student(self, student):
        self.student_name.text = "{} {}".format(student.surname, student.name)
        self.selected_student = student

    def select_skill(self, skill):
        self.skill_name.text = skill.title
        self.skill_summary.text = skill.summary
        self.selected_skill = skill

    def open_skills_popup(self):
        args = {
            'item': self.selected_skill,
            'item_list': self.root_obj.active_skills,
            'attribute': 'title',
            'callback': self.select_skill,
            'title': 'Choisissez une compétence',
            'size_hint_y': 0.4
        }
        return self.root_obj.open_choice_popup(**args)

    def pre_set_student_skill(self, value):
        try:
            skill = self.selected_skill.title
            student = self.selected_student
            content = ConfirmPopup(
                text="Confirmez la note:\n\n{} {}\n\n"
                "{} {}".format(skill, value, student.surname, student.name))
            func = partial(self.set_student_skill, value)
            __on_answer = partial(self._on_answer, func)
            content.bind(on_answer=__on_answer)
            self.confirm_popup = Popup(title="Confirmation",
                                       content=content,
                                       size_hint_y=.4,
                                       auto_dismiss=False)
            self.confirm_popup.open()
        except AttributeError:
            pass

    def set_student_skill(self, value):
        student = self.selected_student.id_
        output = self.app_obj.data_output
        skill = self.selected_skill.title
        try:
            length = len(output[student][skill])
            output[student][skill][length] = value
        except KeyError:
            try:
                output[student][skill] = {0: value}
            except KeyError:
                output[student] = self.students_data[student]
                output[student][skill] = {0: value}
        output._is_changed = True
        output.store_sync()

    def display_stud_skills(self, *ignore):
        try:
            assert self.selected_student and self.selected_skill
            self.student_review.add_widget(Label(text='caca', size_hint_y=.8))
        except AssertionError:
            pass
from kivy.uix.gridlayout import GridLayout
from kivy.uix.button import Button
from kivy.uix.scrollview import ScrollView
from kivy.core.window import Window
from kivy.app import runTouchApp

layout = GridLayout(cols=1, spacing=10, size_hint_y=None)
# Make sure the height is such that there is something to scroll.
layout.bind(minimum_height=layout.setter('height'))
for i in range(10):
    btn = Button(text=str(i), size_hint_y=None, height=40)
    layout.add_widget(btn)
    
    
    boxlayout = 
root = ScrollView(size_hint=(1, None), size=(Window.width, Window.height))
root.add_widget(layout)

runTouchApp(root)
Esempio n. 30
0
    def build(self):
        self._cap = cv2.VideoCapture(video_file)

        # define botton
        kvButtonPlay = Button(text="play", size_hint=(1.0, 0.1))
        kvButtonPlay.bind(on_press=self.buttonCallbackPlay)

        kvButtonStop = Button(text="stop", size_hint=(1.0, 0.1))
        kvButtonStop.bind(on_press=self.buttonCallbackStop)

        # define image
        self.kvImage_raw = Image()
        self.kvImage_pros = Image()

        # define video layout and add image
        #VideoLayout = BoxLayout(orientation='vertical')
        VideoLayout = GridLayout(cols=2)
        VideoLayout.add_widget(self.kvImage_raw)
        VideoLayout.add_widget(self.kvImage_pros)

        # BoxLayout
        #kvLayout2 = BoxLayout(orientation='horizontal', size_hint=(1.0, 0.2))
        #self.kvSlider1Label = Label(text = 'Slider', size_hint=(0.2, 1.0), halign='center')
        #kvSlider1 = Slider(size_hint=(0.7, 1.0))
        #kvSlider1.bind(value=self.slideCallback)
        #kvLayout1.add_widget(kvLayout2)
        #kvLayout2.add_widget(self.kvSlider1Label)
        #kvLayout2.add_widget(kvSlider1)

        # add buttons to layout
        ButtonLayout = BoxLayout(orientation='vertical', size_hint=(1.0, 0.2))
        #ButtonLayoutStop = BoxLayout(orientation='vertical', size_hint=(1.0, 0.1))
        VideoLayout.add_widget(ButtonLayout)
        ButtonLayout.add_widget(kvButtonPlay)
        ButtonLayout.add_widget(kvButtonStop)

        # add text
        self.second_label = Label(text='second: ' + str(self.seconds),
                                  halign='left',
                                  color=(1, 0, 1, 1))
        self.sound_label = Label(text='sound: ' + 'background music',
                                 halign='left',
                                 color=(1, 1, 1, 1))
        self.place_label = Label(text='place: ' + 'caffe',
                                 halign='left',
                                 color=(1, 1, 1, 1))
        #self.text = StringProperty(text='hello')
        LabelLayout = BoxLayout(orientation='vertical', size_hint=(1.0, 1.0))
        VideoLayout.add_widget(LabelLayout)
        LabelLayout.add_widget(self.second_label)
        LabelLayout.add_widget(self.sound_label)
        LabelLayout.add_widget(self.place_label)
        #LabelLayout.add_widget(self.text)

        # wait for opencv video capture
        while not self._cap.isOpened():
            pass
        Clock.schedule_interval(self.update, 1.0 / 30.0)

        self.flag = False

        return VideoLayout