Пример #1
0
	def __init__(self, master, parentw):
		self.master = master
		self.parentw = parentw

		self.tilemapwidget = TilemapWidget(master, parentw)
		self.selectedTile = StringVar(self.parentw)
		self.tileOption = apply( OptionMenu, (self.parentw, self.selectedTile) + tuple(TileConfig.tileoptions.keys()) )
		self.tileOption.pack()
		self.tilemapwidget.canvas.bind("<B1-Motion>", self.motion)

		self.tilemapwidget.new_tilemap(6,8)
Пример #2
0
class GenProcess:

	def __init__(self, master, parentw):
		self.parentw = parentw
		self.master = master

		self.panedw = PanedWindow(parentw, orient=HORIZONTAL, bg="gray", sashwidth=8)

		self.config = GenConfig(self.panedw, master)
		self.config.pack(expand=True, fill="both")

		#self.gc.parentw.pack(side="top", expand=True, fill="both")

		self.resultingmap = TilemapWidget(master, self.panedw)
		self.resultingmap.tilesize = 10
		self.resultingmap.new_tilemap(100, 100)


		self.panedw.pack(fill="both", expand=True)

		self.panedw.add(self.config)
		self.panedw.add(self.resultingmap.canvasframe)
Пример #3
0
class TilemapEdit:
	def __init__(self, master, parentw):
		self.master = master
		self.parentw = parentw

		self.tilemapwidget = TilemapWidget(master, parentw)
		self.selectedTile = StringVar(self.parentw)
		self.tileOption = apply( OptionMenu, (self.parentw, self.selectedTile) + tuple(TileConfig.tileoptions.keys()) )
		self.tileOption.pack()
		self.tilemapwidget.canvas.bind("<B1-Motion>", self.motion)

		self.tilemapwidget.new_tilemap(6,8)

	def request_new_size(self):
		def edit_size_cb(x, y):
			self.tilemapwidget.new_tilemap(int(x), int(y))
		d = RequestSizeDialog(self.master, edit_size_cb)
		self.master.wait_window(d.top)

	def save_json(self):
		file = tkFileDialog.asksaveasfile()
		json.dump(self.tilemapwidget.tilemap.tilemap, file)
		file.close()

	def load_json(self):
		file = tkFileDialog.askopenfile()
		self.tilemapwidget.load_tilemap(json.load(file))
		file.close()

	def motion(self, event):
		canvas = event.widget
		x = canvas.canvasx(event.x)
		y = canvas.canvasy(event.y)
		tilesize = TileConfig.tilesize
		tilex = int(x / tilesize)
		tiley = int(y / tilesize)
		self.tilemapwidget.tilemap.tilemap[tiley][tilex] = TileConfig.tileoptions[self.selectedTile.get()]
		self.tilemapwidget.update_canvas()