0

I am trying to implement the template of the ComicCreator GUI sample as a template for my own project. The code is easy to follow, but I want to change the toolbox.kv to look something like:

enter image description here

Q: How would I be able to append a logo, instead of the buttons currently there, and also have the current date time display (DD/MM/YYYY HH:MM) shown perpetually.And lastly add a string NYC, New York, USA, all underneath each other as in the picture.

3kstc
  • 1,871
  • 3
  • 29
  • 53

1 Answers1

1

Some playing arround with BoxLayout's and Image or AsyncImage if your image is from the web.

So the python code could look like this.

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import StringProperty
from kivy.clock import Clock
import time


class MyLayout(BoxLayout):
    your_time = StringProperty()
    def __init__(self,**kwargs):
        super(MyLayout,self).__init__(**kwargs)
        self.orientation = "vertical"
        self.padding = 10
        Clock.schedule_interval(self.set_time, 0.1)    

    def set_time(self,dt):
        self.your_time = time.strftime("%m/%d/%Y %H:%M")

class MyApp(App):
    def build(self):
        return MyLayout()


if __name__ == "__main__":
    MyApp().run()


And kv file look like this.

#:kivy 1.9.1

<MyLayout>:
    BoxLayout:
        spacing: 10
        padding: 10,10,10,0
        orientation: "horizontal"
        BoxLayout:
            orientation: "vertical"
            size_hint: 0.3,1
            canvas:
                Rectangle:
                    pos: self.pos
                    size: self.size
            AsyncImage
                source: 'http://lmsotfy.com/so.png'
            Label:
                size_hint: 1,0.3
                text: root.your_time
                color: [0,0,0,1]
            Label:
                size_hint: 1,0.3
                text: "NYC, New York, USA"
                color: [0,0,0,1]

        Button:
            text: ""

    BoxLayout:
        padding: 10,10,10,0
        spacing: 10
        size_hint: 1,0.3
        orientation: "horizontal"
        Button:
            text: "Clear"
        Button:
            text: "Remove"
        Button:
            text: "Group"
        Button:
            text: "Color"
        Button:
            text: "Gestures"

    BoxLayout:
        padding: 10,10,10,10
        size_hint: 1,0.3
        Button:
            text: "Total figures: 1          Kivy Started"


This will look like this:

kivy app

el3ien
  • 5,362
  • 1
  • 17
  • 33
  • thanks for that, my question was how would I be able print the _current_ time not just "DD/MM/YYYY HH:MM", – 3kstc Jul 13 '16 at 22:38
  • 1
    @3kstc ok where do you get the timevariable? – el3ien Jul 13 '16 at 22:40
  • that's my key problem - despite reading various [examples](http://stackoverflow.com/questions/18923321/making-a-clock-in-kivy), I just don't understand how to implement it into my code. – 3kstc Jul 13 '16 at 22:42
  • @3kstc Updated. Think that is what you want – el3ien Jul 13 '16 at 22:59
  • @3kstc will you accept this answer :) , or are you seeking something else? – el3ien Jul 14 '16 at 09:14
  • Actually, I have one more [question](http://stackoverflow.com/questions/38388782/how-to-change-a-space-when-a-button-is-pressed-with-kivy) about kivy.... – 3kstc Jul 15 '16 at 06:00
  • @3kstc ok bring it on :) – el3ien Jul 15 '16 at 08:54
  • any luck with my [question](http://stackoverflow.com/questions/38388782/how-to-change-a-space-when-a-button-is-pressed-with-kivy/38391384#38391384) and an example on how to implement it into the code? – 3kstc Jul 19 '16 at 04:19