Skip to content

Commit c717f08

Browse files
Merge pull request #80 from jonathanrocher/feature/add_single_file_stage_4.0
Feature: add single file stage 4.0
2 parents 4f089ed + a5d75bf commit c717f08

32 files changed

+89
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Hello world as a Pyface application
2+
3+
This is a single file pyface application to display a Hello World message as an
4+
application. The next stage, 4.1, has the same content by splatters the content
5+
into a proper Python package so each layer can grow.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
""" Hello world as a single file Pyface application
2+
"""
3+
4+
from traitsui.api import InstanceEditor, Item, ModelView, View
5+
from traits.api import HasStrictTraits, Instance, Str
6+
7+
from pyface.tasks.api import Task, TasksApplication, TaskFactory, \
8+
TraitsTaskPane
9+
10+
11+
class HelloWorldModel(HasStrictTraits):
12+
13+
content = Str
14+
15+
def _content_default(self):
16+
return "Hello World!"
17+
18+
19+
class HelloWorldView(ModelView):
20+
model = Instance(HelloWorldModel, ())
21+
22+
def traits_view(self):
23+
return View(
24+
Item("model.content")
25+
)
26+
27+
28+
class HelloWorldPane(TraitsTaskPane):
29+
30+
#: The unique id of the task.
31+
id = "pycasa.hello_world_pane"
32+
33+
#: The human-readable name of the task.
34+
name = "Message Viewer Pane"
35+
36+
hello_world_view = Instance(HelloWorldView, ())
37+
38+
def traits_view(self):
39+
return View(
40+
Item("hello_world_view", editor=InstanceEditor(), style="custom",
41+
show_label=False)
42+
)
43+
44+
45+
class HelloWorldTask(Task):
46+
47+
#: The unique id of the task.
48+
id = "pycasa.hello_world_task"
49+
50+
#: The human-readable name of the task.
51+
name = "Message Viewer Task"
52+
53+
def create_central_pane(self):
54+
""" Create the central pane: the script editor.
55+
"""
56+
return HelloWorldPane()
57+
58+
59+
class PycasaApplication(TasksApplication):
60+
""" An application to say hello.
61+
"""
62+
id = "pycasa_application"
63+
64+
name = "Pycasa"
65+
66+
description = "An example Tasks application that explores image files."
67+
68+
def _task_factories_default(self):
69+
return [
70+
TaskFactory(
71+
id='pycasa.hello_world_task',
72+
name="Hello World Editor",
73+
factory=HelloWorldTask
74+
)
75+
]
76+
77+
78+
def main():
79+
app = PycasaApplication()
80+
app.run()
81+
82+
83+
if __name__ == '__main__':
84+
main()
File renamed without changes.

0 commit comments

Comments
 (0)