POV-Ray : Newsgroups : povray.binaries.utilities : POV Linux editor Server Time
31 Oct 2024 16:14:39 EDT (-0400)
  POV Linux editor (Message 1 to 6 of 6)  
From: Fabien HENON
Subject: POV Linux editor
Date: 20 Mar 2002 17:29:44
Message: <3C990C87.8010908@club-internet.fr>
I am writing an editor for POV-RAY using Python ( a highly portable
scripting language and Tkinter which is included).

It is still in beta stage : It is working, but a lot of features have
still to be added.

You just have to have python installed ( it is included in most linux
distributions).
You can find at www.python.org

Once installed just type the following line where 82.py is saved :
  >python 82.py

I also assumed that x-povray is installed in /usr/bin/

Comments are appreciated
I know it still a long way

NB : It works with Windows 2000 ( and Mac ?). The render process doesn't.


TODO:
Include output, error streams in the application.
Save the parameters before exiting.
Implement syntax color highlight (Any help there would be appreciated)
Add a horizontal scrollbar to the text editor.
Improve the 'not-too-accurate' line number.
Implement the edit menu. It is useless for the time being.


Fabien


Post a reply to this message


Attachments:
Download 'us-ascii' (8 KB)

From: Fabien HENON
Subject: Re: POV Linux editor
Date: 20 Mar 2002 17:33:56
Message: <3C990D79.4090506@club-internet.fr>
Something wrong with messenger:

just save the part below the -------------
as 82.py


------------------------------------------------------------------------
import sys, os, string
from string import split
from os import spawnv, P_NOWAIT
from Tkinter import *
from tkFileDialog import askopenfilename, asksaveasfilename

# remettre dans ligne de params les parametres
# autosave avant render

class mainWin:
  def __init__(self,tkRoot):
    self.tkRoot=tkRoot
    self.createWidgets()
    return None


global params
global filename
plat=sys.platform




class App:

## ---------------------- Create GUI ----------------------

    def __init__(self, master):



## ---------------------- Mainframe ----------------------

        mframe = Frame(master)
#	mframe.title(text"POV-RAY Editor")
	mframe.pack(expand=1, fill=BOTH)
	frame_input=Frame(mframe)


## ---------------------- Menu ----------------------

        menubar=Menu(frame_input)
        filemenu=Menu(menubar,tearoff=0)
        filemenu.add_command(label="New",command=self.clr)
        filemenu.add_command(label="Open",command=self.enter_text)
        filemenu.add_command(label="Save",command=self.save)
        filemenu.add_command(label="Save As",command=self.saveas)
        filemenu.add_separator()
        filemenu.add_command(label="Quit",command=sys.exit)
        menubar.add_cascade(label="File",menu=filemenu)

        editmenu=Menu(menubar,tearoff=0)
        editmenu.add_command(label="Cut")
        editmenu.add_command(label="Copy")
        editmenu.add_command(label="Paste")
        menubar.add_cascade(label="Edit",menu=editmenu)

        rendermenu=Menu(menubar,tearoff=0)
        rendermenu.add_command(label="Render", command=self.render)
        menubar.add_cascade(label="Render",menu=rendermenu)

        root.config(menu=menubar)

## ---------------------- Buttons ----------------------

	frame_buttons=Frame(mframe)
	self.button_open = Button(frame_buttons, text="Open..", fg="blue",
command=self.enter_text)
	self.button_open.pack(side=LEFT)
	self.button_render = Button(frame_buttons, text="Render..[Alt+g]", fg="red",
command=self.render)
	self.button_render.pack(side=LEFT)
        frame_buttons.pack(expand=0, fill=BOTH)



## ---------------------- Editor ----------------------

        self.text = Text(frame_input)

        self.yscroll_i = Scrollbar(frame_input,orient=VERTICAL,
command=self.text.yview)
	self.yscroll_i.pack(side=RIGHT, fill=Y)
	self.text['yscrollcommand']=self.yscroll_i.set

	self.text.pack(side=LEFT,expand=1, fill=BOTH)
	self.text.bind("<KeyPress>", self.keyPress)
	self.text.bind("<ButtonPress>", self.keyPress)
        self.text.bind("<Alt-KeyPress-g>", self.render_kb)
        self.yscroll_i.pack(side=RIGHT, fill=Y)
        frame_input.pack(expand=1, fill=BOTH)



