Basic command prompt functionality
This commit is contained in:
parent
7269e6e361
commit
8d483d055b
@ -1,11 +0,0 @@
|
|||||||
from kivy.uix.label import Label
|
|
||||||
|
|
||||||
class Command_box(Label):
|
|
||||||
|
|
||||||
def __init__(self,app,**kwargs):
|
|
||||||
# app is used to share information between widgets
|
|
||||||
self.app=app
|
|
||||||
|
|
||||||
# init Label
|
|
||||||
super(Command_box,self).__init__(**kwargs)
|
|
||||||
|
|
30
command_prompt.py
Normal file
30
command_prompt.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
from kivy.uix.label import Label
|
||||||
|
from kivy.core.window import Window
|
||||||
|
|
||||||
|
class Command_prompt(Label):
|
||||||
|
|
||||||
|
def __init__(self,app,**kwargs):
|
||||||
|
# app is used to share information between widgets
|
||||||
|
self.app=app
|
||||||
|
|
||||||
|
# insert mode
|
||||||
|
self.insert=False
|
||||||
|
|
||||||
|
# init Label
|
||||||
|
super(Command_prompt,self).__init__(**kwargs)
|
||||||
|
|
||||||
|
self.keyboard = Window.request_keyboard(None,self,"text")
|
||||||
|
self.keyboard.bind(on_textinput=self.on_textinput,on_key_down=self.on_key_down)
|
||||||
|
|
||||||
|
def on_key_down(self, keyboard, keycode, text, modifiers):
|
||||||
|
if self.insert:
|
||||||
|
if keycode[1]=="enter":
|
||||||
|
self.insert=False
|
||||||
|
self.text=""
|
||||||
|
|
||||||
|
def on_textinput(self,window,text):
|
||||||
|
if self.insert:
|
||||||
|
self.text+=text
|
||||||
|
elif text==':':
|
||||||
|
self.text+=text
|
||||||
|
self.insert=True
|
4
jam.kv
4
jam.kv
@ -12,9 +12,10 @@
|
|||||||
text_size: self.size
|
text_size: self.size
|
||||||
markup: True
|
markup: True
|
||||||
color: (0,0,0,1)
|
color: (0,0,0,1)
|
||||||
|
font_name: "RobotoMono-Regular"
|
||||||
|
|
||||||
|
|
||||||
<Command_box>:
|
<Command_prompt>:
|
||||||
canvas.before:
|
canvas.before:
|
||||||
Color:
|
Color:
|
||||||
rgb: 0,0,0
|
rgb: 0,0,0
|
||||||
@ -24,4 +25,5 @@
|
|||||||
size_hint_y: None
|
size_hint_y: None
|
||||||
height: 20
|
height: 20
|
||||||
text_size: self.size
|
text_size: self.size
|
||||||
|
font_name: "RobotoMono-Regular"
|
||||||
|
|
||||||
|
8
main.py
8
main.py
@ -5,7 +5,7 @@ from kivy.config import Config
|
|||||||
|
|
||||||
from cross import Cross,Cross_painter
|
from cross import Cross,Cross_painter
|
||||||
from status_bar import Status_bar
|
from status_bar import Status_bar
|
||||||
from command_box import Command_box
|
from command_prompt import Command_prompt
|
||||||
|
|
||||||
# App class
|
# App class
|
||||||
class Jam_app(App):
|
class Jam_app(App):
|
||||||
@ -14,12 +14,14 @@ class Jam_app(App):
|
|||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
layout=BoxLayout(orientation="vertical")
|
layout=BoxLayout(orientation="vertical")
|
||||||
|
|
||||||
self.painter=Cross_painter(self)
|
self.painter=Cross_painter(self)
|
||||||
self.status_bar=Status_bar(self)
|
self.status_bar=Status_bar(self)
|
||||||
self.command_box=Command_box(self)
|
self.command_prompt=Command_prompt(self)
|
||||||
|
|
||||||
layout.add_widget(self.painter)
|
layout.add_widget(self.painter)
|
||||||
layout.add_widget(self.status_bar)
|
layout.add_widget(self.status_bar)
|
||||||
layout.add_widget(self.command_box)
|
layout.add_widget(self.command_prompt)
|
||||||
return layout
|
return layout
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user