Пример #1
0
    def color_picker(self, wid, btn_color):

        colPckr = ColorPicker()
        
        select_button = Button(text = "Select", size = (100, 25))
        layout = GridLayout(cols = 1, padding = 10)

        layout.add_widget(select_button)
        layout.add_widget(colPckr)

        color_popup = Popup(title = 'Color Wheel', content = layout,
                            size_hint = (None, None), size = (600, 600))
        color_popup.open()

        # To monitor changes, we can bind to color property changes
        def on_color(instance, value):
            print ("RGBA = ", str(value))  #  or instance.color
            print ("HSV = ", str(instance.hsv))
            print ("HEX = ", str(instance.hex_color))

            global col
            col = value
            wid.selected_color = value

        colPckr.bind(color = on_color)
        select_button.bind(on_press = color_popup.dismiss)
Пример #2
0
    def _create_popup(self, instance):
        # create popup layout
        content = BoxLayout(orientation='vertical', spacing='5dp')
        popup_width = 0.95 * Window.width
        self.popup = popup = Popup(title=self.title,
                                   content=content,
                                   size_hint=(None, 0.9),
                                   width=popup_width)

        self.colorpicker = colorpicker = ColorPicker(
            color=utils.get_color_from_hex(self.value))
        colorpicker.bind(on_color=self._validate)

        self.colorpicker = colorpicker
        content.add_widget(colorpicker)

        # 2 buttons are created for accept or cancel the current value
        btnlayout = BoxLayout(size_hint_y=None, height='50dp', spacing='5dp')
        btn = Button(text='Ok')
        btn.bind(on_release=self._validate)
        btnlayout.add_widget(btn)
        btn = Button(text='Cancel')
        btn.bind(on_release=self._dismiss)
        btnlayout.add_widget(btn)
        content.add_widget(btnlayout)

        popup.open()
Пример #3
0
 def show_color_dialog(self, colname):
     setcol = self.formatter.get_colors_to_set()[colname]
     hex_color = setcol.get(self.formatter)
     if hex_color and hex_color[0] == '#':
         colors = dict(hex_color=hex_color)
     elif hex_color and hex_color in FORMATTER_COLORS:
         colors = dict(hex_color=FORMATTER_COLORS[hex_color])
     else:
         colors = dict(color=(0, 0, 0, 0))
     cp = ColorPicker(size_hint_y=None, height=dp(300), **colors)
     dialog = MDDialog(
         title="Color choice",
         type="custom",
         content_cls=cp,
         buttons=[
             MDRaisedButton(text="Cancel",
                            on_release=partial(self.on_new_color,
                                               renc=cp,
                                               colname=colname)),
             MDFlatButton(text="OK",
                          on_release=partial(self.on_new_color,
                                             renc=cp,
                                             colname=colname)),
         ])
     dialog.open()
Пример #4
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()
Пример #5
0
    def _create_popup(self, instance):
        # create popup layout
        content = BoxLayout(orientation='vertical', spacing='5dp')

        popup_width = min(0.95 * Window.width, dp(500))

        self.colorpicker = ColorPicker(
            color=list(map(float, self.value.split(','))))
        content.add_widget(self.colorpicker)

        # 2 buttons are created for accept or cancel the current value
        btnlayout = BoxLayout(size_hint_y=None, height='50dp', spacing='5dp')
        btn = Button(text='Ok')
        btn.bind(on_release=self._validate)
        btnlayout.add_widget(btn)
        btn = Button(text='Cancel')
        btn.bind(on_release=self._dismiss)
        btnlayout.add_widget(btn)
        content.add_widget(btnlayout)

        self.popup = popup = Popup(title=self.title,
                                   content=content,
                                   size_hint=(None, 0.8),
                                   width=popup_width)

        # all done, open the popup !
        popup.open()
