diff --git a/item.py b/item.py index 2a9f5c5..afa0278 100644 --- a/item.py +++ b/item.py @@ -106,11 +106,15 @@ def draw_bigo(self): def on_back_press(self, instance, touch): if instance.collide_point(*touch.pos): - print('back_pressed') + self.manager.current = 'List' + self.clear_widgets() + self.__init__() def on_buy_press(self): print(f'buy_pressed') + def on_money_button_press(self): + print('money_button_press') class CountNumber(GridLayout): @@ -157,4 +161,51 @@ def decrease_number(self, instance, touch): self.update_number() def update_number(self): - self.number_text.text = str(self.number) \ No newline at end of file + self.number_text.text = str(self.number) + + +class RoundedBorderGrid(GridLayout): + def __init__(self, **kwargs): + super(RoundedBorderGrid, self).__init__(**kwargs) + + self.bind(pos=self.update_canvas, size=self.update_canvas) + + def update_canvas(self, *args): + self.canvas.before.clear() + with self.canvas.before: + Color(1, 0, 0, 1) # Set the color of the border + + # Parameters for top left rounded corner + top_left_center = (self.x, self.top) + top_left_radius = 20 + + # Parameters for top right rounded corner + top_right_center = (self.right, self.top) + top_right_radius = 20 + + # Parameters for straight bottom corners + bottom_left = (self.x, self.y) + bottom_right = (self.right, self.y) + + self.draw_rounded_border(top_left_center, top_left_radius, top_right_center, top_right_radius, bottom_left, + bottom_right, width=2) + + def draw_rounded_border(self, top_left_center, top_left_radius, top_right_center, top_right_radius, bottom_left, + bottom_right, width=2): + diameter_top_left = top_left_radius * 2 + diameter_top_right = top_right_radius * 2 + + # Draw the top-left rounded corner + with self.canvas.before: + Bezier(points=[bottom_left, bottom_left, top_left_center[0] - top_left_radius, + top_left_center[1] + top_left_radius, bottom_left], segment_length=20, width=width) + + # Draw the top-right rounded corner + with self.canvas.before: + Bezier(points=[bottom_right, bottom_right, top_right_center[0] + top_right_radius, + top_right_center[1] + top_right_radius, bottom_right], segment_length=20, width=width) + + # Draw the straight bottom sides + with self.canvas.before: + Color(1, 1, 1, 1) # Set the color for straight borders + Bezier(points=[bottom_left, bottom_right], width=width) \ No newline at end of file diff --git a/kv/list.kv b/kv/list.kv index 5f13e94..03e38ff 100644 --- a/kv/list.kv +++ b/kv/list.kv @@ -222,8 +222,10 @@ WindowManager: font_size: 30 background_normal: './img/bg-btn-1.png' background_color: (1,1,1,0.5) + background_down: './img/price.png' size_hint_x: None size:(200, self.height) + on_press:root.on_money_button_press() BoxLayout: size_hint_x: 0.4 padding: [10, 0, 0, 0] @@ -279,4 +281,5 @@ WindowManager: size_hint_x: None text_size: self.width, None -: \ No newline at end of file +: +: \ No newline at end of file diff --git a/list.py b/list.py index 77cf831..ad7a340 100644 --- a/list.py +++ b/list.py @@ -6,11 +6,11 @@ from kivy.uix.label import Label from kivy.uix.screenmanager import ScreenManager, Screen from kivy.uix.floatlayout import FloatLayout -from kivy.uix.relativelayout import RelativeLayout +from kivy.uix.gridlayout import GridLayout from kivy.uix.boxlayout import BoxLayout from kivy.core.image import Image as CoreImage from kivy.clock import Clock -from kivy.graphics import Color, Rectangle +from kivy.graphics import Color, Rectangle, Bezier # from kivy.graphics.texture import Texture from kivy.properties import StringProperty from PIL import Image as PILImage @@ -139,7 +139,7 @@ def on_draw_category_item(self): return boxlayout - +# product image class ImageItem(Image): def __init__(self, **kwargs): super(ImageItem, self).__init__(**kwargs) @@ -152,7 +152,9 @@ def on_touch_down(self, touch): self.manager.current = 'Item' self.manager.get_screen("Item").set_item_id(self.name) +# top bar image class CategoryItem(Image): def __init__(self, **kwargs): super(CategoryItem, self).__init__(**kwargs) +