3:64a450b65b28
https://bitbucket.org/Wanvipa/gradeaenglish/commits/64a450b65b28268a454ce2f41c090f730ce5f264
========================================================================
from kivy.app import App
from kivy.lang import Builder
from kivy.config import Config
from kivy.metrics import dp, sp
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.widget import Widget
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.graphics import *
Builder.load_file("gui.kv")
# Declare both screens
class MenuScreen(Screen):
pass
class TranslateScreen(Screen):
pass
class KeepScreen(Screen):
pass
class PlayScreen(Screen):
pass
#ลดการจัดการหน้าเหลือแค่ 4 หน้า
# Create the screen manager
sm = ScreenManager()
sm.add_widget(MenuScreen(name='MENU'))
sm.add_widget(TranslateScreen(name='TRANSLATE'))
sm.add_widget(KeepScreen(name='KEEP'))
sm.add_widget(PlayScreen(name='SPELL'))
class TestApp(App):
def build(self):
Config.set('graphics' , 'width' , '300')
Config.set('graphics' , 'height' , '600')
#set not to change size window
# Config.set('graphics' , 'resizable' , False)
return sm
if __name__ == '__main__':
TestApp().run()
======================================================================================
<MenuScreen>:
BoxLayout:
orientation: 'vertical'
Label:
text:'Grade "A" English'
font_size:'60'
Button:
text: 'TRANSLATE'
on_press: root.manager.current = 'TRANSLATE'
Button:
text: 'KEEP'
on_press: root.manager.current = 'KEEP'
Button:
text: 'SPELL'
on_press: root.manager.current = 'SPELL'
Button:
text: 'EXIT'
on_press: root.manager.current = 'START'
<TranslateScreen>:
BoxLayout: #จัด layout แยกเป็น 2 กล่อง คือส่วนใส่ input กับ ส่วนแสดงผลและปุ่มกดต่างๆ
orientation: 'vertical'
BoxLayout:
orientation: 'vertical'
padding:50
TextInput:
id:'search'
size:[30,60]
BoxLayout:
orientation: 'vertical'
Button:
size:[30,30]
text: 'SEARCH'
#สำหรับแสดงผลความหมายกับคำเหมือน โดยให้แสดงออกมาเป็น label
Label:
text: 'Meaning'
Label:
text:'Synonym'
Button:
text: 'Back to menu'
on_press: root.manager.current = 'MENU'
<KeepScreen>:
BoxLayout:
orientation: 'vertical'
Label:
text: 'KEEP'
Button:
text:'word'
Button:
text: 'Back to menu'
on_press: root.manager.current = 'MENU'
<PlayScreen>:
BoxLayout:
orientation: 'vertical'
BoxLayout:
orientation: 'vertical'
Label:
text: 'Meaning'
TextInput:
id:'consonant'
BoxLayout:
GridLayout:
id:btn
cols: 3
rows: 4
text: 'consonant'
BoxLayout:
orientation: 'vertical'
Button:
text: 'Back to menu'
on_press: root.manager.current = 'MENU'
ไม่มีความคิดเห็น:
แสดงความคิดเห็น