mirror of https://github.com/kivy/kivy.git
add font sizes to showcase
This commit is contained in:
parent
f492baa714
commit
ec066bf1ae
|
@ -1,20 +1,22 @@
|
|||
import kivy
|
||||
kivy.require('1.1.3')
|
||||
|
||||
from kivy.properties import NumericProperty
|
||||
import random
|
||||
|
||||
from kivy.app import App
|
||||
from kivy.uix.boxlayout import BoxLayout
|
||||
from kivy.uix.floatlayout import FloatLayout
|
||||
from kivy.clock import Clock
|
||||
from kivy.metrics import Metrics
|
||||
from kivy.properties import NumericProperty
|
||||
from kivy.properties import StringProperty
|
||||
from kivy.uix.anchorlayout import AnchorLayout
|
||||
from kivy.uix.boxlayout import BoxLayout
|
||||
from kivy.uix.button import Button
|
||||
from kivy.uix.widget import Widget
|
||||
from kivy.uix.scatter import Scatter
|
||||
from kivy.uix.treeview import TreeView, TreeViewLabel
|
||||
from kivy.uix.floatlayout import FloatLayout
|
||||
from kivy.uix.label import Label
|
||||
from kivy.uix.popup import Popup
|
||||
from kivy.properties import StringProperty
|
||||
from kivy.clock import Clock
|
||||
import random
|
||||
from kivy.uix.scatter import Scatter
|
||||
from kivy.uix.treeview import TreeView, TreeViewLabel
|
||||
from kivy.uix.widget import Widget
|
||||
|
||||
|
||||
class Showcase(FloatLayout):
|
||||
|
@ -173,6 +175,10 @@ class TreeViewWidgets(FloatLayout):
|
|||
pass
|
||||
|
||||
|
||||
class FontSizesWidgets(BoxLayout):
|
||||
pass
|
||||
|
||||
|
||||
class ShowcaseApp(App):
|
||||
|
||||
def on_select_node(self, instance, value):
|
||||
|
@ -208,6 +214,7 @@ class ShowcaseApp(App):
|
|||
attach_node('Complex widgets', n)
|
||||
attach_node('Scatters', n)
|
||||
attach_node('Treeviews', n)
|
||||
attach_node('Font Sizes', n)
|
||||
attach_node('Popup', n)
|
||||
n = create_tree('Layouts')
|
||||
attach_node('Anchor Layout', n)
|
||||
|
@ -277,6 +284,22 @@ class ShowcaseApp(App):
|
|||
self.populate_treeview(tv.treeview2)
|
||||
return tv
|
||||
|
||||
def show_font_sizes(self):
|
||||
font_sizes = FontSizesWidgets()
|
||||
metrics = Metrics()
|
||||
metrics_values = {
|
||||
'dpi': str(metrics.dpi),
|
||||
'dpi_rounded': str(metrics.dpi_rounded),
|
||||
'density': str(metrics.density),
|
||||
'fontscale': str(metrics.fontscale),
|
||||
}
|
||||
label = font_sizes.children[1]
|
||||
label.text = ('DPI: {dpi} '
|
||||
'DPI Rounded: {dpi_rounded} '
|
||||
'Density: {density} '
|
||||
'Font Scale: {fontscale} ').format(**metrics_values)
|
||||
return font_sizes
|
||||
|
||||
def populate_treeview(self, tv):
|
||||
n = tv.add_node(TreeViewLabel(text='Item 1'))
|
||||
for x in xrange(3):
|
||||
|
|
|
@ -411,3 +411,95 @@
|
|||
|
||||
|
||||
<ScatterWidgets>:
|
||||
|
||||
|
||||
<FontSizesWidgets>:
|
||||
orientation: 'vertical'
|
||||
|
||||
Label:
|
||||
text: 'Metrics'
|
||||
size_hint: (1., .1)
|
||||
|
||||
BoxLayout:
|
||||
orientation: 'horizontal'
|
||||
|
||||
BoxLayout:
|
||||
orientation: 'vertical'
|
||||
|
||||
Label:
|
||||
text: '6sp'
|
||||
font_size: '6sp'
|
||||
|
||||
Label:
|
||||
text: '12sp'
|
||||
font_size: '12sp'
|
||||
|
||||
Label:
|
||||
text: '18sp'
|
||||
font_size: '18sp'
|
||||
|
||||
Label:
|
||||
text: '24sp'
|
||||
font_size: '24sp'
|
||||
|
||||
Label:
|
||||
text: '30sp'
|
||||
font_size: '30sp'
|
||||
|
||||
Label:
|
||||
text: '36sp'
|
||||
font_size: '36sp'
|
||||
|
||||
BoxLayout:
|
||||
orientation: 'vertical'
|
||||
|
||||
Label:
|
||||
text: '6pt'
|
||||
font_size: '6pt'
|
||||
|
||||
Label:
|
||||
text: '12pt'
|
||||
font_size: '12pt'
|
||||
|
||||
Label:
|
||||
text: '18pt'
|
||||
font_size: '18pt'
|
||||
|
||||
Label:
|
||||
text: '24pt'
|
||||
font_size: '24pt'
|
||||
|
||||
Label:
|
||||
text: '30pt'
|
||||
font_size: '30pt'
|
||||
|
||||
Label:
|
||||
text: '36pt'
|
||||
font_size: '36pt'
|
||||
|
||||
BoxLayout:
|
||||
orientation: 'vertical'
|
||||
|
||||
Label:
|
||||
text: '6px'
|
||||
font_size: '6px'
|
||||
|
||||
Label:
|
||||
text: '12px'
|
||||
font_size: '12px'
|
||||
|
||||
Label:
|
||||
text: '18px'
|
||||
font_size: '18px'
|
||||
|
||||
Label:
|
||||
text: '24px'
|
||||
font_size: '24px'
|
||||
|
||||
Label:
|
||||
text: '30px'
|
||||
font_size: '30px'
|
||||
|
||||
Label:
|
||||
text: '36px'
|
||||
font_size: '36px'
|
||||
|
|
Loading…
Reference in New Issue