Skip to content

Instantly share code, notes, and snippets.

@c34s3r
Created November 14, 2015 08:09
Show Gist options
  • Select an option

  • Save c34s3r/19283a6fccd6509392b7 to your computer and use it in GitHub Desktop.

Select an option

Save c34s3r/19283a6fccd6509392b7 to your computer and use it in GitHub Desktop.
kivy popup with 2 buttons
I created a popup in kivy with two buttons...
one button closes the popup while the other does nothing..
I used the floatlayout ..
this is the. py file...
#-*-coding:utf8;-*-
#qpy:2
#qpy:kivy
from kivy.app import App
from kivy.uix.popup import Popup
from kivy.uix.widget import Widget
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.floatlayout import FloatLayout
from kivy.lang import Builder
Builder.load_file("pop.kv")
class pop(Widget):
def show_it(self):
self.box=FloatLayout()
self.lab=(Label(text="this is a pop exampleby vitriol ",font_size=15,
size_hint=(None,None),pos_hint={'x':.25,'y':.6}))
self.box.add_widget(self.lab)
self.but=(Button(text="close",size_hint=(None,None),
width=200,height=50,pos_hint={'x':0,'y':0}))
self.box.add_widget(self.but)
self.box.add_widget(Button(text="blank",size_hint=(None,None),
width=200,height=50,pos_hint={'x':.5,'y':0}))
self.main_pop = Popup(title="my_pop",content=self.box,
size_hint=(None,None),size=(450,300),auto_dismiss=False,title_size=15)
self.but.bind(on_press=self.main_pop.dismiss)
self.main_pop.open()
class PopApp(App):
def build(self):
return pop()
PopApp().run()
and the kv file...
## kivy for my_popup...
<pop>:
Button:
id: main_button
text: "pop-up"
font_size: 25
size_hint: None,None
width:root.width/2
height:60
on_press: root.show_it()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment