Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
AnderSchofield authored Aug 2, 2023
1 parent 5760acc commit 0e1ec70
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
from kivy.uix.label import Label
from kivy.core.window import Window


class KvApp(App):

def build(self):
# Set the window size to 1200x800 pixels
"""Build the root widget."""
Window.size = (1200, 800)

self.root = BoxLayout(orientation='horizontal')
Expand All @@ -24,19 +26,18 @@ def build(self):

return self.root


# ... in the KvViewerApp class ...

def update(self, instance, value)
def update(self, instance, value):
"""Update the KV display widget when the TextInput changes."""
self.root.remove_widget(self.kv_display)
try:
# Use textwrap.dedent on value to remove any common leading whitespace
# Use textwrap.dedent on value to remove any indentation
self.kv_display = Builder.load_string(textwrap.dedent(value))
self.kv_display.size_hint_x = 0.5
self.root.add_widget(self.kv_display)
except Exception as e:
self.kv_display = Label(text=str(e), size_hint_x=0.5)
self.root.add_widget(self.kv_display)


if __name__ == '__main__':
KvApp().run()

1 comment on commit 0e1ec70

@AnderSchofield
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bugs

Please sign in to comment.