Feb-05-2021, 05:40 PM
I'm very new to Kivy and I've hit a wall with popups.
I have a main screen which has four buttons in a float layout. On press down I want the 'MOVE' button to open a popup. Now I've got this working but the popup contains the same four buttons as my mainscreen.
Note: Someone from SO tried running the below code and it worked perfectly for them - no duplicate buttons!
This is my Python code:
All suggestions appreciated!
I have a main screen which has four buttons in a float layout. On press down I want the 'MOVE' button to open a popup. Now I've got this working but the popup contains the same four buttons as my mainscreen.
Note: Someone from SO tried running the below code and it worked perfectly for them - no duplicate buttons!
This is my Python code:
def show_movepop(): show = MovePop() movepopWindow = Popup(title="Move", content=show, size_hint=(None, None),size=(400,400)) movepopWindow.open() class MovePop(FloatLayout): pass class MainWindow(Screen): def movebtn(self): show_movepop() class StatsWindow(Screen): pass class WindowManager(ScreenManager): pass kv = Builder.load_file("gamegui.kv") class MainFloatApp(App): def build(self): return kv if __name__ == "__main__": MainFloatApp().run()and this is my .kv file:
WindowManager: MainWindow: StatsWindow: <Button> font_size:40 color:0.3,0.6,0.7,1 size_hint: 0.5, 0.1 <MainWindow>: name: "mainscreen" FloatLayout Button: text: "MOVE" id: move pos_hint: {"x":0, "y":0.1} on_release: root.movebtn() Button: text: "ACTION" id: action pos_hint: {"x":0.5, "y":0.1} Button: text: "EXAMINE" id: examine pos_hint: {"x":0, "y":0} Button: text: "STATS" id: stats pos_hint: {"x":0.5, "y":0} on_release: app.root.current = "statsscreen" root.manager.transition.direction = "left" <StatsWindow>: name: "statsscreen" Button: text: "Back" on_release: app.root.current = "mainscreen" root.manager.transition.direction = "right" <MovePop>: Button: text: "!" pos_hint: {"x":0.1, "y":0.5} on_release:Apologies in advance if the above is super dirty, I'm not very efficient :')
All suggestions appreciated!