-
-
Notifications
You must be signed in to change notification settings - Fork 693
Fix: Wrong spaing when using Dialog withoutMDDialogHeadlineText #1835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tomasz-brak
wants to merge
2
commits into
kivymd:master
Choose a base branch
from
tomasz-brak:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
|
Hi! |
Author
|
I think, i tested almost every combination possible, and i didn't encounter any issues i used this code to speedup the testing import dataclasses
import inspect
from kivy.logger import Logger
from kivy.uix.widget import Widget
from kivymd.app import MDApp
from kivymd.uix.boxlayout import MDBoxLayout
from kivymd.uix.button.button import MDButton, MDButtonText
from kivymd.uix.dialog.dialog import (
MDDialog,
MDDialogButtonContainer,
MDDialogContentContainer,
MDDialogHeadlineText,
MDDialogIcon,
MDDialogSupportingText,
)
from kivymd.uix.divider.divider import MDDivider
from kivymd.uix.label.label import MDIcon, MDLabel
from kivymd.uix.list.list import (
MDListItem,
MDListItemLeadingIcon,
MDListItemSupportingText,
)
from kivymd.uix.screen import MDScreen
from kivymd.uix.selectioncontrol.selectioncontrol import MDCheckbox
Logger.setLevel("DEBUG")
class Options:
icon = True
supporting_text = True
headline = True
divider = True
item_list = True
buttons = True
opt = Options()
def show_dialog(*_, **__):
MDDialog(
(
MDDialogIcon(
icon="refresh",
)
if opt.icon
else None
),
(
MDDialogHeadlineText(
text="Reset settings?",
)
if opt.headline
else None
),
(
MDDialogSupportingText(
text="This will reset your app preferences back to their "
"default settings. The following accounts will also "
"be signed out:",
)
if opt.supporting_text
else None
),
MDDialogContentContainer(
MDDivider() if opt.divider else None,
(
MDListItem(
MDListItemLeadingIcon(
icon="gmail",
),
MDListItemSupportingText(
text="[email protected]",
),
theme_bg_color="Custom",
)
if opt.item_list
else None
),
(
MDListItem(
MDListItemLeadingIcon(
icon="gmail",
),
MDListItemSupportingText(
text="[email protected]",
),
theme_bg_color="Custom",
)
if opt.item_list
else None
),
MDDivider() if opt.divider else None,
orientation="vertical",
),
(
MDDialogButtonContainer(
Widget(),
MDButton(
MDButtonText(text="Cancel"),
style="text",
),
MDButton(
MDButtonText(text="Accept"),
style="text",
),
spacing="8dp",
)
if opt.buttons
else None
),
).open()
class CheckItem(MDBoxLayout):
def __init__(self, text, **kwargs):
super().__init__(**kwargs)
self.orientation = "horizontal"
self.label = MDLabel(
text=text,
halign="left",
valign="center",
)
self.checkbox = MDCheckbox(
size_hint=(None, None),
size=("48dp", "48dp"),
pos_hint={"center_y": 0.5},
active=True,
)
self.add_widget(self.label)
self.add_widget(self.checkbox)
class MainApp(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark"
self.theme_cls.primary_palette = "Orange"
layout = MDBoxLayout(
MDButton(
MDButtonText(text="Show Dialog"),
pos_hint={"center_x": 0.5, "center_y": 0.5},
on_release=show_dialog,
),
orientation="vertical",
)
attributes = inspect.getmembers(
opt, lambda a: not (inspect.isroutine(a))
)
fields = [
dataclass_field
for dataclass_field in attributes
if not (dataclass_field[0].startswith("__"))
]
print(fields)
for option in fields:
print(option)
check_item = CheckItem(text=option[0].replace("_", " ").title())
check_item.checkbox.bind(
on_active=lambda instance, value, option=option[0]: setattr(
opt, option, value
)
)
layout.add_widget(check_item)
return MDScreen(layout)
MainApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the problem
Describe what problem Closes #1680
Description of Changes
Don't add spacing with the Boxlayout's spacer, instead
Screenshots of the solution to the problem
Code for testing new changes