Still running… in multiple files, with global font_size…

This commit is contained in:
2024-04-29 22:49:29 +02:00
parent e3f032507e
commit 8ed3d2d76c
4 changed files with 51 additions and 37 deletions

44
.idea/workspace.xml generated
View File

@@ -4,15 +4,11 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3745efb7-4727-49d7-a776-8798725fc688" name="Changes" comment=""> <list default="true" id="3745efb7-4727-49d7-a776-8798725fc688" name="Changes" comment="Its running! Yeah!">
<change afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/profiles_settings.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/rankiv.kv" beforeDir="false" afterPath="$PROJECT_DIR$/rankiv.kv" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/ran_kiv.iml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/rannum.py" beforeDir="false" afterPath="$PROJECT_DIR$/rannum.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/rankiv.kv" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -31,14 +27,15 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent">{ <component name="PropertiesComponent"><![CDATA[{
&quot;keyToString&quot;: { "keyToString": {
&quot;Python.main.executor&quot;: &quot;Run&quot;, "Python.main.executor": "Run",
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;, "RunOnceActivity.OpenProjectViewOnStart": "true",
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;, "RunOnceActivity.ShowReadmeOnStart": "true",
&quot;git-widget-placeholder&quot;: &quot;master&quot; "git-widget-placeholder": "master",
"settings.editor.selected.configurable": "preferences.lookFeel"
} }
}</component> }]]></component>
<component name="RunManager"> <component name="RunManager">
<configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true"> <configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<module name="ran_kiv" /> <module name="ran_kiv" />
@@ -54,7 +51,7 @@
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" /> <option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
<option name="PARAMETERS" value="" /> <option name="PARAMETERS" value="--size=360x740" />
<option name="SHOW_COMMAND_LINE" value="false" /> <option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" /> <option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" /> <option name="MODULE_MODE" value="false" />
@@ -79,6 +76,19 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1714247286737</updated> <updated>1714247286737</updated>
</task> </task>
<task id="LOCAL-00001" summary="Its running! Yeah!">
<option name="closed" value="true" />
<created>1714421527721</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1714421527721</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers /> <servers />
</component> </component>
<component name="VcsManagerConfiguration">
<MESSAGE value="Its running! Yeah!" />
<option name="LAST_COMMIT_MESSAGE" value="Its running! Yeah!" />
</component>
</project> </project>

21
main.py
View File

@@ -1,23 +1,14 @@
from random import randint
from kivy.app import App from kivy.app import App
from kivy.uix.boxlayout import BoxLayout from kivy.properties import NumericProperty
from rannum import RanNum
class RanNum(BoxLayout):
pass
class RanKivApp(App): class RanKivApp(App):
def build(self): font_size = NumericProperty(24)
return RanNum()
def generate_random_number(self): def build(self):
try: self.ran_num = RanNum()
upper_boundary = int(self.root.ids.upper_boundary_input.text) return self.ran_num
self.root.ids.output.text = str(randint(1, upper_boundary))
except ValueError:
self.root.ids.output.text = 'Bitte nur positive,\nganze Zahlen eingeben!'
if __name__ == '__main__': if __name__ == '__main__':

View File

@@ -3,12 +3,12 @@
orientation: 'vertical' orientation: 'vertical'
Label: Label:
text: 'Zufallszahl von 1 bis ?' text: 'Zufallszahl von 1 bis ?'
font_size: sp(24) font_size: app.font_size
TextInput: TextInput:
id: upper_boundary_input id: upper_boundary_input
multiline: False multiline: False
halign: 'center' halign: 'center'
font_size: 24 font_size: app.font_size
size_hint: .8, None size_hint: .8, None
height: 42 height: 42
hint_text: 'Gib eine Zahl ein!' hint_text: 'Gib eine Zahl ein!'
@@ -18,12 +18,12 @@
size_hint: None, .2 size_hint: None, .2
Button: Button:
text: 'Generate!' text: 'Generate!'
font_size: 24 font_size: app.font_size
size_hint: .5, None size_hint: .5, None
pos_hint: {'x': .25} pos_hint: {'x': .25}
on_release: app.generate_random_number() on_release: app.ran_num.generate_random_number()
Label: Label:
id: output id: output
text: 'Meine Zufallszahl' text: 'Meine Zufallszahl'
halign: 'center' halign: 'center'
font_size: 24 font_size: app.font_size

View File

@@ -0,0 +1,13 @@
from random import randint
from kivy.uix.boxlayout import BoxLayout
class RanNum(BoxLayout):
pass
def generate_random_number(self):
try:
upper_boundary = int(self.ids.upper_boundary_input.text)
self.ids.output.text = str(randint(1, upper_boundary))
except ValueError:
self.ids.output.text = 'Bitte nur positive,\nganze Zahlen eingeben!'