-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
勉強会での鈴木くんのアドバイスのもと
kvファイル上でscreen毎に分けて
pyファイル上で条件分岐をしようと思ったのですが
上手くいきませんでした。
プログラムの一部を載せます。
[pyファイル]
Subject = 0
Price = 0
class ForSmile1(FloatLayout):
class Screen2(Screen):
def on_command (self, command):
if command == 'list':
if Subject != 0 and Price == 0:
sm = ScreenManager()
sm.add_widget(ForSmile1(name='screen3'))
sm.add_widget(ForSmile1(name='screen2'))
elif command == 'Price':
if Subject == 0 and Price != 0:
sm = ScreenManager()
sm.switch_to(screen2)
presentation = Builder.load_file("ForSmile2.kv")
[kvファイル]
:
AnchorLayout:
anchor_x: 'center'
anchor_y: 'bottom'
ScreenManager:
size_hint: 1, .9
id: _screen_manager
:
Label:
markup: True
text: '[size=24]Welcome to [color=4169e1]ForSmile[/color][/size]'
<Screen2>:
BoxLayout:
orientation: 'vertical'
spacing: 10
BoxLayout:
orientation: 'vertical'
Label:
markup: True
text: '[size=20][color=dd88ff]List[/color][/size]'
color: 1, 0, 1, 1
size:(400, 20)
Button:
text: "2015.12.1 ******"
on_press: root.on_command('list')
font_size: 10
background_color: (1, 1, 1, 1)
size: (20,10)
Button:
text: "2016.4.1 ******"
on_press: root.on_command('list')
font_size: 10
background_color: (1, 1, 1, 1)
size: (20,10)
<Screen3>:
BoxLayout:
orientation: 'vertical'
spacing: 10
BoxLayout:
orientation: 'vertical'
Label:
markup: True
text: '[size=20][color=228b22]Donation[/color][/size]'
background_color: (1, 0 , 1, 1)
size:(400, 20)
Button:
text: "100yen"
on_press: Price = 100, root.on_command('Price')
font_size: 10
background_color: (1, 1, 1, 1)
size: (20,10)
Button:
text: "210yen"
on_press: Price = 210, root.on_command('Price')
font_size: 10
background_color: (1, 1, 1, 1)
size: (20,10)
Button:
text: "500yen"
on_press: Price = 500, root.on_command('Price')
font_size: 10
background_color: (1, 1, 1, 1)
size: (20,10)
Button:
text: "410yen"
on_press: Price = 410, root.on_command('Price')
font_size: 10
background_color: (1, 1, 1, 1)
size: (20,10)
Button:
text: "2000yen"
on_press: Price = 2000, root.on_command('Price')
font_size: 10
background_color: (1, 1, 1, 1)
size: (20,10)
Button:
text: "3000yen"
on_press: Price = 3000, root.on_command('Price')
font_size: 10
background_color: (1, 1, 1, 1)
size: (20,10)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels