Nothing is appearing in my TabbedPanel in Kivy - python

I am trying to code up a program using the TabbedPanel class. I am going to use ScreenManager and navbuttons to navigate different screens within each tab. Problem is nothing is showing up. At first at least the NavLayout was showing up but now all that appears are the tabs with their respective names. How do I get both Navigation buttons and Screen to show up in the tab.
ex1.kv
<MainPanel>:
id: mp
usb_tab_wid: usb_tab
remote_tab_wid: remote_tab
sd_tab_wid: sd_tab
size_hint: 1,1
tab_width: 65
do_default_tab: False
tab_pos: 'top_right'
TabbedPanelItem:
id: usb_tab
text: 'Usb'
BoxLayout:
orientation: 'vertical'
UsbScreenManager:
NavLayout:
TabbedPanelItem:
id: remote_tab
text: 'Remote'
TabbedPanelItem:
id: sd_tab
text: 'SD'
<NavLayout>:
id: grid1
spacing: 5,5
rows: 1
size_hint: 1, .2
LeftButton:
id: left_arrow_button
Image:
source: 'left_arrow_iconb.png'
center: left_arrow_button.center
size: grid1.width*.8, grid1.height*.8
BackButton:
id: back_button
Image:
source: 'back_iconb.png'
center: back_button.center
size: grid1.width*.8, grid1.height*.8
RightButton:
id: right_arrow_button
Image:
source: 'right_arrow_iconb.png'
center: right_arrow_button.center
size: grid1.width*.8, grid1.height*.8
usb.kv
<UsbScreenManager>:
id: usb_screen_manager
H2HScreen:
name: 'h2h'
V9validationScreen:
name: 'v9'
<H2HScreen>:
name: 'h2h'
BoxLayout:
TestIcon:
source: 'h2h.png'
<V9validationScreen>:
name: 'v9'
BoxLayout:
Label:
text: 'V9 tests'
ex1.py
import kivy
kivy.require('1.9.0')
import subprocess
import csv
from datetime import datetime
import usb.core
import usb.util
import threading
import time
from functools import partial
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.behaviors import ButtonBehavior
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.properties import ObjectProperty, StringProperty, NumericProperty
from kivy.clock import Clock
from kivy.uix.image import Image
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition
from kivy.lang import Builder
from kivy.app import App
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.uix.boxlayout import BoxLayout
class MainPanel(TabbedPanel):
usb_tab_wid = ObjectProperty()
remote_tab_wid = ObjectProperty()
sd_tab_wid = ObjectProperty()
usbman = ObjectProperty(None)
def switch_to(self, header):
pass
def print_wd(self):
for widget in self.walk():
print("[]->{}".format(widget, widget.id))
def on_current_tab(self, b, c):
print(self.current_tab)
#return super(MainPanel, self).on_current_tab()
#print(usb_tab_wid)
pass
class TestIcon(ButtonBehavior, Image):
pass
class UsbScreenManager(ScreenManager):
pass
class H2HScreen(Screen):
pass
class V9validationScreen(Screen):
pass
class RemoteScreenManager(ScreenManager):
pass
class SDcardScreenManager(ScreenManager):
pass
class NavLayout(GridLayout):
pass
class LeftButton(Button):
sm = ObjectProperty()
mp = MainPanel()
ct= mp.current_tab
#print (ct)
pass
class RightButton(Button):
sm = ObjectProperty()
panel = ObjectProperty()
pass
class BackButton(Button):
sm = ObjectProperty()
panel = ObjectProperty()
def active_panel():
#if current tab is __ then load corresponding screen manager
pass
pass
class Sam1App(App):
def build(self):
return MainPanel()
Builder.load_file("usb.kv")
if __name__ == '__main__':
Sam1App().run()

I found I overrode the switch_to method for TabbedPanel but did not define anything. So the TabbedPanel did not know what to switch to so it displayed nothing.

Related

How would I switch screens from a .py file while the screens are managed in a main .kv file?