Пример #6
0
def show_popup():
    show = P()  # Create a new instance of the P class
    clr_picker = ColorPicker()
    clr_picker.pos_hint = {"x": 0.05, "top": 0.99}
    show.add_widget(clr_picker)

    def on_color(instance, value):
        print("RGBA = ", str(value))  # or instance.color
        global mcolor
        res = tuple(value)
        mcolor = list(map(mul, res, (255, 255, 255, 255)))
        temp = 0
        temp = mcolor[0]
        mcolor[0] = mcolor[2]
        mcolor[2] = temp
        mcolor = tuple(mcolor)

        print(mcolor)

    clr_picker.bind(color=on_color)
    popupWindow = Popup(title="Popup Window",
                        content=show,
                        size_hint=(None, None),
                        size=(600, 600))
    # Create the popup window

    popupWindow.open()  # show the popup
Пример #7
0
    def addGraph(self,datapoint,xData,yData,dt):
        points = [t for t in zip((xData).astype(int),yData)];
        ymin = int(min(yData))
        ymax = int(max(yData))
        xmin = int(min(xData))
        xmax = int(max(xData))

        if self.setMinMax :
            if self.ids.graph.ymin > ymin:
                self.ids.graph.ymin = ymin
            if self.ids.graph.ymax < ymax:
                self.ids.graph.ymax = ymax
            if self.ids.graph.xmin > xmin:
                self.ids.graph.xmin = xmin
            if self.ids.graph.xmax < xmax:
                self.ids.graph.xmax = xmax  
        else:
            self.ids.graph.ymin = ymin
            self.ids.graph.ymax = ymax
            self.ids.graph.xmin = xmin
            self.ids.graph.xmax = xmax  
            self.setMinMax = True

        plot = LinePlot(color=self.color)
        plot.points = points
        self.ids.graph.add_plot(plot)
        index = random.randint(0,3)
        btn1 = ToggleButton(text=datapoint,background_color=self.color)
        btn1.bind(state=partial(self.on_press,datapoint))
        cp = ColorPicker(color=self.color)
        cp.bind(color=partial(self.on_color,datapoint))
        self.plotdata[datapoint] = {'color':self.color,'button':btn1,'plot':plot,'colorpick':cp,'points':points}
        self.color[index]=self.color[index] - (random.random());
        self.ids.hBox.add_widget(btn1)
        self.ids.hBoxColor.add_widget(cp)
Пример #8
0
    def _create_popup(self, instance) -> None:
        """ create popup layout  """
        oContent:BoxLayout = BoxLayout(orientation='vertical', spacing='5dp')
        self.popup = popup = Popup(title=self.title,content=oContent, size_hint=(0.9, 0.9))

        # Create the slider used for numeric input
        oColorpicker:ColorPicker = ColorPicker()
        self.oColorpicker = oColorpicker

        oContent.add_widget(oColorpicker)
        oContent.add_widget(SettingSpacer())

        oBtn:cMultiLineButton

        # 2 buttons are created for accept or cancel the current value
        oBtnlayout:BoxLayout = BoxLayout(size_hint_y=None, height='50dp', spacing='5dp')
        oBtn = cMultiLineButton(text=ReplaceVars('$lvar(5008)'), halign='center', valign='middle')
        oBtn.bind(on_release=self._validate)
        oBtnlayout.add_widget(oBtn)
        oBtn = cMultiLineButton(text=ReplaceVars('$lvar(5009)'), halign='center', valign='middle')
        oBtn.bind(on_release=self._dismiss)
        oBtnlayout.add_widget(oBtn)
        oContent.add_widget(oBtnlayout)
        oColorpicker.bind(color= self.On_Color)
        # all done, open the popup !

        oColorpicker.hex_color = self.value

        popup.open()
    def show(self, rgba, title="", width=400, height=430):

        self._accept = False
        self._rgba = rgba
        vbox_main = BoxLayout(orientation="vertical")
        hbox_buttons = BoxLayout(orientation="horizontal")
        hbox_buttons.size_hint_y = None
        hbox_buttons.height = 35
        btn_ok = Button(text="Ok", size_hint_y=None, height=30)
        btn_cancel = Button(text="Cancel", size_hint_y=None, height=30)
        self.cp = ColorPicker()
        self.cp.color = self._rgba

        #bind
        self.cp.bind(color=self.on_color)
        btn_ok.on_release = lambda: self.handle_color_picked(self._rgba)
        btn_cancel.on_release = lambda: self.popup.dismiss()

        #layout
        hbox_buttons.add_widget(btn_ok)
        hbox_buttons.add_widget(btn_cancel)
        vbox_main.add_widget(self.cp)
        vbox_main.add_widget(hbox_buttons)

        self.popup = Popup(title='',
                           content=vbox_main,
                           size_hint=(None, None),
                           size=(width, height))
        self.popup.open()
        print("size:", btn_ok.on_release)
