Ejemplo n.º 1
0
 def imports(self, colors):
     filen = filedialog.askopenfilename(
             defaultextension=".png",
             title="Import file")
     if filen != ():
         self.statusbar.config(text="Please wait")
         self.pixelgrid = importer.importpixelgrid(filen, colors)
         tool.initialize(self.pixelgrid, self.quickdraw, self.redraw)
         self.statusbar.config(text="Imported file successfully.")
         self.redraw(True, True, True)
Ejemplo n.º 2
0
 def imports(self, newpalette=-1):
     filen = filedialog.askopenfilename(
             defaultextension=".png",
             title="Import file")
     if filen != ():
         self.statusbar.config(text="Please wait")
         self.pixelgrid = importer.importpixelgrid(
             filen, len(self.pixelgrid.palette), newpalette)
         tool.initialize(self.pixelgrid, self.quickdraw, self.redraw)
         self.statusbar.config(text="Imported file successfully.")
         self.redraw(True, True, True)
Ejemplo n.º 3
0
 def new(self):
     # Create new photoimage
     self.pixelgrid = PixelGrid(palette.ega[:])
     tool.initialize(self.pixelgrid, self.quickdraw, self.redraw)
     self.reselecttile(self.selectedx, self.selectedy)
     self.multiplescale.set(2.0)
     self.currentpage = 0
     self.selecting = False
     self.midstep = False
     self.prevpagebutton.config(state=tk.DISABLED)
     self.pagelabel.config(text="1/1")
     self.currentfilename = ""
     self.selectcolor(0)
     self.drawpalette()
     self.redraw()
Ejemplo n.º 4
0
 def new(self):
     # Create new photoimage
     self.pixelgrid = PixelGrid(palette.ega[:])
     tool.initialize(self.pixelgrid, self.quickdraw, self.redraw)
     self.reselecttile(self.selectedx, self.selectedy)
     self.multiplescale.set(2.0)
     self.currentpage = 0
     self.selecting = False
     self.midstep = False
     self.prevpagebutton.config(state=tk.DISABLED)
     self.pagelabel.config(text="1/1")
     self.currentfilename = ""
     self.selectcolor(0)
     self.drawpalette()
     self.redraw()
Ejemplo n.º 5
0
 def open(self):
     filen = filedialog.askopenfilename(
             filetypes=(("Terraformer images", "*.terra"),
                        ("All files", "*")),
             title="Open paletted image",
             initialdir=self.config["lastdir"])
     if filen != () and filen != "":
         with open(filen, "r") as fileo:
             try:
                 self.pixelgrid = PixelGrid.load(json.load(fileo))
                 tool.initialize(self.pixelgrid, self.quickdraw, self.redraw)
             except VersionError:
                 messagebox.showerror(
                     "Incorrect version",
                     "This file is not intended for this version.")
             except:
                 messagebox.showerror(
                     "Unknown error",
                     "File is not compatible"
                 )
         self.drawpalette()
         self.redraw()
             
         self.currentpage = 0
         self.prevpagebutton.config(state=tk.DISABLED)
         self.pagelabel.config(
             text="{0}/{1}".format(self.currentpage+1,
                                   self.pixelgrid.pages))
         self.config["lastdir"] = os.path.dirname(filen)
         self.currentfilename = os.path.basename(filen) 
         try:
             with open(
                     os.path.expanduser("~/.config/terraformer/config.json")
                     , "w") as fileo:
                 json.dump(self.config, fileo)
         except IOError:
             pass # Not a big deal
         self.statusbar.config(text=(
                     "Opened file " + self.currentfilename + " at " +
                     time.strftime("%I:%M %p", time.localtime())))
Ejemplo n.º 6
0
 def open(self):
     filen = filedialog.askopenfilename(
             filetypes=(("Terraformer images", "*.terra"),
                        ("All files", "*")),
             title="Open paletted image",
             initialdir=self.config["lastdir"])
     if filen != () and filen != "":
         with open(filen, "r") as fileo:
             try:
                 self.pixelgrid = PixelGrid.load(json.load(fileo))
                 tool.initialize(self.pixelgrid, self.quickdraw, self.redraw)
             except VersionError:
                 messagebox.showerror(
                     "Incorrect version",
                     "This file is not intended for this version.")
             except:
                 messagebox.showerror(
                     "Unknown error",
                     "File is not compatible"
                 )
         self.drawpalette()
         self.redraw()
             
         self.currentpage = 0
         self.prevpagebutton.config(state=tk.DISABLED)
         self.pagelabel.config(
             text="{0}/{1}".format(self.currentpage+1,
                                   self.pixelgrid.pages))
         self.config["lastdir"] = os.path.dirname(filen)
         self.currentfilename = os.path.basename(filen) 
         try:
             with open(
                     os.path.expanduser("~/.config/terraformer/config.json")
                     , "w") as fileo:
                 json.dump(self.config, fileo)
         except IOError:
             pass # Not a big deal
         self.statusbar.config(text=(
                     "Opened file " + self.currentfilename + " at " +
                     time.strftime("%I:%M %p", time.localtime())))