I have three codes, I am confused with how I would navigate to the next screen in my Organize.kv from my login.py, I have the main kv file that has all the screens saved and the login python and kv file that manages the login screen, the login kv file balances two different tabs, so far I have the create tab that sends you to the create class of the login python file which is connected to mysql, how would I switch screens to the Main Menu which is in the main Organize.kv file from the login python file? Sorry if this doesn't make sense, I'm super warn out from trying to figure this out.
Anything helps, thank you
The main Organize.kv that has all the screens
#:import organize organize
#:import navigation_screen_manager navigation_screen_manager
#:import anchorlayout_with_action_bar anchorlayout_with_action_bar
#:import sharpen_skills sharpen_skills
#:import login login
<MainMenu#BoxLayout>:
orientation: "vertical"
padding: "40dp"
spacing: "20dp"
size_hint: .7, .9
pos_hint: {"center_x": .5}
Button:
text: "Organize"
on_press: app.manager.push("screen2")
Button:
text: "Journal"
on_press: app.manager.push("screen3")
Button:
text: "Sharpen Skills"
on_press: app.manager.push("SkillsExamplesTabs")
Button:
text: "Exit"
on_press: app.stop()
<MyScreenManager>:
Screen:
name: "Login"
title: "login"
LoginTabs:
Screen:
name: "MainMenu"
MainMenu:
Screen:
name: "screen2"
AnchorLayoutWithActionBar:
title: "Organize"
Screen:
name: "screen3"
AnchorLayoutWithActionBar:
title: "Journal"
Screen:
name: "SkillsExamplesTabs"
AnchorLayoutWithActionBar:
title: "Sharpen Skills"
SkillsExamplesTabs:
My login.kv file
<LoginTabs#TabbedPanel>:
do_default_tab: False
TabbedPanelItem:
text: "Create Account"
Create:
TabbedPanelItem:
text: "Login"
Login:
and finally my login.py file
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.screenmanager import ScreenManager
from kivy.uix.stacklayout import StackLayout
from kivy.uix.anchorlayout import AnchorLayout
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.label import Label
from kivy.graphics import Color, Rectangle
import mysql.connector
import navigation_screen_manager
from kivy.uix.screenmanager import ScreenManager, Screen
from navigation_screen_manager import NavigationScreenManager
Builder.load_file("login.kv")
Builder.load_file("Organize.kv")
sm = ScreenManager()
class MyScreenManager(NavigationScreenManager):
pass
class Create(BoxLayout):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.orientation = "vertical"
self.build()
def build(self):
self.warning = Label(text="", pos_hint={'center_x': .5, 'center_y': .5})
user_label = Label(text="Username", size_hint=(.5, .5),
pos_hint={'center_x': .5, 'center_y': .5})
self.user_textinput = TextInput(text='Enter Username')
pas_label = Label(text="Password", size_hint=(.5, .5),
pos_hint={'center_x': .5, 'center_y': .5})
self.pas_textinput = TextInput(text="enter Password")
enter_button = Button(text="Create")
with user_label.canvas:
Color(0, .25, 1, .25)
enter_button.bind(on_press=self.Add)
self.add_widget(self.warning)
self.add_widget(user_label)
self.add_widget(self.user_textinput)
self.add_widget(pas_label)
self.add_widget(self.pas_textinput)
self.add_widget(enter_button)
def Add(self, btn):
print("Working")
t1 = self.user_textinput.text
t2 = self.pas_textinput.text
print(f"T1 = {t1} and {t2}")
conn = mysql.connector.connect(
user='root',
password='*******',
host='127.0.0.1',
database='Usersdb')
mycursor = conn.cursor()
try:
sql = "INSERT INTO user_info (user_name, user_pass) VALUES (%s, %s)"
val = (t1,t2)
mycursor.execute(sql,val)
conn.commit()
except:
self.warning = "Username Already Taken"
class Login(StackLayout):
pass
And finally my App class
from kivy.app import App
from kivy.uix.label import Label
from kivy.metrics import dp
from kivy.properties import StringProperty, BooleanProperty, ObjectProperty
from kivy.uix.anchorlayout import AnchorLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.gridlayout import GridLayout
from kivy.uix.popup import Popup
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.stacklayout import StackLayout
from kivy.uix.widget import Widget
from navigation_screen_manager import NavigationScreenManager
class MyScreenManager(NavigationScreenManager):
pass
class Organizer(App):
manager = ObjectProperty(None)
def build(self):
self.manager = MyScreenManager()
return self.manager
Organizer().run()
And my Navigation Screen Manager
from kivy.uix.screenmanager import ScreenManager
class NavigationScreenManager(ScreenManager):
screen_stack = []
def push(self, screen_name):
self.screen_stack.append(self.current)
self.transition.direction = "left"
self.current = screen_name
def pop(self):
if len(self.screen_stack) > 0:
screen_name = self.screen_stack[-1]
del self.screen_stack[-1]
self.transition.direction = "right"
self.current = screen_name
Good day. You must access your screen manager in order to set the current screen which is your active screen. In your App class, I recommend saving your screen manager as an attribute via the on_start function.
class MyApp(App):
def on_start(self):
screen_manager = self.root
From there, you could set your current screen using callback methods in kivy or python.
#in kv
on_release: setattr(app.screen_manager, 'current', 'the next screen name')
#in python
def set_screen_callback(self, instance *args):
app.screen_manager.current = "the next screen name"
Your post does not include your App class, so a specific answer is impossible. The fact that you have multiple kv files is irrelevant once those kv files are loaded. In general, you just set the current property of the ScreenManager to the name of the Screen that you want displayed.
Again, the fact that you have multiple kv files is irrelevant once those kv files are loaded. So in any of the kv files, I believe that you should be able to use:
app.manager.push("MainMenu")
or:
app.manager.current = "MainMenu"
to get to the MainMenu Screen.

