How to remove outer layer margin from MDTextField? - kivy

I want to have two MDTextFields touching each other at their bottom and top border
The MDTextField has an outer layer which prevents them from touching each other. Is there a property to remove this margin? Margins I want to remove(black rectangles):
MDTextfields colored to show the margins
Lines I want to touch:
Arrows pointing at parts of borders I want to merge together
BoxLayout:
orientation:"vertical"
size_hint: 1, None
height:textfield1.height+ textfield2.height
MDTextField:
id:textfield1
hint_text: "Rectangle mode"
mode: "rectangle"
MDTextField:
id:textfield2
hint_text: "Rectangle mode"
mode: "rectangle"
Final product would be something like this:
Here
Thank you!

I can't comment due to rep. This worked for me:
spacing:"-10dp" in BoxLayout

Related

Transparent animated graphics in Kivy

I am new to Kivy and want to create a widge graphic image of a tank with a transparent cutout that "fills" with another graphic image of the product. How do I stack 2 graphic images, one with a transparent layer, on top of one another to get this effect? I have created this with a circle/rectangle and fill color, but I want both a custom foreground image and a custom fill image.
You can stack Image widgets by simply placing them at the same position. For example, in kv you can do:
FloatLayout:
Image:
source: 'fill.png'
size_hint: 0.25, 0.25
pos_hint: {'center_x':0.5, 'center_y':0.5}
allow_stretch: True
Image:
source: 'tank.png'
size_hint: 0.25, 0.25
pos_hint: {'center_x':0.5, 'center_y':0.5}
allow_stretch: True
This will show the tank.png with the fill.png showing through any transparent areas of tank.png.

GeoExt Tree Panel Align Left

I am new in ExtJS 6 and GeoExt3 but how do I align layers to my tree panel to the left of the panel. The layers are showing but on the right, I have tried align: 'left' on the panel and its not working, please help.
It seems that you have a border layout. Setting region: "west" for the treepanel wrapper container should solve your problem.

How to position text horizontally in vertical tabs?

I have vertical tabs but want to 'rotate' the tab labels so that these read horizontally. How could this be done?
The kivy file contains:
TabbedPanel:
id: tab_panel
tab_pos: 'left_top'
do_default_tab: False
TabbedPanelItem:
text: '1'
TabbedPanelItem:
text: '2'
TabbedPanelItem:
text: '3'
Edit: Actually, it IS possible!
TabbedPanelItem:
text: '2'
canvas.before:
PushMatrix
Rotate:
angle: -90
axis: 0,0,1
origin: self.center
canvas.after:
PopMatrix
With current api impossible. And it'll be really ugly if you manage to do it, because it'll stretch the tab-header and make it a square or even another, 90° rotated rectangle, which will screw your Layout as much as possible - the original tab will look like a casual Button and whole TabbedPanel as a beginner's try to make html page if you don't want to limit yourself to 3-4 characters with current font size. Just saying.
You may try to edit the source and one of the ways how to do it directly is making a custom ToggleButton from which TabbedPanelHeader inherits and rotate it with Push/PopMatrix().
The other (and more reasonable) way would be to make tabs look like this:
t|
a| content
b|
_|
i.e. text going up -> down, though I don't know how to do it except rotating the whole thing and work with characters like this: t\na\nb

rotate entire widget, not only its canvas

In this example, we can see a rotation of the canvas. But clicking the button's corners isn't registered. How can I rotate the entire button?
You can probably override its collide_point method to account for the rotation by transforming the touch coordinates.
If you use the widget system (e.g. putting the Button in a Scatter), the collision is taken care of for you.
Based on inclement's answer, I've created a button on a scatter layout, which has its hitbox set correctly.
from kivy.app import App
from kivy.lang import Builder
kv = '''
FloatLayout:
ScatterLayout:
size_hint: None, None
size: 200, 200
pos_hint: {'center_x': .5, 'center_y': .5}
rotation: 45
do_rotation: False
do_scale: False
do_translation: False
Button:
text: 'hello world'
'''
class RotationApp(App):
def build(self):
return Builder.load_string(kv)
RotationApp().run()
I used scatter layout instead of scatter, because it passes its size to children widgets. The do_x: False aren't needed in this example, because button intercepts touching events, but if I placed a label, it would move on touch.

Dynamically resizing a Label within a Scrollview?

Let's say you have a setup like the following:
ScrollView:
size_hint: (1, 0.5)
Label:
size_hint: (1, None)
Initially, the Label has no content/text. If I understand correctly, when the objects are created, the Label's height is None.
When the app is run, the Label's text property is set to multiple lines of text, which should push the content of the Label outside the boundaries of the ScrollView. However, for scrolling to happen, it seems that the Label's y dimension/height has to be dynamically resized.
What is the best way to dynamically resize the height of the Label in accordance with the Label's new content such that a scrolling action can occur?
The actual text is displayed in a Rectangle whose size is not coupled to the Label size by default. When the amount of text is large, this grows larger and can exceed the Label bounds, but does not resize the label.
The relevant property controlling the real size of the displayed text is Label.text_size. To get the behaviour you want, you can simply do:
ScrollView:
size_hint: (1, 0.5)
Label:
size_hint: (1, None)
height: self.text_size[1]
This binds the height of the label to track the height of the displayed text, and so should give you the behaviour you want.
As a side note, it's often useful to change or watch text_size. For instance, to make the text wrap at the edges of the Label rather than relying on manual newlines, you can set text_size: self.size which means the text will be automatically wrapped if its width would exceed the label width. This is also important if working with halign or valign, which control the text position within its texture and not within the label itself - those properties will have no visible effect unless you manually set text_size to (again) something larger than the space the text actually takes up.
Edit: As per your comments below, here's an example of a Label in one of my apps, which grows vertically if the length of text increases (so the user can scroll), but also automatically wraps text when its width is greater than the label width. It seems I actually did this by putting the Label in a GridLayout, which I vaguely remember was important for some reason.
GridLayout:
cols: 1
spacing: 10
size_hint_y: None
height: thetb.texture_size[1]
Label:
id: thetb
text: 'whatever'
text_size: self.width, None
size_hint: (1, None)
size: self.parent.width, self.texture_size[1]
You can see I use text_size to control the text boundingbox (so it wraps at the label edges), but bind the GridLayout height to really track the texture_size height. The GridLayout is placed in the ScrollView, and I get exactly the behaviour I think you want.

Resources