examples: minor edits to examples

This commit is contained in:
Qua-non 2012-11-04 02:48:35 +05:30
parent 0530cdfd7c
commit 0e1c793230
6 changed files with 43 additions and 8 deletions

View File

@ -137,7 +137,7 @@
TextInput:
id:info_lbl
readonly: True
font_size: '11sp'
font_size: '14sp'
background_color: (0, 0, 0, 1)
foreground_color: (1, 1, 1, 1)
opacity:0

View File

@ -118,6 +118,8 @@ class Catalog(BoxLayout):
with open(self.screen_manager.current_screen.content.children[
0].kv_file) as file:
self.language_box.text = file.read()
# reset undo/redo history
self.language_box.reset_undo()
def schedule_reload(self):
if self.auto_reload:

View File

@ -1,4 +1,5 @@
#:kivy 1.0
#: import GLShaderLexer pygments.lexers.GLShaderLexer
<ShaderEditor>:
viewer: viewer
@ -13,16 +14,18 @@
text: 'Fragment Shader'
size_hint_y: None
height: self.texture_size[1] + 10
TextInput:
CodeInput:
text: root.fs
lexer: GLShaderLexer()
on_text: root.fs = args[1]
Label:
text: 'Vertex Shader'
size_hint_y: None
height: self.texture_size[1] + 10
TextInput:
CodeInput:
text: root.vs
lexer: GLShaderLexer()
on_text: root.vs = args[1]
ShaderViewer:

View File

@ -17,7 +17,7 @@ class BlehApp(App):
def build(self):
root = BoxLayout()
for idx, word in enumerate(('Hello', 'World')):
wid = Builder.template('BlehItem', {
wid = Builder.template('BlehItem', **{
'idx': idx, 'word': word,
})
root.add_widget(wid)

View File

@ -5,25 +5,50 @@ from kivy.lang import Builder
from kivy.properties import StringProperty, ObjectProperty
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.spinner import SpinnerOption
from kivy.uix.popup import Popup
import os
Builder.load_string(
'''
#: import utils kivy
#: import os os
#: import font pygame.font
#: import Factory kivy.factory.Factory
<FntSpinnerOption>
fnt_name: font.match_font(self.text)
font_name: self.fnt_name if self.fnt_name else self.font_name
<Unicode_TextInput>
orientation: 'vertical'
txt_input: unicode_txt
spnr_fnt: fnt_spnr
BoxLayout:
size_hint: 1, .05
Spinner:
id: fnt_spnr
text: 'DroidSansMono'
fnt_name: font.match_font(self.text)
font_name: self.fnt_name if self.fnt_name else self.font_name
values: sorted(font.get_fonts())
option_cls: Factory.FntSpinnerOption
Spinner:
id: fntsz_spnr
text: '15'
values: map(str, map(sp, range(5,39)))
ScrollView:
size_hint: 1, .9
TextInput:
id: unicode_txt
background_color: [.5, .5, .5, 1]
foreground_color: .5, 1, .5, 1
background_color: .8811, .8811, .8811, 1
foreground_color: 0, 0, 0, 1
font_name: fnt_spnr.font_name
font_size: fntsz_spnr.text + 'sp'
text: root.unicode_string
size_hint: 1, None
height: 1364
height: 1494
on_font_name: self.height = (self.line_height + self.padding_y) * (len(self._lines)-1)
BoxLayout:
size_hint: 1, .05
Label:
@ -86,6 +111,8 @@ if _platform == 'linux' else '/system/fonts' if _platform == 'android' else os.p
(filechooser.path, filechooser.selection)
''')
class FntSpinnerOption(SpinnerOption):
pass
class LoadDialog(FloatLayout):
load = ObjectProperty(None)
@ -172,6 +199,9 @@ Yiddish: דער גיך ברוין פוקס דזשאַמפּס איבער
def load(self, _path, _fname):
self.txt_input.font_name = _fname[0]
_f_name = _fname[0][_fname[0].rfind(os.sep) + 1:]
self.spnr_fnt.text = _f_name[:_f_name.rfind('.')]
self._popup.dismiss()
def show_load(self):

View File

@ -523,7 +523,7 @@
size_hint_x: .66
id: labellayout
markup: True
text: '{0}\n[size=13sp][color=999999]{1}[/color][/size]{2}'.format(root.title or '', root.desc or '', self.font_size)
text: '{0}\n[size=13sp][color=999999]{1}[/color][/size]'.format(root.title or '', root.desc or '')
font_size: '15sp'
text_size: self.width - 32, None