0

Here is the relevant snippet of my mykv.kv file:

<RemoveScreen>:
    MyLayout:
        MyLogo:
            GridLayout:
                rows: 6
                cols: 2
                padding: 100,80,100,80
                Label:
                    font_size: "20sp"
                    bold: True
                    color: [1,1,0,1]
                    text: "Part number:"
                Label:
                    text: "Box 02"  
                Label:
                    font_size: "20sp"
                    bold: True
                    color: [1,1,0,1]
                    text: "Part description:"
                Label:
                    text: "Box 04"  
                Label:
                    font_size: "20sp"
                    bold: True
                    color: [1,1,0,1]
                    text: "Quatity on hand:"
                Label:
                    #font_size: "20sp"
                    text: "Box 06"
                Label:
                    font_size: "20sp"
                    bold: True
                    color: [1,1,0,1]
                    text: "Bin location:"   
                Label:
                    text: "Box 08"
                Label:
                    font_size: "20sp"
                    bold: True
                    color: [1,1,0,1]
                    text: "Direction:"  
                Label:
                    text: "Box 10"
                Label:
                    font_size: "20sp"
                    bold: True
                    color: [1,1,0,1]
                    text: "Scan time:"
                Label:
                    text: "Box 12"


        MyButtons:
            #buttons

The code above outputs this:

enter image description here

I would like to have a merged cell on top, where it is center justified,the left column be right justified, and the right column be left justified. the left column will obtain the strings from a MySQL query, and replace the "Box #" strings, looking like:

enter image description here

Questions: Could you please implement in to my code that will:

  • Merge the first row of two cells into one
  • Right justify the left column
  • Left justify the right column (as per the layout above)
Peter Badida
  • 11,310
  • 10
  • 44
  • 90
3kstc
  • 1,871
  • 3
  • 29
  • 53
  • 1
    So the question is, "will you please write me a program" :) . Could you please show, what you have tried regarding MySQL, to implement it? – el3ien Aug 05 '16 at 02:57
  • 1
    Also you should read this http://stackoverflow.com/help/how-to-ask and http://stackoverflow.com/help/mcve . Also this is not a single question. – el3ien Aug 05 '16 at 03:07
  • @EL3PHANTEN You've got every right to be cross, as I currently am with myself. I get baffled, and stuck. But your help goes a long way - By looking at your code and structure I learn alot! I am thankful and I sincerely do appreciate _your_ input! – 3kstc Aug 05 '16 at 03:45
  • Dont get me wrong. I am happy to help. This should be two seperate questions. The one with mySQL, and one for kivy. Think of the questions, as future reference for other people who search for a specific task. Like joining the cells. The justification can also be in the same question as joining the cells. – el3ien Aug 05 '16 at 04:07
  • @EL3PHANTEN Thank-you!!! - Fair point - I have broken down the question to a [MySQL component](http://stackoverflow.com/questions/38781117/retrieving-mysql-with-kivy]) :D – 3kstc Aug 05 '16 at 04:28

1 Answers1

2

In kivys GridLayout, there is no feature to join cells. But you could do a work around this, to make it look like that.
In kivy it is easy to combine layouts. And you can nest them as much as you want
So a vertical boxlayout, with 2 elements in it, could be the workaround for this problem.

vertical BoxLayout
    Head Label  
    GridLayout

I will show you an example here.

The python file is just a minimal app.

from kivy.app import App

from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout

Builder.load_file("kv.kv")


class RemoveScreen(BoxLayout):
    pass


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


MyApp().run()

And the kv.kv file. To make the code cleaner, I made custom Label classes. That way you only need to change values at one place.

<MyLabel1@Label>:
    font_size: "20sp"
    bold: True
    color: [1,1,0,1]
    halign: "right"
    text_size: root.width, None
    size: self.texture_size


<MyLabel2@Label>:
    halign: "left"
    text_size: root.width, None
    size: self.texture_size


<RemoveScreen>:
    orientation: "vertical"

    MyLabel1:
        text: "Headline"
        size_hint: (1,0.05)
        halign: "center"

    GridLayout:
        rows: 6
        cols: 2
        padding: [0, 0, 0, 25]
        spacing: [10,0]

        MyLabel1:
            text: "Part number:"
        MyLabel2:
            text: "Box 02"  

        MyLabel1:
            text: "Part description:"
        MyLabel2:
            text: "Box 04"  

        MyLabel1:
            text: "Quatity on hand:"
        MyLabel2:
            text: "Box 06"

        MyLabel1:
            text: "Bin location:"   
        MyLabel2:
            text: "Box 08"

        MyLabel1:
            text: "Direction:"  
        MyLabel2:
            text: "Box 10"

        MyLabel1:
            text: "Scan time:"
        MyLabel2:
            text: "Box 12"
el3ien
  • 5,362
  • 1
  • 17
  • 33