コード例 #1
0
    def __init__(self, **kwargs):
        super(CreateNew, self).__init__(**kwargs)
        self.name = 'createnew'
        self.key = 0
        self.stack = StackLayout(cols = 1,
                                 spacing=0,)

        #ActionBar
        self.actionbar = ActionBar(pos_hint={'top':1},
                                   background_color = (0.50,0.50,0.50,1),
                                   height = Window.height*.06,
                                   width = Window.width)
        self.actionview = ActionView()
        self.actionbar.add_widget(self.actionview)
        self.actionprevious = ActionPrevious(with_previous=True,
                                        app_icon = 'mylogo.png',
                                        previous_image = 'arrow.png',
                                        title = '')
        self.actionview.add_widget(self.actionprevious)

        self._savebutton = SaveButton()
        self.savebutton = self._savebutton.button
        self.actionview.add_widget(self._savebutton)
        self.stack.add_widget(self.actionbar)
        self.scroll = Text()
        self.txt = self.scroll.children[0]
        # self.txt = TextInput(size_hint=(1, .92),
        #                  pos_hint={'center_x': .5,'center_y': .46},
        #                      font_size = '35sp')
        self.stack.add_widget(self.scroll)

        self.dropdown = drop()
        self.actionview.add_widget(self.dropdown._main, -1)
        self.add_widget(self.stack)
コード例 #2
0
    def __init__(self, **kwargs):
        super(NoteScreen, self).__init__(**kwargs)
        self.name = 'notescreen'
        self.box = StackLayout(
            cols=1,
            spacing=0,
        )

        #Actionbar
        self.actionbar = ActionBar(pos_hint={'top': 1},
                                   background_color=(0.50, 0.50, 0.50, 1),
                                   height=Window.height * .06,
                                   width=Window.width)
        self.actionview = ActionView()
        self.actionbar.add_widget(self.actionview)
        self.actionprevious = ActionPrevious(with_previous=True,
                                             app_icon='mylogo.png',
                                             previous_image='arrow.png',
                                             title='')
        self._update_button = UpdateButton()
        self.update_button = self._update_button.button
        self._delete_button = DeleteButton()
        self.delete_button = self._delete_button.button
        self.actionview.add_widget(self._update_button)
        self.actionview.add_widget(self._delete_button)
        self.actionview.add_widget(self.actionprevious)
        self.scroll = Text2()
        self.txt = self.scroll.children[0]

        self.box.add_widget(self.actionbar)
        self.box.add_widget(self.scroll)

        self.add_widget(self.box)
        self.dropdown = drop()
        self.actionview.add_widget(self.dropdown._main, -2)
コード例 #3
0
ファイル: main.py プロジェクト: gusugusu1018/junkyard
    def __init__(self):

        actionview = ActionView()
        actionview.use_separator = True
        ap = ActionPrevious(title='Action Bar', with_previous=False)
        actionview.add_widget(ap)
        self.abtn1 = ActionButton(text="Btn1")
        self.abtn1.bind(on_press=self.ActionBtn1Callback)
        actionview.add_widget(self.abtn1)
        self.abtn2 = ActionButton(text="Btn2")
        self.abtn2.bind(on_press=self.ActionBtn2Callback)
        actionview.add_widget(self.abtn2)

        self.abtn3 = ActionButton(text="Btn3", icon="images.jpg")
        self.abtn3.bind(on_press=self.ActionBtn3Callback)
        actionview.add_widget(self.abtn3)

        group1 = ActionGroup()

        self.abtn4 = ActionButton(text="Btn4")
        self.abtn4.bind(on_press=self.ActionBtn4Callback)
        group1.add_widget(self.abtn4)

        self.abtn5 = ActionButton(text="Press Me!!!!")
        self.abtn5.bind(on_press=self.ActionBtn5Callback)
        group1.add_widget(self.abtn5)

        actionview.add_widget(group1)

        self.actionbar = ActionBar()
        self.actionbar.add_widget(actionview)
コード例 #4
0
ファイル: backend_kivy.py プロジェクト: svirvel/matplotlib
    def __init__(self, canvas, **kwargs):
        self.actionbar = ActionBar(pos_hint={'top': 1.0})
        super(NavigationToolbar2Kivy, self).__init__(canvas)
        self.rubberband_color = (1.0, 0.0, 0.0, 1.0)
        self.lastrect = None
        self.save_dialog = Builder.load_string(textwrap.dedent('''\
            <SaveDialog>:
                text_input: text_input
                BoxLayout:
                    size: root.size
                    pos: root.pos
                    orientation: "vertical"
                    FileChooserListView:
                        id: filechooser
                        on_selection: text_input.text = self.selection and\
                        self.selection[0] or ''

                    TextInput:
                        id: text_input
                        size_hint_y: None
                        height: 30
                        multiline: False

                    BoxLayout:
                        size_hint_y: None
                        height: 30
                        Button:
                            text: "Cancel"
                            on_release: root.cancel()

                        Button:
                            text: "Save"
                            on_release: root.save(filechooser.path,\
                            text_input.text)
            '''))
コード例 #5
0
ファイル: main-2.py プロジェクト: stdgn/kivy-tr
    def build(self):

        eylemcubugu = ActionBar(pos_hint={'top': 1})

        eylemgorunumu = ActionView()
        eylemcubugu.add_widget(eylemgorunumu)

        #oncekieylem=ActionPrevious(title='Eylem Çubuğu', app_icon='document-edit.png')
        #oncekieylem=ActionPrevious(title='Eylem Çubuğu', app_icon='atlas://data/images/defaulttheme/close')
        oncekieylem = ActionPrevious(title='Eylem Çubuğu',
                                     app_icon='atlas://atlasim/document-edit')
        eylemgorunumu.add_widget(oncekieylem)

        aksiyondugmesi2 = ActionButton(icon='atlas://atlasim/document-open')
        eylemgorunumu.add_widget(aksiyondugmesi2)

        aksiyondugmesi1 = ActionButton(icon='atlas://atlasim/document-save')
        eylemgorunumu.add_widget(aksiyondugmesi1)

        aksiyondugmesi4 = ActionButton(icon='atlas://atlasim/document-save-as')
        eylemgorunumu.add_widget(aksiyondugmesi4)

        aksiyondugmesi3 = ActionButton(icon='atlas://atlasim/document-new')
        eylemgorunumu.add_widget(aksiyondugmesi3)

        aksiyondugmesi5 = ActionButton(icon='atlas://atlasim/application-exit')
        eylemgorunumu.add_widget(aksiyondugmesi5)

        duzen = BoxLayout(orientation='vertical')
        duzen.add_widget(eylemcubugu)

        self.etiket = Label(text="Ana Alan")
        duzen.add_widget(self.etiket)

        return duzen
コード例 #6
0
    def constroi_titulo(self):
        font_size = self.fonte_padrao
        bar = ActionBar()
        view = ActionView()
        btn_voltar = ActionPrevious(app_icon="./imagens/icone.png")
        btn_voltar.size_hint = (.7, .7)
        btn_voltar.title = self.titulo.title()

        view.add_widget(btn_voltar)
        titulo = btn_voltar.ids["title"]
        titulo.font_name = "Roboto"
        titulo.color = [
            0.9882352941176471, 0.6901960784313725, 0.00392156862745098, 1
        ]
        titulo.font_size = font_size * 1.3

        btn_limpar = ActionButton(text="Limpar", font_size=font_size)
        #btn_limpar.on_release = self.button_limpa_db
        #print(btn_limpar.ids)

        with view.canvas:
            Color(*get_color_from_hex("#040348"))
            Rectangle(size=self.size)

        view.add_widget(btn_limpar)
        bar.add_widget(view)

        self.add_widget(bar)
        self.ids[f"historico_botao_limpar"] = btn_limpar
        self.ids[f"historico_botao_voltar"] = btn_voltar
コード例 #7
0
    def constroi_titulo(self):
        font_size = self.fonte_padrao
        bar = ActionBar()
        view = ActionView()
        btn_voltar = ActionPrevious(app_icon="./imagens/icone.png")
        btn_voltar.title = self.titulo.title()
        btn_voltar.size_hint = .8, .8

        view.add_widget(btn_voltar)
        titulo = btn_voltar.ids["title"]
        titulo.font_name = "Roboto"
        titulo.color = [
            0.9882352941176471, 0.6901960784313725, 0.00392156862745098, 1
        ]
        titulo.font_size = font_size * 1.3

        btn_ok = ActionButton(text="OK", font_size=font_size)

        view.add_widget(btn_ok)
        bar.add_widget(view)

        with view.canvas:
            Color(*get_color_from_hex("#040348"))
            Rectangle(size=(self.width * 3, self.height * 3))

        self.add_widget(bar)
        self.ids[f"{self.nome_tela}_botao_ok"] = btn_ok
        self.ids[f"{self.nome_tela}_botao_voltar"] = btn_voltar
コード例 #8
0
    def _set_menubar2(self, parent_widget):
        menu = ActionBar()
        parent_widget.add_widget(menu)
        self.menu = menu

        previous_button = ActionButton(text="Previous")
        action_view = ActionView(action_previous=previous_button)
        menu.add_widget(action_view)
        add_buttons = ActionDropDown()
        action_view.add_widget(add_buttons)

        self._set_add_buttons(add_buttons)
コード例 #9
0
class GraphView(BoxLayout):
    def __init__(self, **kwargs):
        super(GraphView, self).__init__(orientation='vertical')
        self.label = Label(text="Please slide the slider")
        self.add_widget(self.label)
        self.slider = Slider(min=-2, max=2, value=1)
        self.slider.bind(value=self.SliderCallback)
        self.add_widget(self.slider)
        self.add_widget(self.graph_plot_sample(self.slider.value))
        actionview = ActionView()
        actionview.use_separator = True
        ap = ActionPrevious(title='Dawot', with_previous=False)
        actionview.add_widget(ap)
        self.abtn1 = ActionButton(text="File")
        self.abtn1.bind(on_press=self.ActionBtn1Callback)
        actionview.add_widget(self.abtn1)
        self.abtn2 = ActionButton(text="Plot")
        self.abtn2.bind(on_press=self.ActionBtn2Callback)
        actionview.add_widget(self.abtn2)
        self.actionbar = ActionBar()
        self.actionbar.add_widget(actionview)
        self.add_widget(self.actionbar)

    def SliderCallback(self, instance, value):
        self.label.text = str(value)

    def ActionBtn1Callback(self, instance):
        root = tkinter.Tk()
        root.withdraw()
        fTyp = [("", "*")]
        iDir = os.path.abspath(os.path.dirname(__file__))
        file = tkinter.filedialog.askopenfilename(filetypes=fTyp,
                                                  initialdir=iDir)
        tkinter.messagebox.showinfo('Input file', file)

    def ActionBtn2Callback(self, instance):
        self.graph_plot_sample(self.slider.value)

    def graph_plot_sample(self, value):
        fig, ax = pl.subplots()
        x = np.linspace(-np.pi, np.pi)
        print(type(value))
        print(value)
        y = np.sin(x * float(value))
        #y = np.sin(x*2.0)
        ax.set_xlabel("X label")
        ax.set_ylabel("Y label")
        ax.grid(True)
        ax.plot(x, y)
        pl.draw()
        fig.canvas.draw()
        return fig.canvas
