如果您在第一个GridLayout下面查看一个图像小部件。我想让它移到屏幕的右边。任何帮助都是适当的。这是密码。我在右边需要的widget的id是id=image。我好像根本动不了它。在
我会提供更多的细节,因为stackoverflow想要的就是它。我觉得上面的内容确实很详细,但是你负责,所以这里有更多的文字。在
谢谢大家。在
from kivy.lang import Builder
from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen, NoTransition
Builder.load_string("""
<ClientScreen>:
GridLayout:
id: main_grid_layout
orientation: 'vertical'
cols: 1
Label:
id: name_label
text: '<NO MENU NAME>'
size_hint_y: None
size: self.texture_size
halign: 'left'
valign: 'center'
text_size: self.size
padding_x: 35
canvas.before:
Color:
rgb: .6, .6, .6
Rectangle:
pos: self.pos
size: self.size
Image:
id: image
pos_hint: {'right': 0.5}
ScrollView:
id: text_scroll_view
bar_width: 10
size: self.size
GridLayout:
id: text_grid_layout
orientation: 'vertical'
cols: 1
size_hint_y: None
height: self.minimum_height
ScrollView:
size: self.size
bar_width: 10
size_hint_y: 0.40
GridLayout:
id: action_grid_layout
# padding: [10, 10, 10, 10]
orientation: 'vertical'
cols: 1
size_hint_y: None
# row_default_height: 30
height: self.minimum_height
""")
class LoginScreen(Screen):
pass
class ClientScreen(Screen):
pass
class MyApp(App):
def build(self):
from kivy.core.window import Window
sm = ScreenManager()
sm.transition = NoTransition()
global CLIENT_SCREEN
LOGIN_SCREEN = LoginScreen(name='login')
CLIENT_SCREEN = ClientScreen(name='client')
sm.add_widget(LOGIN_SCREEN)
sm.add_widget(CLIENT_SCREEN)
sm.current = 'client'
Window.size = (300, 120)
self.title = 'xNemesis Client V0'
return sm
MyApp().run()
在kv文件中,执行以下操作。详情请参考下面的例子。在
GridLayout:
替换为BoxLayout:
,因为GridLayout
与{cols: 1
Image:
处,添加size_hint_x: 0.4
pos_hint: {'right': 0.5}
替换为pos_hint: {'right': 1}
注意
GridLayout没有名为orientation的属性。
示例
在主.py在
输出
相关问题 更多 >
编程相关推荐