Пример #10
0
 def __init__(self, **kw):
     super(ColorPickerContainer, self).__init__(**kw)
     brush = APP_CONTEXT.get('brush')
     self.color_picker = ColorPicker()
     if brush:
         self.color_picker.color = brush.color
     self.color_picker.bind(color=self.picker_callback)
     self.add_widget(self.color_picker)
Пример #11
0
    def createGraphicsPanel(self):
        self.graphicsPanel = BoxLayout(orientation='vertical', size_hint_y=0.6)

        graphicsIntro = BoxLayout(orientation='horizontal', size_hint_y=0.15)
        graphicsLabel = Label(text="Graphics")
        self.graphicsName = TextInput(hint_text="Object Name (e.g. center)",
                                      multiline=False)
        graphicsIntro.add_widget(graphicsLabel)
        graphicsIntro.add_widget(self.graphicsName)

        graphicsShape = BoxLayout(orientation='horizontal', size_hint_y=0.15)
        shapeLabel = Label(text="Shape")
        self.shapeSpinner = Spinner(values=["circle", "box", "arrow"])
        graphicsShape.add_widget(shapeLabel)
        graphicsShape.add_widget(self.shapeSpinner)

        graphicsColor = BoxLayout(orientation='horizontal')
        self.colorPicker = ColorPicker()
        graphicsColor.add_widget(self.colorPicker)

        graphicsSize = BoxLayout(orientation='horizontal', size_hint_y=0.15)
        self.sizeX = TextInput(hint_text="Size X",
                               multiline=False,
                               input_filter="float")
        self.sizeY = TextInput(hint_text="Size Y",
                               multiline=False,
                               input_filter="float")
        self.sizeZ = TextInput(hint_text="Size Z",
                               multiline=False,
                               input_filter="float")
        graphicsSize.add_widget(self.sizeX)
        graphicsSize.add_widget(self.sizeY)
        graphicsSize.add_widget(self.sizeZ)

        graphicsPosition = BoxLayout(orientation='horizontal',
                                     size_hint_y=0.15)
        self.posX = TextInput(hint_text="Pos X",
                              multiline=False,
                              input_filter="float")
        self.posY = TextInput(hint_text="Pos Y",
                              multiline=False,
                              input_filter="float")
        self.posZ = TextInput(hint_text="Pos Z",
                              multiline=False,
                              input_filter="float")
        graphicsSize.add_widget(self.posX)
        graphicsSize.add_widget(self.posY)
        graphicsSize.add_widget(self.posZ)

        graphicsButton = Button(text="Add Graphics Object to State", on_release=self.addGraphics,\
                                size_hint_y=0.15)
        self.graphicsPanel.add_widget(graphicsIntro)
        self.graphicsPanel.add_widget(graphicsShape)
        self.graphicsPanel.add_widget(graphicsColor)
        self.graphicsPanel.add_widget(graphicsSize)
        self.graphicsPanel.add_widget(graphicsPosition)
        self.graphicsPanel.add_widget(graphicsButton)
