Skip to main content

Eclipse Configuration for TurboGears

· 2 min read

Continue to my previous article, here is a configuration using eclipse external tools to start web server without open start-proj.py

Here is a list of the current functionality:

External Tools:

  • Start Server

  • Start ToolboxAccessibility:

  • Auto Completion Configure Eclipse to Launch developer server

  • Select** Run -> External Tools -> External Tools **

  • Select** "Program" from the configuration** tree* Select New to create a new program* Enter “Start Server” as the name* Enter C:\Python24\pythonw.exe for the Location* For the Working Directory, use ${project_loc}

  • Enter start-${project_name}.py for the Arguments

  • Select the refresh tab and check Refresh Resources Upon Completion

  • Select the Common tab * Find the section for Display in Favorites Menu

    • Check **External Tools option *** Select Apply Configure Eclipse to Launch ToolBox
  • Select** Run -> External Tools -> External Tools **

  • Select** "Program" from the configuration** tree* Select New to create a new program* Enter “Start ToolBox” as the name* Enter C:\Python24\Scripts\tg-admin.exe for the Location* For the Working Directory, use ${project_loc}

  • Enter toolbox** **for the Arguments

  • Select the Common tab * Find the section for Display in Favorites Menu

    • Check **External Tools option *** Select Apply

Auto-completion

  • Select your project in Navigator panel
  • Select Properties on Right click menu.
  • Select** pyDev - PYTHONPATH Select Add source folder to add project path in Project Source Folder. **it will bring project code-completion and code-analysis.
  • Select ** Add source folder **to add turbogears path in External Source Folder.

it will bring turbogears code-completion PS: I get idea from the rails article, but for mine, you'd have eclipse & pydev installed, I recommand you try EasyEclipse for Python.

PlotKit with EasyPlot in TurboGears

· 2 min read

NOTICE: This Article is updated for 0.9w3

I recently update my TurboGears PlotKit widget. This version(0.9w3, 0.9 is origin lib's version, w means 'widget')

To get these widgets, easy_install them :

$easy_install plotkit

Then, you can Check the demo in TurboGears toolbox :D

How to try it? Well, it's extremely simple.

For a fresh quickstart site,

In controllers.py:

from plotkit import EasyPlot

class Root(controllers.RootController):
@expose(template="wgtest.templates.welcome")
def index(self):
setA = [[0,0], [1,2], [2,3], [3,7], [4,8], [5,6]]
setB = [[0,0], [1,1], [2,4], [3,8], [4,7], [5,20]]
setC = [[0,1], [1,3], [2,5], [3,5], [4,3], [5,2]]
return dict(ep= EasyPlot(id="diag",
style="line",
width="300",
height="300",
data=[setA, setB, setC]))

In welcome.kid:

${ep.display()}

add this script into html "body".

Explain:

from plotkit import EasyPlot

First of all, import the proper widget. (origin PlotKit widget is still availbe)

return dict(ep= EasyPlot(...))

return the "ep" diagram instance to template

${ep.display()}

display the diagram in template

Parameters:

id: (diag) The Diagram's Identifer (Element ID)

style: (line) The diagram could be plot as a "line", "pie", or "bar"diagram.

width, height : (400, 400)

The diagram's size

data : Datasets is structured with [[x,y],[x1,y1],....]

option : options of both Layout and Renderer (dictionary style), need be a string

The origin example is here.


History 0.9w3 07/04/2006: more flexible EasyPlot dataset 0.9w2 : fix bugs and add a EasyPlot() widget to plot a diagram within the code.

The svn repository is in Sourceforge, you can share your TurboGears widget there, too.

known limit: current widget's option param suppor is not very OO, you need pass the dictionary in string format (can't recognize "v", "label")

EasyEclipse for Python

· One min read

習慣用微軟 VisualStudio 或用 Java 的人用了 python 語言, 通常會挑剔 python 語言沒什麼好用的 IDE 來搭配.

現在 EasyEclipse 有提供包好的 eclipse + pydev (eclipse 平台上的 python 語言支援 -) + Subclipse (eclipse 平台上的圖形化 SVN 版本控制工具) http://www.easyeclipse.org/site/distributions/python.html

簡化了 eclipse 平台安裝設定上的繁瑣,拿來做 python 程式開發其實還蠻不賴的,