logo
down
shadow

Adding Scrollbar to Boxlayout in Kivy


Adding Scrollbar to Boxlayout in Kivy

By : Adam
Date : November 18 2020, 01:01 AM
around this issue I am trying to a Boxlayout with ScrollBar in Kivy, but I am not able to do it. Below excerpt of .kv file. I am dynamically adding controls to Boxlayout once the Boxlayout overflows controls are hidden and there is not Scrollbar. Please advise.
code :
ScrollView:
        size_hint: (None, None)
        size: (400, 400)
        BoxLayout:
            id: output
            orientation: 'vertical'
ScrollView:
        size_hint: (None, None)
        size: (400, 400)
        GridLayout:
            id: output
            cols: 1
            size_hint_y: None
            height: self.minimum_height


Share : facebook icon twitter icon
Kivy: Can you subdivide a BoxLayout within another BoxLayout?

Kivy: Can you subdivide a BoxLayout within another BoxLayout?


By : Starburst1427
Date : March 29 2020, 07:55 AM
around this issue Yes that is possible. You just nest another boxlayout.
Like this:
code :
<WeatherWidget>:
    cols: 1
    BoxLayout:
        size_hint_y: None
        BoxLayout:
            size_hint_x: 1
            orientation: "vertical"
            Image:
                src: "yourimage"
            Button:
                text: root.current_temperature()
        Label:
            text: 'Tomorrow'
            size_hint_x: 0.25
Kivy : how to add vertical scrollbar in boxlayout

Kivy : how to add vertical scrollbar in boxlayout


By : Alex Axthelm
Date : March 29 2020, 07:55 AM
I wish this help you when you are using a vertical scrollview you must set the height of the only child like this:
code :
ScrollView:
    BoxLayout:
        size_hint_y: None
        height: #the height that you want
kivy Calendar: How to insert kivy Calendar in a BoxLayout and set a function in its buttons

kivy Calendar: How to insert kivy Calendar in a BoxLayout and set a function in its buttons


By : Julio Zebadua
Date : March 29 2020, 07:55 AM
I wish did fix the issue. As I indicated in my comments, it is bad programming practice to call a variable and a function with the same name since it can hide other properties
Going to the point, calendar = ObjectProperty() is not linked to anything that Calendar does not link to the BoxLayout, it is also a local variable that its life cycle ends when the constructor is finished. In your case when you use self.calendar.add_widget(self.cal) the self.calendar refers to the calendar method where you call it and clearly the name of a method is not a widget causing that error.
code :
from kivy.clock import Clock

...

class Reservation(Screen):
    calendar = ObjectProperty()
    def __init__(self, **kwargs):
        super(Reservation, self).__init__(**kwargs)
        Clock.schedule_once(lambda *args: self.create_calendar())

    def create_calendar(self):
        self.cal = CalendarWidget()
        self.calendar.add_widget(self.cal)
<Reservation>:
     name: "Reserve"
     calendar: calendar # set value to ObjectProperty
     BoxLayout:
         BoxLayout: 
             id: calendar
         BoxLayout: 
             id: output_box
             orientation: 'vertical'
Python Kivy - Adding a GridLayout to a BoxLayout

Python Kivy - Adding a GridLayout to a BoxLayout


By : trontastic
Date : March 29 2020, 07:55 AM
help you fix your problem You have to set the size_hint_y of the GridLayout to None so that the height does not depend on the ScrollView and the size is minimum equal to the size of the GridLayout. On the other hand the Label must have size_hint_y to None so that the height does not depend on the GridLayout.
code :
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.scrollview import ScrollView
from kivy.uix.gridlayout import GridLayout

class MyApp(App):

    main_layout = BoxLayout(orientation='vertical')
    top_layout = BoxLayout(orientation='horizontal')

    scrollView = ScrollView()
    gridLayout = GridLayout(size_hint_y=None)

    gridLayout.cols = 1
    gridLayout.padding = [0, 0, 0, 0]
    gridLayout.bind(minimum_height=gridLayout.setter('height'))
    scrollView.add_widget(gridLayout)

    main_layout.add_widget(top_layout)
    main_layout.add_widget(scrollView)

    def btn_create(self, instance):
        self.gridLayout.add_widget(Label(text='test', size_hint_y=None))

    def btn_edit(self, instance):
        pass

    def btn_delete(self, instance):
        pass

    def build(self):
        self.top_layout.size_hint=(1, .1)

        # Button 'Erstellen'
        btnCreate = Button()
        btnCreate.text = 'Erstellen'
        btnCreate.bind(on_press=self.btn_create)

        # Button 'Bearbeiten'
        btnEdit = Button()
        btnEdit.text = 'Bearbeiten'
        btnEdit.bind(on_press=self.btn_edit)

        # Button 'Löschen'
        btnDelete = Button()
        btnDelete.text = 'Löschen'
        btnDelete.bind(on_press=self.btn_delete)

        self.top_layout.add_widget(btnCreate)
        self.top_layout.add_widget(btnEdit)
        self.top_layout.add_widget(btnDelete)

        return self.main_layout

if __name__ == '__main__':
    MyApp().run()
KIVY : BoxLayout containing horizontal BoxLayout

KIVY : BoxLayout containing horizontal BoxLayout