Пример #12
0
 def __init__(self, can, **kwargs):
     super(clr_pkr, self).__init__(**kwargs)
     self.pkr = ColorPicker(pos_hint={
         'center_x': 0.5,
         'center_y': 0.5
     },
                            size_hint=(1, 1))
     self.pkr.bind(color=lambda instance, value: can.add(
         Color(value[0], value[1], value[2], value[3])))
     self.pk()
Пример #13
0
    def draw_colorwheel(self, name) :
        draw.name = name
        clr_picker = ColorPicker(size_hint =(.5, .5), pos_hint ={"top":0.72, "right": 0.86})
        clr_picker.bind(color=self.on_color)

        if name == "ennemies_glow" :
            try :
                self.rl_visuals.remove_widget(self.rl_wheel_ennemies)
                self.rl_wheel_ennemies = None
                return
            except :
                self.rl_wheel_ennemies = RelativeLayout(size =(0, 0))
                self.rl_wheel_ennemies.add_widget(clr_picker)
                self.rl_visuals.add_widget(self.rl_wheel_ennemies)
        
        elif name == "allies_glow" :
            try :
                self.rl_visuals.remove_widget(self.rl_wheel_allies)
                self.rl_wheel_allies = None
                return
            except :
                self.rl_wheel_allies = RelativeLayout(size =(0, 0))
                self.rl_wheel_allies.add_widget(clr_picker)
                self.rl_visuals.add_widget(self.rl_wheel_allies)
        
        elif name == "ennemies_chams" :
            try :
                self.rl_visuals.remove_widget(self.rl_wheel_ennemies_chams)
                self.rl_wheel_ennemies_chams = None
                return
            except :
                self.rl_wheel_ennemies_chams = RelativeLayout(size =(0, 0))
                self.rl_wheel_ennemies_chams.add_widget(clr_picker)
                self.rl_visuals.add_widget(self.rl_wheel_ennemies_chams)
        
        elif name == "allies_chams" :
            try :
                self.rl_visuals.remove_widget(self.rl_wheel_allies_chams)
                self.rl_wheel_allies_chams = None
                return
            except :
                self.rl_wheel_allies_chams = RelativeLayout(size =(0, 0))
                self.rl_wheel_allies_chams.add_widget(clr_picker)
                self.rl_visuals.add_widget(self.rl_wheel_allies_chams)
            
        elif name == "ui_color" :
            try :
                self.rl_settings.remove_widget(self.rl_wheel_ui)
                self.rl_wheel_ui = None
                return
            except :
                self.rl_wheel_ui = RelativeLayout(size =(0, 0))
                self.rl_wheel_ui.add_widget(clr_picker)
                self.rl_settings.add_widget(self.rl_wheel_ui)
Пример #14
0
 def __init__(self, title, paint, **kwargs):
     super().__init__(**kwargs)
     self.paint = paint
     self.title = title
     self.colorpicker = ColorPicker(color=self.paint.BACKGROUND_COLOR)
     self.colorpicker.bind(color=self.set_bg)
     self.colorbox.add_widget(self.colorpicker)
     self.colorbox.add_widget(
         MDRectangleFlatButton(size_hint=(1, .1),
                               text='Close',
                               on_release=lambda btn: self.dismiss()))
