working on tiles and plan editor
This commit is contained in:
@@ -9,34 +9,26 @@ class TileSelector(Gtk.Window):
|
||||
Gtk.Window.__init__(self)
|
||||
self.connect("destroy", Gtk.main_quit)
|
||||
|
||||
grid = Gtk.Grid()
|
||||
self.grid = Gtk.Grid()
|
||||
|
||||
straight_h = StraigthH()
|
||||
straight_h.connect('button-press-event',self.select)
|
||||
self.add_tile(StraightH,0,0)
|
||||
self.add_tile(StraightV,1,0)
|
||||
self.add_tile(Diag_TL,0,1)
|
||||
self.add_tile(Diag_TR,1,1)
|
||||
self.add_tile(Diag_BR,2,1)
|
||||
self.add_tile(Diag_BL,3,1)
|
||||
self.add_tile(TO_BRL,0,2)
|
||||
|
||||
straight_v = StraigthV()
|
||||
straight_v.connect('button-press-event',self.select)
|
||||
|
||||
diag_tl = Diag_TL()
|
||||
diag_tl.connect('button-press-event',self.select)
|
||||
|
||||
diag_br = Diag_BR()
|
||||
diag_br.connect('button-press-event',self.select)
|
||||
|
||||
to_brl = TO_BRL()
|
||||
to_brl.connect('button-press-event',self.select)
|
||||
|
||||
grid.attach(straight_h,0,0,1,1)
|
||||
grid.attach(straight_v,1,0,1,1)
|
||||
grid.attach(diag_tl,0,1,1,1)
|
||||
grid.attach(diag_br,1,1,1,1)
|
||||
grid.attach(to_brl,1,2,1,1)
|
||||
|
||||
self.add(grid)
|
||||
self.add(self.grid)
|
||||
|
||||
self.show_all()
|
||||
Gtk.main()
|
||||
|
||||
def add_tile(self,tile_class,x,y):
|
||||
tile = tile_class()
|
||||
tile.connect('button-press-event',self.select)
|
||||
self.grid.attach(tile,x,y,1,1)
|
||||
|
||||
def select(self,btn,evt):
|
||||
self.tile = btn.__class__
|
||||
self.hide()
|
||||
|
||||
28
src/Tiles.py
28
src/Tiles.py
@@ -28,7 +28,7 @@ class Tile(Gtk.DrawingArea):
|
||||
def connects_left(self):
|
||||
return self.connections()[3]
|
||||
|
||||
class StraigthH(Tile):
|
||||
class StraightH(Tile):
|
||||
def draw(self,widget,cr):
|
||||
cr.set_source_rgb(0,0,0)
|
||||
cr.rectangle(0,11,32,10)
|
||||
@@ -37,7 +37,7 @@ class StraigthH(Tile):
|
||||
def connections(self):
|
||||
return (False,True,False,True)
|
||||
|
||||
class StraigthV(Tile):
|
||||
class StraightV(Tile):
|
||||
def draw(self,widget,cr):
|
||||
cr.set_source_rgb(0,0,0)
|
||||
cr.rectangle(11,0,10,32)
|
||||
@@ -57,6 +57,18 @@ class Diag_TL(Tile):
|
||||
def connections(self):
|
||||
return (True,False,False,True)
|
||||
|
||||
class Diag_TR(Tile):
|
||||
def draw(self,widget,cr):
|
||||
cr.set_source_rgb(0,0,0)
|
||||
cr.set_line_width(7)
|
||||
cr.move_to(12,-5)
|
||||
cr.line_to(38,21)
|
||||
cr.stroke()
|
||||
|
||||
def connections(self):
|
||||
return (True,True,False,False)
|
||||
|
||||
|
||||
class Diag_BR(Tile):
|
||||
def draw(self,widget,cr):
|
||||
cr.set_source_rgb(0,0,0)
|
||||
@@ -68,6 +80,18 @@ class Diag_BR(Tile):
|
||||
def connections(self):
|
||||
return (False,True,True,False)
|
||||
|
||||
class Diag_BL(Tile):
|
||||
def draw(self,widget,cr):
|
||||
cr.set_source_rgb(0,0,0)
|
||||
cr.set_line_width(7)
|
||||
cr.move_to(-5,11)
|
||||
cr.line_to(21,37)
|
||||
cr.stroke()
|
||||
|
||||
def connections(self):
|
||||
return (False,False,True,True)
|
||||
|
||||
|
||||
class TO_BRL(Tile):
|
||||
def draw(self,widget,cr):
|
||||
cr.set_source_rgb(0,0,0)
|
||||
|
||||
@@ -19,14 +19,14 @@ class TrackPlan(Gtk.Window):
|
||||
Gtk.main()
|
||||
|
||||
def select_tile(self,widget,connections):
|
||||
print 'Button at ({},{}) pressed'.format(widget.x, widget.y)
|
||||
#print 'Button at ({},{}) pressed'.format(widget.x, widget.y)
|
||||
tileSelector = TileSelector(connections)
|
||||
tile = tileSelector.tile()
|
||||
self.putTile(tile,widget.x,widget.y)
|
||||
widget.destroy()
|
||||
|
||||
def putButton(self,x,y,connections):
|
||||
print 'putButton({},{})'.format(x,y)
|
||||
#print 'putButton({},{})'.format(x,y)
|
||||
btn = Gtk.Button('?')
|
||||
btn.x = x
|
||||
btn.y = y
|
||||
@@ -35,7 +35,7 @@ class TrackPlan(Gtk.Window):
|
||||
btn.show()
|
||||
|
||||
def putTile(self,tile,x,y):
|
||||
print 'putTile({},{})'.format(x,y)
|
||||
#print 'putTile({},{})'.format(x,y)
|
||||
tile.x = x
|
||||
tile.y = y
|
||||
self.grid.attach(tile,x,y,1,1)
|
||||
@@ -57,4 +57,8 @@ class TrackPlan(Gtk.Window):
|
||||
bottom = self.grid.get_child_at(x,y+1)
|
||||
if bottom == None:
|
||||
self.putButton(x,y+1,tile.connections())
|
||||
|
||||
|
||||
self.save()
|
||||
|
||||
def save(self):
|
||||
print 'Saving plan not implemented'
|
||||
@@ -36,7 +36,7 @@ class web4rail_server:
|
||||
conn.send(plan+"\n")
|
||||
|
||||
def select_system(self,conn):
|
||||
path='/tmp/srichter/mops/'
|
||||
path='/'
|
||||
conn.send("Welcome to the Web2Rail server. Please select a SYSTEM first:\n");
|
||||
while True:
|
||||
conn.send('current dir: '+path+"\n")
|
||||
|
||||
Reference in New Issue
Block a user