1
私はドライバの数としてボタンを作成しましたが、私はこのためにループに使用しました。しかし、作成されたボタンのパスは同じでF:\だから、私は何をやるべきなのでしょうか?ここKivy、forループのボタンのパスを設定するには?
はPYファイルである: 'D:\'
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout
from kivy.utils import platform
class MyApp(BoxLayout):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.get_drivers()
def get_drivers(self):
if platform == 'win':
import win32api
box_drivers = self.ids.box_drivers
box_driversボタン
drivers = win32api.GetLogicalDriveStrings()
drivers = drivers.split('\x00')[:-1]
ここドライバ= [ '\ C' を含むボックスレイアウトであります、 'E:\'、 'F:\']
はKVファイルです:ここで
#:import os os
<MyApp>:
orientation: 'vertical'
BoxLayout:
BoxLayout:
id: box_drivers
size_hint_x:20
orientation: 'vertical'
Label:
text: 'Drivers'
size_hint_y:None
height: '40dp'
FileChooserIconView:
size_hint_x:80
id: file_chooser
filters: ['*.srt*']
on_selection: pass
path: os.getcwd()
アプリの画像です:
When i press drivers, they get same path(F:)