Add status and command bars to interface
This commit is contained in:
parent
159ac83e86
commit
ecad8ae8d6
8
command_box.py
Normal file
8
command_box.py
Normal file
@ -0,0 +1,8 @@
|
||||
from kivy.uix.label import Label
|
||||
|
||||
class Command_box(Label):
|
||||
|
||||
def __init__(self,**kwargs):
|
||||
# init Label
|
||||
super(Command_box,self).__init__(**kwargs)
|
||||
|
3
cross.py
3
cross.py
@ -229,6 +229,8 @@ class Cross_painter(Widget):
|
||||
|
||||
# respond to mouse down
|
||||
def on_touch_down(self,touch):
|
||||
# only respond to touch in area
|
||||
if self.collide_point(*touch.pos):
|
||||
# create new cross
|
||||
if touch.button=="right":
|
||||
if self.check_interaction_any(Point(touch.x/Cross.size,touch.y/Cross.size),None):
|
||||
@ -253,6 +255,7 @@ class Cross_painter(Widget):
|
||||
|
||||
# respond to drag
|
||||
def on_touch_move(self,touch):
|
||||
if self.collide_point(*touch.pos):
|
||||
# only move on left click
|
||||
if touch.button=="left" and self.selected!=None:
|
||||
self.selected.pos=self.check_move(Point(touch.x/Cross.size,touch.y/Cross.size),self.selected)
|
||||
|
25
jam.kv
25
jam.kv
@ -1,7 +1,22 @@
|
||||
#: kivy 2.0.0
|
||||
|
||||
#<jam>:
|
||||
# canvas:
|
||||
# Rectangle:
|
||||
# pos: 0,0
|
||||
# size: self.width,self.height
|
||||
<Status_bar>:
|
||||
canvas:
|
||||
Color:
|
||||
rgb: 1,1,1
|
||||
Rectangle:
|
||||
pos: self.pos
|
||||
size: self.size
|
||||
size_hint_y: None
|
||||
height: 20
|
||||
|
||||
<Command_box>:
|
||||
canvas:
|
||||
Color:
|
||||
rgb: 0,0,0
|
||||
Rectangle:
|
||||
pos: self.pos
|
||||
size: self.size
|
||||
size_hint_y: None
|
||||
height: 20
|
||||
|
||||
|
17
main.py
17
main.py
@ -1,19 +1,26 @@
|
||||
from kivy.app import App
|
||||
from kivy.uix.widget import Widget
|
||||
from kivy.uix.boxlayout import BoxLayout
|
||||
from kivy.config import Config
|
||||
|
||||
from cross import Cross,Cross_painter
|
||||
from status_bar import Status_bar
|
||||
from command_box import Command_box
|
||||
|
||||
# App class
|
||||
class Jam_app(App):
|
||||
# name of .kv file for main interface
|
||||
#kv_file="jam.kv"
|
||||
kv_file="jam.kv"
|
||||
|
||||
def build(self):
|
||||
parent=Widget()
|
||||
self.cross_painter=Cross_painter()
|
||||
parent.add_widget(self.cross_painter)
|
||||
return parent
|
||||
layout=BoxLayout(orientation="vertical")
|
||||
painter=Cross_painter()
|
||||
status=Status_bar()
|
||||
command=Command_box()
|
||||
layout.add_widget(painter)
|
||||
layout.add_widget(status)
|
||||
layout.add_widget(command)
|
||||
return layout
|
||||
|
||||
|
||||
|
||||
|
8
status_bar.py
Normal file
8
status_bar.py
Normal file
@ -0,0 +1,8 @@
|
||||
from kivy.uix.label import Label
|
||||
from kivy.graphics import Color,Rectangle
|
||||
|
||||
class Status_bar(Label):
|
||||
|
||||
def __init__(self,**kwargs):
|
||||
# init Label
|
||||
super(Status_bar,self).__init__(**kwargs)
|
Loading…
Reference in New Issue
Block a user