Skip to content

Instantly share code, notes, and snippets.

@Crowbrammer
Last active February 2, 2017 20:55
Show Gist options
  • Save Crowbrammer/4454aaa794725bb5af486294a546b50e to your computer and use it in GitHub Desktop.
Save Crowbrammer/4454aaa794725bb5af486294a546b50e to your computer and use it in GitHub Desktop.
# File name: autopositioner.py
AutoPositionerRoot:
<MmpModule>:
orientation: 'vertical'
id: mmp1
BoxLayout: # This should probably be in Root
id: bl_super
height: '90dp'
size_hint_y: None
padding: 10, 10
BoxLayout:
id: bl1
orientation: 'vertical'
Button:
Button:
Button:
BoxLayout:
id: bl2
orientation: 'vertical'
Button:
# - - - - -
# The button text I'm trying to change
# - - - - -
id: machine_name
Button:
id: model_button
<AutoPositionerRoot>:
orientation: 'vertical'
MmpModule
Image:
source: 'data/cat.jpg'
import libs.apa_database
import inspect
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import ObjectProperty, StringProperty, Property
#from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition
class AutoPositionerRoot(BoxLayout):
def __init__(self, **kwargs):
super(AutoPositionerRoot, self).__init__(**kwargs)
# # # # # #
e = MmpModule()
f = MmpModule()
e.machine_name.text = 'Wow'
# - - - - -
# Brings "AttributeError: 'str' object has no attribute 'text'"
# - - - - -
self.add_widget(e)
self.add_widget(f)
# # # # # #
# # # # # #
class MmpModule(BoxLayout):
machine_name = StringProperty()
def __init__(self, **kwargs):
super(MmpModule, self).__init__(**kwargs)
self.machine_name = 'I-34'
self.model_name = 'CSEG'
class AutopositionerApp(App):
def build(self):
AutoPositionerRoot()
if __name__ == '__main__':
AutopositionerApp().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment