Please help. I am writing a simple app in kivymd that allows you to crop images, but images in Boxlayout are smaller. Here’s the part of the code:
KV = ”’
ScreenManager:
CameraScreen:
PhotoScreen:
SelectionScreen:
:
name: ‘camera’
BoxLayout:
padding: 20
orientation: ‘vertical’
Camera:
id: camera
resolution: (640, 480)
play: True
Button:
size_hint: (0.4, 0.4)
pos_hint: {‘center_x’: 0.5, ‘center_y’:0.8}
background_normal : ‘camera_icon.png’
background_down :’camera_icon.png’
on_release: root.capture()
:
name: ‘photo’
BoxLayout:
padding: 20
orientation: ‘vertical’
Image:
id: photo_image
source: ”
BoxLayout:
spacing: 10
padding: 10
orientation: ‘horizontal’
MDRoundFlatButton:
text: ‘New photo’
on_release: root.take_new_photo()
MDFillRoundFlatButton:
text: ‘Result’
on_release: root.show_hello_world()
pos_hint: {‘center_y’:0.4}
size_hint: (1, 0.4)
MDRoundFlatButton:
text: ‘Select Area’
on_release: root.select_area()
:
name: ‘selection’
BoxLayout:
orientation: ‘vertical’
Image:
id: photo_image2
source: ”
allow_stretch: True
keep_ratio: True
BoxLayout:
spacing:180
padding:10
orientation: ‘horizontal’
MDFillRoundFlatButton:
text: ‘Select’
on_release: root.select_area()
MDRoundFlatButton:
text: ‘Back’
on_release: root.to_photo()
”’
class CameraScreen(MDScreen):
def capture(self):
camera = self.ids[‘camera’]
timestr = time.strftime(“%Y%m%d_%H%M%S”)
camera.export_to_png(‘photo_{}.png’.format(timestr))
self.manager.current = ‘photo’
self.manager.get_screen(‘photo’).ids.photo_image.source = ‘photo_{}.png’.format(timestr)
self.manager.get_screen(‘selection’).ids.photo_image2.source = ‘photo_{}.png’.format(timestr)
I’ve tried to use size_hint and fit_mode, but it didn’t work and image stayed the same size.
P.S. Sorry for bad English
poyo pyuo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.