Add status and command bars to interface

This commit is contained in:
Ian Jauslin 2021-09-29 15:52:31 -04:00
parent 159ac83e86
commit ecad8ae8d6
5 changed files with 75 additions and 34 deletions

8
command_box.py Normal file
View 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)

View File

@ -229,6 +229,8 @@ class Cross_painter(Widget):
# respond to mouse down # respond to mouse down
def on_touch_down(self,touch): def on_touch_down(self,touch):
# only respond to touch in area
if self.collide_point(*touch.pos):
# create new cross # create new cross
if touch.button=="right": if touch.button=="right":
if self.check_interaction_any(Point(touch.x/Cross.size,touch.y/Cross.size),None): 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 # respond to drag
def on_touch_move(self,touch): def on_touch_move(self,touch):
if self.collide_point(*touch.pos):
# only move on left click # only move on left click
if touch.button=="left" and self.selected!=None: 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) self.selected.pos=self.check_move(Point(touch.x/Cross.size,touch.y/Cross.size),self.selected)

25
jam.kv
View File

@ -1,7 +1,22 @@
#: kivy 2.0.0 #: kivy 2.0.0
#<jam>: <Status_bar>:
# canvas: canvas:
# Rectangle: Color:
# pos: 0,0 rgb: 1,1,1
# size: self.width,self.height 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
View File

@ -1,19 +1,26 @@
from kivy.app import App from kivy.app import App
from kivy.uix.widget import Widget from kivy.uix.widget import Widget
from kivy.uix.boxlayout import BoxLayout
from kivy.config import Config from kivy.config import Config
from cross import Cross,Cross_painter from cross import Cross,Cross_painter
from status_bar import Status_bar
from command_box import Command_box
# App class # App class
class Jam_app(App): class Jam_app(App):
# name of .kv file for main interface # name of .kv file for main interface
#kv_file="jam.kv" kv_file="jam.kv"
def build(self): def build(self):
parent=Widget() layout=BoxLayout(orientation="vertical")
self.cross_painter=Cross_painter() painter=Cross_painter()
parent.add_widget(self.cross_painter) status=Status_bar()
return parent command=Command_box()
layout.add_widget(painter)
layout.add_widget(status)
layout.add_widget(command)
return layout

8
status_bar.py Normal file
View 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)