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()
class ColorPopup(Popup): color = ColorProperty() cp = ObjectProperty() 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 def on_choosed(self, button): self.color = self.cp.color self.dismiss()
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
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)
def show_color_picker(self, current_color): popup = Popup(title='Color Picker', size_hint=(0.5, 0.5)) color_picker = ColorPicker(color=current_color) color_picker.bind(color=self.on_paint_color) popup.content = color_picker popup.open()
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)
def choose_color(self): view = ModalView() clrpr = ColorPicker() view.add_widget(clrpr) view.open() def on_color(instance, value): self.color_picked = value clrpr.bind(color=on_color)
class ColorPickerContainer(Bubble): def __init__(self, *args, **kw): picked_callback = kw.get("picker_callback") super(ColorPickerContainer, self).__init__(*args, **kw) brush = APP_CONTEXT.get("brush") self.color_picker = ColorPicker() if brush: self.color_picker.color = brush.color self.color_picker.bind(color=picked_callback) self.add_widget(self.color_picker)
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)
class ColorPickerContainer(Bubble): """ color picker container """ picker_callback = ObjectProperty() 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)
class clr_pkr: 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() def pk(self): return self.pkr
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);
class ColorPopup(Popup): '''Color selector for background and center point''' colorbox = ObjectProperty() no_bg_switch = ObjectProperty() no_center_point_switch = ObjectProperty() 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())) def set_bg(self, instance, value): '''sets the background to the selected color''' if self.no_bg_switch.active: Window.clearcolor = list(value) self.paint.canvas.before.get_group('background')[0].a = 0 else: current_bg = self.paint.canvas.before.get_group('background')[0] current_bg.r = value[0] current_bg.g = value[1] current_bg.b = value[2] current_bg.a = value[3] self.paint.BACKGROUND_COLOR = value def disable_center_point(self): '''on off center point''' if self.no_center_point_switch.active: self.paint.canvas.before.get_group('center')[0].a = 0 else: self.paint.canvas.before.get_group('center')[0].a = 1 def disable_bg(self): '''makes the background invisible for saving or turns it back on''' if self.no_bg_switch.active: Window.clearcolor = list(self.paint.BACKGROUND_COLOR) self.paint.canvas.before.get_group('background')[0].a = 0 else: Window.clearcolor = (0, 0, 0, 1) self.paint.canvas.before.get_group('background')[0].a = 1
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)
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
class Modif(GridLayout): def __init__(self, evr): super(Modif, self).__init__() self.evr = evr self.isInfoDisplayed = False Clock.schedule_interval(self.dispMenu, 1 / 10) 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
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
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)
class ColorPickerScreen(Screen): def __init__(self, **kw): super().__init__(**kw) self.size_hint = 0.9, 0.9 self.pos_hint = {"center_x": 0.5, "center_y": 0.5} box = BoxLayout() box.orientation = "vertical" self.add_widget(box) self.pick_btn = MDRaisedButton(on_press=self.press_ok) self.pick_btn.size_hint = 1, 0.1 self.pick_btn.text = "пример" self.app = MDApp.get_running_app() self.current_color = None self.clr_picker = ColorPicker() self.clr_picker.bind(color=self.on_color) okbtn = MDRaisedButton(on_press=self.press_ok) okbtn.text = "принять" box.add_widget(self.pick_btn) box.add_widget(self.clr_picker) box.add_widget(okbtn) def press_ok(self, v): self.app.screen_manager.current = "settings_view" self.app.settings_view.options["color"].set_color(self.current_color) self.app.view.set_color(self.current_color) self.pick_btn.md_bg_color = self.current_color def on_color(self, instance, value): self.current_color = value self.pick_btn.md_bg_color = self.current_color
def get_configuration_subpanel(self, prop, owner, key): layout = StackLayout(orientation='lr-tb', size_hint=(None, None), width=dc.col_width, height=20) clr_picker = ColorPicker() if (key in rvit.core.pars.keys()): current_color = rvit.core.pars[key] clr_picker.color = current_color def on_color(instance, value): prop.set(owner, list(instance.color)) rvit.core.pars[key] = list(instance.color) clr_picker.bind(color=on_color) layout.add_widget( Label(text=prop.name, size_hint=(1.0, None), height=dc.text_height)) layout.add_widget(clr_picker) layout.height = 550 return layout
from kivy.uix.boxlayout import BoxLayout from kivy.app import App parent = BoxLayout() clr_picker = ColorPicker() parent.add_widget(clr_picker) # 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)) clr_picker.bind(color=on_color) class UltimateNoterApp(App): def build(self): return parent def on_pause(self): return True def on_resume(self): pass if __name__ == '__main__': UltimateNoterApp().run()
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)
def show_color_picker(self): popup = Popup(title='Color Picker', size_hint=(0.5, 0.5)) color_picker = ColorPicker() color_picker.bind(color=self.on_color) popup.content = color_picker popup.open()
from kivy.uix.colorpicker import ColorPicker clr_picker = ColorPicker() add_widget(clr_picker) def on_color(): print "RGBA = ", str(value) print "HSV = ", str(instance.hsv) print "HEX = ", str(instance.hex_color) clr_picker.bind(color=on_color)
class MainBox(BoxLayout): ''' Mainbox class ''' def __init__(self, **kwargs): ''' Init main class ui ''' super(MainBox, self).__init__(**kwargs) self.f_size = '15sp' # Shape Widget self.shape = Shape(size_hint=(0.7, 1)) self.add_widget(self.shape) # Right Menu self.panel = TabbedPanel(size_hint=(0.3, 1), do_default_tab=False) self.tab_param = TabbedPanelItem(text='Parameters') self.tab_color = TabbedPanelItem(text='Shape') self.tab_color_bg = TabbedPanelItem(text='Background') self.tab_export = TabbedPanelItem(text='Export') self.panel.add_widget(self.tab_param) self.panel.add_widget(self.tab_color) self.panel.add_widget(self.tab_color_bg) self.panel.add_widget(self.tab_export) self.menu_right = RightMenu( padding=15, orientation="vertical") # Switch mode line self.box_switch = BoxLayout(orientation='horizontal') self.mode_label = Label( text="Line mode", font_size=self.f_size, markup=True) self.box_switch.add_widget(self.mode_label) self.switch_mode = Switch(active=False) self.switch_mode.bind(active=self.on_switch) self.box_switch.add_widget(self.switch_mode) self.menu_right.add_widget(self.box_switch) # Size value self.box_size = BoxLayout(orientation='horizontal') self.size_label = Label( text="Shape size", font_size=self.f_size, markup=True) self.size_label_value = Label( text=str(self.shape.shape_size), font_size=self.f_size, markup=True) self.box_size.add_widget(self.size_label) self.box_size.add_widget(self.size_label_value) self.slider_shape_size = Slider( min=self.shape.property('shape_size').get_min(self.shape), max=self.shape.property('shape_size').get_max(self.shape), value=self.shape.shape_size, step=1) self.slider_shape_size.bind(value=self.change_shape_size) self.menu_right.add_widget(self.box_size) self.menu_right.add_widget(self.slider_shape_size) # Width point or line self.box_stroke = BoxLayout(orientation='horizontal') self.wdth_label = Label( text="Stroke width", font_size=self.f_size, markup=True) self.wdth_label_value = Label( text=str(self.shape.wdth), font_size=self.f_size, markup=True) self.box_stroke.add_widget(self.wdth_label) self.box_stroke.add_widget(self.wdth_label_value) self.slider_wdth = Slider( min=self.shape.property('wdth').get_min(self.shape), max=self.shape.property('wdth').get_max(self.shape), value=self.shape.wdth, step=1) self.slider_wdth.bind(value=self.change_wdth) self.menu_right.add_widget(self.box_stroke) self.menu_right.add_widget(self.slider_wdth) # a value self.box_a = BoxLayout(orientation='horizontal') self.a_label = Label( text="Param a ", font_size=self.f_size, markup=True) self.a_label_value = Label( text=str(self.shape.a), font_size=self.f_size, markup=True) self.box_a.add_widget(self.a_label) self.box_a.add_widget(self.a_label_value) self.slider_a = Slider( min=self.shape.property('a').get_min(self.shape), max=self.shape.property('a').get_max(self.shape), value=self.shape.a) self.slider_a.bind(value=self.change_a) self.menu_right.add_widget(self.box_a) self.menu_right.add_widget(self.slider_a) # b value self.box_b = BoxLayout(orientation='horizontal') self.b_label = Label( text="Param b ", font_size=self.f_size, markup=True) self.b_label_value = Label( text=str(self.shape.b), font_size=self.f_size, markup=True) self.box_b.add_widget(self.b_label) self.box_b.add_widget(self.b_label_value) self.slider_b = Slider( min=self.shape.property('b').get_min(self.shape), max=self.shape.property('b').get_max(self.shape), value=self.shape.b) self.slider_b.bind(value=self.change_b) self.menu_right.add_widget(self.box_b) self.menu_right.add_widget(self.slider_b) # m value self.box_m = BoxLayout(orientation='horizontal') self.m_label = Label( text="Param m ", font_size=self.f_size, markup=True) self.m_label_value = Label( text=str(self.shape.m), font_size=self.f_size, markup=True) self.box_m.add_widget(self.m_label) self.box_m.add_widget(self.m_label_value) self.slider_m = Slider( min=self.shape.property('m').get_min(self.shape), max=self.shape.property('m').get_max(self.shape), value=self.shape.m) self.slider_m.bind(value=self.change_m) self.menu_right.add_widget(self.box_m) self.menu_right.add_widget(self.slider_m) # n1 value self.box_n1 = BoxLayout(orientation='horizontal') self.n1_label = Label( text="Param n1 ", font_size=self.f_size, markup=True) self.n1_label_value = Label( text=str(self.shape.n1), font_size=self.f_size, markup=True) self.box_n1.add_widget(self.n1_label) self.box_n1.add_widget(self.n1_label_value) self.slider_n1 = Slider( min=self.shape.property('n1').get_min(self.shape), max=self.shape.property('n1').get_max(self.shape), value=self.shape.n1) self.slider_n1.bind(value=self.change_n1) self.menu_right.add_widget(self.box_n1) self.menu_right.add_widget(self.slider_n1) # n2 value self.box_n2 = BoxLayout(orientation='horizontal') self.n2_label = Label( text="Param n2 ", font_size=self.f_size, markup=True) self.n2_label_value = Label( text=str(self.shape.n2), font_size=self.f_size, markup=True) self.box_n2.add_widget(self.n2_label) self.box_n2.add_widget(self.n2_label_value) self.slider_n2 = Slider( min=self.shape.property('n2').get_min(self.shape), max=self.shape.property('n2').get_max(self.shape), value=self.shape.n2) self.slider_n2.bind(value=self.change_n2) self.menu_right.add_widget(self.box_n2) self.menu_right.add_widget(self.slider_n2) # n3 value self.box_n3 = BoxLayout(orientation='horizontal') self.n3_label = Label( text="Param n3 ", font_size=self.f_size, markup=True) self.n3_label_value = Label( text=str(self.shape.n3), font_size=self.f_size, markup=True) self.box_n3.add_widget(self.n3_label) self.box_n3.add_widget(self.n3_label_value) self.slider_n3 = Slider( min=self.shape.property('n3').get_min(self.shape), max=self.shape.property('n3').get_max(self.shape), value=self.shape.n3) self.slider_n3.bind(value=self.change_n3) self.menu_right.add_widget(self.box_n3) self.menu_right.add_widget(self.slider_n3) # Nb points self.box_nbp = BoxLayout(orientation='horizontal') self.nbp_label = Label( text="Points number ", font_size=self.f_size, markup=True) self.nbp_label_value = Label( text=str(self.shape.nbp), font_size=self.f_size, markup=True) self.box_nbp.add_widget(self.nbp_label) self.box_nbp.add_widget(self.nbp_label_value) self.slider_nbp = Slider( min=self.shape.property('nbp').get_min(self.shape), max=self.shape.property('nbp').get_max(self.shape), value=self.shape.nbp, step=2) self.slider_nbp.bind(value=self.change_nbp) self.menu_right.add_widget(self.box_nbp) self.menu_right.add_widget(self.slider_nbp) # Percent self.box_percent = BoxLayout(orientation='horizontal') self.percent_label = Label( text="Percent ", font_size=self.f_size, markup=True) self.percent_label_value = Label( text=str(self.shape.percent), font_size=self.f_size, markup=True) self.box_percent.add_widget(self.percent_label) self.box_percent.add_widget(self.percent_label_value) self.slider_percent = Slider( min=self.shape.property('percent').get_min(self.shape), max=self.shape.property('percent').get_max(self.shape), value=self.shape.percent, step=1) self.slider_percent.bind(value=self.change_percent) self.menu_right.add_widget(self.box_percent) self.menu_right.add_widget(self.slider_percent) # Travel self.box_travel = BoxLayout(orientation='horizontal') self.travel_label = Label( text="Travel ", font_size=self.f_size, markup=True) self.travel_label_value = Label( text=str(self.shape.travel), font_size=self.f_size, markup=True) self.box_travel.add_widget(self.travel_label) self.box_travel.add_widget(self.travel_label_value) self.slider_travel = Slider( min=self.shape.property('travel').get_min(self.shape), max=self.shape.property('travel').get_max(self.shape), value=self.shape.travel, step=2) self.slider_travel.bind(value=self.change_travel) self.menu_right.add_widget(self.box_travel) self.menu_right.add_widget(self.slider_travel) # ColorPicker for Shape self.picker = ColorPicker() self.picker.bind(color=self.on_color) # ColorPicker for background self.picker_bg = ColorPicker() self.picker_bg.bind(color=self.on_color_bg) # Export svg button self.export_button = Button(text='Export', size_hint=(1, 0.15)) self.export_button.bind(on_press=self.export) # Tab packs self.tab_param.add_widget(self.menu_right) self.tab_color.add_widget(self.picker) self.tab_color_bg.add_widget(self.picker_bg) self.tab_export.add_widget(self.export_button) self.add_widget(self.panel) # Popups self.pop_export = Popup( title="Export file", content=Label(text="File exported"), size_hint=(None, None), size=(640, 240)) def change_wdth(self, *args): ''' Change stroke width ''' self.shape.wdth = self.slider_wdth.value self.wdth_label_value.text = str(self.slider_wdth.value) def on_switch(self, *args): ''' Switch mode line or point ''' self.shape.line = self.switch_mode.active def on_color(self, *args): ''' Shape color ''' self.shape.color = self.picker.hex_color def on_color_bg(self, *args): ''' Shape background color ''' self.shape.bg_color = self.picker_bg.hex_color def change_shape_size(self, *args): ''' Shape size ''' self.shape.shape_size = self.slider_shape_size.value self.size_label_value.text = str(self.slider_shape_size.value) def change_a(self, *args): ''' a value ''' self.shape.a = self.slider_a.value self.a_label_value.text = str(self.slider_a.value) def change_b(self, *args): ''' b value ''' self.shape.b = self.slider_b.value self.b_label_value.text = str(self.slider_b.value) def change_m(self, *args): ''' m value ''' self.shape.m = self.slider_m.value self.m_label_value.text = str(self.slider_m.value) def change_n1(self, *args): ''' n1 value ''' self.shape.n1 = self.slider_n1.value self.n1_label_value.text = str(self.slider_n1.value) def change_n2(self, *args): ''' n2 value ''' self.shape.n2 = self.slider_n2.value self.n2_label_value.text = str(self.slider_n2.value) def change_n3(self, *args): ''' n3 value ''' self.shape.n3 = self.slider_n3.value self.n3_label_value.text = str(self.slider_n3.value) def change_nbp(self, *args): ''' point number ''' self.shape.nbp = self.slider_nbp.value self.nbp_label_value.text = str(self.slider_nbp.value) def change_percent(self, *args): ''' Percent value ''' self.shape.percent = self.slider_percent.value self.percent_label_value.text = str(self.slider_percent.value) def change_travel(self, *args): ''' Travel number ''' self.shape.travel = self.slider_travel.value self.travel_label_value.text = str(self.slider_travel.value) def export(self, *args): ''' Export to svg file ''' document = svgwrite.Drawing(filename='export.svg', debug=True) tmp = [(float("%.4g" % e)) for e in self.shape.path] # Export polygon if self.shape.line: svg_path = coupled(tmp) document.add(document.polygon(points=svg_path)) else: # Export points svg_path = coupled(coupled(tmp)) for elem in svg_path: document.add(document.line( start=elem[0], end=elem[1] )) document.save() self.shape.export_to_png('export.png') self.pop_export.open()
def modificar_valores_de_um(nome_botao, estoque_maximo, estoque_minimo, estoque_emergencial, estoque_atual): def on_color(instance, value): pass # or instance.color def modificar_valores_materiaprima_db(instance): tabela_pro_execute = [ estoque_maximo.text, estoque_minimo.text, estoque_emergencial.text, str(clr_picker.color), estoque_atual.text, nome_botao ] print(tabela_pro_execute) nome_pra_teste = [nome_botao] cursor_kamaleao.execute( "SELECT * from materia_prima WHERE nome =? ", nome_pra_teste) a = cursor_kamaleao.fetchone() print(a) conn_kamaleao.execute( "UPDATE materia_prima SET estoque_maximo = ?,estoque_minimo =?,estoque_emergencial=?,rgb=?,estoque_atual=? WHERE nome = ?", tabela_pro_execute) cursor_kamaleao.execute( "SELECT * from materia_prima WHERE nome =? ", nome_pra_teste) c = cursor_kamaleao.fetchone() print(c) clr_picker = ColorPicker() nome_pra_teste = [nome_botao] cursor_kamaleao.execute( "SELECT * from materia_prima WHERE nome =? ", nome_pra_teste) a = cursor_kamaleao.fetchone() estoque_maximo = a[1] estoque_minimo = a[2] estoque_emergencial = a[3] estoque_atual = a[5] layout_modificar_valores = GridLayout(cols=2) layout_modificar_valores.add_widget(Label(text="Nome")) nome = TextInput(multiline=False, text=str(nome_botao)) layout_modificar_valores.add_widget(nome) layout_modificar_valores.add_widget( Label(text="Estoque máximo\n (g)")) estoque_maximo = TextInput(multiline=False, input_filter='float', text=str(estoque_maximo)) layout_modificar_valores.add_widget(estoque_maximo) layout_modificar_valores.add_widget( Label(text="Estoque mínimo\n (%)")) estoque_minimo = TextInput(multiline=False, input_filter='float', text=str(estoque_minimo)) layout_modificar_valores.add_widget(estoque_minimo) layout_modificar_valores.add_widget( Label( text="Estoque Emergencial\n (%)") ) estoque_emergencial = TextInput( multiline=False, input_filter='float', text=str(estoque_emergencial)) layout_modificar_valores.add_widget( estoque_emergencial) layout_modificar_valores.add_widget( (Label(text="Estoque Atual\n (g)"))) estoque_atual = TextInput(multiline=False, input_filter='float', text=str(estoque_atual)) layout_modificar_valores.add_widget(estoque_atual) layout_modificar_valores.add_widget(Label(text="COR")) layout_modificar_valores.add_widget(clr_picker) clr_picker.bind(color=on_color) layout_modificar_valores_btt = Button( text="Adicionar no DataBase") layout_modificar_valores_btt.bind( on_press=modificar_valores_materiaprima_db) layout_modificar_valores.add_widget( layout_modificar_valores_btt) layout_modificar_valores_popup = Popup( title="MODIFICAR VALORES DA MATÉRIA PRIMA : " + nome_botao, content=layout_modificar_valores) layout_modificar_valores_popup.open()
def __init__(self, **kwargs): # Definitions defaults - config implementation later! self.newLabelColor = (0, 0, 0, 1) self.newLabelBgColor = (1, 1, 1, 1) self.newLabelWidth = 200 self.newLabelHeight = 80 self.store = kwargs.get("store") self.currentLayout = kwargs.get("currentLayout") self.engineRoot = kwargs.get("engineRoot") print("Access store -> ", self.store) # Prepare content content = GridLayout(orientation="lr-tb", spacing=1, padding=[150, 10, 150, 10], cols=2) clrPickerTextColor = ColorPicker(size_hint=(1, 10)) clrPickerBackgroundColor = ColorPicker(size_hint=(1, 10)) content.add_widget(Label(text='Label Name(Tag)')) self.buttonNameText = TextInput(text='MyLabel', halign="center", size_hint=(1, None), height=30) content.add_widget(self.buttonNameText) content.add_widget(Label(text='Label background color')) content.add_widget(clrPickerBackgroundColor) content.add_widget(Label(text='Label text color')) content.add_widget(clrPickerTextColor) content.add_widget(Label(text='Position X in pixels')) self.buttonPositionX = TextInput(text='0', halign="center", size_hint=(1, None), height=30) content.add_widget(self.buttonPositionX) content.add_widget(Label(text='Position Y in pixels')) self.buttonPositionY = TextInput(text='0', halign="center", size_hint=(1, None), height=30) content.add_widget(self.buttonPositionY) content.add_widget(Label(text='Position Hint X')) self.buttonPositionHintX = TextInput(text='0', halign="center", size_hint=(1, None), height=30) content.add_widget(self.buttonPositionHintX) content.add_widget(Label(text='Position Hint Y')) self.buttonPositionHintY = TextInput(text='0', halign="center", size_hint=(1, None), height=30) content.add_widget(self.buttonPositionHintY) content.add_widget(Label(text='Text', halign="center")) self.buttonText = TextInput(text='My Label Text', size_hint=(1, None), height=30) content.add_widget(self.buttonText) content.add_widget(Label(text='Font size', halign="center")) self.fontSizeBtn = TextInput(text='18', halign="center", size_hint=(1, None), height=30) content.add_widget(self.fontSizeBtn) content.add_widget(Label(text='Font Family', halign="center")) self.fontFamilyBtn = TextInput(text='Arial', halign="center", size_hint=(1, None), height=30) content.add_widget(self.fontFamilyBtn) # Bold check box #myCheckBold = BoxLayout() # myCheckBold.add_widget(Label(text='Use Bold')) content.add_widget(Label(text='Use Bold')) self.checkBoxBold = CheckBox(size_hint=(1, None), height=30) content.add_widget(self.checkBoxBold) self.checkBoxBold.bind( active=self.on_checkbox_bold_active) # pylint disable=no-member # myCheckDimSys = BoxLayout() # myCheckDimSys.add_widget(Label(text='Use Pixel Dimensions')) content.add_widget(Label(text='Use Pixel Dimensions')) self.checkboxDim = CheckBox(size_hint=(1, None), height=30) content.add_widget(self.checkboxDim) self.checkboxDim.bind( active=self.on_checkbox_active) # pylint disable=no-member content.add_widget(Label(text='Use Pixel for Width')) self.buttonWidthText = TextInput(text='200', halign="center", size_hint=(1, None), height=30) content.add_widget(self.buttonWidthText) content.add_widget(Label(text='Use Pixel for Height')) self.buttonHeightText = TextInput(text='100', halign="center", size_hint=(1, None), height=30) content.add_widget(self.buttonHeightText) #myCheckPerSys = BoxLayout() #myCheckPerSys.add_widget(Label(text='Use Pixel Dimensions')) content.add_widget(Label(text='Use Percent `hint` Dimensions')) self.checkboxPer = CheckBox(active=True) content.add_widget(self.checkboxPer) self.checkboxPer.bind( active=self.on_checkbox_per_active) # pylint disable=no-member content.add_widget( Label( text= 'Use percent dimensions for width `Range from 0 to 1 . Value 1 represent 100%` ' )) self.buttonHintX = TextInput(text='1', halign="center", size_hint=(1, None), height=30) content.add_widget(self.buttonHintX) content.add_widget( Label( text= 'Use percent dimensions for height `Range from 0 to 1 . Value 1 represent 100%` ' )) self.buttonHintY = TextInput(text='1', halign="center", size_hint=(1, None), height=30) content.add_widget(self.buttonHintY) # Popup self.popup = Popup(title='Add new label editor box', content=content, auto_dismiss=False) # Events attach clrPickerTextColor.bind(color=self.on_color) # pylint: disable=no-member clrPickerBackgroundColor.bind(color=self.on_bgcolor) # pylint: disable=no-member # Open popup self.popup.open() # Bind elements addNewLabelBtn = Button( text='[b]Add new Label[/b]', markup=True, size_hint=(1, None), height=70, color=self.engineRoot.engineConfig.getThemeTextColor(), background_normal='', background_color=(self.engineRoot.engineConfig.getThemeCustomColor( 'engineBtnsBackground')), on_press=lambda a: self.oAdd(self)) content.add_widget(addNewLabelBtn) cancelBtn = Button( text='[b]Cancel[/b]', markup=True, size_hint=(1, None), height=70, color=self.engineRoot.engineConfig.getThemeTextColor(), background_normal='', background_color=(self.engineRoot.engineConfig.getThemeCustomColor( 'engineBtnsBackground')), on_press=lambda a: self.oAdd(self)) content.add_widget(cancelBtn)
def adicionar_materiaPrima_func(instance): def on_color(instance, value): pass # or instance.color def adicionar_no_database(instance): lista_adicionar_materiaPrima_btt = [ nome.text, estoque_maximo.text, estoque_minimo.text, estoque_emergencial.text, str(clr_picker.color), estoque_atual.text ] cursor_kamaleao.execute( "INSERT INTO materia_prima VALUES(?,?,?,?,?,?)", lista_adicionar_materiaPrima_btt) # conn_kamaleao.commit() cursor_kamaleao.execute("SELECT * FROM materia_prima") materias_primas_bd = cursor_kamaleao.fetchall() for i in materias_primas_bd: print("i[1]= " + str(i[1])) print("i 0= " + str(i[0])) clr_picker = ColorPicker() layout_adicionar_materiaPrima = GridLayout(cols=2) layout_adicionar_materiaPrima.add_widget( Label(text="Nome")) nome = TextInput(multiline=False) layout_adicionar_materiaPrima.add_widget(nome) layout_adicionar_materiaPrima.add_widget( Label(text="Estoque máximo\n (g)")) estoque_maximo = TextInput(multiline=False, input_filter='float') layout_adicionar_materiaPrima.add_widget(estoque_maximo) layout_adicionar_materiaPrima.add_widget( Label(text="Estoque mínimo\n (%)")) estoque_minimo = TextInput(multiline=False, input_filter='float') layout_adicionar_materiaPrima.add_widget(estoque_minimo) layout_adicionar_materiaPrima.add_widget( Label(text="Estoque Emergencial\n (%)")) estoque_emergencial = TextInput(multiline=False, input_filter='float') layout_adicionar_materiaPrima.add_widget( estoque_emergencial) layout_adicionar_materiaPrima.add_widget( (Label(text="Estoque Atual\n (g)"))) estoque_atual = TextInput(multiline=False, input_filter='float') layout_adicionar_materiaPrima.add_widget(estoque_atual) layout_adicionar_materiaPrima.add_widget(Label(text="COR")) layout_adicionar_materiaPrima.add_widget(clr_picker) clr_picker.bind(color=on_color) layout_adicionar_materiaPrima_btt = Button( text="Adicionar no DataBase") layout_adicionar_materiaPrima_btt.bind( on_press=adicionar_no_database) layout_adicionar_materiaPrima.add_widget( layout_adicionar_materiaPrima_btt) layout_adicionar_materiaPrima_popup = Popup( title="Adicionar matéria prima", content=layout_adicionar_materiaPrima) layout_adicionar_materiaPrima_popup.open()
def __init__(self, **kwargs): # Definitions defaults - config implementation later! self.newBtnColor = (0, 0, 0, 1) self.newBtnBgColor = (1, 1, 1, 1) self.newBtnWidth = 200 self.newBtnHeight = 80 self.store = kwargs.get("store") self.currentLayoutId = kwargs.get("currentLayoutId") self.engineRoot = kwargs.get("engineRoot") print("Access currentLayoutId -> ", self.currentLayoutId) # Prepare content content = GridLayout(orientation="lr-tb", padding=[150, 0, 150, 0], cols=2) clrPickerTextColor = ColorPicker(size_hint=(1, 1)) clrPickerBackgroundColor = ColorPicker(size_hint=(1, 1)) content.add_widget(Label(text='Layout Name(Tag)')) self.buttonNameText = TextInput(text='MyBoxLayout') content.add_widget(self.buttonNameText) content.add_widget(Label(text='Layout Type(Visual type)')) # self.buttonNameText = AlignedTextInput(text='utton', halign="middle", valign="center") self.layoutTypeList = DropDown() self.selectBtn = Button(text='Box', on_press=self.layoutTypeList.open) content.add_widget(self.selectBtn) self.layoutTypeList.dismiss() #Anchor layout: #Box layout: #Float layout: #Grid layout: #Page Layout: #Relative layout: #Scatter layout: # Stack layout: self.btnBox = Button(text='Box', size_hint_y=None, height=44) self.btnBox.bind(on_release=partial(self.__setLayoutType)) self.layoutTypeList.add_widget(self.btnBox) self.btnAnchor = Button(text='Anchor', size_hint_y=None, height=44) self.btnAnchor.bind(on_release=partial(self.__setLayoutType)) self.layoutTypeList.add_widget(self.btnAnchor) self.btnFloat = Button(text='Float', size_hint_y=None, height=44) self.btnFloat.bind(on_release=partial(self.__setLayoutType)) self.layoutTypeList.add_widget(self.btnFloat) self.btnGrid = Button(text='Grid', size_hint_y=None, height=44) self.btnGrid.bind(on_release=partial(self.__setLayoutType)) self.layoutTypeList.add_widget(self.btnGrid) self.btnPage = Button(text='Page', size_hint_y=None, height=44) self.btnPage.bind(on_release=partial(self.__setLayoutType)) self.layoutTypeList.add_widget(self.btnPage) self.btnRelative = Button(text='Relative', size_hint_y=None, height=44) self.btnRelative.bind(on_release=partial(self.__setLayoutType)) self.layoutTypeList.add_widget(self.btnRelative) self.btnScatter = Button(text='Scatter', size_hint_y=None, height=44) self.btnScatter.bind(on_release=partial(self.__setLayoutType)) self.layoutTypeList.add_widget(self.btnScatter) self.btnStack = Button(text='Stack', size_hint_y=None, height=44) self.btnStack.bind(on_release=partial(self.__setLayoutType)) self.layoutTypeList.add_widget(self.btnStack) content.add_widget(self.layoutTypeList) colorHolder = BoxLayout(size_hint=(1, None), height=160) content.add_widget(colorHolder) colorHolder.add_widget(Label(text='Button background color')) colorHolder.add_widget(clrPickerBackgroundColor) colorHolderT = BoxLayout(size_hint=(1, None), height=160) content.add_widget(colorHolderT) colorHolderT.add_widget(Label(text='Button text color')) colorHolderT.add_widget(clrPickerTextColor) content.add_widget(Label(text='Orientation')) self.orientation = TextInput(text='vertical') content.add_widget(self.orientation) content.add_widget(Label(text='cols')) self.colsInput = TextInput(text='6') content.add_widget(self.colsInput) content.add_widget(Label(text='rows')) self.rowsInput = TextInput(text='0') content.add_widget(self.rowsInput) content.add_widget(Label(text='Padding')) self.layoutPadding = TextInput(text='0') content.add_widget(self.layoutPadding) content.add_widget(Label(text='Spacing')) self.layoutSpacing = TextInput(text="0") content.add_widget(self.layoutSpacing) #myCheckDimSys = BoxLayout() content.add_widget(Label(text='Use Pixel Dimensions')) #content.add_widget(myCheckDimSys) self.checkboxDim = CheckBox() content.add_widget(self.checkboxDim) self.checkboxDim.bind( active=self.on_checkbox_active) # pylint disable=no-member content.add_widget(Label(text='Use Pixel For Width')) self.buttonWidthText = TextInput(text='200') content.add_widget(self.buttonWidthText) content.add_widget(Label(text='Use Pixel For Height')) self.buttonHeightText = TextInput(text='100') content.add_widget(self.buttonHeightText) #myCheckPerSys = BoxLayout() content.add_widget(Label(text='Use Percent Dimensions')) #content.add_widget(myCheckPerSys) self.checkboxPer = CheckBox(active=True) content.add_widget(self.checkboxPer) self.checkboxPer.bind( active=self.on_checkbox_per_active) # pylint disable=no-member content.add_widget( Label(text='Use percent dimensions range(0 - 1). Width')) self.buttonHintX = TextInput(text='1') content.add_widget(self.buttonHintX) content.add_widget( Label(text='Use percent dimensions range(0 - 1). Height')) self.buttonHintY = TextInput(text='1') content.add_widget(self.buttonHintY) content.add_widget(Label(text='Position X in pixels')) self.buttonPositionX = TextInput(text='0', halign="center") content.add_widget(self.buttonPositionX) content.add_widget(Label(text='Position Y in pixels')) self.buttonPositionY = TextInput(text='0', halign="center") content.add_widget(self.buttonPositionY) content.add_widget(Label(text='Position Hint X')) self.buttonPositionHintX = TextInput(text='0', halign="center") content.add_widget(self.buttonPositionHintX) content.add_widget(Label(text='Position Hint Y')) self.buttonPositionHintY = TextInput(text='0', halign="center") content.add_widget(self.buttonPositionHintY) # Popup self.popup = Popup(title='Add new Layout editor box', content=content, auto_dismiss=False) # Events attach clrPickerTextColor.bind(color=self.on_color) # pylint: disable=no-member clrPickerBackgroundColor.bind(color=self.on_bgcolor) # pylint: disable=no-member # Open popup self.popup.open() # Bind elements commitBtn = Button( text='Add new Layout', size_hint=(1, None), height=88, color=self.engineRoot.engineConfig.getThemeTextColor(), background_color=(self.engineRoot.engineConfig.getThemeCustomColor( 'engineBtnsBackground')), on_press=lambda a: self.oAddBox(self)) content.add_widget(commitBtn) cancelBtn = Button( text='Cancel', size_hint=(1, None), height=88, color=self.engineRoot.engineConfig.getThemeTextColor(), background_color=(self.engineRoot.engineConfig.getThemeCustomColor( 'engineBtnsBackground')), on_press=lambda a: self.DissmisPopup(self)) content.add_widget(cancelBtn)
def __init__(self): super().__init__() color_picker = ColorPicker() self.add_widget(color_picker) color_picker.bind(color=self.on_color)
def __init__(self, **kwargs): # Definitions defaults - config implementation later! self.newBtnColor = (0, 0, 0, 1) self.newBtnBgColor = (1, 1, 1, 1) self.newBtnWidth = 200 self.newBtnHeight = 80 self.store = kwargs.get("store") self.currentLayout = kwargs.get("currentLayout") self.engineRoot = kwargs.get("engineRoot") print("Access store -> ", self.store) # Prepare content content = GridLayout(cols=2, padding=[150, 0, 150, 0], spacing=1) clrPickerTextColor = ColorPicker(size_hint=(1, 3)) clrPickerBackgroundColor = ColorPicker(size_hint=(1, 3)) content.add_widget( Label(text='Button Name(Tag)', size_hint=(1, None), height=30)) self.buttonNameText = TextInput(text='MyButton', halign="center", size_hint=(1, None), height=30) content.add_widget(self.buttonNameText) content.add_widget(Label(text='Text', size_hint=(1, None), height=30)) self.buttonText = TextInput(text='My Button Text', halign="center", size_hint=(1, None), height=30) content.add_widget(self.buttonText) content.add_widget( Label(text='Font size', size_hint=(1, None), height=30)) self.fontSizeBtn = TextInput(text='18', halign="center", size_hint=(1, None), height=30) content.add_widget(self.fontSizeBtn) content.add_widget( Label(text='Font Family', size_hint=(1, None), height=30)) self.fontFamilyBtn = TextInput(text='Arial', halign="center", size_hint=(1, None), height=30) content.add_widget(self.fontFamilyBtn) content.add_widget(Label(text='Button background color')) content.add_widget(clrPickerBackgroundColor) content.add_widget(Label(text='Button text color')) content.add_widget(clrPickerTextColor) content.add_widget( Label(text='Position X in pixels', size_hint=(1, None), height=30)) self.buttonPositionX = TextInput(text='0', halign="center", size_hint=(1, None), height=30) content.add_widget(self.buttonPositionX) content.add_widget( Label(text='Position Y in pixels', size_hint=(1, None), height=30)) self.buttonPositionY = TextInput(text='0', halign="center", size_hint=(1, None), height=30) content.add_widget(self.buttonPositionY) content.add_widget( Label(text='Position Hint X', size_hint=(1, None), height=30)) self.buttonPositionHintX = TextInput(text='0', halign="center", size_hint=(1, None), height=30) content.add_widget(self.buttonPositionHintX) content.add_widget( Label(text='Position Hint Y', size_hint=(1, None), height=30)) self.buttonPositionHintY = TextInput(text='0', halign="center", size_hint=(1, None), height=30) content.add_widget(self.buttonPositionHintY) # myCheckDimSys = BoxLayout(size_hint=(1,None), # height=30) content.add_widget( Label(text='Use Pixel Dimensions', size_hint=(1, None), height=30)) # content.add_widget(myCheckDimSys) self.checkboxDim = CheckBox(size_hint=(1, None), height=30) content.add_widget(self.checkboxDim) self.checkboxDim.bind( active=self.on_checkbox_active) # pylint disable=no-member #content.add_widget(Label(text='Use Pixel Dimensions Width', size_hint=(1,None), # height=30)) content.add_widget(Label(text='Width', size_hint=(1, None), height=30)) self.buttonWidthText = TextInput(text='200', halign="center", size_hint=(1, None), height=30) content.add_widget(self.buttonWidthText) content.add_widget(Label(text='Height', size_hint=(1, None), height=30)) self.buttonHeightText = TextInput(text='100', halign="center", size_hint=(1, None), height=30) content.add_widget(self.buttonHeightText) # myCheckPerSys = BoxLayout(size_hint=(1,None), # height=30) content.add_widget( Label(text='Use Percent Dimensions range[0-1]', size_hint=(1, None), height=30)) # content.add_widget(myCheckPerSys) self.checkboxPer = CheckBox(active=True, size_hint=(1, None), height=30) content.add_widget(self.checkboxPer) self.checkboxPer.bind( active=self.on_checkbox_per_active) # pylint disable=no-member #content.add_widget(Label(text='Use percent dimensions. Use 0.2 is 20%\ of parent width/height ', size_hint=(1,None), # height=30)) content.add_widget( Label(text='Width in percent range[0-1]', size_hint=(1, None), height=30)) self.buttonHintX = TextInput(text='1', halign="center", size_hint=(1, None), height=30) content.add_widget(self.buttonHintX) content.add_widget( Label(text='Height in percent range[0-1]', size_hint=(1, None), height=30)) self.buttonHintY = TextInput(text='1', halign="center", size_hint=(1, None), height=30) content.add_widget(self.buttonHintY) self.attachEventCurrentElement = Label( text="print('recommended edit from details box')", size_hint=(1, None), height=30) content.add_widget(self.attachEventCurrentElement) content.add_widget( TextInput(text='print("ATTACH EVENT WORKS")', size_hint=(1, None), height=30)) # Popup self.popup = Popup(title='Add new button editor box', content=content, auto_dismiss=False) # Events attach clrPickerTextColor.bind(color=self.on_color) # pylint: disable=no-member clrPickerBackgroundColor.bind(color=self.on_bgcolor) # pylint: disable=no-member # Open popup self.popup.open() # Bind elements infoBtn2 = Button( text='Add new button', size_hint=(1, None), height=70, font_size=18, background_normal='', background_color=(self.engineRoot.engineConfig.getThemeCustomColor( 'engineBtnsBackground')), color=self.engineRoot.engineConfig.getThemeTextColor(), on_press=lambda a: self.oAddBtn(self)) content.add_widget(infoBtn2) cancelBtn = Button( text='Cancel', font_size=18, size_hint=(1, None), height=70, background_normal='', background_color=(self.engineRoot.engineConfig.getThemeCustomColor( 'engineBtnsBackground')), color=self.engineRoot.engineConfig.getThemeTextColor(), on_press=lambda a: self.closePopup(self)) content.add_widget(cancelBtn)
class ColorDialog(Widget): def __init__(self, **kwargs): self._rgba = [1.0, 1.0, 1.0, 1.0] self._tmp_rgba = [1.0, 1.0, 1.0, 1.0] self.widget_props: set = {"rgba"} @property def accept(self): return self._accept @property def rgba(self): return self._rgba @rgba.setter def rgba(self, value): self._rgba = value 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) @property def rgba(self): return self._rgba @rgba.setter def rgba(self, value): self._rgba = value def on_color(self, instance, rgba): self._tmp_rgba = rgba def handle_color_picked(self, *args): self.rgba = self._tmp_rgba self.trigger_color_picked(*args) self.popup.dismiss() return True def handle_cancel(self, *args): self.popup.dismiss()