파이썬[Python]: kivy - FileChooserIconView 클래스
kivy.uix.filechooser 모듈 - FileChooserIconView 클래스(class)
/// 설명
아이콘을 사용하여 FileChooserController 를 구현한 클래스입니다.
참고: uix 모듈 목록
※ 형식
FileChooserIconView(**kwargs)
reference
https://kivy.org/doc/stable/api-kivy.uix.filechooser.html
참고: uix 모듈 목록
※ 형식
FileChooserIconView(**kwargs)
reference
https://kivy.org/doc/stable/api-kivy.uix.filechooser.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 | import kivy kivy.require('2.0.0') import os from kivy.app import App from kivy.core.window import Window from kivy.uix.boxlayout import BoxLayout from kivy.uix.filechooser import FileChooserIconView from kivy.uix.textinput import TextInput from kivy.uix.button import Button from functools import partial Window.clearcolor = (.6, 1, .8, 1) Window.size = (563, 1001) Window.top, Window.left = 30, 800 class FantasticApp(App): def _load(self, fciv, bt_instance): with open(os.path.join(fciv.path, fciv.selection[0])) as stream: self.ti.text = stream.read() self.ti.cursor = (0, 0) # move cursor def build(self): self.ti = ti = TextInput() fciv = FileChooserIconView() fciv.path = os.getcwd() fciv.filters = ['*.txt', '*.py', '*.ini'] bt = Button(text='Load File', size_hint_y=None, height=200, on_release=partial(self._load, fciv)) bl = BoxLayout(orientation='vertical') bl.add_widget(ti) bl.add_widget(fciv) bl.add_widget(bt) return bl FantasticApp().run() | cs |
/// 출력
* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)
– 당신을 응원합니다. –
댓글
댓글 쓰기