コード例 #10
0
ファイル: tela_calculos.py プロジェクト: Danilodcn/AppFazenda
    def gera_titulo(self):
        bar = ActionBar()
        view = ActionView()

        bnt_back = ActionPrevious(app_icon="./imagens/icone.png")
        bnt_back.size_hint = (.9, .9)
        bnt_back.title = "Cálculos"

        view.add_widget(bnt_back)
        bar.add_widget(view)

        self.add_widget(bar)
        self.ids["calculos_botao_voltar"] = bnt_back
コード例 #11
0
    def __init__(self, **kwargs):
        super(Notes, self).__init__(**kwargs)
        self.name = 'notes'
        self.stackcon = StackLayout(cols = 1,
                                    spacing=0,)

        #Actionbar
        self.actionbar = ActionBar(background_color = (0.50,0.50,0.50,1),
                                   pos_hint={'top':1},
                                   height = Window.height*.06,
                                   width = Window.width)

        self.actionview = ActionView()
        self.actionprevious = ActionPrevious(with_previous=False,
                                        app_icon = 'icon.png',
                                        previous_image = '',
                                        title = '')


        self._addnotebutton = AddNew()
        self.addnotebutton = self._addnotebutton.button
        self.stack = GridLayout(cols = 1,
                               spacing=0,
                               size_hint_y=None)

        self.scroll = ScrollView(size_hint=(1, None),
                                 size=(Window.width, Window.height-50))

        self.txt = Txt(text = '')

        self.close_button = CloseButton()
        self._search = SearchButton()
        self.search_button = self._search.button


        self.stack.bind(minimum_height=self.stack.setter('height'))


        self.actionbar.add_widget(self.actionview)
        self.actionview.add_widget(self.actionprevious)
        self.actionview.add_widget(self.txt)
        self.actionview.add_widget(self._search)
        self.actionview.add_widget(self._addnotebutton)

        self.stackcon.add_widget(self.actionbar)
        self.scroll.add_widget(self.stack)
        self.stackcon.add_widget(self.scroll)
        self.add_widget(self.stackcon)

        self.search_button.bind(on_release = self.hidetextbar)
        self.close_button.bind(on_release = self.showtextbar)
コード例 #12
0
class RootWidget(BoxLayout):
    def __init__(self, **kwargs):
        super().__init__(**kwargs, orientation='vertical')
        self.legacy = Legacy()
        self.actionbar = ActionBar(pos_hint={'top': 1})
        self.av = av = ActionView()
        av.add_widget(ActionPrevious(title='', with_previous=False))
        av.add_widget(ActionOverflow())
        backbutton = ActionButton(text='Back')
        av.add_widget(backbutton)
        backbutton.bind(on_press=(self.back))
        self.nextbutton = ActionButton(text='Next')
        av.add_widget(self.nextbutton)
        self.nextbutton.bind(on_press=(self.nextbtn))
        self.last_widget = self.monitor = Title(self)

        self.actionbar.add_widget(av)

        # can't be set in F.ActionView() -- seems like a bug
        av.use_separator = True
        self.add_widget(self.actionbar)
        self.add_widget(self.monitor)
        self.av = av


    def next_visible(self, visible=True):
        try:
            if visible:
                self.av.add_widget(self.nextbutton)
            else:
                self.av.remove_widget(self.nextbutton)
        except WidgetException:
            pass

    def back(self, _):
        self.next_visible(True)
        self.remove_widget(self.monitor)
        self.monitor = self.last_widget
        self.add_widget(self.monitor)

    def nextbtn(self, _):
        self.last_widget = self.monitor
        self.remove_widget(self.monitor)
        self.monitor = self.monitor.next()
        self.add_widget(self.monitor)

    def callnext(self, next):
        self.last_widget = self.monitor
        self.remove_widget(self.monitor)
        self.monitor = next
        self.add_widget(self.monitor)
コード例 #13
0
ファイル: main.py プロジェクト: AtsushiSakai/kivy_samples
class MyActionBar():
    def __init__(self):

        actionview = ActionView()
        actionview.use_separator=True
        ap = ActionPrevious(title='Action Bar', with_previous=False) 
        actionview.add_widget(ap) 
        self.abtn1=ActionButton(text="Btn1")
        self.abtn1.bind(on_press=self.ActionBtn1Callback)
        actionview.add_widget(self.abtn1) 
        self.abtn2=ActionButton(text="Btn2")
        self.abtn2.bind(on_press=self.ActionBtn2Callback)
        actionview.add_widget(self.abtn2) 

        self.abtn3=ActionButton(text="Btn3",icon="images.jpg")
        self.abtn3.bind(on_press=self.ActionBtn3Callback)
        actionview.add_widget(self.abtn3) 

        group1=ActionGroup()

        self.abtn4=ActionButton(text="Btn4")
        self.abtn4.bind(on_press=self.ActionBtn4Callback)
        group1.add_widget(self.abtn4)

        self.abtn5=ActionButton(text="Press Me!!!!")
        self.abtn5.bind(on_press=self.ActionBtn5Callback)
        group1.add_widget(self.abtn5)



        actionview.add_widget(group1)

        self.actionbar=ActionBar()
        self.actionbar.add_widget(actionview)


    def ActionBtn1Callback(self,instance):
        print("Btn1 press!!")

    def ActionBtn2Callback(self,instance):
        print("Btn2 press!!")

    def ActionBtn3Callback(self,instance):
        print("Btn3 press!!")

    def ActionBtn4Callback(self,instance):
        print("Btn4 press!!")

    def ActionBtn5Callback(self,instance):
        print("Btn5 press!!")
コード例 #14
0
    def __init__(self, **kwargs):
        super(BattleScreen, self).__init__(**kwargs)

        self.bScene = BattleScene()
        self.layout = BoxLayout(orientation='vertical')
        self.actionBar = ActionBar()
        self.view = ActionView()
        self.prompt = self.bScene.getTurn()
        self.nametag = ActionPrevious(title=self.prompt)
        self.MoveButton = ActionButton(text='Move')
        self.AttackButton = ActionButton(text='Attack')
        self.AbilityButton = ActionButton(text='Item')
        self.ConfirmButton = ActionButton(text='Take Turn')
        self.MoveButton.bind(on_press=self.Move)
        self.AttackButton.bind(on_press=self.Action)
        self.AbilityButton.bind(on_press=self.Ability)
        self.ConfirmButton.bind(on_press=self.TakeTurn)
        self.battleLog = 'Now Beginning Battle...'
        self.label = ScrollableLabel(text=self.battleLog)
        self.layout.add_widget(self.actionBar)
        self.layout.add_widget(self.label)
        self.actionBar.add_widget(self.view)
        self.view.add_widget(self.nametag)
        self.view.add_widget(self.MoveButton)
        self.view.add_widget(self.AttackButton)
        self.view.add_widget(self.AbilityButton)
        self.view.add_widget(self.ConfirmButton)
        self.add_widget(self.layout)
        self.Target = Combatants.get(0)
        Combatants.checkItems(0)
        if Combatants.getHasItems(0) == False:
            self.AbilityButton.disabled = True
コード例 #15
0
    def __init__(self, canvas, **kwargs):
        self.actionbar = ActionBar(pos_hint={'top': 1.0})
        super(NavigationToolbar2Kivy, self).__init__(canvas)
        self.rubberband_color = (1.0, 0.0, 0.0, 1.0)
        self.lastrect = None
        self.save_dialog = Builder.load_string(textwrap.dedent('''\
            <SaveDialog>:
                text_input: text_input
                BoxLayout:
                    size: root.size
                    pos: root.pos
                    orientation: "vertical"
                    FileChooserListView:
                        id: filechooser
                        on_selection: text_input.text = self.selection and\
                        self.selection[0] or ''

                    TextInput:
                        id: text_input
                        size_hint_y: None
                        height: 30
                        multiline: False

                    BoxLayout:
                        size_hint_y: None
                        height: 30
                        Button:
                            text: "Cancel"
                            on_release: root.cancel()

                        Button:
                            text: "Save"
                            on_release: root.save(filechooser.path,\
                            text_input.text)
            '''))
コード例 #16
0
ファイル: main.py プロジェクト: DoughxD/DIstanciaRaio_Kivy
    def build(self, *args):
        self.icon = 'icon.png'

        self.permissao = False
        self.cont = 0
        self.gerenciador = ScreenManager()
        self.tela = Screen(name='tela')
        self.tela2 = Screen(name='tela2')
        self.help = Screen(name='help')

        #adiciona ao ScreenManager as telas
        self.gerenciador.add_widget(self.tela)
        self.gerenciador.add_widget(self.tela2)
        self.gerenciador.add_widget(self.help)

        #Cria e adiciona o ActionBar
        self.actionbox = BoxLayout(orientation='vertical')
        self.actionbar = ActionBar()
        self.actionbox.add_widget(self.actionbar)
        self.tela.add_widget(self.actionbox)

        #Cria o resto da BoxLayout Principal
        self.box = BoxLayout(orientation='vertical',
                             padding='100sp',
                             spacing='60sp')
        self.texto = Label(text='0', font_size='60')
        self.botao = Botao(text='iniciar', font_size='60')
        self.box.add_widget(self.texto)
        self.box.add_widget(self.botao)
        self.tela.add_widget(self.box)

        self.botao.bind(on_release=self.inicia)

        return self.gerenciador
コード例 #17
0
    def build(self):
    
        eylemcubugu= ActionBar(pos_hint= {'top':1})

        eylemgorunumu=ActionView()
        eylemcubugu.add_widget(eylemgorunumu)

        oncekieylem=ActionPrevious(title='Eylem Çubuğu')
        eylemgorunumu.add_widget(oncekieylem)
        
        duzen = BoxLayout(orientation='vertical')
        duzen.add_widget(eylemcubugu)

        self.etiket=Label(text="Ana Alan")
        duzen.add_widget(self.etiket)
        
        return duzen