## ---------------------- Output ----------------------

	frame_output=Frame(mframe)
        self.text_out = Text(frame_output,state=NORMAL,height=6)
        self.text_out.pack(side=LEFT,expand=1, fill=BOTH)
        self.scroll = Scrollbar(frame_output, command=self.text_out.yview)
        self.text_out.configure(yscrollcommand=self.scroll.set)
        self.scroll.pack(side=RIGHT, fill=Y)
        frame_output.pack(expand=1, fill=BOTH)


## ---------------------- Status Bar ----------------------


	frame_status_bar=Frame(mframe)
	self.parameters = Label(frame_status_bar,text="Parameters : ",
anchor="w",bg='gray70')
	self.parameters.pack(side='left')
	self.fill_params=Entry(frame_status_bar,bg='gray100')
	self.fill_params.insert(INSERT,"+w320 +h240 -f +dgt +p")
	self.fill_params.pack(side='left', expand=1, fill=BOTH)
        self.status_filename1 = Label(frame_status_bar,text="File : ",width=5,
anchor="w",bg='gray70')
        self.status_filename1.pack(side=LEFT )
        self.status_filename2 = Label(frame_status_bar,text="",width=20,relief=SUNKEN,
anchor="w", bg="gray90")
        self.status_filename2.pack(side=LEFT)



	self.status_line = Label(frame_status_bar,padx=1,
                                 relief=SUNKEN,bg="gray90",
                                 width=10,
                                 anchor="w",
                                 textvariable=affi_Ligne)
        self.status_line.pack(side='right')
        self.status_linetext = Label(frame_status_bar,padx=1,bg='gray70',
                                 width=7,
                                 anchor="w",
                                 text="Line : ")
        self.status_linetext.pack(side='right')


        frame_status_bar.pack(side=LEFT,expand=1, fill='x')


## ---------------------- Open file ----------------------

    def enter_text(self):
          filetypes = ( ( "Pov files","*.pov"), ( "Include files","*.inc"), (
"All","*"))
          self.filename = askopenfilename(filetypes=filetypes)
          if self.filename:
		self.text.delete(1.0, END)
		fd = open(self.filename)
	  for line in fd.readlines():
		if line.endswith("\r\n"):
			line = line[:-2] + "\n"
		self.text.insert(END, line)
	  fd.close()
          self.status_filename2.config(text=os.path.split(self.filename)[1])





## ---------------------- Clear ----------------------

    def clr(self):
        self.text.delete(1.0, END)



## ---------------------- Save ----------------------

    def save(self, forPrt=None):
      try:
        script = self.text.get(1.0, END)
        if script:
          fd = open(self.filename, 'w')
          for line in string.split(script, '\n'):
            fd.write(line)
            fd.write('\n')
          fd.close
      except:
       self.saveas()



## ---------------------- Saveas ----------------------

    def saveas(self, forPrt=None):
        script = self.text.get(1.0, END)
        if script:
#          global filename
#          self.filename=".pov"
          self.filename = file = asksaveasfilename()
          fd = open(self.filename, 'w')
          for line in string.split(script, '\n'):
                fd.write(line)
                fd.write('\n')
          fd.close
          self.status_filename2.config(text=os.path.split(self.filename)[1])



## ---------------------- Render button ----------------------

    def render(self):
        global params
	params=self.fill_params.get()
	script = self.text.get(1.0, END)
        if script:
          fd = open(self.filename, 'w')
          for line in string.split(script, '\n'):
            fd.write(line)
            fd.write('\n')
          fd.close

	app = '/usr/bin/x-povray'
#        appli = split(app)[1]
#		os.spawnl(os.P_NOWAIT, app , params)
#		os.popen3(app +' '+params)
#		os.system("dir" +params+" foo.txt 2>foo.error.txt")
	spawnv(P_NOWAIT, app , ('x-povray', "+i"+self.filename+" "+params))


## ---------------------- Render keyboard ----------------------

    def render_kb(self,event):
	        global params
      		params=self.fill_params.get()
		app = r"C:\perso\bureautique\Microsoft Office\Office\excel.exe"
                appli = split(app)[1]
#		os.spawnl(os.P_NOWAIT, app , params)
#		os.system(app +' '+params)
#		os.system(app)
                spawnv(P_NOWAIT, app, (appli, params))


## ---------------------- Top-Level Command line button ----------------------

    def parameters_button(self):
      self.tl=Toplevel()
      self.lb=Label(self.tl, text="Render parameters:")
      self.cl=Entry(self.tl,width=40)
      self.ok=Button(self.tl, text="OK", fg="red", command=self.get_parameters)
      self.ok.pack(side=BOTTOM)
      self.cl.pack(side=RIGHT)
      self.lb.pack()


