Ejemplo n.º 1
0
    def color_chooser(self):
        if uiApp.current_selected_widget == None:
            toast("select a wire first")
            return

        content = Button(text='Close me!', size_hint_y=0.1)
        popup = Popup(title="Theme color")

        box = BoxLayout(orientation='vertical')
        clr_picker = ColorPicker()

        def on_color(instance, value):
            # self.current_selected_widget.clr.color=instance.color

            for i in (uiApp.current_selected_widget.parent.parent).children:
                for j in i.children:
                    if isinstance(j, DraggableWire):
                        child = j.children[0]
                        child.canvas.before.children[0].rgba = instance.color
            # child = self.current_selected_widget.children[0]
            # child.canvas.before.children[0].rgba = instance.color

        clr_picker.bind(color=on_color)
        box.add_widget(clr_picker)
        content.bind(on_press=popup.dismiss)
        box.add_widget(content)
        popup.add_widget(box)
        popup.open()
Ejemplo n.º 2
0
    def build(self):
        Window.size=(350,180)
        screen = MDScreen()
        layout = BoxLayout(orientation="vertical")
        self.b_9=MDRaisedButton(text="9",on_press=self.insert_text)
        self.b_8=MDRaisedButton(text="8",on_press=self.insert_text)
        self.b_7=MDRaisedButton(text="7",on_press=self.insert_text)
        self.b_6=MDRaisedButton(text="6",on_press=self.insert_text)
        self.b_5=MDRaisedButton(text="5",on_press=self.insert_text)
        self.b_4=MDRaisedButton(text="4",on_press=self.insert_text)
        self.b_3=MDRaisedButton(text="3",on_press=self.insert_text)
        self.b_2=MDRaisedButton(text="2",on_press=self.insert_text)
        self.b_1=MDRaisedButton(text="1",on_press=self.insert_text)
        self.b_zero=MDRaisedButton(text="0",on_press=self.insert_text)
        self.b_equals=MDRaisedButton(text="=",on_press=self.equals)
        self.b_CLR=MDRaisedButton(text="CLR",on_press=self.clear_text)
        self.b_plus=MDRaisedButton(text="+",on_press=self.addition)
        self.b_minus=MDRaisedButton(text="-",on_press=self.sub)
        self.b_mul=MDRaisedButton(text="*",on_press=self.mul)
        self.b_Div=MDRaisedButton(text="/",on_press=self.div)
        self.text_field = MDTextFieldRect(text="",size_hint=(1, None),height="30dp",pos_hint={'centr_x':0,'center_y':0.96})
        gl = GridLayout(cols=4)
        layout.add_widget(self.text_field)

        lis=[self.b_9,self.b_8,self.b_7,self.b_plus,self.b_6,self.b_5,self.b_4,self.b_minus,self.b_3,self.b_2,self.b_1,self.b_mul,self.b_CLR,self.b_zero,self.b_equals,self.b_Div]
        for k in lis:
            gl.add_widget(k)
        
        
        layout.add_widget(gl)
        return layout
Ejemplo n.º 3
0
class SettingsPage(BoxLayout):
    def __init__(self):
        super().__init__()
        self.orientation = "vertical"
        self.toolbar = MDToolbar(title="Setting")
        self.toolbar.left_action_items = [["arrow-left", self.back]]
        self.add_widget(self.toolbar)
        self.container = BoxLayout()
        label = MDLabel(text="", halign="center")
        self.container.add_widget(label)
        self.add_widget(self.container)

    def back(self, instance):
        app.screen_manager.current = "listpage"
Ejemplo n.º 4
0
class PlayingPage(BoxLayout):
    def __init__(self):
        super().__init__()
        self.pointer = 0
        self.state_ = {
            "isPlaying": True,
            "title": "Test Title",
            "artist": "J. Cole",
            "lenght": 100.0
        }
        self.orientation = "vertical"
        self.toolbar = MDToolbar(title="Now Playing")
        self.toolbar.left_action_items = [["arrow-left", self.back]]
        self.add_widget(self.toolbar)
        self.upper_container = BoxLayout()
        self.upper_container.orientation = "vertical"
        self.title = MDLabel(text=self.state_['title'] + '\n' +
                             self.state_['artist'],
                             halign="center",
                             font_style="H5")
        self.upper_container.add_widget(self.title)
        self.lower_container = BoxLayout()
        self.lower_container.orientation = "horizontal"
        self.lower_container.halign = "center"
        self.lower_container.size_hint_max_y = 0.2
        self.slider_time_line = BoxLayout()
        self.slider_time_line.orientation = "horizontal"
        self.play_btn = MDIconButton(icon="pause")
        self.play_btn.on_press = self.pause_
        self.next_Btn = MDIconButton(icon="skip-forward")
        self.slider = MDSlider(min=0, max=self.state_['lenght'])
        self.prev_Btn = MDIconButton(icon="skip-backward")
        self.lower_container.add_widget(self.prev_Btn)
        self.lower_container.add_widget(self.play_btn)
        self.lower_container.add_widget(self.next_Btn)
        self.slider_time_line.add_widget(self.slider)
        self.add_widget(self.upper_container)
        self.add_widget(self.slider_time_line)
        self.add_widget(self.lower_container)

    def init_config(self, title, artist, lenght):
        if not artist:
            artist = ""
        self.title.text = str(title) + "\n" + str(artist)
        self.slider.max = lenght

    def pause_(self):
        self.state_['isPlaying'] = not self.state_['isPlaying']
        self.slider.max = self.state_['lenght']
        if self.state_['isPlaying']:
            self.play_btn.icon = "pause"
            app.playing.play()
        else:
            self.play_btn.icon = "play"
            app.playing.stop()

    def back(self, instance):
        app.screen_manager.current = "listpage"
 def hocr_dialog(self, instance, *args):
     from kivy.uix.image import Image
     from PIL.Image import open
     # texture.get_region seems to be buggy
     if not self.pil_image:
         self.pil_image = open(self.image.source)
     snippet = self.pil_image.crop(instance.bbox)
     image = Image()
     self._update_image(image, snippet)
     from kivymd.uix.boxlayout import BoxLayout
     from kivymd.uix.textfield import TextInput, MDTextField
     layout = BoxLayout(orientation="vertical", size=(500, 200), size_hint=(None, None))
     bboxlayout = BoxLayout(orientation="vertical")
     bboxvaluelayout = BoxLayout(orientation="horizontal")
     bboxlayout.add_widget(OneLineListItem(text="BBOX"))
     for bbox in instance.bbox:
         bboxvaluelayout.add_widget(MDTextField(text=str(bbox)))
     bboxlayout.add_widget(bboxvaluelayout)
     layout.add_widget(bboxlayout)
     layout.add_widget(image)
     layout.add_widget(TextInput(text=instance.text,font_name=get_font()))
     dialog = MDDialog(title="Snippets",
                       type='custom',
                       auto_dismiss=False,
                       text=instance.text,
                       content_cls=layout,
                       size=(500, 800),
                       size_hint=(None, None),
                       buttons=[
                           MDFlatButton(
                               text="UPDATE BBOX", on_release=partial(self.update_bbox, instance)
                           ),
                           MDFlatButton(
                               text="SAVE", on_release=partial(self.update_text, instance)
                           ),
                           MDFlatButton(
                               text="DISCARD", on_release=partial(self.close_dialog)
                           ),
                       ],
                       )
     dialog.open()