.
I did a quick hack below, sizing the scatter to the lower half of the screen, and commenting out a few things so the code would run with out having to install anything.
'scat'
size_hint: None, None
size: root.width, root.height/2
gid: scat
on_touch_up: root.set_focus()
#pos: 200,200
background_color: 0,255,0,1 #'lime'
Label: #hello
id: helo
size_hint: None, None
size: self.texture_size
name: 'helo'
text: "Hello!"
#font_size: '90sp'
font_size: 50
#pos_hint: {'center_x':.5, 'center_y':.6}
pos: 350,345
color: 'teal'
background_color: 0,128,128,1 #'teal'
Button:
id:lsiz
name: 'lsiz'
text: " Press\n to\ndisplay"
on_press: root.Listsizes(0)
on_release: root.set_focus()
size_hint_y: None
size_hint: root.xbutsiz
pos_hint: {'x':root.xbutxpos, 'top':.80}
background_color: 0,255,0,1 #green
color: 'black'
Button: #list sizes to file
id: lfil
name: 'lfil'
text: "Press\n to\n file"
on_press: root.Listsizes(1)
on_release: root.set_focus()
size_hint_y: None
size_hint: root.xbutsiz
pos_hint: {'x':root.xbutxpos*2, 'top':.80}
background_color: 0,0,255,1 #blue
color: 'black'
Button: #clear
id: clea
name: 'clea'
text: 'Clear'
on_press: disp .text=''
on_release: root.clear_it()
size_hint_y: None
size_hint: root.xbutsiz
pos_hint: {'x':root.xbutxpos*3, 'top':.80}
background_color: 255,0,0,1 #red
color: 'black'
Button: #mode
id: mode
name: 'mode'
text: 'Mode\n '+root.xmode
on_press: root.set_mode()
on_release: root.set_focus()
size_hint_y: None
size_hint: root.xbutsiz
pos_hint: {'x':root.xbutxpos*4, 'top':.80}
background_color: 255,255,0,1 #yellow
color: 'black'
Button: #draw
id: draw
name: 'draw'
text: "Draw"
on_press: root.drawit()
on_release: root.set_focus()
size_hint_y: None
size_hint: root.xbutsiz
pos_hint: {'x':root.xbutxpos*5, 'top':.80}
background_color: 128,0,128,1 #'purple'
color: 'black'
Button: #xtest
id: test
name: 'test'
on_press: root.xtest()
text: 'xtest'
size_hint_y: None
size_hint: root.xbutsiz
pos_hint: {'x':root.xbutxpos*6, 'top':.80}
background_color: 128,128,128,1 #'maroon'
color: 'black'
--
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/3e1da8a8-39f7-46d6-9be1-ad0d5b63f608n%40googlegroups.com.
I updated the kv code. The layout changes here break functionality, but I’m sure you can fix that quickly. I added some comments to the kv, I hope this is helpful. Happy to answer any questions.
#:kivy 1.0.9
<ScatterTextWidget>: # BoxLayout
orientation: 'vertical'
id: 'Main'
name: 'Main'
AnchorLayout: # use to center the row of buttons
BoxLayout: # hold the row of buttons in a horizontal layout
size_hint_y: None
height: dp(70) # set the height of the buttons
spacing: dp(5) # set spacing between the buttons
padding: dp(5) # padding around the outside of the buttons
Button:
id:lsiz
name: 'lsiz'
text: " Press\n to\ndisplay"
on_press: root.Listsizes(0)
on_release: root.set_focus()
background_color: 0,255,0,1 #green
color: 'black'
Button: #list sizes to file
id: lfil
name: 'lfil'
text: "Press\n to\n file"
on_press: root.Listsizes(1)
on_release: root.set_focus()
background_color: 0,0,255,1 #blue
color: 'black'
Button: #clear
id: clea
name: 'clea'
text: 'Clear'
on_press: disp .text=''
on_release: root.clear_it()
background_color: 255,0,0,1 #red
color: 'black'
Button: #mode
id: mode
name: 'mode'
text: 'Mode\n '+root.xmode
on_press: root.set_mode()
on_release: root.set_focus()
background_color: 255,255,0,1 #yellow
color: 'black'
Button: #draw
id: draw
name: 'draw'
text: "Draw"
on_press: root.drawit()
on_release: root.set_focus()
background_color: 128,0,128,1 #'purple'
color: 'black'
Button: #xtest
id: test
name: 'test'
on_press: root.xtest()
text: 'xtest'
background_color: 128,128,128,1 #'maroon'
color: 'black'
Label:
id: titl
name: 'titl'
text: 'Enter Text - Version: '+kivy.platform
size_hint_y: None
height: dp(50)
font_size: sp(20)
background_color: 0,0,128,1 #'navy'
TextInput:
id: txti
name: 'txti'
size_hint_y: None
height: dp(50)
font_size: '25sp'
focus: True
on_text: helo.text = self.text #change helo to match txti entered
#background_color:
#color: 255,0,0,1 #red
Label: #widget display text
size_hint_y: 3 # use size hint to set large area for text
id: disp
name: 'disp'
text: 'disp' #root.xltxt
font_name: root.xfontname
font_size: 14
background_color: 255,255,0,1 #yellow
RelativeLayout:
id: rel
size_hint: None, None # use a relative layout so the position of the scatter widget is honored
size: 0, 0 # make the size zero so the Layout does not take any space
Scatter:
id: scat
name: 'scat'
size_hint: None, None
size: helo.texture_size # make the Scatter the same size as the text "Hello!"
pos: disp.center_x - helo.width/2, disp.center_y
background_color: 0,255,0,1 #'lime'
Label: #hello
id: helo
size_hint: None, None
size: scat.size
name: 'helo'
text: "Hello!"
font_size: 50
color: 'teal'
background_color: 0,128,128,1 #'teal'
From: elli...@cox.net <elli...@cox.net>
Sent: Wednesday, August 16, 2023 7:00 AM
To: kivy-...@googlegroups.com
Subject: RE: [kivy-users] Scatter Widget problem
.
I did a quick hack below, sizing the scatter to the lower half of the screen, and commenting out a few things so the code would run with out having to install anything.
#:kivy 1.0.9
'scat'
size_hint: None, None
size: root.width, root.height/2
gid: scat
on_touch_up: root.set_focus()
#pos: 200,200
background_color: 0,255,0,1 #'lime'
Label: #hello
id: helo
size_hint: None, None
size: self.texture_size
name: 'helo'
text: "Hello!"
#font_size: '90sp'
font_size: 50
#pos_hint: {'center_x':.5, 'center_y':.6}
pos: 350,345
color: 'teal'
background_color: 0,128,128,1 #'teal'
Button:
id:lsiz
name: 'lsiz'
text: " Press\n to\ndisplay"
on_press: root.Listsizes(0)
on_release: root.set_focus()
size_hint_y: None
size_hint: root.xbutsiz
pos_hint: {'x':root.xbutxpos, 'top':.80}
background_color: 0,255,0,1 #green
color: 'black'
Button: #list sizes to file
id: lfil
name: 'lfil'
text: "Press\n to\n file"
on_press: root.Listsizes(1)
on_release: root.set_focus()
size_hint_y: None
size_hint: root.xbutsiz
pos_hint: {'x':root.xbutxpos*2, 'top':.80}
background_color: 0,0,255,1 #blue
color: 'black'
Button: #clear
id: clea
name: 'clea'
text: 'Clear'
on_press: disp .text=''
on_release: root.clear_it()
size_hint_y: None
size_hint: root.xbutsiz
pos_hint: {'x':root.xbutxpos*3, 'top':.80}
background_color: 255,0,0,1 #red
color: 'black'
Button: #mode
id: mode
name: 'mode'
text: 'Mode\n '+root.xmode
on_press: root.set_mode()
on_release: root.set_focus()
size_hint_y: None
size_hint: root.xbutsiz
pos_hint: {'x':root.xbutxpos*4, 'top':.80}
background_color: 255,255,0,1 #yellow
color: 'black'
Button: #draw
id: draw
name: 'draw'
text: "Draw"
on_press: root.drawit()
on_release: root.set_focus()
size_hint_y: None
size_hint: root.xbutsiz
pos_hint: {'x':root.xbutxpos*5, 'top':.80}
background_color: 128,0,128,1 #'purple'
color: 'black'
Button: #xtest
id: test
name: 'test'
on_press: root.xtest()
text: 'xtest'
size_hint_y: None
size_hint: root.xbutsiz
pos_hint: {'x':root.xbutxpos*6, 'top':.80}
background_color: 128,128,128,1 #'maroon'
color: 'black'
From: kivy-...@googlegroups.com <kivy-...@googlegroups.com> On Behalf Of Dan Moormann
Sent: Tuesday, August 15, 2023 8:36 PM
To: Kivy users support <kivy-...@googlegroups.com>
Subject: [kivy-users] Scatter Widget problem
I've been using the Scatter widget tutorial as a launch pad to learn python/kivy/kv. I've added a lot of stuff to the original program and have made a lot of changes. Most noticeably I've added buttons to learn more about size and position. This includes a display and drawing of the widgets (using turtle). I've recently reordered the widgets and placed most of them in a FloatLayout in order to get absolute positioning. This seems to work.
--
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/039b01d9d08c%2407c2dc30%2417489490%24%40cox.net.
I have found the Inspector is very useful when you are trying to debug issues with layouts.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAHHXr4AxTyxcPXZ9etiKeGtiRo7D-SSk4yoeZpagy%3DvgbupieQ%40mail.gmail.com.