Python Forum
[Kivy] Kivy pop up shows duplicate buttons from main screen
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Kivy] Kivy pop up shows duplicate buttons from main screen
#1
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:

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!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] showing return from button on main screen blazejwiecha 4 2,595 Nov-22-2020, 04:33 PM
Last Post: blazejwiecha
  [Kivy] Kivy text label won't shows up! AVD_01 1 2,894 Jun-21-2020, 04:01 PM
Last Post: AVD_01
  [PyQt] Ubuntu Taskbar icon shows title as "Unknown" while hover davidmuni 3 3,686 Jan-28-2020, 01:13 PM
Last Post: davidmuni
  “main thread is not in main loop” in Tkinter Long_r 1 24,081 Jun-26-2019, 11:00 PM
Last Post: metulburr
  [Tkinter] Thread for serial Reading shows an error eabs86 0 3,008 Sep-20-2018, 01:44 AM
Last Post: eabs86
  GTK main window calling a main window DennisT 4 6,689 Oct-19-2016, 09:36 PM
Last Post: DennisT

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020