0

I am trying to display some output in the corresponding text input boxes but when I click on the update button output should be in the left Input box that's working but when I click on Updatee button output is displayed on left text input box itself(it overwrites whatever is there in the left input area).

When I click on Updatee it should display in the right box and when update is clicked output should be in the left input box or area. And same with the clear function which is clearing only the left box I want it to clear both. Also I want only one button i.e. just Update to display in the corresponding boxes.

This is the Python file:

from kivy.app import App
from kivy.uix.gridlayout import GridLayout


class DemoGridLayout(GridLayout):
    def update(self, query):
        if query:
            a = query + str("Area 1")
            self.display.text = a

    def updatee(self, query):
        if query:
            a = query + str("Area 2")
            self.display.text = a

    def clear(self):
        self.display.text = ""


class DemoApp(App):
    def build(self):
        return DemoGridLayout()


demoApp = DemoApp()
demoApp.run()

Kivy File(as demo.kv) :

<CustButton@Button>:
    font_size: 28
<DemoGridLayout>:
    id:test
    display:entry
    rows:3
    cols:2
    padding:10
    spacing:10
    BoxLayout:
        TextInput:
            id: entry
            font_size:20
            multiline:True
    BoxLayout
        TextInput:
            id: entrye
            font_size:20
            multiline:True
    CustButton:
        id: b1
        size_hint_y:0.1
        text:"Update"
        on_press:test.update(entry.text)
    CustButton:
        id: b2
        size_hint_y:0.1
        text:"Updatee"
        on_press:test.updatee(entrye.text)
    CustButton:
        size_hint_y:0.1
        size_hint_x:0.5
        text:"Clear"
        on_press:test.clear()
halfer
  • 19,824
  • 17
  • 99
  • 186
  • Can you show a minimal example of what you have tried? – el3ien Jan 19 '17 at 02:43
  • ill be uploading the images in a few hours thanks for taking interest pls check again later but basically it self.display.text is using only one text input box to output but takes input from both perfectly pls check back thanks once again – Napier Logan Jan 19 '17 at 02:49
  • 1
    I meant a code example. Then I can just run it, and tell you what you can do to get your expected result. – el3ien Jan 19 '17 at 02:50
  • Pro tips for posting: (a) don't ask explicitly for "detailed" or "step by step" answers here. In many cases that is a hidden request for someone else to do all of the work, which we get a great deal of - don't be one of those people. (b) Don't add "ASAP" or any other form of begging to your posts or your comments. Attempts to queue-jump do not sit well with volunteers - they get around to questions they find interesting, at their leisure. – halfer Jan 19 '17 at 20:23
  • Possible duplicate of [Changing a Kivy Widget Text](http://stackoverflow.com/questions/26458020/changing-a-kivy-widget-text) – Napier Logan Feb 05 '17 at 16:30

2 Answers2

0

I didn't clearly get you what you were trying to ask but yes i will provide you minimal code that might help to answer your question.I designed this code replicating your case.If you are newbie this link will help you get started.Keep on using Kivy it is awesome.

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout 
from kivy.uix.button import Button
from kivy.lang import Builder


Builder.load_string('''
#: import Platform kivy.utils.platform
<Interface>:
    orientation: 'vertical'
    TextInput:
        id:label
        hint_text: "enter text"
    Button:
        text:"change label and text_hint" 
        on_press:label2.hint_text=label.text
    Label:
        id:label3
        text:label.text
    TextInput:
        id:label2
        text_hint:label.text
''')


class Interface(BoxLayout):
    pass


class SampleApp(App):

    def build(self):
        return Interface()

if __name__ == "__main__":
    app = SampleApp()
    app.run() 
Community
  • 1
  • 1
phunsukwangdu
  • 412
  • 5
  • 13
  • Please check now, hope its clear i'm a newbie so don't get mad at me if its a silly mistake ,a detailed answer would be appreciated since i'm a newbie.....need answer asap – Napier Logan Jan 19 '17 at 12:35
0

Here is the updated code.You should read official docs to get your doubts clarified.In process you learn more things.

from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.properties import ObjectProperty

class DemoGridLayout(GridLayout):
    entry = ObjectProperty(None)
    entrye = ObjectProperty(None)
    def update(self, query):
        if query:
            a = query + str("Area 1")
            self.entry.text = a

    def updatee(self, query):
        if query:
            a = query + str("Area 2")
            self.entrye.text = a

    def clear(self):
        self.display.text = ""


class DemoApp(App):
    def build(self):
        return DemoGridLayout()

if __name__ == "__main__":
    demoApp = DemoApp()
    demoApp.run()

demo.kv =>

<CustButton@Button>:
    font_size: 28
<DemoGridLayout>:
    id:test
    display:entry
    rows:3
    cols:2
    padding:10
    spacing:10
    entry: entry
    entrye: entrye
    TextInput:
        id: entry
        font_size:20
        multiline:True
    TextInput:
        id: entrye
        font_size:20
        multiline:True
    CustButton:
        id: b1
        size_hint_y:0.1
        text:"Update"
        on_press:test.update(entry.text)
    CustButton:
        id: b2
        size_hint_y:0.1
        text:"Updatee"
        on_press:test.updatee(entrye.text)
    CustButton:
        size_hint_y:0.1
        size_hint_x:0.5
        text:"Clear"
        on_press:test.clear()

i have intentionally left clear part for you to work out.

phunsukwangdu
  • 412
  • 5
  • 13