Here is an example below. Notice I simplified your Buttonbox layout to simply use a BoxLayout and let the horizontal box layout position and size the buttons. I added 2 labels on the left and right side of the buttons as placeholders, to leave the space you had in your design.
Pressing button A instances the TextAndLabel class and adds it to the BoxLayout ti_box. Type in the text box and the text will appear in the label below the textbox.
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
kv = '''
<TextAndLabel>:
orientation: 'vertical'
padding: 20
spacing: 10
TextInput:
id: ti
Label
text: ti.text
text_size: self.size
halign: 'left'
valign: 'top'
<ButtonBox@BoxLayout>:
size_hint_y: None
height: 48
Label: # Place holder
Button:
text: 'A'
on_press: app.add_textbox()
Button:
text: 'B'
on_press:
Button:
text: 'C'
on_press:
Button:
text: 'D'
on_press:
Button:
text: 'E'
on_press:
Button:
text: 'F'
on_press:
Button:
text: 'G'
on_press:
Button:
text: 'H'
on_press:
Label: # Placeholder
BoxLayout:
orientation: 'vertical'
BoxLayout:
orientation: 'vertical'
size_hint_y: None
height: 100
Label:
text: 'Click a Button'
font_size: 20
size_hint_y: None
height: 40
ButtonBox:
BoxLayout:
padding: 40
orientation: 'vertical'
id: ti_box
'''
class TextAndLabel(BoxLayout):
pass
class MyApp(App):
def build(self):
return Builder.load_string(kv)
def add_textbox(self):
self.root.ids.ti_box.add_widget(TextAndLabel())
MyApp().run()
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/907b2577-4370-4a17-ab5f-c36942c6a489n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/60305f88.1c69fb81.41302.9ccbSMTPIN_ADDED_MISSING%40gmr-mx.google.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CABDb-VjuRgRBViJrJnFF%2Bo_DduAvmEaEyBSgzz2GGq_0GZvdFA%40mail.gmail.com.
<ButtonBox@BoxLayout>:
size_hint_y: None
height: 48
Label: # Place holder
id: label
Button:
id: A
text: 'A'
on_press:
app.add_textbox()
label.text = self.text
Button:
text: 'B'
on_press:
app.add_textbox()
label.text = self.text
Button:
text: 'C'
on_press:
app.add_textbox()
label.text = self.text
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAGpYEyxW2CTG%2B_4npKY-fhkQqfTFC0UHHHi4xDhYQ_eHLXd%2BGA%40mail.gmail.com.
The Label needs to be added to the TextAndLabel class. A StringProperty, text, was added to hold the value.
The method add_text_box(), was changed to have a text value passed in, and sets the text value.
You will need to remove widget when pressing buttons,( or create a number of screens and switch between them, or a scrollview…). Currently pressing multiple buttons causes the widgets to stack.
from kivy.app import App
from kivy.lang import Builder
from kivy.properties import StringProperty
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
kv = '''
<TextAndLabel>:
orientation: 'vertical'
padding: 20
spacing: 10
BoxLayout:
Label:
text: root.text
size_hint_x: .1
TextInput:
id: ti
Label
text: ti.text
text_size: self.size
halign: 'left'
valign: 'top'
#Button:
# text: 'print'
# on_press: root.print_textbox()
<LabelBesidesTI>:
id:label
<ButtonBox@BoxLayout>:
size_hint_y: None
height: 48
Label: # Place holder
#LabelBesidesTI:
Button:
id: A
text: 'A'
on_press:
app.add_textbox(self.text)
Button:
text: 'B'
on_press:
app.add_textbox(self.text)
Button:
text: 'C'
on_press:
app.add_textbox(self.text)
Button:
text: 'D'
on_press:
app.add_textbox(self.text)
Button:
text: 'E'
on_press:
app.add_textbox(self.text)
Button:
text: 'F'
on_press:
app.add_textbox(self.text)
Button:
text: 'G'
on_press:
app.add_textbox(self.text)
Button:
text: 'H'
on_press:
app.add_textbox(self.text)
Label: # Placeholder
BoxLayout:
orientation: 'vertical'
BoxLayout:
orientation: 'vertical'
size_hint_y: None
height: 100
Label:
text: 'Click a Button'
font_size: 20
size_hint_y: None
height: 40
ButtonBox:
BoxLayout:
padding: 40
orientation: 'vertical'
id: ti_box
BoxLayout:
BoxLayout:
BoxLayout:
padding:20
orientation:'horizontal'
spacing: 10
size_hint_y: None
width: 300
Button:
text:'Next'
on_press: print('Ready to run the process.')
Button:
text:'Close'
on_press: app.stop()
BoxLayout:
'''
class TextAndLabel(BoxLayout):
text = StringProperty()
# def read(self):
# print(self.ids.label.text +' '+self.ids.ti.text)
pass
class LabelBesidesTI(BoxLayout, Label):
pass
class MyApp(App):
def build(self):
return Builder.load_string(kv)
def add_textbox(self, text):
self.root.ids.ti_box.add_widget(TextAndLabel(text=text))
# self.labels.ids.label.text.add_widget(LabelBesidesTI())
# def delete_textbox(self):
# print(self.ids.ti.text)
MyApp().run()
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CABDb-Vh4%2B8TcPz3ta86mzYnSUjq7qwWUzS1PhbVDxs2jVBnj8A%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/60328c2a.1c69fb81.6e206.1297SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
BoxLayout:
orientation: 'vertical'
BoxLayout:
orientation: 'vertical'
size_hint_y: None
height: 100
Label:
text: 'Click a Button'
font_size: 20
size_hint_y: None
height: 40
ButtonBox:
BoxLayout:
padding: 40
orientation: 'vertical'
ScrollView:
do_scroll: False, True
bar_width: dp(10)
size_hint_y: None
height: 30 * 3
scroll_type: ['bars','content']
BoxLayout:
orientation: 'vertical'
id:ti_box
spacing: dp(2)
size_hint_y: None
height: self.minimum_height
#id: ti_box
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/60328c2a.1c69fb81.6e206.1297SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
I changed the scrollview. In short you needed to size the items going into the ScrollView.
I removed the sizing of the ScrollView itself so it would fill the screen. I sized the buttons on the bottom of the screen.
I also updated the delete_textbook() method. I passed in the widget, and deleted that… additional comments in the code.
Other changes made.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CABDb-ViXyZY8m%2BeA1M6E3u4s1miYPMOh%3DyxtQV2pto%3D5nUE7jg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/6033c24f.1c69fb81.41302.5944SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
kv = '''
<TextAndLabel>:
id:tl
size_hint_y: None
height: 48 # Fix the size of the widget going into the ScrollView
# padding: 20
# spacing: 10
Label:
id:lab
text: root.text
size_hint_x: .1
TextInput:
id: ti
Button:
text: 'Delete'
size_hint_x: .1
on_press:
#root.read()
root.getAll()
print('going to delete')
app.delete_textbox(root) # send the widget you want deleted
BoxLayout:
orientation: 'vertical'
BoxLayout:
orientation: 'vertical'
size_hint_y: None
height: 100
Label:
text: 'Click a Button'
font_size: 20
size_hint_y: None
height: 40
ButtonBox:
BoxLayout:
padding: 40
orientation: 'vertical'
ScrollView:
do_scroll: False, True
bar_width: dp(10)
# size_hint_y: None # Let this fill the space
# height: 30 * 3
scroll_type: ['bars','content']
BoxLayout:
orientation: 'vertical'
id:ti_box
spacing: dp(2)
size_hint_y: None
height: self.minimum_height
#id: ti_box
BoxLayout:
size_hint_y: None
height: 75 # Set the height for the bottom row
BoxLayout:
BoxLayout:
padding:20
orientation:'horizontal'
spacing: 10
# size_hint_y: None
# width: 300
Button:
text:'Next'
on_press:
print('Ready to run the process.')
app.ids.tl.getAll()
Button:
text:'Close'
on_press: app.stop()
BoxLayout:
'''
class TextAndLabel(BoxLayout):
text = StringProperty()
def read(self):
print(f'Label "{self.ids.lab.text}" has "{self.ids.ti.text}"')
def getAll(self):
inputs_list = [ni.text for ni in self.children]
print(f'list in reverse order {inputs_list}')
inputs_list.reverse()
print(f'list in correct order {inputs_list}')
pass
class MyApp(App):
def build(self):
return Builder.load_string(kv)
def add_textbox(self, text):
self.root.ids.ti_box.add_widget(TextAndLabel(text = text))
#self.labels.ids.label.text.add_widget(LabelBesidesTI())
#print(self.check.ids.ti.text)
def delete_textbox(self, w):
self.root.ids.ti_box.remove_widget(w)error message:-Traceback (most recent call last):
File "kivy\properties.pyx", line 860, in kivy.properties.ObservableDict.__getattr__
KeyError: 'tl'
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/6033c24f.1c69fb81.41302.5944SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
You need to get to the root widget… app.root.ids.t1
Button:
text:'Next'
on_press:
print('Ready to run the process.')
app.root.ids.tl.getAll()
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CABDb-Vg4jxvBH_90dEfXT8A9qxxpjr%2BpovbcsuJ%2Be2gmioHYKg%40mail.gmail.com.
BoxLayout:
orientation: 'vertical'
BoxLayout:
orientation: 'vertical'
size_hint_y: None
height: 100
Label:
text: 'Click a Button'
font_size: 20
size_hint_y: None
height: 40
ButtonBox:
TextAndLabel:
id: tl
app.root.ids.tl.getAll()
Button:
text:'Close'
on_press: app.stop()
BoxLayout:
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/60340fa7.1c69fb81.cce48.09c6SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
In app do something like:
def get_all(self):
top = ('Top Item', self.root.ids.tl.ids.ti.text )
rest = [(w.text, w.ids.ti.text) for w in self.root.ids.ti_box.children]
print([top] + rest[::-1])
The item on top does not have a label so I called it Top Item. This generates tuples of labels and the text values.
You want this in a level above the TextAndLabel object because it needs to see across all of them. You could create a TextAndLabel method to return the tuple.
Sample output: [('Top Item', 'Hello'), ('A', 'aaa'), ('D', 'ddd'), ('F', 'ffffff')]
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CABDb-VjoJpbsusAHOK5q_Nw_EZ16FywSbsLOpCAmGb2j_OKWzQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/60350797.1c69fb81.eb881.5a8cSMTPIN_ADDED_MISSING%40gmr-mx.google.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/60350797.1c69fb81.eb881.5a8cSMTPIN_ADDED_MISSING%40gmr-mx.google.com.
Assuming you have an unstructured email message with a url in the text, I would use a regular expression to find the URLs.
See:
https://docs.python.org/3/howto/regex.html
https://docs.python.org/3/library/re.html
I like this tool when creating regex expressions: https://regex101.com/
If you do a google search for finding a url with regex, you will find a number of examples.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CABDb-VgQLZHrc%2B4g1S5Xhg3NDwKQKkkjRpXn-nct9hhUquzq9Q%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/6037db9d.1c69fb81.933d3.6b78SMTPIN_ADDED_MISSING%40gmr-mx.google.com.