Пример #15
0
    def __init__(self, **kwargs):
        super(GraphSettingsScreen, self).__init__(**kwargs)
        self.sp_n = None
        self.color_graph_nsave = None
        self.color_lines_nsave = None
        self.beta_step = None
        slider = Slider(orientation = 'horizontal', max = "1", min = 0.025, step = 0.005)
        gl = GridLayout(cols = 2)
        lbl1 = Label(text = "You can change color of graphic", font_size = 26)
        bl = BoxLayout(orientation = "vertical")
        bl_btns = BoxLayout(size_hint = (1, 0.3))

        colorpicker_graph = ColorPicker()
        colorpicker_lines = ColorPicker()
        self.lbl_detail = Label(text = "Mid", font_size = 26)
        lbl2 = Label(text = "You can change color of lines ", font_size = 26)
        btn_save = Button(text = "Save Changes", font_size = 26, on_press = self.save_settings)
        btn_return = Button(text = "Return", font_size = 26, on_press = self.return_main)
        n_input = TextInput(text = "14", multiline = False, font_size = 26)
        n_input.bind(text = self.change_n)
        colorpicker_graph.bind(color = self.on_color_graph)
        colorpicker_lines.bind(color = self.on_color_lines)
        slider.bind(value = self.detail)
        gl.add_widget(lbl1)
        gl.add_widget(colorpicker_graph)
        gl.add_widget(lbl2)
        gl.add_widget(colorpicker_lines)
        gl.add_widget(Label(text = "Print number of cordanate system", font_size = 26))
        gl.add_widget(n_input)
        gl.add_widget(slider)
        gl.add_widget(self.lbl_detail)
        bl_btns.add_widget(btn_save)
        bl_btns.add_widget(btn_return)
        bl_btns.add_widget(Button())
        bl.add_widget(gl)
        bl.add_widget(bl_btns)
        self.add_widget(BackgroudWidget())
        self.add_widget(bl)
Пример #16
0
    def dispMenu(self, sth):
        if self.evr.elemSelected is not None and self.isInfoDisplayed is False:
            self.rows = 2
            self.deleteBtn = DeleteBtn()
            self.deleteBtn.bind(on_press=self.evr.deleteElemSelec)
            self.add_widget(self.deleteBtn)
            self.isInfoDisplayed = True
            self.clr_picker = ColorPicker()
            self.clr_picker.bind(color=self.evr.elemSelected.changecolor)
            self.add_widget(self.clr_picker)

        if self.evr.elemSelected is None and self.isInfoDisplayed is True:
            self.clear_widgets()
            self.isInfoDisplayed = False
Пример #17
0
   def colorDialog(self, button): 
       # Create a layout for the widget
       layout = GridLayout(cols = 1, padding = 10);
       layout.spacing = [0, 5];
       # Add widget and close button
       clr_picker = ColorPicker();
       closeButton = Button(text ='Close', size_hint=(1, 0.075));
       layout.add_widget(clr_picker);          
       layout.add_widget(closeButton);      
 
       # Instantiate the modal popup and display 
       popup = Popup(title ='Pick a Color', content = layout, auto_dismiss=False);
       popup.open();
       # Bind the widgets with respective functions
       clr_picker.bind(color=self.pickColor);
       closeButton.bind(on_press=popup.dismiss);
    def change_color(self,*args):

        r,g,b,a = self.col[0], self.col[1], self.col[2], self.col[3]
        self.picker = ColorPicker(pos_hint={'center_x': .5, 'center_y': .5},
                                color = [r,g,b,a],
                                size_hint = (1,1))

        self.picker.add_widget(Button(text = 'Select',
                                  pos_hint = {'center_x': .76, 'y': -.02},
                                  size_hint = (.08, .08),
                                #   size = (100, 35),
                                  on_press = self.selected))

        self.edge_toggle = ToggleButton(text = 'Edge',
                                       pos_hint = {'center_x': .55, 'y': -.02},
                                       size_hint = (.08, .08),
                                    #    size = (100, 35),
                                       group = 'color',
                                       state = 'down')
        self.edge_toggle.bind(on_press = self.pressed_toggle_edge)
        self.picker.add_widget(self.edge_toggle)

        self.fill_toggle = ToggleButton(text = 'Fill',
                                            pos_hint = {'center_x': .63, 'y': -.02},
                                            size_hint = (.08, .08),
                                            # size = (100, 35),
                                            group = 'color')
        self.fill_toggle.bind(on_press = self.pressed_toggle_fill)
        self.picker.add_widget(self.fill_toggle)

        self.match_toggle = ToggleButton(text = 'Match',
                                            pos_hint = {'x': .8, 'y': -.02},
                                            size_hint = (.08, .08),
                                            # size = (100, 35),
                                            group = 'match')
        self.picker.add_widget(self.match_toggle)


        self.ColPop = Popup(title = "Choose Color",
                        size_hint = (.50, .50),
                        content = self.picker,
                        # size = (1500, 750),
                        auto_dismiss = True)

        self.ColPop.open()
