我正在编写带有2个按钮的代码,用kivy将随机文本返回到标签,但是我无法通过2个按钮将文本返回到同一行,我希望任何一个按钮都覆盖任何第二个按钮显示在同一行
: BoxLayout的:
orientation: 'vertical'
pos: self.pos
Label:
id: label1
text: root.truths
Label:
id: label2
text: root.dares
GridLayout:
cols: 2
spaccing: 20
padding: 25
Button:
text: 'Truth'
on_press: root.truthkey()
Button:
text: "Dare"
on_press: root.darekey()
以上是kv文件中的代码,python文件中的代码显示在下面
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.gridlayout import GridLayout
from kivy.uix.boxlayout import BoxLayout
import random
from kivy.properties import StringProperty
class TruthandDare(BoxLayout):
truths = StringProperty()
dares = StringProperty()
def __init__(self, **kwargs):
super(TruthandDare, self).__init__(**kwargs)
self.truths=str(random.choice(['a']))
self.dares=str(random.choice(['b']))
def truthkey(self):
self.truths=str(random.choice(['What is your biggest fear in a relationship',
'What was your funniest date ever',
'How many kids would you like to have',
'What was your childhood nickname',
'what is your favourite movie',
'what is your favourite food',
'what is your dream job',
'if you were trapped on an island for 3 days, what would you take with you',
'Do you prefer apple or android device',
'What is your best talent',
'Do you believe in love at first sight',
'What is your dream wedding',
'if you could change one thing on your body, what would it be']))
def darekey(self):
self.dares = str(random.choice(['b','c','d','e','f']))
class TruthDareApp(App):
def build(self):
return TruthandDare()
if __name__=='__main__':
TruthDareApp().run()
答案 0 :(得分:0)
也许做类似的事情:
PS C:\TestPlatform\executables> TestApp.exe -c off -d file -q otp 47f64 | tee LogFile.txt
PS C:\TestPlatform\executables> TestApp.exe -c off -d file -q otp 47f64 | out-file -append LogFile.txt
C:\TestPlatform\executables> TestApp.exe -c off -d file -q otp 47f64 > logFile.txt 2>&1
我希望这会有所帮助,即使没有让我知道。