Kivy font büyütme hatası


#1

screenmanager üzerinde font büyütmek için butona bastığımda bu hatayı aldım.


#2

Kodları atabilirimisin?


#3

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager,Screen


kv='''
<ekran1>:
	BoxLayout:
		canvas:
			Color:
				rgba:.2,0,.5,1
			Rectangle:
				size:self.size
				pos:self.pos
		BoxLayout:
			orientation:'vertical'	
			spacing:10
			padding:10	
	    	Button:
		    	text:'ileri'
		    	size_hint_y:.1
	    		on_press:
			    	root.manager.transition.direction='left'
		    		root.manager.current='ekran2'
 	   	BoxLayout:
		        orientation:'vertical'
	    		#pos_hint:{'x':.0,'y':.9}
	    		size_hint:.6,.9
		       # Button:
		          #  text:'masaüstü
		        Button:
		        	text:'ayar'
		        	on_press:app.buyut()
		        Button:
		        	text:'renk'
		        Button:
		        	text:'hakkında'
		  
<ekran2>:
	BoxLayout:
		canvas:
			Color:
				rgba:(.2,.2,0,9)
			Rectangle:
				size:self.size
				pos:self.pos
		BoxLayout:
			orientation:'vertical'
			Button:
				text:'geri'
				size_hint_y:.1
				on_press:
					root.manager.transition.direction='left'
					root.manager.current='ekran1'
				
			Label:
				text:'Masaüstü 2'
				size_hint_y:.9
			BoxLayout:
				orientation:'vertical'
				size_hint_y:.8
				Button:
					text:'üçümcü ekran'
					id: txt
					on_press:root.manager.current='ekran3'
				Button:
					text:'2'
				Button:
					text:'masaüstüüüü'
					id: txt
				Button:
					text:'4'
<ekran3>:
	BoxLayout:
		canvas:
			Color:
				rgba:(.3,0,.3,3)
			Rectangle:
				size:self.size
				pos:self.pos
		BoxLayout:
			orientation:'vertical'
			Button:
				text:'ana ekran'
				size_hint_y:.1
			    on_press:root.manager.current='ekran2'
			Label:
				text:'ana ekran'
				size_hint_y:.8
						
	
'''
Builder.load_string(kv)

class ekran1(Screen):
	pass
class ekran2(Screen):
	pass
class ekran3(Screen):
	pass
	
sm=ScreenManager()
sm.add_widget(ekran2(name='ekran2'))
sm.add_widget(ekran1(name='ekran1'))
sm.add_widget(ekran3(name='ekran3'))	

class uygulama(App):
	def build(self):
		return sm
	
	def buyut(self):
		self.root.ids.txt.font_size +=1
		
uygulama().run()

Birinci ekranda tuşa bastımı ikinci ekranda büyütmesi gerek.


#4

Böyle örnek verdim. Siz kendi yazdıgınız kodlara uyarlarsınız.

burda kullandıgım kodla yapabilirsiniz. 0 ise screenmanager da o sınıfın oldugu yeri yazdım.

sm.screens[0].ids.lbl.font_size += 1

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager,Screen

kv="""
<ekran1>:
	BoxLayout:
		Label:
			font_size: sp(20)
			text: "Metin"
			id: lbl
		Button:
			text: "Ekran 1 Button"
			on_press: root.manager.current = "ekran2"
<ekran2>:
	BoxLayout:
		orientation: "vertical"
		Button:
			text: "-1 AZALT"
			font_size: sp(20)
			on_press: root.azalt()

		Button:
			text: "+1 ARTTIR"
			font_size: sp(20)
			on_press: root.arttır()

		Button:
			text: "RED"
			font_size: sp(20)
			on_press: root.red()
		Button:
			text: "BLUE"
			font_size: sp(20)
			on_press: root.blue()
		Button:
			text: "GREEN"
			font_size: sp(20)
			on_press: root.green()
		Button:
			text: "Ekran 2 Button"
			font_size: sp(20)
			on_press: root.manager.current = "ekran1"	
"""

Builder.load_string(kv)

sm=ScreenManager()
sm.add_widget(ekran1(name='ekran1')) #0. sıra
sm.add_widget(ekran2(name='ekran2')) #1. sıra

class ekran1(Screen):
	pass
class ekran2(Screen):
	def arttır(self):
		sm.screens[0].ids.lbl.font_size += 1

	def azalt(self):
		sm.screens[0].ids.lbl.font_size -= 1

	def red(self):
		sm.screens[0].ids.lbl.color = (1,0,0,1)
	def blue(self):
		sm.screens[0].ids.lbl.color = (0,0,1,1)
	def green(self):
		sm.screens[0].ids.lbl.color = (0,1,0,1)

class uygulama(App):
	def build(self):
		return sm
		
uygulama().run()