Пример #19
0
class RGBW_Layout_Container(GridLayout):
    rgbw1 = ObjectProperty(RGBW_Led_Widget)
    rgbw2 = ObjectProperty(RGBW_Led_Widget)
    clr_picker = ColorPicker()

    def __init__(self, colors, config):
        super(RGBW_Layout_Container, self).__init__()
        self.rgbw1 = RGBW_Led_Widget(1, config)
        self.rgbw2 = RGBW_Led_Widget(2, config)
        #self.cols = 3
        self.cols = 2
        self.rgbw1.build(colors[1])
        self.add_widget(self.rgbw1)
        self.rgbw2.build(colors[2])
        self.add_widget(self.rgbw2)
        #self.add_widget(self.clr_picker)
    def build(self):
        return self
Пример #20
0
 def create_color_popup(self):
     self.color_popup = MyPopup()
     self.color_popup.title = 'Colors'
     bxl = BoxLayout(orientation='vertical', padding=25)
     clr_picker = ColorPicker(color=self.COLOR)
     clr_picker.bind(color=self.on_color)
     bxl.add_widget(clr_picker)
     self.random_color_select = MDSwitch()
     radmcolrbx = BoxLayout(size_hint=(1, .15))
     radmcolrbx.add_widget(Label(text='Use random colors:'))
     radmcolrbx.add_widget(self.random_color_select)
     bxl.add_widget(radmcolrbx)
     bxl.add_widget(
         MDRectangleFlatButton(
             text="Close",
             size_hint=(1, .1),
             on_release=lambda btn: self.color_popup.dismiss()))
     self.color_popup.add_widget(bxl)
Пример #21
0
    def open_colorpicker_popup(self, popup, _id, buttoninstance):
        colorPicker = ColorPicker(id=_id)
        buttonLayout = BoxLayout(orientation="horizontal",
                                 padding="5sp",
                                 size_hint_y=0.2)
        okButton = Button(
            text="OK",
            on_release= lambda but: \
                self.popup_dismissed(_id, colorPicker.hex_color, colorPicker.color, buttoninstance) and \
                popup.dismiss())
        cancelButton = Button(text="Cancel",
                              on_release=lambda but: popup.dismiss())
        buttonLayout.add_widget(okButton)
        buttonLayout.add_widget(cancelButton)

        mainLayout = BoxLayout(orientation="vertical")
        mainLayout.add_widget(colorPicker)
        mainLayout.add_widget(buttonLayout)
        return mainLayout
    def change_color_background(self,*args):

        r,g,b,a = self.col_background[0], self.col_background[1], self.col_background[2], self.col_background[3]
        self.picker_background = ColorPicker(pos_hint={'center_x': .5, 'center_y': .5},
                                color = [r,g,b,a],
                                size_hint = (1, 1))

        self.picker_background.add_widget(Button(text = 'Select',
                                  pos_hint = {'center_x': .76, 'y': -.02},
                                  size_hint = (.08, .08),
                                #   size = (100, 35),
                                  on_press = self.background_selected))
        self.ColPop_background = Popup(title = "Choose Background",
                        size_hint = (.5, .5),
                        content = self.picker_background,
                        # size = (1500, 750),
                        auto_dismiss = True)

        self.ColPop_background.open()
