問題描述
我正在制作一個 BoxLayout 小部件(orientation = 'horizo??ntal'),其中包含三個小部件、一個標簽、一個文本框和一個復選框.
I am making a BoxLayout widget (orientation = 'horizontal') that contains three widgets inside of it, a label, a text box, and a check box.
thisRow = BoxLayout(orientation='horizontal')
l = Label(text='Enter plate 1:
(Plate #)')
t = TextInput(text = 'this is a text box')
c = CheckBox()
thisRow.add_widget(l)
thisRow.add_widget(t)
thisRow.add_widget(c)
這會產生以下小部件 (thisRow):
This produces the following widget (thisRow):
勾選后...
最右邊的黑框實際上是復選框,并且可以正常工作,但是用戶無法知道它實際上是一個復選框.我希望中間有一個較小的空方塊,如圖 這里的圖片所示.
The rightmost black box is actually the checkbox, and works functionally, however there is no way for the user to know that it is in fact a checkbox. I would expect a smaller empty square in the middle, as is depicted in pictures here.
如何獲得傳統的復選框圖像(較小的空方框)?或者一般來說,我怎樣才能更明顯地表明該框是一個復選框,而不僅僅是一個空標簽?
How do i get the traditional checkbox image (smaller empty square box)? Or generally, how can I make it more obvious that the box is a check box and not just an empty label?
謝謝
推薦答案
這是一個非常有趣的問題,Malonge 很好地嘗試了它.現在(1.9.2-dev) CheckBox
的井上仍然有固定的大小,稱之為背景.它是 Widget
從 atlas 中獲取的圖像,并在狀態更改時更改.因此,直到 現在 之前,還沒有明確的方法可以做到這一點.這是一個例子.很快在 master 上會有 CheckBox(color=[r,g,b,a])
選項.謝謝;)
This is really interesting question and Malonge tried it in a good way. Right now(1.9.2-dev) there is still fixed size on CheckBox
's well, call it a background. It's an image that Widget
takes from atlas and changes if the state changes. Therefore until now there was no clear way how to do it. Here is an example. Soon on master there'll be CheckBox(color=[r,g,b,a])
option. Thanks ;)
from kivy.lang import Builder
from kivy.base import runTouchApp
from kivy.uix.boxlayout import BoxLayout
Builder.load_string('''
<CheckBoxBG>:
Label:
TextInput:
CheckBox:
canvas.before:
Color:
rgb: 1,0,0
Rectangle:
pos:self.center_x-8, self.center_y-8
size:[16,16]
Color:
rgb: 0,0,0
Rectangle:
pos:self.center_x-7, self.center_y-7
size:[14,14]
''')
class CheckBoxBG(BoxLayout):pass
runTouchApp(CheckBoxBG())
這篇關于Kivy CheckBox 看起來像實心黑框(不是復選框)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!