By : zachhhanding
Date : March 29 2020, 07:55 AM
will help you What about this: I changed HBOX and VBOX widget to BoxLayout and added Label and another BoxLayouts to ContainerBox. It looks quite like on your drawing
code :
<HBoxWidget>:

    AnchorLayout:
        anchor_x: 'center'
        anchor_y: 'center'
        Image:
            source: 'duck.jpg'
<VBoxWidget1>:
    BoxLayout:
        orientation: "horizontal"
        size: [1,.25]
        pos: root.pos
        Label:
            text: "Status : "
            color: [0,84,80,19]
        Label:
            text: "Pending"
            color: [0,84,80,19]
        Widget: # Because of this widget Labels are not in the middle, its not on your drawing tough


<ContainerBox>:
    orientation: 'vertical'
    Label:
        text: 'Label'
        size_hint_y: 0.1
    BoxLayout:
        id: four_horizontals
        orientation: 'horizontal'
        HBoxWidget:
        BoxLayout:
            orientation:'vertical'
            # One solution
            #GridLayout:
            #    cols:1
            #    padding: 100
            #    VBoxWidget1:
            #    VBoxWidget1:
            #    VBoxWidget1:
            #    VBoxWidget1:

            #Second Solution
            BoxLayout:
                #size_hint_y: 0 to 1 - it says how much you reduce height. Now its 1/3 of its parent, because there are 3 boxlayouts. if you set 0.5, it will have 1/3*0.5 and the other 2 boxlayouts takes the height which you took from this one 
            BoxLayout:
                orientation:'vertical'
                VBoxWidget1:
                VBoxWidget1:
                VBoxWidget1:
                VBoxWidget1:
            BoxLayout:
from kivy.app import App
from kivy.uix.togglebutton import ToggleButton
from kivy.uix.widget import Widget
from kivy.uix.boxlayout import BoxLayout

class HBoxWidget(BoxLayout):
    def __init__(self, **kwargs):
        super(HBoxWidget, self).__init__(**kwargs)

class VBoxWidget1(BoxLayout):
    def __init__(self, **kwargs):
        super(VBoxWidget1, self).__init__(**kwargs)


class ContainerBox(BoxLayout):
    def __init__(self, **kwargs):
        super(ContainerBox, self).__init__(**kwargs)

class TestApp(App):
    def build(self):
        return ContainerBox() 

if __name__ == '__main__':
    TestApp().run()
Related Posts Related Posts :
  • Remove commas in a string, surrounded by a comma and double quotes / Python
  • How to chain Django querysets preserving individual order
  • Comparison with Python
  • How to find backlinks in a website with python
  • Return new instance of subclass when using methods inherited from parent class in Python
  • Which function in django.contrib.auth creates the default model permissions?
  • Formatting text in tabular form with Python
  • How to determine the first day of a month in Python
  • Error while converting date to timestamp in python
  • Python string iterations
  • Is there any file number limitation when you select multiple files with wxFileDialog?
  • Errors with Matplotlib when making an executable with Py2exe (Python)
  • Django Haystack - Indexing single field
  • Go Pro Hero 3 - Streaming video over wifi
  • Appending a column in .csv with Python/Pandas
  • How to change my result directory in Robot framework using RIDE?
  • problem with using pandas to manipulate a big text file in python
  • python-magic module' object has no attribute 'open'
  • Where goes wrong for this High Pass Filter in Python?
  • Why inserting keys in order into a python dict is faster than doint it unordered
  • flann index saving in python
  • Create new instance of list or dictionary without class
  • How can I easily convert FORTRAN code to Python code (real code, not wrappers)
  • Address of lambda function in python
  • Python adding space between characters in string. Most efficient way
  • python http server, multiple simultaneous requests
  • Disguising username & password on distributed python scripts
  • Post GraphQL mutation with Python Requests
  • Why doesnt pandas create an excel file?
  • Rolling comparison between a value and a past window, with percentile/quantile
  • How to avoid repetitive code when defining a new type in python with signature verification
  • How to configure uWSGI in order to debug with pdb (--honour-stdin configuration issue)
  • In Python, how do you execute objects that are functions from a list?
  • Python- Variable Won't Subtract?
  • Processing Power In Python
  • Python 2.7.2 - Cannot import name _random or random from sys
  • Why doesn't the Python sorted function take keyword order instead of reverse?
  • Make a function redirect to other functions depending on a variable
  • get_absolute_url in django-categories
  • Monitoring non-Celery background task with New Relic in Python
  • Feature selection with LinearSVC
  • LSTM - Predicting the same constant values after a while
  • Test the length of elements in a list
  • Django: render radiobutton with 3 columns, cost column must change according to size & quantity selected
  • Python class attributes vs global variable
  • sys.stdout.writelines("hello") and sys.stdout.write("hello")
  • is ndarray faster than recarray access?
  • Python - search through directory trees, rename certain files
  • GAE: How to build a query where a string begins with a value
  • TypeError: __init__() takes at least 2 arguments (1 given)
  • Overriding and customizing "django.contrib.auth.views.login"
  • Django : Redirect to a particular page after login
  • Python search and copy files in directory
  • pretty printing numpy ndarrays using unicode characters
  • Frequent pattern mining in Python
  • How can I make a set of functions that can be used synchronously as well as asynchronously?
  • Convert one dice roll to two dice roll
  • count occourrence in a list
  • Writing an If condition to filter out the first word
  • to read file and compare column in python
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org