Skip to content

Commit

Permalink
itemscreen - 1
Browse files Browse the repository at this point in the history
  • Loading branch information
vanguardmaster01 committed Sep 10, 2023
1 parent ee3e035 commit f8175f6
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 40 deletions.
2 changes: 1 addition & 1 deletion DbFuncs/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def get_product(id):
cursor = conn.cursor()

print(f'id: {id}')
select_query = '''select id, name, count, price from products where id = ?'''
select_query = '''select id, name, image, count, price from products where id = ?'''
cursor.execute(select_query, (id,))
record = cursor.fetchone()

Expand Down
61 changes: 54 additions & 7 deletions item.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
from kivy.app import App
from kivy.core.window import Window
from kivy.lang import Builder
from kivy.uix.button import ButtonBehavior
from kivy.uix.button import ButtonBehavior, Button
from kivy.uix.image import Image
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.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.texture import Texture
from kivy.properties import StringProperty
from PIL import Image as PILImage
import io
import math

Expand All @@ -23,7 +19,6 @@

from config import utils


class ItemScreen(Screen):
def __init__(self, **kwargs):
super(ItemScreen, self).__init__(**kwargs)
Expand All @@ -35,4 +30,56 @@ def set_item_id(self, id):

def draw_page(self, id):
product = db.get_product(id)
# print(product)

# display name
self.draw_title(product[1])

# display product (image, price, ...)
self.draw_product_info(product)

self.draw_bigo()

def draw_title(self, name):
titleLayout = self.ids.title_layout
titleLabel = Label(text=name)
titleLabel.color = '#c00000'
titleLabel.font_size = 30
titleLabel.size_hint_x = None
titleLabel.padding = [200, 5, 5, 5]
titleLayout.add_widget(titleLabel)

def draw_product_info(self, product):
image = Image()
image_stream = io.BytesIO(product[2])
img = CoreImage(image_stream, ext='png')
image.texture = img.texture
self.ids.image_layout.add_widget(image)

self.draw_label('Abc1234')
self.draw_label('600')
self.draw_label('20mg')
self.draw_label('40asda0mAh')
self.draw_label('2ml')

def draw_label(self, value):
boxLayout = BoxLayout()
boxLayout.size_hint_x = None
boxLayout.padding = [10, 2, 2, 2]

firstLabel = Label(text=value)
firstLabel.color = '#000000'
boxLayout.add_widget(firstLabel)
self.ids.info_layout.add_widget(boxLayout)

def draw_bigo(self):
bigoLayout = self.ids.bigo_layout
# Create an Image widget
img = Image(source='./img/bigo.png') # Replace 'your_image.png' with your image file path

# Calculate the position for the image (top-right corner)
image_x = utils.screenX - img.width - 50
image_y = utils.screenY / 4 - img.height / 2

# Draw the image on the canvas
with bigoLayout.canvas:
Rectangle(pos=(image_x, image_y), size=img.size, texture=img.texture)
119 changes: 87 additions & 32 deletions kv/list.kv
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,51 @@ WindowManager:
size: self.size

GridLayout:
rows: 3
rows: 4
GridLayout:
id: title_layout
cols: 2
size_hint_y: 0.2
padding: [20, 10, 20, 10]
canvas.before:
Color:
rgb: (1,1,1)
Rectangle:
pos: self.pos
size: self.size
Image:
source:'./img/back.png'
size: self.size
size_hint_x: None

GridLayout:
cols: 2
spacing: 10
BoxLayout:
padding: 10
size_hint_x: .6
RelativeLayout:
Image:
source: './img/1-1.png'
size: self.texture_size
id: image_layout

GridLayout:
rows: 2
size_hint_x: .4
GridLayout:
padding: 10, 50, 10, 10
cols: 2
spacing: 5
canvas.before:
Color:
rgb: (192,0,0)
Line:
width: 1
rectangle: self.x , self.y - 15 , self.width-10, self.height-10

GridLayout:
rows: 5
spacing: 5
Label:
text: 'Art.Nr:'
text: 'Art.sdasdadsNr:'
color: (0,0,0,1)
Label:
text: 'Züge:'
Expand All @@ -139,21 +163,8 @@ WindowManager:
GridLayout:
rows: 5
spacing: 5
Label:
text: 'ABC1234'
color: (0,0,0,1)
Label:
text: '600'
color: (0,0,0,1)
Label:
text: '20mg'
color: (0,0,0,1)
Label:
text: '400mAh'
color: (0,0,0,1)
Label:
text: '2ml'
color: (0,0,0,1)
id: info_layout

GridLayout:
cols: 3
spacing: 5
Expand All @@ -172,17 +183,61 @@ WindowManager:
spacing: 20
padding: 10, 20, 10, 20
size_hint: (1, 0.3)
Button:
text: '20.00 Eur'
color: (0,0,0,1)
background_normal: './img/bg-btn-1.png'
background_color: (1,1,1,0.5)
Button:
text: 'Buy'
background_color: (0,0,1,1)
border_radius: [20]
BoxLayout:
size_hint_x: 0.6
padding: [10, 0, 0, 0]
Button:
text: '20.00 Eur'
color: (0,0,0,1)
font_size: 30
background_normal: './img/bg-btn-1.png'
background_color: (1,1,1,0.5)
size_hint_x: None
size:(200, self.height)
BoxLayout:
size_hint_x: 0.4
padding: [10, 0, 0, 0]
Button:
id: round_button
canvas.before:
Color:
rgba: (1,.7,0.3,1) if self.state=='normal' else (1,0,0,1)
RoundedRectangle:
pos: self.pos
size: self.size
radius: [20,]

text: 'Buy'
color: (1,1,1,1)
font_size: 30
background_color: (1,1,1,0)
size_hint_x: None
size:(200, self.height)

BoxLayout:
size_hint:(1, 1)
RelativeLayout:

id: bigo_layout
size_hint:(1, 0.8)
orientation: 'vertical'
padding: [20, 20, 20, 20]
canvas.before:
Color:
rgb: (192,0,0)
Line:
width: 1
rectangle: self.x + 5 , self.y + 20 , self.width - 10, self.height - 50
Label:
text: 'Hello orldHello worldHello worldHello worldHello worldHello worldHello worldHello worldHello'
color: (0.1,0.1,0.1,.5)
Label:
text: 'Hello world'
color: (0.1,0.1,0.1,.5)
Label:
text: 'Hello world'
color: (0.1,0.1,0.1,.5)
Label:
text: 'Hello world'
color: (0.1,0.1,0.1,.5)
Label:
text: 'Hello world'
color: (0.1,0.1,0.1,.5)

0 comments on commit f8175f6

Please sign in to comment.