Note that there are some explanatory texts on larger screens.

plurals
  1. POCombobox-based map editor in tkinter
    text
    copied!<p>Heh, the title must sound dreadful and noobish</p> <p>Anyway, I'm working on a simple web game that's basically a labyrinth. To make a map I have to manually write coordinates of walls, and I thought it'd speed up the development process greatly if I'd make a map editor. The first thing that came to my mind was python's tkinter generating a grid of combo boxes.</p> <p>The grid is generated fine, but I have problems with exporting the "map". I think each combobox has to have an unique text variable and a way to check it's coordinates. I thought I'd solve both problems if I'd set the variable's name to its coordinates, but I don't think it's working and I don't know how to access the values later on. Here's the important bit of the code (sorry for not showing everything right away, but StackOverflow's formatting is horrible when posting python):</p> <pre><code>def scale(self, *args, **kwargs): self.width.set(self.setwidth.get()) self.height.set(self.setheight.get()) name=[0,0] while name[0]&lt;=(self.width.get() - 1) and name[1]&lt;=self.height.get(): n=(str(name[0]) + ',' + str(name[1])) o={'name': n} self.o['name']=tk.StringVar() self.n=ttk.Combobox(self, textvariable=o['name'], values=('F', 'W', 'V', 'S'), width=1, state='readonly') self.n.grid(column=name[0], row=(name[1] + 1)) self.n.set('V') print self.o['name'].get() if name[0]==(self.width.get() - 1) and name[1]&lt;self.height.get(): name[0]=0 name[1]=name[1]+1 else: name[0]=name[0]+1 self.update() </code></pre> <p>The code above gives me the <code>App instance has no attribute 'o'</code>... what can I do about it? Can it even be done?</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload