파이썬[Python]: kivy - BorderImage 클래스
kivy.graphics 모듈 - BorderImage 클래스(class)
/// 설명
테두리에 이미지를 부여합니다.
참고: graphics 모듈 목록
※ 형식
BorderImage(**kwargs)
reference
https://kivy.org/doc/stable/api-kivy.graphics.html
참고: graphics 모듈 목록
※ 형식
BorderImage(**kwargs)
reference
https://kivy.org/doc/stable/api-kivy.graphics.html
/// 예제
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | import kivy kivy.require('2.0.0') from kivy.app import App from kivy.core.window import Window from kivy.graphics import BorderImage from kivy.uix.boxlayout import BoxLayout from kivy.uix.image import Image from kivy.uix.label import Label Window.clearcolor = (1, 1, 1, 1) Window.size = (563, 1001) Window.top, Window.left = 30, 2900 class FantasticApp(App): def update_pos(self, inst, value): img_bottom_left = (self.img.size[0] - self.img.norm_image_size[0]) / 2, \ (self.img.size[1] - self.img.norm_image_size[1]) / 2 b_pos = (self.img.pos[0] + img_bottom_left[0], self.img.pos[1] + img_bottom_left[1]) with self.img.canvas.before: BorderImage( source='./football.png', pos=(b_pos[0]-10, b_pos[1]-10), size=(220, 220), border=(10, 10, 10, 10) ) def build(self): bl = BoxLayout(orientation='vertical') self.img = img = Image(source='./basketball.png') img.bind(size=self.update_pos) bl.add_widget(img) bl.add_widget(Label(text='BorderImage', color='black', font_size=50)) return bl FantasticApp().run() | cs |
/// 출력
* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)
– 당신을 응원합니다. –
댓글
댓글 쓰기