본문 바로가기

파이썬/Kivy 예제

플래닛사이드 2 메인 메뉴 - 파이썬 Kivy

Kivy로 플래닛사이드 2의 메인 메뉴를 구현한 예제입니다.

파이썬 Kivy
파이썬 Kivy
파이썬 Kivy
파이썬 Kivy
파이썬 Kivy
파이썬 Kivy
파이썬 Kivy
파이썬 Kivy
파이썬 Kivy
파이썬 Kivy
파이썬 Kivy
파이썬 Kivy
파이썬 Kivy
파이썬 Kivy
파이썬 Kivy
파이썬 Kivy
파이썬 Kivy
파이썬 Kivy
파이썬 Kivy

from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.core.window import Window

Window.size = (1500,860)

kv = '''
Screen:

    BoxLayout:
        pos_hint : { 'x' : 0, 'y' : 0 }
        size_hint: (0.25,1)
        canvas:
            Color:
                rgba: 86/255.0, 97/255.0, 115/255.0, 1
            Rectangle:
                pos: self.pos
                size: self.size
                    
    MDLabel:
        pos_hint : { 'x' : 0.01, 'y' : 0.91 }
        size_hint : ( 0.24, 0.07 )
        text : "PLANETSIDE 2"
        halign: "center"
        theme_text_color: 'Custom'
        text_color : 1,1,1,1
        
    MDLabel:
        pos_hint : { 'x' : 0.01, 'y' : 0.85 }
        size_hint : ( 0.24, 0.04 )
        text : "CHARACTERS          1/7"
        halign: "center"
        theme_text_color: 'Custom'
        text_color : 67/255.0, 189/255.0, 217/255.0,1
    
    ScrollView:
        pos_hint : { 'x' : 0.01, 'y' : 0.39 }
        size_hint : ( 0.24, 0.43 )
        MDList:
            OneLineAvatarListItem:
                text: "MapleLiberty"
                theme_text_color: 'Custom'
                text_color : 175/255.0, 226/255.0, 237/255.0,1
                ImageLeftWidget:
                    source: "data/a.png"
            OneLineAvatarListItem:
                text: "<OPEN CHARACTER SLOT>"
                theme_text_color: 'Custom'
                text_color : 175/255.0, 226/255.0, 237/255.0,1
                ImageLeftWidget:
                    source: "data/b.png"
            OneLineAvatarListItem:
                text: "<OPEN CHARACTER SLOT>"
                theme_text_color: 'Custom'
                text_color : 175/255.0, 226/255.0, 237/255.0,1
                ImageLeftWidget:
                    source: "data/b.png"
            OneLineAvatarListItem:
                text: "<OPEN CHARACTER SLOT>"
                theme_text_color: 'Custom'
                text_color : 175/255.0, 226/255.0, 237/255.0,1
                ImageLeftWidget:
                    source: "data/b.png"
            OneLineAvatarListItem:
                text: "<OPEN CHARACTER SLOT>"
                theme_text_color: 'Custom'
                text_color : 175/255.0, 226/255.0, 237/255.0,1
                ImageLeftWidget:
                    source: "data/b.png"
            OneLineAvatarListItem:
                text: "<OPEN CHARACTER SLOT>"
                theme_text_color: 'Custom'
                text_color : 175/255.0, 226/255.0, 237/255.0,1
                ImageLeftWidget:
                    source: "data/b.png"
            OneLineAvatarListItem:
                text: "<OPEN CHARACTER SLOT>"
                theme_text_color: 'Custom'
                text_color : 175/255.0, 226/255.0, 237/255.0,1
                ImageLeftWidget:
                    source: "data/b.png"
    
    MDRectangleFlatIconButton:
        pos_hint : { 'x' : 0.01, 'y' : 0.33 }
        size_hint : ( 0.11, 0.03 )
        icon : "plus"
        text : "CREATE CHARACTER"
        text_color : 1,1,1,1
        font_size : 11
        md_bg_color : 82/255.0, 168/255.0, 154/255.0, 1
        
    MDRectangleFlatIconButton:
        pos_hint : { 'x' : 0.13, 'y' : 0.33 }
        size_hint : ( 0.11, 0.03 )
        icon : "minus"
        text : "DELETE CHARACTER"
        text_color : 1,1,1,1
        font_size : 11
        md_bg_color : 82/255.0, 168/255.0, 154/255.0, 1
        
    MDRectangleFlatButton: 
        pos_hint : { 'x' : 0.01, 'y' : 0.02 }
        size_hint : ( 0.23, 0.08 )
        text: "PLAY"
        text_color: 1, 1, 1, 1
        font_size : 30
        md_bg_color: 0/255.0, 173/255.0, 113/255.0, 1
        
    MDRectangleFlatIconButton: 
        pos_hint : { 'x' : 0.93, 'y' : 0.91 }
        size_hint : ( 0.07, 0.05 )
        icon : "exit-to-app"
        text: "EXIT"
        text_color: 0, 0, 0, 1
        
    MDRectangleFlatIconButton:  
        pos_hint : { 'x' : 0.93, 'y' : 0.02 }
        size_hint : ( 0.07, 0.05 )
        icon : "cogs"
        text: "SETTINGS"
        text_color: 0, 0, 0, 1
        font_size : 11
        
    BoxLayout:
        pos_hint : { 'x' : 0.76, 'y' : 0.6 }
        size_hint : ( 0.15, 0.24 )
        orientation : "vertical"
        
        BoxLayout:
            size_hint: (1,0.25)
            orientation: "vertical"
            canvas:
                Color:
                    rgba: 41/255.0, 103/255.0, 117/255.0, 1
                Rectangle:
                    pos: self.pos
                    size: self.size
            
            MDLabel:
                text: "US East"
                theme_text_color: 'Custom'
                text_color : 67/255.0, 189/255.0, 217/255.0,1
                padding_x : 5
                
            MDLabel:
                text: "Server Population"
                theme_text_color: 'Custom'
                text_color : 67/255.0, 189/255.0, 217/255.0,1
                padding_x : 5
      
        BoxLayout:
            size_hint: (1,0.5)
            canvas:
                Color:
                    rgba: 41/255.0, 103/255.0, 117/255.0, 0.5
                Rectangle:
                    pos: self.pos
                    size: self.size
            
            MDProgressBar:
                size_hint : (0.33,1)
                value : 36
                color : 75/255.0, 0/255.0, 130/255.0, 1
                orientation : "vertical"
                 
            MDProgressBar:
                size_hint : (0.33,1)
                value : 32
                color : 178/255.0, 34/255.0 , 34/255.0, 1
                orientation : "vertical"
                
            MDProgressBar:
                size_hint : (0.33,1)
                value : 32
                color : 0/255.0 ,191/255.0 ,255/255.0, 1
                orientation : "vertical"
            
        GridLayout:
            size_hint : (1,0.25)
            cols : 3
            canvas:
                Color:
                    rgba: 41/255.0, 103/255.0, 117/255.0, 1
                Rectangle:
                    pos: self.pos
                    size: self.size
            
            MDLabel:
                size_hint : (0.165,1)
                text : "36"
                halign : "center"
                theme_text_color: 'Custom'
                text_color : 1,1,1,1                
            
            MDLabel:
                size_hint : (0.165,1)
                text : "32"
                halign : "center"
                theme_text_color: 'Custom'
                text_color : 1,1,1,1
            
            MDLabel:
                size_hint : (0.165,1)
                text : "32"
                halign : "center"
                theme_text_color: 'Custom'
                text_color : 1,1,1,1
            
            MDIcon:
                size_hint : (0.165,1)
                source : "data/c.png"
                size_hint_x : None
                width: 30
                
            MDIcon:
                size_hint : (0.165,1)
                source : "data/d.png"
                size_hint_x : None
                width: 30
            
            MDIcon:
                size_hint : (0.165,1)
                source : "data/e.png"
                size_hint_x : None
                width: 30
'''


class MainApp(MDApp):

    def build(self):
        screen = Builder.load_string(kv)
        return screen


MainApp().run()