コード例 #18
0
 def menu(self):
     action_previous = ActionPrevious(title='Taxi price',
                                      app_icon='image/taxi_logo_16.png',
                                      on_press=self.back,
                                      with_previous=self.with_previous)
     ag = ActionGroup(text='Menu', mode='spinner')
     for i in [('Рассчитать', self.countresult), ('Инфо', self.info),
               ('На главную', self.back), ('Выход', self.quit)]:
         bt = ActionButton(text=i[0])
         bt.bind(on_press=i[1])
         ag.add_widget(bt)
     aw = ActionView()
     aw.add_widget(ag)
     aw.add_widget(action_previous)
     menu = ActionBar()
     menu.add_widget(aw)
     self.add_widget(menu)
コード例 #19
0
    def build(self):

        layout = GridLayout(cols=4,
                            spacing=30,
                            padding=30,
                            row_default_height=150)
        ser_ports = serial_ports()

        self.label = Label(text=label_text)
        with layout.canvas.before:
            Color(.2, .2, .2, 1)
            self.rect = Rectangle(size=(1023, 840), pos=layout.pos)
        wimg = Image(source='logo.png')
        rSlider = Slider(orientation='vertical', min=0, max=255, value=r)
        gSlider = Slider(orientation='vertical', min=0, max=255, value=g)
        bSlider = Slider(orientation='vertical', min=0, max=255, value=b)
        btn = Button(text="Exit", size_hint_y=None, height=100)
        actionBar = ActionBar(size_hint_x=None, width=150)
        actionView = ActionView(
            action_previous=ActionPrevious(with_previous=False, ))
        actionBar.add_widget(actionView)
        for port in ser_ports:
            actionView.add_widget(
                ActionButton(text=port,
                             size_hint=(None, 1),
                             width=50,
                             on_release=self.call_back))

        btn.bind(on_press=self.exitApp)
        rSlider.bind(on_touch_move=self.update_r)
        gSlider.bind(on_touch_move=self.update_g)
        bSlider.bind(on_touch_move=self.update_b)

        layout.add_widget(wimg)
        layout.add_widget(rSlider)
        layout.add_widget(gSlider)
        layout.add_widget(bSlider)
        layout.add_widget(actionBar)
        layout.add_widget(btn)
        layout.add_widget(self.label)

        return layout
コード例 #20
0
    def build(self):
        global MainSelectionTitle, GRID, BACKUP_GRID

        maze = self
        root = GridLayout(cols=1, rows=2, spacing=[1,
                                                   1])  # Root layout for app.
        actionbar = ActionBar(pos_hint={'top': 0})  # ActionBar for menu
        actionview = ActionView()

        ap2 = ActionPrevious(title='A*',
                             with_previous=False,
                             app_icon="icon_transparent.ico")
        actionview.add_widget(MainSelectionTitle)
        actionview.add_widget(ap2)

        start = ActionButton(text='Start', on_press=maze.Start)
        end = ActionButton(text='End', on_press=maze.End)
        search = ActionButton(text='Search', on_press=maze.Search)
        res = ActionButton(text='Restart', on_press=maze.Restart)

        actionview.add_widget(start)
        actionview.add_widget(end)
        actionview.add_widget(search)
        actionview.add_widget(res)

        actionbar.add_widget(actionview)
        root.add_widget(actionbar)

        layout = GridLayout(cols=self.cols, rows=self.rows,
                            spacing=[5, 5])  # Maze layout

        # Initializing maze
        for i in range(0, self.rows):
            for j in range(0, self.cols):
                node = Node(i, j)
                layout.add_widget(node)
                GRID[i][j] = node

        root.add_widget(layout)

        return root
コード例 #21
0
ファイル: main.py プロジェクト: Gexygamma/PartyFinderApp
    def __init__(self, *args, **kwargs):

        super().__init__(*args, **kwargs)
        self.orientation = "vertical"

        # Action bar (top)
        self.actionbar = ActionBar()
        self.actionview = ActionView()
        self.actionview.action_previous = ActionPrevious(
            with_previous=False, app_icon="res/appicon.png")
        actionbtn = ActionButton(text="Perfil",
                                 icon="res/profile.png",
                                 on_release=lambda _: App.get_running_app().
                                 go_screen(Screens.Profile.value))
        self.actionview.add_widget(actionbtn)
        actionbtn = ActionButton(text="Ajustes", icon="res/settings.png")
        self.actionview.add_widget(actionbtn)
        self.actionbar.add_widget(self.actionview)

        # Navigation bar (bottom)
        self.navigationbar = BoxLayout(orientation="horizontal",
                                       size_hint_y=None,
                                       height=dp(48),
                                       padding=dp(8))
        navbtn = ImageButton(source="res/search.png")
        navbtn.on_press = lambda: App.get_running_app().go_screen(Screens.
                                                                  Search.value)
        self.navigationbar.add_widget(navbtn)
        navbtn = ImageButton(source="res/home.png")
        navbtn.on_press = lambda: App.get_running_app().go_screen(Screens.Main.
                                                                  value)
        self.navigationbar.add_widget(navbtn)
        navbtn = ImageButton(source="res/message.png")
        navbtn.on_press = lambda: App.get_running_app().go_screen(
            Screens.Message.value)
        self.navigationbar.add_widget(navbtn)

        # Screen manager
        self.screenmanager = ScreenManager()
        self._load_screen_manager()
        self.add_widget(self.screenmanager)
コード例 #22
0
ファイル: main-son.py プロジェクト: stdgn/kivy-tr
    def build(self):

        eylemcubugu = ActionBar(pos_hint={'top': 1})

        eylemgorunumu = ActionView()
        eylemcubugu.add_widget(eylemgorunumu)

        oncekieylem = ActionPrevious(title='Eylem Çubuğu')
        eylemgorunumu.add_widget(oncekieylem)

        eylemdugmesi = ActionButton(text="Eylem Düğmesi")
        eylemgorunumu.add_widget(eylemdugmesi)
        eylemdugmesi.bind(on_press=self.dugmeyeTikla)

        duzen = BoxLayout(orientation='vertical')
        duzen.add_widget(eylemcubugu)

        self.etiket = Label(text="Ana Alan")
        duzen.add_widget(self.etiket)

        return duzen
コード例 #23
0
 def __init__(self, **kwargs):
     super(GraphView, self).__init__(orientation='vertical')
     self.label = Label(text="Please slide the slider")
     self.add_widget(self.label)
     self.slider = Slider(min=-2, max=2, value=1)
     self.slider.bind(value=self.SliderCallback)
     self.add_widget(self.slider)
     self.add_widget(self.graph_plot_sample(self.slider.value))
     actionview = ActionView()
     actionview.use_separator = True
     ap = ActionPrevious(title='Dawot', with_previous=False)
     actionview.add_widget(ap)
     self.abtn1 = ActionButton(text="File")
     self.abtn1.bind(on_press=self.ActionBtn1Callback)
     actionview.add_widget(self.abtn1)
     self.abtn2 = ActionButton(text="Plot")
     self.abtn2.bind(on_press=self.ActionBtn2Callback)
     actionview.add_widget(self.abtn2)
     self.actionbar = ActionBar()
     self.actionbar.add_widget(actionview)
     self.add_widget(self.actionbar)
コード例 #24
0
ファイル: main-2.py プロジェクト: mbaser/kivy-tr
    def build(self):
    
        eylemcubugu= ActionBar(pos_hint= {'top':1})

        eylemgorunumu=ActionView()
        eylemcubugu.add_widget(eylemgorunumu)

        #oncekieylem=ActionPrevious(title='Eylem Çubuğu', app_icon='document-edit.png')
        #oncekieylem=ActionPrevious(title='Eylem Çubuğu', app_icon='atlas://data/images/defaulttheme/close')
        oncekieylem=ActionPrevious(title='Eylem Çubuğu', app_icon='atlas://atlasim/document-edit')
        eylemgorunumu.add_widget(oncekieylem)
        
        aksiyondugmesi2=ActionButton(icon='atlas://atlasim/document-open')
        eylemgorunumu.add_widget(aksiyondugmesi2)
        

        
        aksiyondugmesi1=ActionButton(icon='atlas://atlasim/document-save')
        eylemgorunumu.add_widget(aksiyondugmesi1)
        

        aksiyondugmesi4=ActionButton(icon='atlas://atlasim/document-save-as')
        eylemgorunumu.add_widget(aksiyondugmesi4)
        
        
        
        aksiyondugmesi3=ActionButton(icon='atlas://atlasim/document-new')
        eylemgorunumu.add_widget(aksiyondugmesi3)

        aksiyondugmesi5=ActionButton(icon='atlas://atlasim/application-exit')
        eylemgorunumu.add_widget(aksiyondugmesi5)

        
        duzen = BoxLayout(orientation='vertical')
        duzen.add_widget(eylemcubugu)

        self.etiket=Label(text="Ana Alan")
        duzen.add_widget(self.etiket)
        
        return duzen
コード例 #25
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs, orientation='vertical')
        self.legacy = Legacy()
        self.actionbar = ActionBar(pos_hint={'top': 1})
        self.av = av = ActionView()
        av.add_widget(ActionPrevious(title='', with_previous=False))
        av.add_widget(ActionOverflow())
        backbutton = ActionButton(text='Back')
        av.add_widget(backbutton)
        backbutton.bind(on_press=(self.back))
        self.nextbutton = ActionButton(text='Next')
        av.add_widget(self.nextbutton)
        self.nextbutton.bind(on_press=(self.nextbtn))
        self.last_widget = self.monitor = Title(self)

        self.actionbar.add_widget(av)

        # can't be set in F.ActionView() -- seems like a bug
        av.use_separator = True
        self.add_widget(self.actionbar)
        self.add_widget(self.monitor)
        self.av = av
コード例 #26
0
    def build_full_app(self):
        from mydevoirs.agenda import Agenda
        from mydevoirs.colorchooser import ColorChooser
        from mydevoirs.todo import Todo

        self.sm = ScreenManager(transition=SlideTransition(direction="up"))
        self.agenda = Agenda(name="agenda")
        self.todo = Todo(name="todo")
        self.colorchooser = ColorChooser(name="colorchooser")
        self.sm.add_widget(self.agenda)
        self.sm.add_widget(self.todo)
        self.sm.add_widget(self.colorchooser)
        self.sm.current = "agenda"

        self.box = BoxLayout(orientation="vertical")
        self.box.add_widget(ActionBar())
        self.box.add_widget(self.sm)

        return self.box
