- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
因此,我正在尝试使用 Kivy 构建一个应用程序,最近,我了解了 KivyMD 但被卡住了。当我更改主调色板颜色时,每个按钮都保持蓝色,但 MDDropDownMenu 会发生变化。我尝试在构建方法之前和构建方法中使用它,但它仍然只对 MDDropDownMenu 有效。什么会导致这种情况?
主要.py:
from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder
from kivy.core.window import Window
from kivy.config import Config
from kivy.properties import ObjectProperty
from root.ModelPrep import validate_params, change_koatuu, prep_params, load_regression
from kivymd.theming import ThemeManager
from kivymd.toast import toast
class MainWindow(Screen):...
class LoadWindow(Screen):...
class ResultWindow(Screen):...
class WindowManager(ScreenManager):
pass
# kv_non_md = Builder.load_file('deepeval_non_md.kv')
kv_md = Builder.load_file('deepeval_md.kv')
class DeepEval(App):
theme_cls = ThemeManager()
title = 'DeepEval'
main_widget = None
menu_items = []
def callback_for_menu_items(self, *args):
toast(args[0])
def build(self):
self.theme_cls.primary_palette = 'Teal'
self.theme_cls.theme_style = 'Light'
self.menu_items = [{
"viewclass": "MDMenuItem",
"text": "Example item %d" % i,
"callback": self.callback_for_menu_items,
}
for i in range(15)
]
return kv_md
if __name__ == '__main__':
DeepEval().run()
deepeval_md.kv:
#:import Factory kivy.factory.Factory
#:import Clock kivy.clock.Clock
#:import MDDropdownMenu kivymd.uix.menu.MDDropdownMenu
WindowManager:
MainWindow:
LoadWindow:
ResultWindow:
<MainWindow>
name: 'main'
koatuu_obl_cent: koatuu_obl_cent
koatuu_city: koatuu_city
kitchen_area: kitchen_area
qt_room: qt_room
floor: floor
qt_floor: qt_floor
total_area: total_area
living_area: living_area
year_building: year_building
AnchorLayout:
anchor_x: 'center'
anchor_y: 'center'
size: root.width, root.height
BoxLayout:
orientation: 'vertical'
height: 350
width: 225
size_hint_x: None
size_hint_y: None
spacing: 22.5
MDTextFieldRect:
id: total_area
multiline: False
hint_text: "Param12"
halign: 'center'
height: 33
width: 225
size_hint_x: None
size_hint_y: None
MDTextFieldRect:
id: kitchen_area
multiline: False
hint_text: "Param1"
halign: 'center'
height: 33
width: 225
size_hint_x: None
size_hint_y: None
MDTextFieldRect:
id: living_area
multiline: False
hint_text: "Param1"
halign: 'center'
height: 33
width: 225
size_hint_x: None
size_hint_y: None
MDTextFieldRect:
id: qt_room
multiline: False
hint_text: "Param1"
halign: 'center'
height: 33
width: 225
size_hint_x: None
size_hint_y: None
MDTextFieldRect:
id: floor
multiline: False
hint_text: "Param1"
halign: 'center'
height: 33
width: 225
size_hint_x: None
size_hint_y: None
MDTextFieldRect:
id: qt_floor
multiline: False
hint_text: "Param1"
halign: 'center'
height: 33
width: 225
size_hint_x: None
size_hint_y: None
MDTextFieldRect:
id: year_building
multiline: False
hint_text: "Param1"
halign: 'center'
height: 33
width: 225
size_hint_x: None
size_hint_y: None
MDFillRoundFlatButton:
id: koatuu_obl_cent
text: 'Open popup'
pos_hint: {'center_x': .5}
on_release: MDDropdownMenu(items=app.menu_items, width_mult=3).open(self)
height: 33
width: 225
size_hint_x: None
size_hint_y: None
MDFillRoundFlatButton:
id: koatuu_city
pos_hint: {'center_x': .5}
text: 'Open popup'
on_release: MDDropdownMenu(items=app.menu_items, width_mult=3).open(self)
height: 33
width: 225
size_hint_x: None
size_hint_y: None
AnchorLayout:
anchor_x: "center"
anchor_y: "bottom"
padding: 0,0,0,25
MDFillRoundFlatButton:
text: "Calculate"
size_hint_x: None
size_hint_y: None
height: 50
on_press: app.root.current = 'load'
on_release:
最佳答案
您可以使用以下方法更改按钮颜色:MDFillRoundFlatIconButton:md_bg_color: [0, 0, 0, .3]
我只是希望这会有所帮助!
关于python - 使用 KivyMD 时更改主调色板颜色对按钮没有影响,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58787864/
我是 kivy/kivymd 的新手,我正在尝试通过 kivymd 文档创建一个下拉菜单。但是,每当我单击下拉菜单时,它都会向我返回此错误: AttributeError: 'Box_2' 对象没有属
我正在使用 KivyMD 并想使用“on_pre_enter”方法刷新第二个屏幕中的数据。我试图从屏幕类“on_pre_enter”方法中访问标签 ID,但没有成功。 我可以从“MainApp”类访问
因此,我正在尝试使用 Kivy 构建一个应用程序,最近,我了解了 KivyMD 但被卡住了。当我更改主调色板颜色时,每个按钮都保持蓝色,但 MDDropDownMenu 会发生变化。我尝试在构建方法之
我正在尝试增加kivyMD 按钮 的宽度 和高度,但它不受支持(size_hint)。 •我应该创建自己的继承自 Button 类的按钮类吗? •考虑到我希望我的应用程序在 Android 上运行,这
如何将 Action 添加到“确定”按钮?我从 KivyMd 文档中获得了示例代码,但没有解释如何将操作添加到这些按钮。代码: from kivy.lang import Builder from k
我最近将我的 kvmd 更新到了 0.104.1 版,它包含了一些对对话框的重大更改。我的程序包含一个按钮,按下该按钮时会显示一个包含一些文本的对话框和 2 个按钮,即 OK 和 CANCEL。取消按
我正在尝试学习 KivyMD 工具。所以我创建了 MDToolBar,它的标题在点击一些按钮后发生了变化。我试图优化它的 text_size 但不能做到。我已经尝试过 font_type:'H1' ,
我不确定如何根据屏幕尺寸动态调整 MDDatePicker 的大小,它不能像 Labels 和 Buttons 那样正确调整,而是会不规律地调整。 我在 KivyMD 文档中找不到像在 Kivy 小部
我正在 KivyMD 中编写一个简单的应用程序。根据 kivy 文档,我的 .kv 结构与 MDNavigationDrawer 和 MDToolbar 是正确的,只要屏幕是空的,一切都可以正常工作。
我是 Python 和 KivyMD 的新手。也可以使用数据库。我想检查用户使用 KivyMD 应用程序提供的数据是否已经在 Firebase 实时数据库中。这些是 Firebase 中的数据。 代码
我试图在我的 kv 文件中获取 MDDropwdownMenu 的选择我正在通过以下代码使用 MDRaisedButton MDRaisedButton:
我想更改 MDToolbar left_action_item 图标颜色。它默认为白色,但现在我想将其更改为红色。最简单的方法是什么?我几乎尝试了所有方法(text_color、bg_color 等)
我目前在使用 MDCheckbox 时遇到一些问题。当我使用默认的 Kivy Checkbox 时,kv 代码中的 on_active 参数似乎工作得很好。但现在我尝试将 KivyMD MDCheck
我尝试使用 pip3 install kivymd 安装 kivymd ,但出现错误: /tmp/pip-build-46hjob8h/kivy/kivy/include/gl_redirect.h:
我正在使用 Kivy 和 KivyMD 创建布局,并希望更改 MD 按钮中显示的文本颜色,但颜色仍然停留在浅蓝色。 我在下面的代码中包含了我尝试过的示例。 .py代码 import kivy, kiv
我在从 MDDropdownMenu 单击 MDMenuItem 后更改 2 个不同按钮上的按钮文本时遇到问题 - 只有一个按钮可以更改自身文本。每个按钮都必须单独更改文本。 在那种情况下 - 两个按
示例代码似乎有点过时,例如我不得不用“MDNavigationLayout”替换“NavigationLayout”。 我正在使用从 github 下载的最新 kivymd 这是simplest ex
我的 Kivy 应用在 Android 手机上启动时崩溃。 buildozer logcat 显示以下错误: 02-21 17:09:58.777 14941 14979 I python : M
我是一名优秀的程序员,十分优秀!