## ---------------------- Prints the current line number and contents
----------------------

    def lin(self):
        tindex = self.text.index(INSERT)
	Ligne, column = map(int, string.split(tindex, "."))
        valeur=int((Ligne))
        affi_Ligne.set(valeur)



## ---------------------- Called when a key is pressed ----------------------

    def keyPress(self,event):
        self.lin()




        
root = Tk()
affi_Ligne=StringVar()
#params=StringVar()
larg = root.winfo_screenwidth()
haut = root.winfo_screenheight()
root.maxsize()
# root.geometry("%dx%d+0+0" % (larg,haut))
app = App(root)
root.mainloop()


Post a reply to this message

From: ingo
Subject: Re: POV Linux editor
Date: 21 Mar 2002 03:44:54
Message: <Xns91D8638A98E2Aseed7@povray.org>
in news:3C9### [at] club-internetfr Fabien HENON wrote:

> NB : It works with Windows 2000 ( and Mac ?). The render process
> doesn't. 

Works for me:
        # app = dir where pov is located (on my system) and
        # use pvengine.exe in spawnv
    	   # /EXIT /NR are there to close the gui after rendering.

        app = 'c:\\graphics\\POV-RAY35\\bin\\pvengine'
        spawnv(P_NOWAIT, app , ('pvengine.exe /EXIT /NR',     	    
	    	    	"+i"+self.filename+" "+params))

Also if I recall well. Python can detect what os is being used and thus 
could select the right app/spawnv combination. The user would still have 
to tell where pov is located the first time the editor is used.

> TODO:

> Implement syntax color highlight (Any help there would be
> appreciated) 

Pick whatever you need:

http://members.home.nl/seedseven/povsdl2html.py

Also look for the colordelegator(?) in the code for IDLE that comes with 
Python.

Ingo


Post a reply to this message

From: Fabien Hénon
Subject: Re: POV Linux editor
Date: 21 Mar 2002 14:49:58
Message: <3C9A1A9B.5B47A70D@club-internet.fr>


> in news:3C9### [at] club-internetfr Fabien HENON wrote:
>
> > NB : It works with Windows 2000 ( and Mac ?). The render process
> > doesn't.
>
> Works for me:
>         # app = dir where pov is located (on my system) and
>         # use pvengine.exe in spawnv
>            # /EXIT /NR are there to close the gui after rendering.
>

I did use it and raytrace under W2K, but what's the point? There is
already
a very good editor for Windows.


>
>         app = 'c:\\graphics\\POV-RAY35\\bin\\pvengine'
>         spawnv(P_NOWAIT, app , ('pvengine.exe /EXIT /NR',
>                         "+i"+self.filename+" "+params))

>
> Also if I recall well. Python can detect what os is being used and thus
> could select the right app/spawnv combination. The user would still have
> to tell where pov is located the first time the editor is used.
>

Yes that requires a few lines of script. But there again, there is
already a
windows editor.

>
> > TODO:
>
> > Implement syntax color highlight (Any help there would be
> > appreciated)
>
> Pick whatever you need:
>
> http://members.home.nl/seedseven/povsdl2html.py
>

Thanks for the url.
It is going to take a while to understand it all. I am still a python
newbie. Python meant nothing to me 2 months ago.
This project is a good learning tool.

>
> Also look for the colordelegator(?) in the code for IDLE that comes with
> Python.
>
> Ingo


Post a reply to this message

From: ingo
Subject: Re: POV Linux editor
Date: 21 Mar 2002 14:59:20
Message: <Xns91D8D5E2AB1D1seed7@povray.org>


> I did use it and raytrace under W2K, but what's the point? There is
> already a very good editor for Windows.
> 

Then I didn't understand your remark: "The render process
doesn't."

Ingo


Post a reply to this message

From: Fabien Hénon
Subject: Re: POV Linux editor
Date: 22 Mar 2002 17:53:02
Message: <3C9BB4FC.D0C0035F@club-internet.fr>
No, I did not get myself clear. It is not set to work as it is with
Windows.

Fabien




>
> > I did use it and raytrace under W2K, but what's the point? There is
> > already a very good editor for Windows.
> >
>
> Then I didn't understand your remark: "The render process
> doesn't."
>
> Ingo


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.