Python Forum
[Kivy] GUI properties defined (and changed) by variables in .py file
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Kivy] GUI properties defined (and changed) by variables in .py file
#2
main.py

from kivy.app import App
from kivy.properties import StringProperty
import values

class MainApp(App):
    label_text = StringProperty()
    def build(self):
        self.label_text = values.label_text
    def increment(self):
        self.label_text = str(int(self.label_text) + 1)
    def decrement(self):
        self.label_text = str(int(self.label_text) - 1)
 
if __name__ == '__main__':
    MainApp().run()
main.kv
Output:
BoxLayout: orientation: "vertical" Label: text: app.label_text Button: text: "increment" on_press: app.increment() Button: text: "decrement" on_press: app.decrement()
values.py
label_text = "0"
However I would use kivy.config and eventually add kivy.settings to initialize and have settings shown to user
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: GUI properties defined (and changed) by variables in .py file - by buran - Aug-07-2018, 08:35 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Menus and icons changed after upgrade blackclover 0 1,959 May-11-2018, 08:14 PM
Last Post: blackclover
  PyGtk3, How to Create “title-changed” signal for Gtk.Window Widget? harun2525 2 6,169 May-01-2017, 07:59 AM
Last Post: harun2525

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020