コード例 #27
0
class NavigationToolbar2Kivy(NavigationToolbar2):
    '''This class extends from matplotlib class NavigationToolbar2 and
       creates an action bar which is added to the main app to allow the
       following operations to the figures.

        Home: Resets the plot axes to the initial state.
        Left: Undo an operation performed.
        Right: Redo an operation performed.
        Pan: Allows to drag the plot.
        Zoom: Allows to define a rectangular area to zoom in.
        Configure: Loads a pop up for repositioning elements.
        Save: Loads a Save Dialog to generate an image.
    '''

    def __init__(self, canvas, **kwargs):
        self.actionbar = ActionBar(pos_hint={'top': 1.0})
        super(NavigationToolbar2Kivy, self).__init__(canvas)
        self.rubberband_color = (1.0, 0.0, 0.0, 1.0)
        self.lastrect = None
        self.save_dialog = Builder.load_string(textwrap.dedent('''\
            <SaveDialog>:
                text_input: text_input
                BoxLayout:
                    size: root.size
                    pos: root.pos
                    orientation: "vertical"
                    FileChooserListView:
                        id: filechooser
                        on_selection: text_input.text = self.selection and\
                        self.selection[0] or ''

                    TextInput:
                        id: text_input
                        size_hint_y: None
                        height: 30
                        multiline: False

                    BoxLayout:
                        size_hint_y: None
                        height: 30
                        Button:
                            text: "Cancel"
                            on_release: root.cancel()

                        Button:
                            text: "Save"
                            on_release: root.save(filechooser.path,\
                            text_input.text)
            '''))

    def _init_toolbar(self):
        '''A Toolbar is created with an ActionBar widget in which buttons are
           added with a specific behavior given by a callback. The buttons
           properties are given by matplotlib.
        '''
        basedir = os.path.join(rcParams['datapath'], 'images')
        actionview = ActionView()
        actionprevious = ActionPrevious(title="Navigation", with_previous=False)
        actionoverflow = ActionOverflow()
        actionview.add_widget(actionprevious)
        actionview.add_widget(actionoverflow)
        actionview.use_separator = True
        self.actionbar.add_widget(actionview)
        id_group = uuid.uuid4()
        for text, tooltip_text, image_file, callback in self.toolitems:
            if text is None:
                actionview.add_widget(ActionSeparator())
                continue
            fname = os.path.join(basedir, image_file + '.png')
            if text in ['Pan', 'Zoom']:
                action_button = ActionToggleButton(text=text, icon=fname,
                                                   group=id_group)
            else:
                action_button = ActionButton(text=text, icon=fname)
            action_button.bind(on_press=getattr(self, callback))
            actionview.add_widget(action_button)

    def configure_subplots(self, *largs):
        '''It will be implemented later.'''
        pass

    def dismiss_popup(self):
        self._popup.dismiss()

    def show_save(self):
        '''Displays a popup widget to perform a save operation.'''
        content = SaveDialog(save=self.save, cancel=self.dismiss_popup)
        self._popup = Popup(title="Save file", content=content,
                            size_hint=(0.9, 0.9))
        self._popup.open()

    def save(self, path, filename):
        self.canvas.export_to_png(os.path.join(path, filename))
        self.dismiss_popup()

    def save_figure(self, *args):
        self.show_save()

    def draw_rubberband(self, event, x0, y0, x1, y1):
        w = abs(x1 - x0)
        h = abs(y1 - y0)
        rect = [int(val)for val in (min(x0, x1) + self.canvas.x, min(y0, y1)
                        + self.canvas.y, w, h)]
        if self.lastrect is None:
            self.canvas.canvas.add(Color(*self.rubberband_color))
        else:
            self.canvas.canvas.remove(self.lastrect)
        self.lastrect = InstructionGroup()
        self.lastrect.add(Line(rectangle=rect, width=1.0, dash_length=5.0,
                dash_offset=5.0))
        self.lastrect.add(Color(1.0, 0.0, 0.0, 0.2))
        self.lastrect.add(Rectangle(pos=(rect[0], rect[1]),
                                    size=(rect[2], rect[3])))
        self.canvas.canvas.add(self.lastrect)

    def release_zoom(self, event):
        self.lastrect = None
        return super(NavigationToolbar2Kivy, self).release_zoom(event)