Пример #23
0
    def get_ok_cancel_content(self, popup):
        '''Return content with OK and cancel buttons for validating'''
        colorPicker = ColorPicker()
        buttonLayout = BoxLayout(orientation="horizontal",
                                 padding="5sp",
                                 size_hint_y=0.2)
        okButton = Button(
            text="Okay",
            on_release=lambda but: \
                popup.dismiss() and \
                self.popup_dismissed(popup, colorPicker.hex_color))
        cancelButton = Button(text="Cancel",
                              on_release=lambda but: popup.dismiss())
        buttonLayout.add_widget(okButton)
        buttonLayout.add_widget(cancelButton)

        mainLayout = BoxLayout(orientation="vertical")
        mainLayout.add_widget(colorPicker)
        mainLayout.add_widget(buttonLayout)
        return mainLayout
Пример #24
0
	def build(self):
		self.ids.setbox.clear_widgets()
		
		#create layout to display the data
		color_picker = ColorPicker()
		self.ids.setbox.add_widget(color_picker)
		
		#capture color selection
		def on_color(instance, value):
			RGBA = list(color_picker.hex_color[1:])
			
			A = (RGBA[6] + RGBA[7])
			B = (RGBA[4] + RGBA[5])
			G = (RGBA[2] + RGBA[3])
			R = (RGBA[0] + RGBA[1])
			
			global ARGB
			ARGB = A+R+G+B
			
		color_picker.bind(color=on_color) #binds to function above
    def _create_popup(self, instance):
        # create popup layout
        content = BoxLayout(orientation='vertical', spacing='5dp')
        popup_width = min(0.95 * Window.width, dp(500))
        self.popup = popup = Popup(title=self.title,
                                   content=content,
                                   size_hint=(None, 0.9),
                                   width=popup_width)

        # create the textinput used for numeric input
        # self.textinput = textinput = TextInput(
        #     text=self.value, font_size='24sp', multiline=False,
        #     size_hint_y=None, height='42sp')
        # textinput.bind(on_text_validate=self._validate)
        # self.textinput = textinput

        # construct the content, widget are used as a spacer
        # content.add_widget(Widget())
        # content.add_widget(textinput)
        self.colorpicker = colorpicker = ColorPicker(
            color=utils.get_color_from_hex(self.value))
        colorpicker.bind(on_color=self._validate)

        self.colorpicker = colorpicker
        content.add_widget(colorpicker)
        # content.add_widget(Widget())
        content.add_widget(SettingSpacer())

        # 2 buttons are created for accept or cancel the current value
        btnlayout = BoxLayout(size_hint_y=None, height='50dp', spacing='5dp')
        btn = Button(text='Ok')
        btn.bind(on_release=self._validate)
        btnlayout.add_widget(btn)
        btn = Button(text='Cancel')
        btn.bind(on_release=self._dismiss)
        btnlayout.add_widget(btn)
        content.add_widget(btnlayout)

        # all done, open the popup !
        popup.open()
Пример #26
0
 def messageShow(self, passcode, p):
     if passcode == self.code1:
         self.vt = 1
         p.dismiss()
     elif passcode == "exitevm":
         p.dismiss()
         sys.exit()
     elif passcode == self.code2:
         res = list()
         result_grid = GridLayout(cols = 2, padding = [50, 50, 50, 50], spacing = [5, 50], size_hint_y = None)
         for btn in self.buttons:
             a = self.result.find_one({'name': btn.text})
             res.append(a)
         res = sorted(res, key = itemgetter('votes'), reverse = True)
         for doc in res:
             result_grid.add_widget(Label(text = doc['name'], font_size = 24))
             result_grid.add_widget(Label(text = str(doc['votes']), font_size = 24))
         a = self.result.find_one({'name': 'counter'})
         result_grid.add_widget(Label(text = "Number of Voters", font_size = 32))
         result_grid.add_widget(Label(text = str(a['votes']), font_size = 32))
         scrollbar = ScrollView()
         scrollbar.add_widget(result_grid)
         result = Popup(title = "Results", content = scrollbar)
         p.content.text = ""
         result.open()
     elif passcode == "resetallvotes":
         self.result.update_many({'name': {'$exists': True}}, {'$set': {'votes': 0}})
         p.content.text = ""
     elif passcode == "factoryreset":
         self.client.drop_database(self.database)
         p.content.text = ""
         UpdateEVM().Update()
     elif passcode == "settings":
         self.settings_func(p)
         p.content.text = ""
     elif passcode == "colorpicker":
         color_w = ColorPicker()
         color_p = Popup(title = "Color Picker", content = color_w)
         p.content.text = ""
         color_p.open()
Пример #27
0
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     self.auto_dismiss = False
     self.size = (500, 500)
     self.size_hint = (None, None)
     self.cp = ColorPicker(size_hint=(1, 0.9), color=self.color)
     self.title_align = "center"
     self.title_color = [0, 0, 0, 1]
     self.background = ""
     self.separator_height = 0
     self.cp.bind(color=self.setter("background_color"))
     box = BoxLayout(orientation="vertical")
     box.add_widget(self.cp)
     self.ok_button = Button(text="Ok", on_press=self.on_choosed, size_hint=(1, 1))
     self.cancel_button = Button(
         text="Annuler", on_press=self.dismiss, size_hint=(1, 1)
     )
     button_box = BoxLayout(orientation="horizontal", size_hint=(1, 0.1))
     button_box.add_widget(self.ok_button)
     button_box.add_widget(self.cancel_button)
     box.add_widget(button_box)
     self.content = box
Пример #28
0
    def select_color(self, instance, no_buts=True):
        '''
        The button click has fired the event, so show the popup.
        no_buts is  boolean and specifies whether to include buttons
        in the popup or not.
        '''
        popup = Popup(title="Select your colour", size_hint=(0.75, 0.75))

        # NOTE: the below properties can also be passed in to the Popup
        # constructor but we do them separately for clarity.
        if no_buts:
            colorPicker = ColorPicker()
            popup.bind(
                on_dismiss=lambda popup: \
                    self.popup_dismissed(popup, colorPicker.hex_color))
            popup.content = colorPicker
        else:
            # We prevent the default dismiss behaviour and roll our own in
            # the content.
            popup.auto_dismiss = False
            popup.content = self.get_ok_cancel_content(popup)
        popup.open()
Пример #29
0
    def build(self):
        #create layout to display the data
        color_picker = ColorPicker()
        self.ids.setbox.add_widget(color_picker)

        #capture color selection
        def on_color(instance, value):
            #print "RGBA = ", str(value)  #  or instance.color
            #print "HSV = ", str(instance.hsv)
            #print "HEX = ", str(instance.hex_color)
            RGBA = list(color_picker.hex_color[1:])

            A = (RGBA[6] + RGBA[7])
            B = (RGBA[4] + RGBA[5])
            G = (RGBA[2] + RGBA[3])
            R = (RGBA[0] + RGBA[1])

            global ARGB
            ARGB = A + R + G + B
            print(ARGB)

        color_picker.bind(color=on_color)  #binds to function above
Пример #30
0
    def __init__(self, **kvargs):
        super(CDialog, self).__init__(**kvargs)

        box = BoxLayout(orientation='vertical')
        select_color = ColorPicker(hex_color=self.default_color)
        button_select = Button(
            text=self.text_button_ok, size_hint=(1, .1),
            background_normal=self.background_image_buttons[0],
            background_down=self.background_image_shadows[0]
        )

        box.add_widget(select_color)
        box.add_widget(Widget(size_hint=(None, .02)))
        box.add_widget(SettingSpacer())
        box.add_widget(Widget(size_hint=(None, .02)))
        box.add_widget(button_select)

        button_select.bind(
            on_press=lambda color: self.events_callback(select_color.hex_color),
            on_release=lambda *args: self.dismiss()
        )
        self.content = box
        self.open()