def display_itemlist(self, itemlist): self.clear_widgets() for item in itemlist: w = Builder.template(self.item_template, **item) self.add_widget(w)
def build(self): self.theme_cls.primary_palette = "Yellow" screen = Builder.load_string(screen_helper) return screen
def build(self): obj = Builder.load_string(kv) return obj
self.parent.parent.current = "ventana_login" print(self.cerrar_sesion.__name__ + ": Finalizado") def ayuda(self): # webbrowser.open('http://www.google.com') # Android dont support webbrowser library print("Android dont supp webbrowser") pass class admin(MDApp): def __init__(self, **kwargs): self.title = "Administrador" self.theme_cls.primary_palette = "Blue" super().__init__(**kwargs) def build(self): return Ventana_admin() try: Builder.load_file("ventanas/admin/admin.kv") except Exception as e: print(e) if __name__ == "__main__": aplicacion = admin() aplicacion.run()
from kivy.uix.screenmanager import Screen from akivymd.uix.progressbutton import AKProgressbutton from kivymd.uix.button import MDFillRoundFlatIconButton Builder.load_string(""" #:import MDFillRoundFlatIconButton kivymd.uix.button.MDFillRoundFlatIconButton <ProgressButton>: name: 'ProgressButton' BoxLayout: orientation: 'vertical' MDToolbar: title: root.name left_action_items:[['arrow-left' , lambda x:app.show_screen('Home','back') ]] FloatLayout: AKProgressbutton: id: progressbutton_success pos_hint: {'center_x': .5, 'center_y':.7} button: MDFillRoundFlatIconButton(text='Start', on_release= root.success, icon='language-python') AKProgressbutton: id: progressbutton_failure pos_hint: {'center_x': .5, 'center_y':.3} button: MDFillRoundFlatIconButton(text='Start', on_release= root.failure, icon='language-python') """) class ProgressButton(Screen): def __init__(self, **kw): super().__init__(**kw)
def build(self): self.theme_cls.primary_palette = 'Blue' self.theme_cls.primary_hue = 'A700' screen = Builder.load_string(screen_manager) return screen
Builder.load_string(""" <SongPlayer>: canvas.after: Color: rgba: 0, 0, 0, .5 if self.disabled else 0 Rectangle: size: self.size pos: self.pos rows: 1 size_hint_y: None height: '44dp' disabled: not root._song SongPlayerStop: size_hint_x: None song: root width: '44dp' source: root.image_stop allow_stretch: True SongPlayerPlayPause: size_hint_x: None song: root width: '44dp' source: root.image_pause if root.state == 'play' else root.image_play allow_stretch: True SongPlayerVolume: song: root size_hint_x: None width: '44dp' source: root.image_volumehigh if root.volume > 0.8 else (root.image_volumemedium if root.volume > 0.4 else (root.image_volumelow if root.volume > 0 else root.image_volumemuted)) allow_stretch: True Widget: size_hint_x: None width: 5 SongPlayerProgressBar: song: root max: 1 value: root.position Widget: size_hint_x: None width: 10 """)
def build(self): Builder.load_string(kv) return ServiceUI()
from kivy.properties import ObjectProperty from generalElements.buttons.NormalButton import NormalButton from kivy.lang.builder import Builder Builder.load_string(""" <ExitFullscreenButton>: text: 'Back' """) class ExitFullscreenButton(NormalButton): owner = ObjectProperty() def on_press(self): self.owner.fullscreen = False
magic_lib = card_library.create_update_cards_db() return magic_lib def pressed_load_db(self): os.chdir('database/magic_cards') print(os.getcwd()) magic_lib = card_library.load_cards_db() return magic_lib print(os.getcwd()) os.chdir('..') os.chdir('..') kv = Builder.load_file('mtg.kv') class MTGApp(App): def build(self): return kv MTGApp().run() select = input('What mode do you want to play? ') selecting = True while selecting: if select == '1': print('Player One...') p1_deck, p1_commander = DeckBuild.deck_manager()
from kivy.uix.spinner import Spinner from kivy.uix.textinput import TextInput from utils import async_upload_levels_to_quest, async_get_details, async_get_levels, get_song_urls, \ get_sanitized_filename, commit_to_quest Config.set('input', 'mouse', 'mouse,multitouch_on_demand') Builder.load_string(''' <WrapButton>: halign: "center" font_size: 15 text_size : self.width, None height: 40 size_hint_y: None <WrapSpinner>: sync_height: True halign: "center" font_size: 15 height: 40 text_size : self.width, None height: self.texture_size[1] ''') class WrapButton(Button): pass class WrapSpinner(Spinner): def __init__(self, **kwargs):
from kivy.app import App from kivy.uix.settings import SettingItem from kivy.lang.builder import Builder Builder.load_string(""" <SettingDatabaseImport>: WideButton: text: 'Import/Rescan Database' size: root.size pos: root.pos font_size: '15sp' disabled: app.database_scanning on_release: root.database_import() """) class SettingDatabaseImport(SettingItem): """Database scan/import widget for the settings screen.""" def database_import(self): app = App.get_running_app() app.database_import()
from kivy.lang.builder import Builder from kivycalendarwidget import DateCellBase, KivyCalendarWidget from kivycalendarwidget.backgroundwidgets import BackgroundLabel from kivycalendarwidget.colors import KivyRgbaColor, CalenderThemes Builder.load_string(''' #<KvLang> <MyDateCell>: orientation: 'vertical' label_date: lbl_date label_schedule: lbl_schedule BackgroundLabel: id: lbl_date background_color: root.background_color size_hint_y: 0.5 BackgroundLabel: id: lbl_schedule background_color: root.background_color size_hint_y: 0.5 text: 'something' #</KvLang> ''') class MyDateCell(DateCellBase, BoxLayout): label_date: BackgroundLabel label_schedule: BackgroundLabel
def build(self): return Builder.load_file('main.kv')
from generalElements.dropDowns.NormalDropDown import NormalDropDown from kivy.lang.builder import Builder Builder.load_string(""" <AspectRatioDropDown>: MenuButton: text: 'Current Ratio' on_release: root.select('current') MenuButton: text: '6 x 4' on_release: root.select('6x4') MenuButton: text: '7 x 5' on_release: root.select('7x5') MenuButton: text: '11 x 8.5' on_release: root.select('11x8.5') MenuButton: text: '4 x 3' on_release: root.select('4x3') MenuButton: text: '16 x 9' on_release: root.select('16x9') MenuButton: text: '1 x 1' on_release: root.select('1x1') """) class AspectRatioDropDown(NormalDropDown): """Drop-down menu for sorting aspect ratio presets""" pass
Builder.load_string(""" #:import Toolbar kivymd.toolbar.Toolbar #:import MDList kivymd.list.MDList #:import OneLineIconListItem kivymd.list.OneLineIconListItem #:import colors kivymd.color_definitions.colors #:import get_color_from_hex kivy.utils.get_color_from_hex #:import ScrollView kivy.uix.scrollview.ScrollView #:import Window kivy.core.window.Window <NavigationDrawerToolbar> elevation: 0 specific_text_color: root.theme_cls.secondary_text_color opposite_colors: False title_theme_color: 'Secondary' md_bg_color: root.theme_cls.bg_light canvas: Color: rgba: root.theme_cls.divider_color Line: points: self.x, self.y, self.x+self.width,self.y <NavigationLayout> <MDNavigationDrawer>: _list: list _header_container: _header_container canvas: Color: rgba: root.theme_cls.bg_light Rectangle: size: root.size pos: root.pos canvas.before: Color: rgba: root.shadow_color Rectangle: size: Window.size pos: 0, 0 BoxLayout: id: _header_container size_hint_y: None height: _header_container.minimum_height ScrollView: do_scroll_x: False MDList: id: list <NavigationDrawerIconButton>: theme_text_color: 'Primary' if not root._active else 'Custom' if root.use_active else 'Primary' text_color: root.theme_cls.secondary_text_color if not root._active else root.active_color if \ root.active_color_type == "custom" else root._active_color if root.use_active else \ root.theme_cls.secondary_text_color NDIconLabel: id: _icon font_style: 'Icon' theme_text_color: 'Secondary' if not root._active else 'Custom' if root.use_active else 'Custom' text_color: root.theme_cls.secondary_text_color if not root._active else root.active_color if \ root.active_color_type == "custom" else root._active_color if root.use_active else \ root.theme_cls.secondary_text_color BoxLayout: id: _right_container size_hint: None, None x: root.x + root.width - _badge.texture_size[0] - dp(25) # - m_res.HORIZ_MARGINS y: root.y + root.height/2 - self.height/2 size: dp(70), root.height NDBadgeLabel: id: _badge theme_text_color: 'Secondary' if not root._active else 'Custom' if root.use_active else 'Custom' text_color: root.theme_cls.secondary_text_color if not root._active else root.active_color if \ root.active_color_type == "custom" else root._active_color if root.use_active else \ root.theme_cls.secondary_text_color text: root.badge_text halign: 'right' <NavigationDrawerDivider>: canvas: Color: rgba: self.theme_cls.divider_color Line: points: root.x ,root.y+dp(8), root.x+self.width, root.y+dp(8) """)
def build(self): update = Update(self, Window) update.start() return Builder.load_string(open("kv/main.kv", encoding='utf-8').read())
__version__ = "0.0.1" from kivy.app import App from kivy.config import Config Config.set('graphics', 'resizable', '1') Config.set('graphics', 'width', '360') Config.set('graphics', 'height', '640') from kivy.lang.builder import Builder Builder.load_file('elements/import_elements.kv') from kivy.uix.boxlayout import BoxLayout from kivy.uix.popup import Popup from contents import BudgetBox, GliderBox, ListBox, ProgressBox, RecipesBox from global_variables import TEXTINPUT, BUTTON, WINDOW, USER class MainBoxLayout(BoxLayout): def __init__(self, **kwargs): super(MainBoxLayout, self).__init__(**kwargs) def set_current_slide(self, button): ContentBox = self.ids.content_box if self.matching_slides_and_buttons[ ContentBox.current_slide] != button: ContentBox.load_slide( list(self.matching_slides_and_buttons.keys())[list( self.matching_slides_and_buttons.values()).index(button)]) button.state = 'down'
Builder.load_string( """ <BadgeItem> size_hint: None,None padding: dp(5) size: self.size if root.text else [dp(20), dp(20)] opacity: 1 if self.badge_disabled==False else 0 pos: (self.parent.x -self.width*(root.offset), self.parent.y+ self.parent.height -self.height*(1-root.offset)) if root.position=='left'\ else (self.parent.x +self.parent.width -self.width*(1-root.offset) , self.parent.y +self.parent.height -self.height*(1-root.offset)) canvas.before: Color: rgba: root.bg_color if root.bg_color else root.theme_cls.bg_normal RoundedRectangle: pos:self.pos size: self.size radius: [root.height/2, root.height/2, root.height/2, root.height/2] Color: rgba: root.badgeitem_color if root.badgeitem_color else root.theme_cls.accent_color RoundedRectangle: pos: [self.pos[0]+ root.badgeitem_padding/2 , self.pos[1]+ root.badgeitem_padding/2] size: [ self.size[0]-root.badgeitem_padding, self.size[1]-root.badgeitem_padding ] radius: [root.height/2, root.height/2, root.height/2, root.height/2] Label: size_hint: None,None size: self.texture_size[0]+dp(10), self.texture_size[1] halign: 'center' valign: 'center' font_size: dp(13) bold: root.bold pos_hint: {'center_x': .5, 'center_y': .5} text: root.text color: 1,1,1,1 <AKBadgeLayout>: size_hint: None,None size: box.size BadgeContent: id: box pos: root.pos size_hint: None,None size: self.minimum_size BadgeItem: id: badge size_hint: None,None size: self.minimum_size bg_color: root.bg_color badgeitem_padding: root.badgeitem_padding badgeitem_color: root.badgeitem_color position: root.position text: root.text bold: root.bold offset: root.offset badge_disabled: root.badge_disabled """ )
def build(self): self.mainkv = Builder.load_string(kv) return self.mainkv
from kivy.lang.builder import Builder from kivymd.uix.boxlayout import MDBoxLayout Builder.load_string(""" <SwipeCities> padding: dp(10) orientation: "vertical" adaptive_height: True """) class SwipeCities(MDBoxLayout): pass
from kivy.clock import Clock from kivy.lang.builder import Builder from kivy.properties import ObjectProperty from kivy import Logger from includes.Controls.AdaptView import AdaptView from includes.Controls.Navigator import Navigator from includes.Controls.DatePicker import DatePicker from includes.Controls.Menu import Menu from includes.Controls.Log import Log import re from datetime import * import csv import platform import subprocess Builder.load_file('includes/History.kv') class HistoryView(AdaptView): menu=ObjectProperty(None) navigator=ObjectProperty(None) log=ObjectProperty(None) datePicker=ObjectProperty(None) def __init__(self,screenName,sysArgs,**kwargs): super(HistoryView,self).__init__(screenName,sysArgs,**kwargs) #self.menu.Init(Save=self.SaveLog,Export=self.ExportLog) self.menu.Init(Export=self.ExportLog) self.navigator.Init(1) self.datePicker.DrawLog=self.DrawLog self.log.viewMode=True def laterInit(time=None): self.datePicker.Init()
def build(self): return Builder.load_file(os.path.join('Data\statviewer.kv'))
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.start_loading() def start_loading(self): self.loading = True self.start_animating() def stop_loading(self): self.loading = False if self.anim is not None: self.anim.stop(self) def start_animating(self): self.angle = 0 self.arc_angle = 270 self.animate() def animate(self, animation=None, animating_object=None): self.anim = Animation(angle=self.angle - 360, arc_angle=0 if self.arc_angle == 270 else 270, duration=2) self.anim.bind(on_complete=self.animate) self.anim.start(self) Builder.load_file( LoadingBar.kv_file ) # with this the kv file will be laoded once the file is imported
else: print(self.conectar.__name__ + ": INICIO DE SESIÓN FALLIDO") except Exception as e: self.mensaje_login.text = str(e) #print(self.conectar.__name__+":", mensajes_global['MSG_4']) # aplicacion.screen_manager.current="Ventana_login" else: self.mensaje_login.text = '[color=#FF0000] Usuario y/o contraseña incorrecto[/color]' print(self.conectar.__name__ + ": {}".format("Finalizando")) class login(App): def build(self): return Ventana_login() try: Builder.load_file("ventanas/login/login.kv") except Exception as e: print(e) if __name__ == "__main__": aplicacion = login() aplicacion.run()
opencv = False from PIL import ImageFile ImageFile.LOAD_TRUNCATED_IMAGES = True from kivy.config import Config Config.window_icon = "data/icon.png" from kivy.properties import StringProperty from kivy.uix.boxlayout import BoxLayout from kivy.uix.treeview import TreeViewNode from kivy.lang.builder import Builder Builder.load_string(""" <TreeViewInfo>: color_selected: app.selected_color odd_color: app.list_background_odd even_color: app.list_background_even size_hint_y: None height: app.button_scale orientation: 'horizontal' LeftNormalLabel: text: root.title """) class TreeViewInfo(BoxLayout, TreeViewNode): """Simple treeview node to display a line of text. Has two elements, they will be shown as: 'title: content'""" title = StringProperty()
Builder.load_string(""" <ColorElement>: size_hint_y: None cols: 1 height: self.minimum_height orientation: 'vertical' ColorElementButton: on_press: root.toggle_expanded() orientation: 'horizontal' size_hint_y: None height: app.button_scale NormalLabel: text: root.text Widget: size_hint: 1, 1 canvas.before: Color: rgba: 0, 0, 0, 1 BorderImage: size: self.size pos: self.pos source: 'data/button.png' Color: rgba: root.color BorderImage: size: self.size pos: self.pos source: 'data/button.png' BoxLayout: size_hint_y: None height: 0 id: colorPickerContainer """)
def __init__(self, **kwargs): Builder.load_file('views/today_view.kv') super().__init__(**kwargs)
def build(self): self.title = "my primary app" self.theme_cls.primary_palette = "Green" return Builder.load_file("main.kv")
Builder.load_string(""" <-TextInput>: canvas.before: Color: rgba: self.background_color BorderImage: display_border: [app.display_border/2, app.display_border/2, app.display_border/2, app.display_border/2] border: self.border pos: self.pos[0] + 3, self.pos[1] + 3 size: self.size[0] -6, self.size[1] - 6 source: self.background_active if self.focus else (self.background_disabled_normal if self.disabled else self.background_normal) Color: rgba: (self.cursor_color if self.focus and not self._cursor_blink else (0, 0, 0, 0)) Rectangle: pos: self._cursor_visual_pos size: root.cursor_width, -self._cursor_visual_height Color: rgba: self.disabled_foreground_color if self.disabled else (self.hint_text_color if not self.text else self.foreground_color) padding: app.display_padding <NormalInput>: mipmap: True cursor_color: app.theme.text write_tab: False background_color: app.theme.input_background hint_text_color: app.theme.disabled_text disabled_foreground_color: 1,1,1,.75 foreground_color: app.theme.text size_hint_y: None height: app.button_scale font_size: app.text_scale <FloatInput>: write_tab: False background_color: app.theme.input_background disabled_foreground_color: 1,1,1,.75 foreground_color: app.theme.text size_hint_y: None height: app.button_scale font_size: app.text_scale <IntegerInput>: write_tab: False background_color: app.theme.input_background disabled_foreground_color: 1,1,1,.75 foreground_color: app.theme.text size_hint_y: None height: app.button_scale font_size: app.text_scale <InputMenu>: canvas.before: Color: rgba: app.theme.menu_background BorderImage: display_border: [app.display_border, app.display_border, app.display_border, app.display_border] size: self.size pos: self.pos source: 'data/buttonflat.png' background_image: 'data/transparent.png' size_hint: None, None size: app.button_scale * 9, app.button_scale show_arrow: False MenuButton: text: 'Select All' on_release: root.select_all() MenuButton: text: 'Cut' on_release: root.cut() MenuButton: text: 'Copy' on_release: root.copy() MenuButton: text: 'Paste' on_release: root.paste() """)
Builder.load_string(""" <ScreenOne>: BoxLayout: orientation:'vertical' Label: text: 'I am ScreenOne' Label: id: lbl1 Button: text: 'Read' on_press: root.press_read() Button: text: 'Change' on_press: root.press_change() Button: text: 'Go to ScreenTwo' on_press: app.sm.current = "screen_2" <ScreenTwo>: BoxLayout: orientation:'vertical' Label: text: 'I am ScreenTwo' Label: id: lbl2 Button: text: 'Read' on_press: root.press_read() Button: text: 'Change' on_press: root.press_change() Button: text: 'Go to ScreenOne' on_press: app.sm.current = "screen_1" """)
from kivymd.theming import ThemableBehavior from kivymd.vendor.navigationdrawer import NavigationDrawer Builder.load_string(""" #:import Window kivy.core.window.Window <ModifiedNavigationDrawer>: canvas: Color: rgba: root.theme_cls.bg_light Rectangle: size: root.size pos: root.pos canvas.before: Color: rgba: root.shadow_color Rectangle: size: Window.size pos: 0, 0 BoxLayout: size_hint_y: None orientation: 'vertical' height: self.minimum_height """) class ModifiedNavigationDrawer(BoxLayout, ThemableBehavior, RectangularElevationBehavior):
Builder.load_string(""" #:import Toolbar kivymd.toolbar #:import uiximage kivy.uix.image #:import MDLabel kivymd.label #:import MDSeperator kivymd.card.MDSeparator #:import MDTextField kivymd.textfields.MDTextField #:import MDCheckbox kivymd.selectioncontrols.MDCheckbox #:import MDCard kivymd.card.MDCard <BigOne>: thebigone: thebigone size_hint_x: None width: dp(500) MDRaisedButton: id: thebigone text: 'The big one' size_hint: 1, None on_release: app.drop.open(self) <MyDropdown>: canvas: Color: rgb: 1, 0, .3 Rectangle: size: self.size pos: self.pos id: drop size_hint_x: None width: dp(450) on_select: app.get_running_app().root.ids.thebigone.text = args[1] auto_width: False MDRaisedButton: size_hint_y: None text: 'one' height: dp(100) on_release: drop.select('item1') MDRaisedButton: size_hint_y: None text: 'two' height: dp(100) on_release: drop.select('item2') MDRaisedButton: text: 'three' height: dp(100) size_hint_y: None on_release: drop.select('item3') MDRaisedButton: text: 'four' height: dp(100) size_hint_y: None on_release: drop.select('item4') """)
def build(self, *args, **kwargs): return Builder.load_string(kv)
from kivy.app import App from kivy.uix.floatlayout import FloatLayout from kivy.uix.gridlayout import GridLayout from kivy.lang.builder import Builder from player import Player Builder.load_file('sprites.kv') class Fleet(GridLayout): pass class GalaxyInvaders(FloatLayout): pass class GalaxyInvadersApp(App): def build(self): return GalaxyInvaders() if __name__ == '__main__': GalaxyInvadersApp().run()