kivymd Card scroll list items with the help of loop?

I am working on a mobile app and I want to create multiple of scoll items by using for loop but whenever I use for loop, gives me some error It has already parent widget. how can I make list of MDCard?
My App:
Click here
My Code:
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.core.window import Window
from kivy.uix.screenmanager import Screen, ScreenManager
from kivymd.uix.boxlayout import BoxLayout
from kivy.uix.image import AsyncImage
from kivymd.uix.card import MDCard
from kivymd.uix.label import MDLabel
Window.size = (450, 740)
kv = '''
ScreenManager:
Main:
<main>:
name: 'main'
video_list: video_list
BoxLayout:
orientation: 'vertical'
MDToolbar:
title: 'Video downloader'
ScrollView:
Screen:
id: video_list
'''
class Main(Screen):
pass
sm = ScreenManager()
sm.add_widget(Main(name='main'))
class Ytube(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.theme_cls.colors = 'Red'
self.theme_cls.primary_palette = "Red"
self.root = Builder.load_string(kv)
image = AsyncImage(
source='https://static.hub.91mobiles.com/wp-content/uploads/2020/05/How-to-download-youtube-videos.jpg', size_hint=(1, .7), )
screen_id = self.root.get_screen('main').ids.video_list
for i in range(1):
card = MDCard(orientation='vertical', pos_hint={
'center_x': .5, 'center_y': .7}, size_hint=(.9, .4))
card.add_widget(image)
card.add_widget(MDLabel(
text='Phishing attacks are SCARY easy to do!! (let me show you!)', size_hint=(.6, .2), ))
screen_id.add_widget(card)
def build(self):
return self.root
if __name__ == "__main__":
Ytube().run()
Is there any way to make it
look like this.
The problem is that you are trying to use the same image widget for every MDCard. Any widget can only have one parent. You can only use that image widget once. You can fix that by moving the creation of the image widget inside the loop.
Also, a BoxLayout is a better choice for the child of a ScrollView, since it has a minimum_height property that you can use. Here is a modified version of your code that applies both those suggestions:
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.core.window import Window
from kivy.uix.screenmanager import Screen, ScreenManager
from kivy.uix.image import AsyncImage
from kivymd.uix.card import MDCard
from kivymd.uix.label import MDLabel
Window.size = (450, 740)
kv = '''
ScreenManager:
Main:
<main>:
name: 'main'
video_list: video_list
BoxLayout:
orientation: 'vertical'
MDToolbar:
title: 'Video downloader'
ScrollView:
do_scroll_x: False
BoxLayout:
id: video_list
orientation: 'vertical'
size_hint_y: None
height: self.minimum_height
'''
class Main(Screen):
pass
sm = ScreenManager()
sm.add_widget(Main(name='main'))
class Ytube(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.theme_cls.colors = 'Red'
self.theme_cls.primary_palette = "Red"
self.root = Builder.load_string(kv)
screen_id = self.root.get_screen('main').ids.video_list
for i in range(5):
# Make a new image widget for each MDCard
image = AsyncImage(
source='https://static.hub.91mobiles.com/wp-content/uploads/2020/05/How-to-download-youtube-videos.jpg', size_hint=(1, .7), )
card = MDCard(orientation='vertical', pos_hint={
'center_x': .5, 'center_y': .7}, size_hint=(.9, None), height=200)
card.add_widget(image)
card.add_widget(MDLabel(
text='Phishing attacks are SCARY easy to do!! (let me show you!)', size_hint=(.6, .2), ))
screen_id.add_widget(card)
def build(self):
return self.root
if __name__ == "__main__":
Ytube().run()

Changing kivy widget properties within Class

I'm having difficulty figuring out how to change the text of a label within a kivy widget. For simplicity, I have a label set to 0 and I would like to change the text to read 30 in this example. However, I get the following error.
AttributeError: 'super' object has no attribute 'getattr'
I understand that I'm probably not properly targeting that widget and I am hoping someone can please explain how to specifically reference the text of this label (self.ids.mainel1temp.stuff_r.text = '30') to update (with more detail than fixing the code)
#!/usr/bin/kivy
import kivy
from random import random
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.gridlayout import GridLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.switch import Switch
from kivy.uix.label import Label
from kivy.config import Config
Config.set('graphics', 'width', '800')
Config.set('graphics', 'height', '480')
Builder.load_string("""
<Menuscreen>:
#Handling the gesture event.
ScreenManager:
id: manager
Screen:
id: main_screen
name:'main_screen'
stuff_r: mainel1temp
FloatLayout:
Label:
id: mainel1temp
size: self.texture_size
text:'0'
size_hint: None, None
text_size: 75,75
pos: 295,308
font_size:'20sp'
halign: 'center'
""")
class Thermostuff(Screen):
stuff_r = ObjectProperty(None)
def starttherm(self):
Clock.schedule_interval((self.read_temp), 1)
def read_temp(self, dt):
self.ids.mainel1temp.stuff_r.text = '30'
Thermrun = Thermostuff()
Thermrun.starttherm()
class MenuScreen(Screen):
pass
sm = ScreenManager()
menu_screen = MenuScreen(name='menu')
sm.add_widget(menu_screen)
class TestApp(App):
def build(self):
return sm
if __name__ == '__main__':
TestApp().run()
You do a couple of things wrong here.
You dont want to put a ScreenManager inside a Screen
Only one ScreenManager is needed.
Then you can start the Clock in the __init__ of the Thermostuff(Screen)
Or if you want it to initiate on_enter you need to overrite that. In that case you might want to check somehow, if its allready started, so you wont have multiple clocks running.
Then when you create an ObjectProperty you dont need self.ids, because you allready created that property. So self.stuff_r is now the label.
I rewrote your example a bit, to demonstrate this.
Try this:
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen
from kivy.properties import ObjectProperty
from kivy.clock import Clock
sm = """
#Handling the gesture event.
ScreenManager:
id: manager
MenuScreen:
Button:
text: "Go to Thermostuff"
on_release:
root.current = "main_screen"
Thermostuff:
name:'main_screen'
stuff_r: mainel1temp
FloatLayout:
Label:
id: mainel1temp
size: self.texture_size
text:'0'
size_hint: None, None
text_size: 75,75
pos: 295,308
font_size:'20sp'
halign: 'center'
"""
class Thermostuff(Screen):
stuff_r = ObjectProperty(None)
test_temp = 0
def __init__(self,**kwargs):
super(Thermostuff,self).__init__(**kwargs)
Clock.schedule_interval((self.read_temp), 1)
def read_temp(self, dt):
self.test_temp += 1
self.stuff_r.text = str(self.test_temp)
class MenuScreen(Screen):
pass
class TestApp(App):
def build(self):
return Builder.load_string(sm)
if __name__ == '__main__':
TestApp().run()

Kivy Updating text with color from Python

Can someone please show me how to correctly update the color of text in a label/button in Kivy with Python?
I want to be able to change the color, the user guide suggests markup language but I've tried and just can't get it to work. Ultimately I want to change the color of the text at different times of day - I can code that bit its just the changing of the text color outside of Kivy language?
I've extracted the following from my code as the relevant (I hope!) bits that i need the guidance on ..
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen
from kivy.properties import ObjectProperty, StringProperty
from kivy.clock import Clock
import time
from datetime import datetime, timedelta
Builder.load_string('''
<MainScreen>:
name: 'main'
the_time: _id_lbl_time
BoxLayout:
orientation: 'vertical'
Label:
id: _id_lbl_time
text: 'Time'
font_size: 120
''')
class MainScreen(Screen):
def update_time(self, sec):
MyTime = time.strftime("%H:%M:%S")
self.the_time.text = MyTime <--- UPDATE COLOR HERE?
class ScreenManagerApp(App):
def build(self):
self.main_screen = MainScreen()
return self.main_screen
def on_start(self):
Clock.schedule_interval(self.main_screen.update_time, 1)
#===========================================================
# run the App !
ScreenManagerApp().run()
I changed your code a bit, to make it change to a random color.
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen
from kivy.properties import ObjectProperty, StringProperty, ListProperty
from kivy.clock import Clock
import time
from datetime import datetime, timedelta
from random import random
Builder.load_string('''
<MainScreen>:
name: 'main'
the_time: _id_lbl_time
BoxLayout:
orientation: 'vertical'
Label:
color: root.color
id: _id_lbl_time
text: 'Time'
font_size: 120
''')
class MainScreen(Screen):
color = ListProperty([1,1,1,1])
def __init__(self,**kwargs):
super(MainScreen,self).__init__(**kwargs)
Clock.schedule_interval(self.update_time, 1)
def update_time(self, sec):
MyTime = time.strftime("%H:%M:%S")
self.the_time.text = MyTime
self.color = [random(), random(), random(), 1]
class ScreenManagerApp(App):
def build(self):
self.main_screen = MainScreen()
return self.main_screen
ScreenManagerApp().run()

How to handle screen manager for multiple interfaces in Python and Kivy?

I'm an early beginner in Python an Kivy and i'd like to build a interface with multiple interfaces.
I decided to start with a very simple application that consist in defying a musical scale.
The first interface (class AskUser) has 2 buttons : scale (class Scale) and tonality (class Tonality).
In the interface scale, the user define the interval of the scale (scale of 7 notes) and in the tonality interface he gives the tonality.
I succeed to program each interface but i didn't succeed
to launch the interfaces scale and tonality by clicking on the corresponding buttons on the first interface. (see code below)
Does anybody has a simple solution to fix this issue ?
Thank you in advance.
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.popup import Popup
user_interface=Builder.load_string('''
BoxLayout:
orientation: 'vertical'
Label:
size_hint_y: 0.2
font_size: 20
GridLayout:
padding: 50
spacing: 10
cols: 3
rows: 3
Button:
text: 'Scale'
Button:
text: 'Tonality'
''')
class AskUser(App):
def build(self):
return user_interface
AskUser().run()
class Scale(BoxLayout):
def build(self):
self.orientation='vertical'
self.spacing=20
self.haut()
self.chiffres()
self.BoutonValider=Button(text='Valider',size_hint=(0.5,0.15),pos_hint={'right': 0.75},background_color=[0,0,1])
self.BoutonValider.bind(on_press=self.valider)
self.add_widget(self.BoutonValider)
def haut(self):
Layout1=GridLayout(cols=2,size_hint_y=0.2,padding=20)
scale='Scale=?'
self.scale=Label(text=scale,font_size=30, color=[1,1,1,1])
Layout1.add_widget(self.scale)
self.reponse=''
self.user_reponse = TextInput(text=self.reponse,font_size=30)
Layout1.add_widget(self.user_reponse)
self.add_widget(Layout1)
def chiffres(self):
Layout2=GridLayout(cols=2,size_hint_y=0.5,spacing=10)
self.Bouton1=Button(text='1')
self.Bouton1.bind(on_press=self.nombre)
Layout2.add_widget(self.Bouton1)
self.Bouton2=Button(text='2')
self.Bouton2.bind(on_press=self.nombre)
Layout2.add_widget(self.Bouton2)
self.Bouton3=Button(text='3')
self.Bouton3.bind(on_press=self.nombre)
Layout2.add_widget(self.Bouton3)
self.Bouton4=Button(text='4')
self.Bouton4.bind(on_press=self.nombre)
Layout2.add_widget(self.Bouton4)
self.add_widget(Layout2)
def nombre(self,instance):
self.reponse+=str(int((instance.text)))
self.user_reponse.text=(self.reponse)
def valider(self,instance):
reponse=((self.user_reponse.text))
sum_scale = sum([int(i) for i in str(reponse)])
if sum_scale ==12 and len(reponse)==7:
content = Button(text='Scale ok !', font_size=50)
popup = Popup(title='',content=content, size_hint=(0.5,0.5))
content.bind(on_press=popup.dismiss)
popup.open()
else :
content = Button(text='Not a 12 tones scale !', font_size=50)
popup = Popup(title='',content=content, size_hint=(0.5,0.5))
content.bind(on_press=popup.dismiss)
self.reponse=''
popup.open()
class Tonality(BoxLayout):
def build(self):
self.orientation='vertical'
self.spacing=20
self.haut()
self.chiffres()
self.BoutonValider=Button(text='Valider',size_hint=(0.5,0.15),pos_hint={'right': 0.75},background_color=[0,0,1])
self.BoutonValider.bind(on_press=self.valider)
self.add_widget(self.BoutonValider)
def haut(self):
Layout1=GridLayout(cols=2,size_hint_y=0.2,padding=20)
scale='Tonality=?'
self.scale=Label(text=scale,font_size=30, color=[1,1,1,1])
Layout1.add_widget(self.scale)
self.reponse=''
self.user_reponse = TextInput(text=self.reponse,font_size=30)
Layout1.add_widget(self.user_reponse)
self.add_widget(Layout1)
def chiffres(self):
Layout2=GridLayout(cols=2,size_hint_y=0.5,spacing=10)
self.Bouton1=Button(text='c')
self.Bouton1.bind(on_press=self.nombre)
Layout2.add_widget(self.Bouton1)
self.Bouton2=Button(text='c#')
self.Bouton2.bind(on_press=self.nombre)
Layout2.add_widget(self.Bouton2)
self.Bouton3=Button(text='d')
self.Bouton3.bind(on_press=self.nombre)
Layout2.add_widget(self.Bouton3)
self.Bouton4=Button(text='d#')
self.Bouton4.bind(on_press=self.nombre)
Layout2.add_widget(self.Bouton4)
self.add_widget(Layout2)
def nombre(self,instance):
self.reponse=instance.text
self.user_reponse.text=(self.reponse)
def valider(self,instance):
reponse=((self.user_reponse.text))
if len(reponse)<3:
content = Button(text='Tonality ok !', font_size=50)
popup = Popup(title='',content=content, size_hint=(0.5,0.5))
content.bind(on_press=popup.dismiss)
popup.open()
class scaleApp(App):
def build(self):
Panel1=Scale()
Panel1.build()
Panel2=Tonality()
Panel2.build()
return Panel1
if __name__ == '__main__':
scaleApp().run()
Solution:
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.popup import Popup
Builder.load_string('''
<user_interface>:
orientation: 'vertical'
Label:
size_hint_y: 0.2
font_size: 20
GridLayout:
padding: 50
spacing: 10
cols: 3
rows: 3
Button:
text: 'Scale'
Button:
text: 'Tonality'
''')
class user_interface(BoxLayout):
pass
class AskUser(App):
def build(self):
return user_interface()
AskUser().run()

Categories