def __init__(self, *args, **kwargs): if 'color' in kwargs: self.background_color = kwargs['color'] del kwargs['color'] else: self.background_color = hex_color("#333333") if 'border_color' in kwargs: self.border_color = kwargs['border_color'] del kwargs['border_color'] else: self.border_color = hex_color("#595959") # left, top, right, bottom if 'border' in kwargs: self.border = kwargs['border'] if not isinstance(self.border, tuple): self.border = tuple([self.border] * 4) del kwargs['border'] else: self.border = (0, 0, 0, 0) super(CustomBoxLayout, self).__init__(*args, **kwargs) self.draw_instructions = None self.updateDraw() self.bind(size=self._update_rect, pos=self._update_rect)
def validate_form(self, amount, date, description) -> None: """ Validates data entered in the transaction form and calls for addition if the information is valid. """ data = {} validation_list = [] # Validate amount try: float(amount) data['amount'] = str(amount) validation_list.append(True) except ValueError: self.ids[ 'transaction_amount'].hint_text = "Please enter a valid amount" self.ids['transaction_amount'].hint_text_color = hex_color( "#CC241D") validation_list.append(False) # Validate date try: datetime.strptime(date, "%d/%m/%Y") data['date'] = str(date) validation_list.append(True) except ValueError: self.ids[ 'transaction_date'].hint_text = "Date entered does not match format dd/mm/yyyy" self.ids['transaction_date'].hint_text_color = hex_color("#CC241D") validation_list.append(False) # Validate description if len(description) == "0": self.ids[ 'transaction_description'].hint_text = "Please enter a description" self.ids['transaction_description'].hint_text_color = hex_color( "#CC241D") validation_list.append(False) else: data['description'] = str(description) validation_list.append(True) # Items that come from selectors and dropdowns data['account'] = str(self.account) data['category'] = str(self.category) data['transaction_type'] = self.transaction_type data['transaction_currency'] = str(self.currency) if False in validation_list: pass else: self.add_transaction(data)
def __init__(self, *args, **kwargs): self.class_color = kwargs['class_color'] self.index = kwargs['index'] self.class_name = kwargs['class_name'] del kwargs['class_color'] del kwargs['index'] del kwargs['class_name'] kwargs['orientation'] = 'horizontal' kwargs['size_hint_y'] = None kwargs['color'] = hex_color('#222222') kwargs['height'] = 36 kwargs['border'] = (1, 1, 1, 1) kwargs['padding'] = (1, 1, 1, 1) super(DropDownContourItem, self).__init__(*args, **kwargs) # We want to display the color of this item in a box on the # left of the button. After this, we want the index of the item # and then the class of the item. self.color_box = CustomBoxLayout(height=34, size_hint_y=None, width=47, size_hint_x=None, border=(8, 8, 9, 8), color=self.class_color) self.index_box = CustomBoxLayout(height=34, size_hint_y=None, width=47, color=hex_color('#222222'), size_hint_x=None, border=(0, 0, 1, 0)) self.index_label = Label(text=str(self.index)) self.index_box.add_widget(self.index_label) self.class_label_box = CustomBoxLayout(height=34, color=hex_color('#222222'), size_hint_y=None) self.class_label = Label(text=self.class_name) self.class_label_box.add_widget(self.class_label) self.add_widget(self.color_box) self.add_widget(self.index_box) self.add_widget(self.class_label_box)
def changeBorderColor(self, color): if color is None: self.border_color = hex_color("#595959") else: self.border_color = color self.updateDraw()
def updateColor(self, color): if color is None: self.background_color = hex_color("#333333") else: self.background_color = color self.updateDraw()
def _zoom_pressed(self, inst): if self.is_zooming: self.is_zooming = False self.zoom_button.background_color = self.saved_color else: self.saved_color = self.zoom_button.background_color self.zoom_button.background_color = hex_color('#616161') self.is_zooming = True
def __init__(self, *args, **kwargs): super(ClassSummary, self).__init__(*args, **kwargs) # The first item in this panel should be a dropdown containing # all of the contours in the current image. self.contour_select_dropdown = DropDown() self.contour_select_dropdown.auto_dismiss = False self.editor_box = CustomBoxLayout(orientation='vertical', padding=[8, 8, 8, 8], spacing=5) self.class_select_dropdown = DropDown() self.class_select_dropdown.auto_dismiss = False self.class_select_button = Button(text='Select Class', size_hint_y=None, height=30) self.class_select_button.bind(on_press=self._class_select_pressed) self.name_input = TextInput(text='Item Name', multiline=False, size_hint_y=None, height=30) self.comment_input = TextInput(text='Comments', multiline=True, size_hint_y=None, height=120) self.name_input.bind(text=self._name_text_changed) self.comment_input.bind(text=self._comment_text_changed) self.editor_box.add_widget(self.class_select_button) self.editor_box.add_widget(self.name_input) self.editor_box.add_widget(self.comment_input) self.dropdown_activator = DropDownContourItem( class_color=hex_color('#000000'), index=-1, class_name='none') self.dropdown_activator.bind(on_press=self._activator_pressed) self.add_widget(self.dropdown_activator) self.add_widget(self.editor_box) self.dropdown_open = False self.current_entry = None self.dataset = None self.contours = [] self.contour_dropdown_items = [] self.current_contour = None self.class_names = [] self.class_buttons = []
def change_state(self): card_data = { 'card_title': self.ids['card_title'].text, 'card_image': self.ids['card_image'].source, 'card_text': self.ids['card_text'].text } if self.state == 'down': with self.canvas.before: Color(0.2, 0.2, 0.2, 1) RoundedRectangle(size=self.size, pos=self.pos, radius=[36]) with self.canvas: RoundedRectangle(size=self.size, pos=self.pos, radius=[36], source='assets/img/card_black.png') self.ids['card_title'].color = hex_color('#FDFDFD') self.ids['card_image'].source = card_data['card_image'].replace( '.png', '_white.png') self.ids['card_text'].color = hex_color('#FDFDFD') else: with self.canvas.before: Color(0.949, 0.949, 0.949, 1) RoundedRectangle(size=self.size, pos=self.pos, radius=[36]) with self.canvas: RoundedRectangle(size=self.size, pos=self.pos, radius=[36], source='assets/img/card.png') self.ids['card_title'].color = hex_color('#333333') self.ids['card_image'].source = card_data['card_image'].replace( '_white.png', '.png') self.ids['card_text'].color = hex_color('#333333')
def __init__(self, *args, **kwargs): super(ImageDisplay, self).__init__(*args, **kwargs) self.toolbar = CustomBoxLayout( orientation='horizontal', size_hint_y=None, height=50, padding=[5, 5, 5, 5], spacing=5, border=(0, 0, 1, 0) ) self.zoom_button = Button( text='Zoom', size_hint_x=None, size_hint_y=1, width=70 ) self.reset_button = Button( text='Reset Zoom', size_hint_x=None, size_hint_y=1, width=120 ) self.contour_button = Button( text='New Contour', size_hint_x=None, size_hint_y=1, width=120 ) # This will store the geometry for any contours drawn on the image # by the user. Each contour will be stored as # (color, [[x0, y0], [x1, y1, ...]]) # The image_manager object will internally manage the graphics # objects necessary to draw these. self.contours = [] self.current_entry = None self.toolbar.add_widget(self.zoom_button) self.toolbar.add_widget(self.reset_button) self.toolbar.add_widget(self.contour_button) self.add_widget(self.toolbar) self.image_manager = ImageManager( border=(0, 0, 1, 0), padding=(3, 3, 4, 3) ) self.add_widget(self.image_manager) # These events just call the relevent function in this classes # image_manager instance and/or set flags that it reads. self.zoom_button.bind(on_press=self._zoom_pressed) self.reset_button.bind(on_press=self._reset_pressed) self.contour_button.bind(on_press=self._contour_pressed) self.is_zooming = False self.is_editing_contour = False # Tracks whether or not a contour has been added to the image # manager stack for the current contour. self.contour_on_stack = False self.default_colors = [ hex_color('#FF0000'), hex_color('#00FF00'), hex_color('#0000FF') ] self.dataset = None self.current_entry = None
from kivy.uix.label import Label from kivy.utils import get_color_from_hex as hex_color from kivy.utils import platform from kivy.clock import Clock if platform == "win": from kivy.config import Config Config.set("graphics", "resizable", False) Config.set("graphics", "width", 720) Config.set("graphics", "height", 780) os.environ['KIVY_GL_BACKEND'] = 'angle_sdl2' kivy.require('1.11.1') WHITE_CHOCOLATE = hex_color("#ECE5DD") TEA_GREEN = hex_color("#DCF8C6") GREEN = hex_color("#25D366") TEAL_GREEN = hex_color("#128C7E") BANGLADESH_GREEN = hex_color("#075e54") PICTON_BLUE = hex_color("34B7F1") GRAY_CHATEAU = hex_color("#9ca1a7") IRON = hex_color("#d7d8da") ROLLING_STONE = hex_color("#6c777d") EBONY_CLAY = hex_color("#232d36") AZTEC = hex_color("#101d25") # class MessageNotify(BoxLayout): # # def __init__(self, **kwargs): # super(MessageNotify, self).__init__(**kwargs)