コード例 #28
0
ファイル: gui.py プロジェクト: jacky4566/ykpilot
class gui(App):

    testHDG = 10
    remotePythonPid = None

    #npTest = NumericProperty(1)

    btH = kivy.metrics.cm(1)
    lineH = kivy.metrics.cm(0.7)
    lDynamicLable = ObjectProperty(1)

    wifiTcpStatusOpts = {
        'on': "icons/ico_armG_256_256.png",
        'off': "icons/ico_armR_256_256.png"
    }
    wifiTcpStatus = StringProperty("icons/ico_manZle_256_256.png")

    def __init__(self, *a, **kw):
        super(gui, self).__init__(*a, **kw)

        if kivy.platform == 'android':
            self.sensorsRemoteTcp = "host:port"
        else:
            #self.sensorsRemoteTcp = "192.168.43.208:11223"
            #self.sensorsRemoteTcp = "192.168.43.208:11223"
            self.sensorsRemoteTcp = "192.168.49.199:11223"

        self.colorTheme = "day"
        self.isReady = False

    def doLocalIp(self):
        print("- do local ips")
        import subprocess

        r = subprocess.Popen(['ip', 'address'], stdout=subprocess.PIPE)
        so, se = r.communicate()
        self.ips = []
        l = so.split()
        print("	got elements", len(l))
        for ii, i in enumerate(l):
            i = str(i)[2:-1]
            #print("i:[",i,']')
            if len(i) > 2:
                if i[-1] == ":":
                    print("	interface: ", i)

                if str(l[ii - 1])[2:-1] == 'inet':
                    ip = i
                    ip = ip.split("/")
                    ip = ip[0]
                    print("		ip:", ip)
                    if ip == "127.0.0.1":
                        print("	skip it's local")
                    else:
                        self.ips.append(ip)

        self.rl.ids.l_phoLocIps.text = "Local ip's: {}".format(", ".join(
            self.ips))

        #sys.exit(0)

    def build(self):

        Builder.load_file('layoutMain.kv')

        Window.bind(on_key_down=self.on_key_down)
        Window.bind(on_key_up=self.on_key_up)

        self.rl = RootLayout()
        self.rl.current = 'Loader'

        self.loaderStep = 0
        Clock.schedule_once(self.loaderNextStep, 0.1)

        return self.rl

    def loaderNextStep(self, a=0, b=0):
        self.loaderStep += 1
        print("loaderNextStep step now", self.loaderStep)

        if self.loaderStep == 1:
            self.rl.ids.l_loaMaiWin.text = "DONE"
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 2:
            from TimeHelper import TimeHelper
            from FileActions import FileActions
            self.th = TimeHelper()
            self.fa = FileActions()
            self.timeAppStart = self.th.getTimestamp()
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 3:
            self.rl.ids.l_loaHel.text = "DONE"
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 4:
            bS = self.th.benStart()
            self.config = DataSR_restore('ykpilot.conf')
            if self.config == None:
                self.config = {}
            self.doLocalIp()
            self.bE = self.th.benDone(bS, "")
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 5:
            self.rl.ids.l_loaCon.text = "DONE in %s sec." % self.bE
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 6:
            bS = self.th.benStart()
            if kivy.platform == 'android':
                self.platform = 'android'
                self.animation = False
                ipSens = '192.168.43.208'
                if len(self.ips) > 0:
                    ipSens = self.ips[0]
                ip = ipSens
                self.senderIp = ip
                self.senderPort = 11223
                makeRender = True
                print("- setting up a sensor server at ", ipSens, ":",
                      self.senderPort)

                # android service
                if mkservice:
                    from android import AndroidService
                    service = AndroidService("ykpilot background",
                                             "running ....")
                    service.start("service started")
                    self.service = service
                # android service

                self.workingFolderAdress = '/storage/emulated/0/ykpilot/'
                self.virtualButtons = False

            else:
                self.platform = 'pc'
                self.animation = True
                ipSens = '192.168.49.199'
                if len(self.ips) > 0:
                    ipSens = self.ips[0]
                ip = ipSens
                self.senderIp = ip
                self.senderPort = 11225
                makeRender = True
                Clock.schedule_once(self.connectToSensorsRemoteTcp, 4)
                self.workingFolderAdress = './ykpilot/'
                self.virtualButtons = True

            self.bE = self.th.benDone(bS, "")
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 7:
            self.rl.ids.l_loaPlaChk.text = "DONE in %s sec." % self.bE
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 8:
            bS = self.th.benStart()
            self.loaderStep0()
            self.bE = self.th.benDone(bS, "")
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 9:
            self.rl.ids.l_loaRest.text = "DONE in %s sec." % self.bE
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 10:
            bS = self.th.benStart()
            from ScreenWidgets import ScreenWidgets
            self.sWidgets = ScreenWidgets(self)
            self.sWidgets.setGui()
            self.bE = self.th.benDone(bS, "")
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 11:
            self.rl.ids.l_loaSWid.text = "DONE in %s sec." % self.bE
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 12:
            bS = self.th.benStart()
            try:
                from ScreenAutopilot import ScreenAutopilot
                self.ap = ScreenAutopilot(self)
                self.sen.comCal.addCallBack(self.ap)
            except:
                print("EE - no audiostream so no ScreenAutopilot")
            self.bE = self.th.benDone(bS, "")
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 13:
            self.rl.ids.l_loaSAut.text = "DONE in %s sec." % self.bE
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 14:
            bS = self.th.benStart()
            from ScreenRace import ScreenRace
            self.sRace = ScreenRace(self)
            self.sRace.setupGui()
            self.sen.gpsD.addCallBack(self.sRace)
            self.bE = self.th.benDone(bS, "")
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 15:
            self.rl.ids.l_loaSRac.text = "DONE in %s sec." % self.bE
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 16:
            bS = self.th.benStart()
            from ScreenCompass import ScreenCompass
            self.sCompass = ScreenCompass()
            self.sCompass.setGui(self)
            self.rl.ids.blCompass.add_widget(self.sCompass)
            self.sen.gpsD.addCallBack(self.sCompass)
            self.sen.comCal.addCallBack(self.sCompass)
            self.sen.comCalAccelGyro.addCallBack(self.sCompass)
            self.bE = self.th.benDone(bS, "")
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 17:
            self.rl.ids.l_loaSCom.text = "DONE in %s sec." % self.bE
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 18:
            bS = self.th.benStart()
            from ScreenNMEAMultiplexer import ScreenNMEAMultiplexer
            self.sNMEAMul = ScreenNMEAMultiplexer()
            self.sNMEAMul.setGui(self)
            self.bE = self.th.benDone(bS, "")
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 19:
            self.rl.ids.l_loaSMul.text = "DONE in %s sec." % self.bE
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 20:
            bS = self.th.benStart()
            from boatRender import Renderer
            self.senBoat = Renderer()
            self.senBoat.setGui(self)
            self.rl.ids.blModelScreen.add_widget(self.senBoat)
            self.bE = self.th.benDone(bS, "")
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 21:
            self.rl.ids.l_loaMScr.text = "DONE in %s sec." % self.bE
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 22:
            bS = self.th.benStart()
            from simRender import simRender
            from simEngine import simEngine
            from driver1 import driver1
            from driver2 import driver2
            from driver3 import driver3
            from driver4 import driver4
            from driver5 import driver5
            from driver6 import driver6
            from driver7 import driver7
            from driver8 import driver8
            from driver9 import driver9

            self.simRen = simRender()
            self.simEng = simEngine(self, self.simRen)
            self.simRen.setSim(self.simEng)
            self.simRen.setGui(self)
            self.simEng.renderFrame()

            self.rl.ids.blSimulator.add_widget(self.simRen)

            self.driver1 = driver1(self.simEng)
            self.driver2 = driver2(self.simEng)
            self.driver3 = driver3(self.simEng)
            self.driver4 = driver4(self.simEng)
            self.driver5 = driver5(self.simEng)
            self.driver6 = driver6(self.simEng)
            self.driver7 = driver7(self.simEng)
            self.driver8 = driver8(self.simEng)
            self.driver9 = driver9(self.simEng)

            self.bE = self.th.benDone(bS, "")
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 23:
            self.rl.ids.l_loaSSim.text = "DONE in %s sec." % self.bE
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 24:
            bS = self.th.benStart()
            print("Sender Server is on port[%s]" % self.senderPort)
            self.sf = MyServerFactory(self)
            reactor.listenTCP(self.senderPort, self.sf)
            self.bE = self.th.benDone(bS, "")
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 25:
            self.rl.ids.l_loaTcpSer.text = "DONE in %s sec." % self.bE
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 26:
            bS = self.th.benStart()
            self.tcp4ap = ttc(self)
            self.bE = self.th.benDone(bS, "")
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 27:
            self.rl.ids.l_AutoWifiArmTCP.text = "DONE in %s sec." % self.bE
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 999:
            bS = self.th.benStart()

            self.bE = self.th.benDone(bS, "")
            Clock.schedule_once(self.loaderNextStep, 0.1)

        elif self.loaderStep == 1000:
            #self.rl.ids.l_loaSWid.text = "DONE in %s sec."%self.bE
            Clock.schedule_once(self.loaderNextStep, 0.1)

        else:
            print(" loader finished ?")
            defScreen = 'ykpilot'
            goToScreen = defScreen
            dontStartAt = [
                'Loader', 'EditWidget', 'SettingUpWidget', 'SelectWidgetToAdd'
            ]
            try:
                goToScreen = self.config['screenCurrent']
            except:
                print("EE - no def  config['screenCurrent'] :/")

            if goToScreen in dontStartAt:
                goToScreen = defScreen

            try:
                self.screenChange(goToScreen)
            except:
                print("EE - no screen [", goToScreen, "] in screenmanager")
                self.screenChange(defScreen)

            print(" starting main loop for sensors ")
            self.sen.run()

            #Clock.schedule_once(self.sen.on_PlayFromFile_play, 1.0)
            #Clock.schedule_once(self.sWidgets.on_addEditDelButton, 1.0)
            #Clock.schedule_once(self.sWidgets.rebuildWs, 5.0)

            self.isReady = True

    def loaderStep0(self):

        #self.s3dtextures = Screen3dtextures()
        #self.s3dtextures.setGui(self)
        #self.rl.ids.bl3dtextures.add_widget( self.s3dtextures.l )
        from sensors import sensors

        self.cDefVals = {
            'screenCurrent': 'Sensors',
            'totalUptime': 0,
            'totalMiles': 0.0,
            'apDirectionReverse': 0,
            'apDriver': 'driver9',
            'apCommunicationMode': "audio jack",
            'apWifiIp': '192.168.4.1'
        }

        for k in self.cDefVals.keys():
            try:
                print("config  			", k, " -- > ", self.config[k])
            except:
                print("config default - > no value [", k, "] setting [",
                      self.cDefVals[k], "]")
                self.config[k] = self.cDefVals[k]

        if self.virtualButtons:
            self.vBut = ScreenVirtualButtons(self)

        wfa = self.workingFolderAdress.split("/")
        dirName = wfa[-2]

        try:
            print("working folder adres ",
                  self.fa.mkDir(self.workingFolderAdress[:-1]))
        except:
            pass

        #self.tcp = helperTCP(ip)
        self.rl.passGuiApp(self)
        self.sen = sensors(self)
        self.sen.comCal.addCallBack(self.sen)

        #self.sen.run()
        """
		self.graph = Graph(xlabel='time', ylabel="angle", x_ticks_minor=1,
			ymax=1.0,ymin=0.0			
			)
		self.pPitch = MeshLinePlot(color=[1,1,0,1])
		self.pHeel = MeshLinePlot(color=[1,0,1,1])
		self.graph.add_plot(self.pPitch)
		self.graph.add_plot(self.pHeel)
		self.rl.ids.blModSimGra.add_widget(self.graph)

		self.graphGyro = Graph(xlabel='time', ylabel="gyro", x_ticks_minor=1,
			ymax=1.0,ymin=0.0			
			)
		self.pgx = MeshLinePlot(color=[1,1,0,1])
		self.pgy = MeshLinePlot(color=[1,0,1,1])
		self.pgz = MeshLinePlot(color=[1,0,0,1])
		self.graphGyro.add_plot(self.pgx)
		self.graphGyro.add_plot(self.pgy)
		self.graphGyro.add_plot(self.pgz)
		self.rl.ids.blModSimGra.add_widget(self.graphGyro)


		self.graphFFT = Graph(xlabel="Hz Heel", ylabel="Db Heel", ymax=1.0, ymin=0.0)
		self.pFFTHeel = MeshLinePlot(color=[1,0,0,1])
		self.pFFTPitch = MeshLinePlot(color=[0,1,0,1])
		self.pFFTUD = MeshLinePlot(color=[0,0,1,1])

		self.graphFFT.add_plot(self.pFFTHeel)
		self.graphFFT.add_plot(self.pFFTPitch)
		self.graphFFT.add_plot(self.pFFTUD)
		self.rl.ids.blModSimFFT.add_widget( self.graphFFT )

		self.compasGyro = Graph(xlabel='time', ylabel="compas", x_ticks_minor=1,
			ymax=1.0,ymin=0.0			
			)
		self.pc = MeshLinePlot(color=[1,1,0,1])
		self.compasGyro.add_plot(self.pc)
		self.rl.ids.blModSimGra.add_widget(self.compasGyro)

		self.graphMic = Graph(xlabel="Hz mic", ylabel="Db mic", ymax=1.0, ymin=0.0)
		self.pMic = MeshLinePlot(color=[1,0,0,1])
		self.pMic1 = MeshLinePlot(color=[0,1,0,1])
		self.pMic2 = MeshLinePlot(color=[0,0,1,1])
		self.graphMic.add_plot(self.pMic)
		self.graphMic.add_plot(self.pMic1)
		self.graphMic.add_plot(self.pMic2)
		self.rl.ids.blMicScre.add_widget(self.graphMic)
		"""

        #self.d3tex2 = d3tex2()
        #self.d3tex2.setGui(self)
        #self.rl.ids.bl3dtextures2.add_widget( self.d3tex2 )

        #action bar
        if True:
            self.mw = BoxLayout(orientation="vertical")
            self.ab = ActionBar()
            av = ActionView()
            self.ab.add_widget(av)
            ap = ActionPrevious(title="ykpilot",
                                with_previous=False,
                                app_icon="icons/ico_sailboat_256_256.png")
            ap.bind(on_release=self.screenChange)
            av.add_widget(ap)

            ao = ActionOverflow()
            ab = ActionButton(text="Sensors",
                              icon="icons/ico_find_256_256.png")
            ab.bind(on_release=self.screenChange)
            av.add_widget(ab)
            ab = ActionButton(text="Model Screen",
                              icon="icons/ico_sailboat_256_256.png")
            ab.bind(on_release=self.screenChange)
            av.add_widget(ab)
            ab = ActionButton(text="Simulator",
                              icon="icons/ico_sum_256_256.png")
            ab.bind(on_release=self.screenChange)
            av.add_widget(ab)

            if self.virtualButtons:
                ab = ActionButton(text="Virtual Buttons",
                                  icon="icons/ico_in_256_256.png")
                ab.bind(on_release=self.screenChange)
                av.add_widget(ab)

            ab = ActionButton(text="Compass")
            ab.bind(on_release=self.screenChange)
            av.add_widget(ab)
            """
			ab = ActionButton(text="3dtextures")
			ab.bind(on_release=self.screenChange)
			av.add_widget(ab)
			
			ab = ActionButton(text="3dtextures2")
			ab.bind(on_release=self.screenChange)
			av.add_widget(ab)
			"""

            ab = ActionButton(text="Race", icon="icons/ico_time_256_256.png")
            ab.bind(on_release=self.screenChange)
            av.add_widget(ab)

            ab = ActionButton(text="Autopilot")
            ab.bind(on_release=self.screenChange)
            av.add_widget(ab)

            ab = ActionButton(text="Mic Screen")
            ab.bind(on_release=self.screenChange)
            av.add_widget(ab)

            ao = ActionOverflow()
            ab = ActionButton(text="Day")
            ab.bind(on_release=self.screenDay)
            av.add_widget(ab)
            ao = ActionOverflow()
            ab = ActionButton(text="Night")
            ab.bind(on_release=self.screenNight)
            av.add_widget(ab)

            ab = ActionButton(text="Widgets")
            ab.bind(on_release=self.screenChange)
            av.add_widget(ab)

            #ab = ActionButton(text="MSM")
            #ab.bind(on_release=self.screenChange)
            #av.add_widget(ab)

            ab = ActionButton(text="NMEA multiplexer")
            ab.bind(on_release=self.screenChange)
            av.add_widget(ab)

            av.add_widget(ao)

            self.mw.add_widget(self.ab)
            try:
                rlParent = self.rl.parent
                rlParent.remove_widget(self.rl)

            except:
                print("rl. don't have parent !")
            self.mw.add_widget(self.rl)

            toreturn = self.mw
        else:
            toreturn = self.rl
        # actionbar

        #play from file
        toreturn = self.sen.buidPlayer(toreturn)
        #play from file

        #self.sWidgets.setUpGui()

        #self.ap.setupDriver()

        #Window.set_title("ykpilot")

        #self.ode = odeRTB(self)
        #self.sen.accel.addCallBack(self.ode)

        rlParent.add_widget(toreturn)

    def hide_widget(self, wid, dohide=True):
        if hasattr(wid, 'saved_attrs'):
            if not dohide:
                wid.height, wid.size_hint_y, wid.opacity, wid.disabled = wid.saved_attrs
                del wid.saved_attrs
        elif dohide:
            wid.saved_attrs = wid.height, wid.size_hint_y, wid.opacity, wid.disabled
            wid.height, wid.size_hint_y, wid.opacity, wid.disabled = 0, None, 0, True

    def on_start(self):
        print("-------- on_start")
        try:
            dont_go_sleep()
        except:
            pass

    def on_pause(self):
        print("--------- on pause")
        try:
            self.sen.gps_stop()
        except:
            pass

        self.on_configSave()

        return True

    def on_resume(self):
        print("------- on resume")
        self.sen.gps_start(1000, 0)

    def on_configSave(self):
        self.config['screenCurrent'] = self.rl.current
        self.config['totalUptime'] += self.th.getTimestamp(
        ) - self.timeAppStart

        print("save config res", DataSR_save(self.config, 'ykpilot.conf'))

        print("save widgets config")
        try:
            self.sWidgets.saveConfig()
        except:
            print("EE - trying to save sWidget but it is not there yet !")

    # Screen: "Welcome"

    def on_push_udp_msg(self):
        udp = helperUdp()
        udp.setAsSender()
        self.testHDG += 1
        udp.send("$AAHDG,%s,0,W,0,E" % self.testHDG)

    def on_push_tcp_msg(self):
        self.testHDG += 1
        self.tcp.sendToAll("$AAHDG,%s,0,W,0,E" % self.testHDG)

    def on_cb_remotePython(self, checkbox):
        print(checkbox.active)
        if checkbox.active:
            rp = remotePython()
            _thread.start_new(rp.run, ())

    def on_cb_twistedTcp(self, checkobx):
        pass

    def on_push_sensorsInit(self):
        print("android host ------------------")
        self.sen.gps_start(1000, 0)
        print("sensors object !")

        print("sensors running :)")

    # actionbar
    def screenChange(self, screenName):
        if type(screenName) == str:
            sn = screenName
        else:
            try:
                sn = screenName.text
            except:
                sn = screenName.title

        if self.rl.current == "Model Screen":
            self.senBoat.on_noMoreDisplayd()
        if self.virtualButtons and self.rl.current == "Virtual Buttons":
            self.vBut.on_noMoreDisplayd()

        self.rl.current = sn

        print("screenChange to [%s]" % sn)
        if sn == "Model Screen":
            self.senBoat.on_displayNow()
        if sn[:7] in ['Compass', 'Widgets']:
            print("make updateIt on sn change")
            if sn == 'Compass':
                self.sCompass.updateIt()
            elif sn[:7] == 'Widgets':
                self.sWidgets.updateIt()

        if self.virtualButtons and sn == "Virtual Buttons":
            self.vBut.on_displayNow()
        if sn == "Autopilot":
            self.ap.updateGui()
        if self.rl.current == "3dtextures2":
            self.d3tex2.on_displayNow()

    def screenNight(self, a):
        print("screenNight")
        self.corolTheme = "night"
        self.rl.fs = shader_red

    def screenDay(self, a):
        print("screenDay")
        self.colorTheme = "day"
        self.rl.fs = shader_day

    def screenNightDay(self, a):
        if self.colorTheme == "day":
            self.corolTheme = "night"
        elif self.colorTheme == "night":
            self.colorTheme = "day"
        print("screenNightDay!", self.colorTheme)

    def on_touch_down(self, touch):
        print('down', touch.x, touch.y)
        if 0:  #collide_point:
            return True
        return False

    def on_touch_up(self, touch):
        print('up', touch.x, touch.y)
        if 0:  #collide_point:
            return True
        return False

    def on_key_down(self, *args):
        print("on_key_down", list(args))
        if self.rl.current == '3dtextures':
            self.s3dtextures.on_key_down(list(args))

    def on_key_up(self, *args):
        print("on_key_up", list(args))
        if self.rl.current == 'Simulator':
            self.simEng.on_key_up(list(args))
        elif self.rl.current == '3dtextures':
            self.s3dtextures.on_key_up(list(args))

    # screen: "Model Screen"
    def on_touchSail(self, slider):
        self.senBoat.setSail(slider.value)

    def on_touchHeel(self, slider):
        self.senBoat.setHeel(slider.value)

    # screen: "Sensors"
    def on_cb_sensorsRemoteTcp(self, checkbox):
        if checkbox.active:
            self.connectToSensorsRemoteTcp(0)

    def connectToSensorsRemoteTcp(self, a):
        self.rl.ids.cb_sensorsRemoteTcp.active = True
        self.cf = MyClientFactory(self)
        ip, port = str(self.rl.ids.ti_sensorsRemoteTcp.text).split(":")
        reactor.connectTCP(str(ip), int(port), self.cf)
コード例 #29
0
ファイル: gui.py プロジェクト: jacky4566/ykpilot
    def loaderStep0(self):

        #self.s3dtextures = Screen3dtextures()
        #self.s3dtextures.setGui(self)
        #self.rl.ids.bl3dtextures.add_widget( self.s3dtextures.l )
        from sensors import sensors

        self.cDefVals = {
            'screenCurrent': 'Sensors',
            'totalUptime': 0,
            'totalMiles': 0.0,
            'apDirectionReverse': 0,
            'apDriver': 'driver9',
            'apCommunicationMode': "audio jack",
            'apWifiIp': '192.168.4.1'
        }

        for k in self.cDefVals.keys():
            try:
                print("config  			", k, " -- > ", self.config[k])
            except:
                print("config default - > no value [", k, "] setting [",
                      self.cDefVals[k], "]")
                self.config[k] = self.cDefVals[k]

        if self.virtualButtons:
            self.vBut = ScreenVirtualButtons(self)

        wfa = self.workingFolderAdress.split("/")
        dirName = wfa[-2]

        try:
            print("working folder adres ",
                  self.fa.mkDir(self.workingFolderAdress[:-1]))
        except:
            pass

        #self.tcp = helperTCP(ip)
        self.rl.passGuiApp(self)
        self.sen = sensors(self)
        self.sen.comCal.addCallBack(self.sen)

        #self.sen.run()
        """
		self.graph = Graph(xlabel='time', ylabel="angle", x_ticks_minor=1,
			ymax=1.0,ymin=0.0			
			)
		self.pPitch = MeshLinePlot(color=[1,1,0,1])
		self.pHeel = MeshLinePlot(color=[1,0,1,1])
		self.graph.add_plot(self.pPitch)
		self.graph.add_plot(self.pHeel)
		self.rl.ids.blModSimGra.add_widget(self.graph)

		self.graphGyro = Graph(xlabel='time', ylabel="gyro", x_ticks_minor=1,
			ymax=1.0,ymin=0.0			
			)
		self.pgx = MeshLinePlot(color=[1,1,0,1])
		self.pgy = MeshLinePlot(color=[1,0,1,1])
		self.pgz = MeshLinePlot(color=[1,0,0,1])
		self.graphGyro.add_plot(self.pgx)
		self.graphGyro.add_plot(self.pgy)
		self.graphGyro.add_plot(self.pgz)
		self.rl.ids.blModSimGra.add_widget(self.graphGyro)


		self.graphFFT = Graph(xlabel="Hz Heel", ylabel="Db Heel", ymax=1.0, ymin=0.0)
		self.pFFTHeel = MeshLinePlot(color=[1,0,0,1])
		self.pFFTPitch = MeshLinePlot(color=[0,1,0,1])
		self.pFFTUD = MeshLinePlot(color=[0,0,1,1])

		self.graphFFT.add_plot(self.pFFTHeel)
		self.graphFFT.add_plot(self.pFFTPitch)
		self.graphFFT.add_plot(self.pFFTUD)
		self.rl.ids.blModSimFFT.add_widget( self.graphFFT )

		self.compasGyro = Graph(xlabel='time', ylabel="compas", x_ticks_minor=1,
			ymax=1.0,ymin=0.0			
			)
		self.pc = MeshLinePlot(color=[1,1,0,1])
		self.compasGyro.add_plot(self.pc)
		self.rl.ids.blModSimGra.add_widget(self.compasGyro)

		self.graphMic = Graph(xlabel="Hz mic", ylabel="Db mic", ymax=1.0, ymin=0.0)
		self.pMic = MeshLinePlot(color=[1,0,0,1])
		self.pMic1 = MeshLinePlot(color=[0,1,0,1])
		self.pMic2 = MeshLinePlot(color=[0,0,1,1])
		self.graphMic.add_plot(self.pMic)
		self.graphMic.add_plot(self.pMic1)
		self.graphMic.add_plot(self.pMic2)
		self.rl.ids.blMicScre.add_widget(self.graphMic)
		"""

        #self.d3tex2 = d3tex2()
        #self.d3tex2.setGui(self)
        #self.rl.ids.bl3dtextures2.add_widget( self.d3tex2 )

        #action bar
        if True:
            self.mw = BoxLayout(orientation="vertical")
            self.ab = ActionBar()
            av = ActionView()
            self.ab.add_widget(av)
            ap = ActionPrevious(title="ykpilot",
                                with_previous=False,
                                app_icon="icons/ico_sailboat_256_256.png")
            ap.bind(on_release=self.screenChange)
            av.add_widget(ap)

            ao = ActionOverflow()
            ab = ActionButton(text="Sensors",
                              icon="icons/ico_find_256_256.png")
            ab.bind(on_release=self.screenChange)
            av.add_widget(ab)
            ab = ActionButton(text="Model Screen",
                              icon="icons/ico_sailboat_256_256.png")
            ab.bind(on_release=self.screenChange)
            av.add_widget(ab)
            ab = ActionButton(text="Simulator",
                              icon="icons/ico_sum_256_256.png")
            ab.bind(on_release=self.screenChange)
            av.add_widget(ab)

            if self.virtualButtons:
                ab = ActionButton(text="Virtual Buttons",
                                  icon="icons/ico_in_256_256.png")
                ab.bind(on_release=self.screenChange)
                av.add_widget(ab)

            ab = ActionButton(text="Compass")
            ab.bind(on_release=self.screenChange)
            av.add_widget(ab)
            """
			ab = ActionButton(text="3dtextures")
			ab.bind(on_release=self.screenChange)
			av.add_widget(ab)
			
			ab = ActionButton(text="3dtextures2")
			ab.bind(on_release=self.screenChange)
			av.add_widget(ab)
			"""

            ab = ActionButton(text="Race", icon="icons/ico_time_256_256.png")
            ab.bind(on_release=self.screenChange)
            av.add_widget(ab)

            ab = ActionButton(text="Autopilot")
            ab.bind(on_release=self.screenChange)
            av.add_widget(ab)

            ab = ActionButton(text="Mic Screen")
            ab.bind(on_release=self.screenChange)
            av.add_widget(ab)

            ao = ActionOverflow()
            ab = ActionButton(text="Day")
            ab.bind(on_release=self.screenDay)
            av.add_widget(ab)
            ao = ActionOverflow()
            ab = ActionButton(text="Night")
            ab.bind(on_release=self.screenNight)
            av.add_widget(ab)

            ab = ActionButton(text="Widgets")
            ab.bind(on_release=self.screenChange)
            av.add_widget(ab)

            #ab = ActionButton(text="MSM")
            #ab.bind(on_release=self.screenChange)
            #av.add_widget(ab)

            ab = ActionButton(text="NMEA multiplexer")
            ab.bind(on_release=self.screenChange)
            av.add_widget(ab)

            av.add_widget(ao)

            self.mw.add_widget(self.ab)
            try:
                rlParent = self.rl.parent
                rlParent.remove_widget(self.rl)

            except:
                print("rl. don't have parent !")
            self.mw.add_widget(self.rl)

            toreturn = self.mw
        else:
            toreturn = self.rl
        # actionbar

        #play from file
        toreturn = self.sen.buidPlayer(toreturn)
        #play from file

        #self.sWidgets.setUpGui()

        #self.ap.setupDriver()

        #Window.set_title("ykpilot")

        #self.ode = odeRTB(self)
        #self.sen.accel.addCallBack(self.ode)

        rlParent.add_widget(toreturn)
コード例 #30
0
ファイル: actionBar.py プロジェクト: KenoLeon/KivyMenagerie
 def build(self):
     return ActionBar()
コード例 #31
0
	def __init__(self, **kwargs):
		super(MainScreen, self).__init__(**kwargs)
	
		self.cols = 1
		self.rows = 1

		self._data_queue = queue.Queue()
		self.gps_location = None
		self.gps_status = None
		self.default_sensor = "Accelerometer"
		self.default_protocol = "terminal"
		self.default_server = "test.mosquitto.org"
		self.default_port = "1883"
		self.default_topic_url = "ie/dcu/ee513"

		#Layouts
		self._main_layout = BoxLayout(orientation='vertical', padding=0, size_hint=(1, 1))
		if (platform == 'android') or (platform == 'ios'):
			_terminal_layout = BoxLayout(orientation='vertical', padding=0, size_hint=(1, 0.7))
			_partition_layout = GridLayout(cols=2, rows=6, padding=0, size_hint=(1, 1), row_force_default=True, \
										rows_minimum={0: 150, 1: 150, 2: 150, 3: 150}, row_default_height=150, spacing=25)
		else:
			_terminal_layout = BoxLayout(orientation='vertical', padding=0, size_hint=(1, 0.4))
			_partition_layout = GridLayout(cols=2, rows=6, padding=0, size_hint=(1, 1), row_force_default=True, \
										rows_minimum={0: 50, 1: 50, 2: 50, 3: 50}, row_default_height=50, spacing=25)
  
		_action_previous = ActionPrevious(title='EE513 LABS', with_previous=False, app_icon='icons/sxmitter-logo-app-small.png', padding=0)
		_action_overflow = ActionOverflow()
		_action_view = ActionView(overflow_group=_action_overflow, use_separator=True)
		_action_button = ActionButton(text='debug')
		_action_overflow.add_widget(_action_button)
		_action_button_about = ActionButton(text='About')
		_action_button_about.bind(on_release=self._popup_about)
		_action_button_quit = ActionButton(text='Quit')
		_action_button_quit.bind(on_release=self.quitApp)
		_action_view.add_widget(_action_previous)
		_action_view.add_widget(_action_button_about)
		_action_view.add_widget(_action_button_quit)
		_action_view.add_widget(_action_overflow)
		_action_bar = ActionBar(pos_hint={'top': 1})
		_action_bar.add_widget(_action_view)

		_partition_layout.add_widget(Label(text='Server', size_hint_x=None, width=400))
		self._data_object["server"] = self.default_server
		self.server = TextInput(text='test.mosquitto.org', multiline=False, cursor_blink=True)
		self.server.bind(text=self.callback_server_text)
		_partition_layout.add_widget(self.server)
	
		_partition_layout.add_widget(Label(text='Port', size_hint_x=None, width=400))
		self._data_object["port"] = self.default_port
		self.port = TextInput(text='1883', multiline=False)
		self.port.bind(text=self.callback_port_text)
		_partition_layout.add_widget(self.port)

		_partition_layout.add_widget(Label(text='Sensor', size_hint_x=None, width=400))
		self._data_object["sensor"] = self.default_sensor
		sensor_spinner = Spinner(
					text=self.default_sensor,
					values=('Accelerometer', 'Compass', 'GPS', 'Barometer', 'Gravity', 'Gyroscope'),
					size_hint=(0.3, 0.5), sync_height=True)
		sensor_spinner.bind(text=self.callback_sensor_spinner_text)
		_partition_layout.add_widget(sensor_spinner)

		_partition_layout.add_widget(Label(text='Protocol', size_hint_x=None, width=400))
		self._data_object["protocol"] = self.default_protocol
		protocol_spinner = Spinner(
					text=self.default_protocol,
					values=('http', 'https', 'mqtt', 'udp', 'terminal'),
					size_hint=(0.3, 0.5), sync_height=True)
		protocol_spinner.bind(text=self.callback_protocol_spinner_text)
		_partition_layout.add_widget(protocol_spinner)

		_partition_layout.add_widget(Label(text='Topic/URL', size_hint_x=None, width=400))
		self._data_object["topic_url"] = self.default_topic_url
		self.topic_url = TextInput(text='ie/dcu/ee513', multiline=False)
		self.topic_url.bind(text=self.callback_topic_url_text)
		_partition_layout.add_widget(self.topic_url)
  
		_partition_layout.add_widget(Label(text='Connect', size_hint_x=None, width=400))
		switch = Switch()
		switch.bind(active=self.callback_switch)
		_partition_layout.add_widget(switch)

		self.terminal = TextInput(text='Terminal output...', multiline=True, readonly=False, size_hint=(1, 1))
		self.global_terminal = self.terminal
		_terminal_layout.add_widget(self.terminal)		
		
		self._main_layout.add_widget(_action_bar)
		self._main_layout.add_widget(_partition_layout)
		self._main_layout.add_widget(_terminal_layout)
		self.add_widget(self._main_layout)
コード例 #32
0
class NavigationToolbar2Kivy(NavigationToolbar2):
    '''This class extends from matplotlib class NavigationToolbar2 and
       creates an action bar which is added to the main app to allow the
       following operations to the figures.

        Home: Resets the plot axes to the initial state.
        Left: Undo an operation performed.
        Right: Redo an operation performed.
        Pan: Allows to drag the plot.
        Zoom: Allows to define a rectangular area to zoom in.
        Configure: Loads a pop up for repositioning elements.
        Save: Loads a Save Dialog to generate an image.
    '''
    def __init__(self, canvas, **kwargs):
        self.actionbar = ActionBar(pos_hint={'top': 1.0})
        super(NavigationToolbar2Kivy, self).__init__(canvas)
        self.rubberband_color = (1.0, 0.0, 0.0, 1.0)
        self.lastrect = None
        self.save_dialog = Builder.load_string(
            textwrap.dedent('''\
            <SaveDialog>:
                text_input: text_input
                BoxLayout:
                    size: root.size
                    pos: root.pos
                    orientation: "vertical"
                    FileChooserListView:
                        id: filechooser
                        on_selection: text_input.text = self.selection and\
                        self.selection[0] or ''

                    TextInput:
                        id: text_input
                        size_hint_y: None
                        height: 30
                        multiline: False

                    BoxLayout:
                        size_hint_y: None
                        height: 30
                        Button:
                            text: "Cancel"
                            on_release: root.cancel()

                        Button:
                            text: "Save"
                            on_release: root.save(filechooser.path,\
                            text_input.text)
            '''))

    def _init_toolbar(self):
        '''A Toolbar is created with an ActionBar widget in which buttons are
           added with a specific behavior given by a callback. The buttons
           properties are given by matplotlib.
        '''
        basedir = os.path.join(rcParams['datapath'], 'images')
        actionview = ActionView()
        actionprevious = ActionPrevious(title="Navigation",
                                        with_previous=False)
        actionoverflow = ActionOverflow()
        actionview.add_widget(actionprevious)
        actionview.add_widget(actionoverflow)
        actionview.use_separator = True
        self.actionbar.add_widget(actionview)
        id_group = uuid.uuid4()
        for text, tooltip_text, image_file, callback in self.toolitems:
            if text is None:
                actionview.add_widget(ActionSeparator())
                continue
            fname = os.path.join(basedir, image_file + '.png')
            if text in ['Pan', 'Zoom']:
                action_button = ActionToggleButton(text=text,
                                                   icon=fname,
                                                   group=id_group)
            else:
                action_button = ActionButton(text=text, icon=fname)
            action_button.bind(on_press=getattr(self, callback))
            actionview.add_widget(action_button)

    def configure_subplots(self, *largs):
        '''It will be implemented later.'''
        pass

    def dismiss_popup(self):
        self._popup.dismiss()

    def show_save(self):
        '''Displays a popup widget to perform a save operation.'''
        content = SaveDialog(save=self.save, cancel=self.dismiss_popup)
        self._popup = Popup(title="Save file",
                            content=content,
                            size_hint=(0.9, 0.9))
        self._popup.open()

    def save(self, path, filename):
        self.canvas.export_to_png(os.path.join(path, filename))
        self.dismiss_popup()

    def save_figure(self, *args):
        self.show_save()

    def draw_rubberband(self, event, x0, y0, x1, y1):
        w = abs(x1 - x0)
        h = abs(y1 - y0)
        rect = [
            int(val) for val in (min(x0, x1) + self.canvas.x,
                                 min(y0, y1) + self.canvas.y, w, h)
        ]
        if self.lastrect is None:
            self.canvas.canvas.add(Color(*self.rubberband_color))
        else:
            self.canvas.canvas.remove(self.lastrect)
        self.lastrect = InstructionGroup()
        self.lastrect.add(
            Line(rectangle=rect, width=1.0, dash_length=5.0, dash_offset=5.0))
        self.lastrect.add(Color(1.0, 0.0, 0.0, 0.2))
        self.lastrect.add(
            Rectangle(pos=(rect[0], rect[1]), size=(rect[2], rect[3])))
        self.canvas.canvas.add(self.lastrect)

    def release_zoom(self, event):
        self.lastrect = None
        return super(NavigationToolbar2Kivy, self).release_zoom(event)
コード例 #33
0
ファイル: main.py プロジェクト: Gexygamma/PartyFinderApp
class RootLayout(BoxLayout):
    def __init__(self, *args, **kwargs):

        super().__init__(*args, **kwargs)
        self.orientation = "vertical"

        # Action bar (top)
        self.actionbar = ActionBar()
        self.actionview = ActionView()
        self.actionview.action_previous = ActionPrevious(
            with_previous=False, app_icon="res/appicon.png")
        actionbtn = ActionButton(text="Perfil",
                                 icon="res/profile.png",
                                 on_release=lambda _: App.get_running_app().
                                 go_screen(Screens.Profile.value))
        self.actionview.add_widget(actionbtn)
        actionbtn = ActionButton(text="Ajustes", icon="res/settings.png")
        self.actionview.add_widget(actionbtn)
        self.actionbar.add_widget(self.actionview)

        # Navigation bar (bottom)
        self.navigationbar = BoxLayout(orientation="horizontal",
                                       size_hint_y=None,
                                       height=dp(48),
                                       padding=dp(8))
        navbtn = ImageButton(source="res/search.png")
        navbtn.on_press = lambda: App.get_running_app().go_screen(Screens.
                                                                  Search.value)
        self.navigationbar.add_widget(navbtn)
        navbtn = ImageButton(source="res/home.png")
        navbtn.on_press = lambda: App.get_running_app().go_screen(Screens.Main.
                                                                  value)
        self.navigationbar.add_widget(navbtn)
        navbtn = ImageButton(source="res/message.png")
        navbtn.on_press = lambda: App.get_running_app().go_screen(
            Screens.Message.value)
        self.navigationbar.add_widget(navbtn)

        # Screen manager
        self.screenmanager = ScreenManager()
        self._load_screen_manager()
        self.add_widget(self.screenmanager)

    def show_bars(self, show):
        if show:
            self.add_widget(self.actionbar, 1)
            self.add_widget(self.navigationbar)
        else:
            self.remove_widget(self.actionbar)
            self.remove_widget(self.navigationbar)

    def is_bar_visible(self):
        return self.actionbar in self.children and self.navigationbar in self.children

    def _load_screen_manager(self):
        """ Carga las pantallas de la aplicación en el screenmanager. """
        # Las transiciones se realizan respetando el orden en el que fueron agregadas las pantallas
        self.screenmanager.add_widget(LoginScreen())
        self.screenmanager.add_widget(SearchScreen())
        self.screenmanager.add_widget(MainScreen())
        self.screenmanager.add_widget(MessageScreen())
        self.screenmanager.add_widget(LobbyCreationScreen())
        self.screenmanager.add_widget(ProfileScreen())
        self.screenmanager.add_widget(MembersScreen())
        self.screenmanager.current = Screens.Login.value
        self.actionview.action_previous.title = self.screenmanager.current_screen.title
コード例 #34
0
class BattleScreen(Screen):
    def __init__(self, **kwargs):
        super(BattleScreen, self).__init__(**kwargs)

        self.bScene = BattleScene()
        self.layout = BoxLayout(orientation='vertical')
        self.actionBar = ActionBar()
        self.view = ActionView()
        self.prompt = self.bScene.getTurn()
        self.nametag = ActionPrevious(title=self.prompt)
        self.MoveButton = ActionButton(text='Move')
        self.AttackButton = ActionButton(text='Attack')
        self.AbilityButton = ActionButton(text='Item')
        self.ConfirmButton = ActionButton(text='Take Turn')
        self.MoveButton.bind(on_press=self.Move)
        self.AttackButton.bind(on_press=self.Action)
        self.AbilityButton.bind(on_press=self.Ability)
        self.ConfirmButton.bind(on_press=self.TakeTurn)
        self.battleLog = 'Now Beginning Battle...'
        self.label = ScrollableLabel(text=self.battleLog)
        self.layout.add_widget(self.actionBar)
        self.layout.add_widget(self.label)
        self.actionBar.add_widget(self.view)
        self.view.add_widget(self.nametag)
        self.view.add_widget(self.MoveButton)
        self.view.add_widget(self.AttackButton)
        self.view.add_widget(self.AbilityButton)
        self.view.add_widget(self.ConfirmButton)
        self.add_widget(self.layout)
        self.Target = Combatants.get(0)
        Combatants.checkItems(0)
        if Combatants.getHasItems(0) == False:
            self.AbilityButton.disabled = True

    def TakeTurn(self, obj):
        if isDM == True:
            if(Combatants.get(0).hasMoved == True and Combatants.get(0).hasActed == True):
                delay = 100
            elif(Combatants.get(0).hasMoved == False and Combatants.get(0).hasActed == False):
                delay = 60
            else:
                delay = 80
            Combatants.get(0).CT -= delay
            Combatants.get(0).hasMoved = False
            Combatants.get(0).hasActed = False
            self.prompt = self.bScene.getTurn()
            self.nametag.title = self.prompt
        self.MoveButton.disabled = False
        self.AttackButton.disabled = False
        Combatants.checkItems(0)
        if Combatants.getHasItems(0) == True:
            self.AbilityButton.disabled = False
        else:
            self.AbilityButton.disabled = True

    def Move(self, obj):
        Combatants.get(0).hasMoved = True
        self.MoveButton.disabled = True

    def Action(self, obj):
        Screens[0].populate()
        self.manager.current = 'Action Menu'

    def Ability(self, obj):
        Screens[1].populateItems()
        Screens[1].populateTargs()
        self.manager.current = 'Ability Menu'

    def Attack(self):
        damage = Action.Attack(Combatants.get(0).acc, self.Target.eva, Combatants.get(0).attack, self.Target.defense)
        if(damage == -1):
            msg = "%s missed %s!" %(Combatants.get(0).name, self.Target.name)
            self.battleLog = self.battleLog + "\n" + msg
            self.label.text = self.battleLog
        else:
            msg = "%s hit %s for %d points of damage!" %(Combatants.get(0).name, self.Target.name, damage)
            self.battleLog = self.battleLog + "\n" + msg
            self.label.text = self.battleLog
            self.Target.HP -= damage
            if(self.Target.HP <= 0):
                msg = "%s was defeated!" %(self.Target.name)
                self.battleLog = self.battleLog + "\n" + msg
                self.label.text = self.battleLog

    def UseItem(self, num):
        Combatants.get(0).inventory[num].quantity -= 1
        methodToCall = getattr(Item, Combatants.get(0).inventory[num].name)
        msg = methodToCall(self.Target)
        self.battleLog = self.battleLog + "\n" + msg
        self.label.text = self.battleLog
コード例 #35
0
class MyPaintLayout(BoxLayout):
    def __init__(self, **kwargs):
        super(MyPaintLayout, self).__init__(**kwargs)

        # 変数・設定
        self.orientation = 'vertical'
        self.pen_width_dropdown = PenWidthDropDown()

        # ウィジェットの定義
        self.paint = MyPaintWidget()
        self.action_bar = ActionBar()
        self.action_view = ActionView()
        self.action_previous = ActionPrevious()
        self.pen_preview = ActionPenPreview()

        # 戻る・やり直しボタン
        self.back_action_button = ActionButton(
            text='Back', on_press=lambda _: self.paint.back_action())

        self.redo_action_button = ActionButton(
            text='Redo', on_press=lambda _: self.paint.redo_action())

        # 色の決定用のモーダルウィンドウ
        self.pen_color_modal_view = ModalView(size_hint=(0.8, 0.8))
        self.clr_picker = ColorPicker(size_hint_y=9)
        self.clr_picker.bind(
            color=lambda _, color: self.change_pen_color(color))
        self.pen_color_modal_layout = BoxLayout(orientation='vertical')
        self.pen_color_modal_layout.add_widget(self.clr_picker)

        self.pen_color_modal_layout.add_widget(
            Button(text='Close',
                   on_press=self.pen_color_modal_view.dismiss,
                   size_hint_y=1))
        self.pen_color_modal_view.add_widget(self.pen_color_modal_layout)

        # 全消去用のモーダルウィンドウ
        self.clear_modal_view = ModalView(size_hint=(0.7, 0.7))
        self.clear_modal_layout = BoxLayout(orientation='vertical')
        self.clear_modal_layout.add_widget(
            Label(text='Do you really want to clear?'))
        self.clear_modal_layout.add_widget(
            Button(text='Yes',
                   on_press=lambda button: [
                       self.paint.canvas.clear(),
                       self.paint.back_redo_log.clear(),
                       self.clear_modal_view.dismiss()
                   ]))
        self.clear_modal_layout.add_widget(
            Button(text='No',
                   on_press=lambda button: self.clear_modal_view.dismiss()))
        self.clear_modal_view.add_widget(self.clear_modal_layout)

        # ペンの太さのモーダルウィンドウ
        self.pen_width_modal_view = ModalView(size_hint=(0.7, 0.5))
        self.pen_width_modal_layout = BoxLayout(orientation='vertical')
        self.pen_width_label = Label(text="Width: " +
                                     str(int(self.paint.current_width)))
        self.pen_width_slider = Slider(
            min=1,
            max=20,
            value=self.paint.current_width,
            step=1,
            on_touch_move=lambda x, y: self.change_pen_width(
                self.pen_width_slider.value))
        self.pen_width_modal_layout.add_widget(self.pen_width_label)
        self.pen_width_modal_layout.add_widget(self.pen_width_slider)
        self.pen_width_modal_layout.add_widget(
            Button(text='Close', on_press=self.pen_width_modal_view.dismiss))
        self.pen_width_modal_view.add_widget(self.pen_width_modal_layout)

        self.pen_color_btn = ActionButton(
            text='Color', on_press=lambda _: self.pen_color_modal_view.open())

        self.pen_width_btn = ActionButton(
            text='width: ' + str(int(self.paint.current_width)),
            on_press=self.pen_width_modal_view.open)
        self.clear_btn = ActionButton(text='Clear',
                                      on_press=self.clear_modal_view.open)

        # ウィジェットの配置
        self.action_view.add_widget(self.action_previous)
        self.action_view.add_widget(self.pen_preview)
        self.action_view.add_widget(self.back_action_button)
        self.action_view.add_widget(self.redo_action_button)
        self.action_view.add_widget(self.pen_color_btn)
        self.action_view.add_widget(self.pen_width_btn)
        self.action_view.add_widget(self.clear_btn)
        self.action_bar.add_widget(self.action_view)
        self.add_widget(self.paint)
        self.add_widget(self.action_bar)

    def change_pen_width(self, width):
        self.paint.set_current_width(width)
        self.pen_width_btn.text = "width: " + str(width)
        self.pen_width_label.text = "Width: " + str(width)
        self.pen_preview.update_current_pen(self.paint.red, self.paint.green,
                                            self.paint.blue,
                                            self.paint.current_width)

    def change_pen_color(self, color):
        self.paint.red = color[0]
        self.paint.green = color[1]
        self.paint.blue = color[2]
        self.pen_preview.update_current_pen(self.paint.red, self.paint.green,
                                            self.paint.blue,
                                            self.paint.current_width)