14
14
"MIME-Version: 1.0\n"
15
15
"Content-Type: text/plain; charset=UTF-8\n"
16
16
"Content-Transfer-Encoding: 8bit\n"
17
"X-Launchpad-Export-Date: 2010-10-08 04:44+0000\n"
18
"X-Generator: Launchpad (build Unknown)\n"
20
#: data/templates/ubuntu-application/help/tutorial.xml:13(firstname)
24
#: data/templates/ubuntu-application/help/tutorial.xml:14(surname)
28
#: data/templates/ubuntu-application/help/tutorial.xml:17(firstname)
17
"X-Launchpad-Export-Date: 2011-02-16 05:11+0000\n"
18
"X-Generator: Launchpad (build 12351)\n"
20
#: data/templates/ubuntu-pygame/help/tutorial.xml:13(firstname)
32
#: data/templates/ubuntu-application/help/tutorial.xml:18(surname)
24
#: data/templates/ubuntu-pygame/help/tutorial.xml:14(surname)
36
#: data/templates/ubuntu-application/help/tutorial.xml:20(corpauthor)
28
#: data/templates/ubuntu-pygame/help/tutorial.xml:16(corpauthor)
37
29
msgid "Canonical ltd"
38
30
msgstr "Canonical ltd"
40
#: data/templates/ubuntu-application/help/tutorial.xml:24(date) data/templates/ubuntu-application/help/tutorial.xml:29(invpartnumber)
32
#: data/templates/ubuntu-pygame/help/tutorial.xml:20(date) data/templates/ubuntu-pygame/help/tutorial.xml:25(invpartnumber)
44
#: data/templates/ubuntu-application/help/tutorial.xml:0(application) data/templates/ubuntu-application/help/tutorial.xml:1160(application) data/templates/ubuntu-application/help/tutorial.xml:1160(application) data/templates/ubuntu-application/help/tutorial.xml:1163(application)
36
#: data/templates/ubuntu-pygame/help/tutorial.xml:0(application)
37
msgid "Quickly PyGame Template"
48
#: data/templates/ubuntu-application/help/tutorial.xml:28(productnumber)
40
#: data/templates/ubuntu-pygame/help/tutorial.xml:24(productnumber)
52
#: data/templates/ubuntu-application/help/tutorial.xml:30(title)
53
msgid "<application>Quickly</application> 0.6.1 User Guide"
54
msgstr "<application>Quickly</application> 0.6.1 Anleitung"
44
#: data/templates/ubuntu-pygame/help/tutorial.xml:26(title)
45
msgid "<application>Quickly PyGame Template</application> 0.6.1 Tutorial"
56
#: data/templates/ubuntu-application/help/tutorial.xml:35(title)
48
#: data/templates/ubuntu-pygame/help/tutorial.xml:31(title)
57
49
msgid "About This Guide"
58
50
msgstr "Über diese Anleitung"
60
#: data/templates/ubuntu-application/help/tutorial.xml:36(para)
62
"<application>Quickly</application> is a set of choices about writing apps "
63
"for Ubuntu. Out of all the wonderful richness and variety of programming for "
64
"Linux, <application>Quickly</application> make some very opinionated choices "
65
"about what tools to use, and how to combine them. The criteria for these "
66
"choices was to make it easy and fun to write and release Linux applications, "
67
"even if it's your first time trying, but also in a way that delivers the "
68
"full power and flexibility of the platform. One benefit of these choices, is "
69
"that it's also easier to write tools that make it even easier and more fun. "
70
"So <application>Quickly</application> is also a set of commands."
73
#: data/templates/ubuntu-application/help/tutorial.xml:39(link) data/templates/ubuntu-application/help/tutorial.xml:45(title)
74
msgid "Getting Started"
75
msgstr "Erste Schritte"
77
#: data/templates/ubuntu-application/help/tutorial.xml:46(para)
79
"This part 1 of the <application>Quickly</application> tutorial. This part is "
80
"will introduce some key <application>Quickly</application> commands, editing "
81
"a user interface in Glade, and editing code in Gedit. This part of the "
82
"tutorial will familiarize you with these three tools, and how they work "
83
"together with python and pygtk so that you can "
84
"<application>Quickly</application> build applications."
87
#: data/templates/ubuntu-application/help/tutorial.xml:48(title)
88
msgid "Creating a <application>Quickly</application> Project"
89
msgstr "Ein <application>Quickly</application>-Projekt erstellen"
91
#: data/templates/ubuntu-application/help/tutorial.xml:48(para)
93
"<placeholder-1/>Creating an empty but working program couldn't be simpler. "
94
"First, open a terminal window to type commands into. When it's open, type "
98
#: data/templates/ubuntu-application/help/tutorial.xml:49(programlisting)
100
msgid "quickly create ubuntu-application jotty"
101
msgstr "quickly create ubuntu-application jotty"
103
#: data/templates/ubuntu-application/help/tutorial.xml:53(para)
105
"This will create a jotty sub directory containing a complete directory tree "
106
"and files for an empty python application. The command finishes by running "
107
"the newly created empty application."
110
#: data/templates/ubuntu-application/help/tutorial.xml:57(title)
111
msgid "Testing the Empty Application"
112
msgstr "Die leere Anwendung testen"
114
#: data/templates/ubuntu-application/help/tutorial.xml:57(para)
116
"<placeholder-1/> They are populated and set up, and you can resize the "
117
"window. Notice that <application>Quickly</application> inferred that the "
118
"application title is \"Jotty\". Only a few of menu items do anything in the "
119
"empty application, Help->About, Edit->Preferences, and File->Quit."
122
#: data/templates/ubuntu-application/help/tutorial.xml:61(title)
123
msgid "Running the Application"
124
msgstr "Die Anwendung ausführen"
126
#: data/templates/ubuntu-application/help/tutorial.xml:61(para)
128
"<placeholder-1/> Close the application by closing the window or using the "
129
"Quit command. Since the empty application isn't installed into Ubuntu yet, "
130
"you can't start the application from the application menu yet. To start the "
131
"applicaton, use the terminal to first cd into the new subdirectory, and then "
132
"use \"quickly run\" to start the program."
135
#: data/templates/ubuntu-application/help/tutorial.xml:63(programlisting)
146
#: data/templates/ubuntu-application/help/tutorial.xml:70(title)
147
msgid "Editing an Application"
148
msgstr "Eine Anwendung bearbeiten"
150
#: data/templates/ubuntu-application/help/tutorial.xml:71(title)
151
msgid "Edit the User Interface in Glade"
152
msgstr "Die Oberfläche in Glade bearbeiten"
154
#: data/templates/ubuntu-application/help/tutorial.xml:71(para)
156
"<placeholder-1/><application>Quickly</application> programs use Glade to "
157
"edit the user interface. Start Glade with \"quickly design\" in order to set "
158
"up Glade for editing the empty applicaton. Don't start glade directly, or it "
159
"won't load the necessary catalogue files for editing the classes that were "
160
"automaticaly generated by <application>Quickly</application>."
163
#: data/templates/ubuntu-application/help/tutorial.xml:73(programlisting) data/templates/ubuntu-application/help/tutorial.xml:128(programlisting)
165
msgid "quickly design"
166
msgstr "quickly design"
168
#: data/templates/ubuntu-application/help/tutorial.xml:77(para)
169
msgid "Glade will open with the project loaded up and ready to edit."
172
#: data/templates/ubuntu-application/help/tutorial.xml:81(para)
173
msgid "Use the Project Menu to choose \"JottytWindow.ui\" for editing."
176
#: data/templates/ubuntu-application/help/tutorial.xml:85(para)
178
"We want to create a text area for typing into. There are some default "
179
"Widgets added to the Window. We won't need these so we'll start with "
180
"deleting them. Click on the label, and press delete, and it will disappear "
184
#: data/templates/ubuntu-application/help/tutorial.xml:92(para)
185
msgid "Do the same with the image widget. This leave us two free slots."
188
#: data/templates/ubuntu-application/help/tutorial.xml:96(para)
190
"We'll use the bottom slot to add a TextView widget for the user to type "
191
"into. In the toolbox, click on the TextView widget. Then click in the empty "
195
#: data/templates/ubuntu-application/help/tutorial.xml:100(para)
197
"Make sure you save the file in Glade, or your changes won't take! Then run "
198
"the application from terminal again. The window now has a place where the "
202
#: data/templates/ubuntu-application/help/tutorial.xml:104(para)
204
"Now we'll add the entry field for the title, and also a label for it. We'll "
205
"use the top empty slot for that. First, click on Horizontal Box (HBox) from "
206
"the \"Containers\" section of the pallette, and then click on the top slot. "
207
"A dialog box will open, tell it that you want two items."
210
#: data/templates/ubuntu-application/help/tutorial.xml:108(para)
212
"The HBox is a container that arranges it's children horizontally. Add a "
213
"label to the empty left hand box, and a Text Entry to the right hand one."
216
#: data/templates/ubuntu-application/help/tutorial.xml:112(para)
218
"Before going on, let's clean up the UI just a tad here. Select the new HBox "
219
"from the treeview in the inspector window. Then go to the Packing tab, and "
220
"set Expand and Fill to \"No\"."
223
#: data/templates/ubuntu-application/help/tutorial.xml:116(para)
224
msgid "Go to the General tab, and set spacing to 5."
227
#: data/templates/ubuntu-application/help/tutorial.xml:120(para)
229
"Select the label. On the general tab, set \"Label\" to \"Name:\". Set expand "
230
"and fill to \"no\" for the label, but keep it \"yes\" for the entry. Set the "
231
"padding for both to 5 (also on the Packing tab)."
234
#: data/templates/ubuntu-application/help/tutorial.xml:124(title)
235
msgid "Add the Save, Open, and New Features"
238
#: data/templates/ubuntu-application/help/tutorial.xml:124(para)
240
"<placeholder-1/> After the user types something, they may want to save it. A "
241
"File->Save menu item was automatically created when the empty applicaton "
242
"was created, but it's not hooked up to any code. To make Save work, we need "
243
"tell the menu item what function to call, and then create a function to "
244
"actually do the saving."
247
#: data/templates/ubuntu-application/help/tutorial.xml:126(title)
248
msgid "Set the Signal Handler in Glade"
251
#: data/templates/ubuntu-application/help/tutorial.xml:126(para)
253
"<placeholder-1/> To tell the menu item what function to call. If glade is "
254
"not still open, open up the application in glade:"
257
#: data/templates/ubuntu-application/help/tutorial.xml:129(para)
259
"Click on the file menu, and the menu opens as if the application were "
263
#: data/templates/ubuntu-application/help/tutorial.xml:133(para)
264
msgid "Choose the Save menu item, and it will be selected in Glade."
267
#: data/templates/ubuntu-application/help/tutorial.xml:137(para)
268
msgid "Then choose the \"Signals\" tab of the properties window."
271
#: data/templates/ubuntu-application/help/tutorial.xml:141(para)
273
"In pygtk, menu items are \"activated\" when a user chooses the item from the "
274
"menu. Since we want a function to run when the user chooses Save, we want to "
275
"specify a function to respond to the activate signal from the menu item. "
276
"We'll call the function \"save_file\". Simply type the function name into "
277
"the box for the activate signal.Make sure to save the glade file."
280
#: data/templates/ubuntu-application/help/tutorial.xml:145(para)
282
"Note that you will need to setup the \"open_file\" signal and the "
283
"\"new_file\" signal as well when you get to those functions later."
286
#: data/templates/ubuntu-application/help/tutorial.xml:146(title)
287
msgid "Edit the Code in Gedit"
288
msgstr "Den Quelltext in Gedit bearbeiten"
290
#: data/templates/ubuntu-application/help/tutorial.xml:147(title)
291
msgid "Set Up Tabs Correctly"
294
#: data/templates/ubuntu-application/help/tutorial.xml:147(para)
296
"<placeholder-1/> Note a major gotcha here. In python spaces and tabs are "
297
"totally different, but they look just the same in an editor. So being "
298
"indented one tab stop is not the same as being indented four spaces, even "
299
"though they might look the same. And indentation level is very important in "
300
"python. You will get a lot of errors if you mix tab indentation with space "
301
"indentation. Your generated project follows the python standard of using "
302
"four spaces for each indentation level. So you'll either have to hit the "
303
"space bar four time every time you indent, or set up your editor to use the "
304
"right number of spaces for tabs."
307
#: data/templates/ubuntu-application/help/tutorial.xml:149(para)
309
"The upshot is that you should take a moment to set up your Gedit (or "
310
"whatever editor you are using) to use spaces for tabs. In Gedit, select "
311
"Preferences from the Edit menu, and choose the Editor tab. Then set Tab "
312
"width to 4, and turn on \"Insert spaces instead of tabs\". Your preferences "
313
"should look like this:"
316
#: data/templates/ubuntu-application/help/tutorial.xml:153(title)
317
msgid "Create the Save File Signal Handler"
320
#: data/templates/ubuntu-application/help/tutorial.xml:153(para)
322
"<placeholder-1/> Now you're ready to write some code. Of course just telling "
323
"the glade file what signal to emit won't make the file actually save, "
324
"because we haven't created the \"save_file\" function yet. The code for "
325
"JottyWindow is stored in the file jotty. jotty is a special python file that "
326
"is the entry point for your application. Other python files in your "
327
"application have the \".py\" suffix."
330
#: data/templates/ubuntu-application/help/tutorial.xml:155(para)
332
"Use the <application>Quickly</application> edit command to start editing "
336
#: data/templates/ubuntu-application/help/tutorial.xml:156(programlisting)
339
msgstr "quickly edit"
341
#: data/templates/ubuntu-application/help/tutorial.xml:157(para)
343
"This will open the default Ubuntu text editor \"Gedit\" with any python "
344
"files in the python directory."
347
#: data/templates/ubuntu-application/help/tutorial.xml:161(para)
349
"JottyWindow.ui is now expecting to find a function JottyWindow.save_file(), "
350
"so we simply add one to the JottyWindow class in the jotty file right under "
351
"the on_destroy funtion.:"
354
#: data/templates/ubuntu-application/help/tutorial.xml:163(programlisting)
358
" def save_file(self, widget, data=None):\n"
363
" def save_file(self, widget, data=None):\n"
364
" print \"speichern\"\n"
367
#: data/templates/ubuntu-application/help/tutorial.xml:169(para)
369
"This will print the word \"save\" to the terminal when run. The method "
370
"signature is the standard signature expected in a signal handler. If you are "
371
"new to python, be sure to copy the indentations exactly, as the indentation "
372
"level is very important in python."
375
#: data/templates/ubuntu-application/help/tutorial.xml:170(para)
376
msgid "Save the file, and run it again:"
379
#: data/templates/ubuntu-application/help/tutorial.xml:171(programlisting)
388
#: data/templates/ubuntu-application/help/tutorial.xml:174(para)
390
"Choose \"File->Save\" from the menu, and you'll see the word \"save\" "
391
"printing out interminal. That's all there is to hookig up the functions!"
394
#: data/templates/ubuntu-application/help/tutorial.xml:178(title)
395
msgid "Implementing Save"
398
#: data/templates/ubuntu-application/help/tutorial.xml:178(para)
400
"<placeholder-1/> Now we'll write a little code in the signal handler to "
401
"actually save the text. Because we want it to be easy for users to do things "
402
"like syncronize their Jotty documents between computers, back it up, etc... "
403
"we'll use couchdb as our backend, and we'll use desktopcouch for our api. "
404
"We'll also use a widget from the Quickly Widgets library to make it really "
405
"easy to use desktopcouch. Desktop couch and the desktopcouch records API "
406
"should be installed for you already, but you may need to install Quickly "
407
"Widgets. The fastest way to do this is from the terminal:"
410
#: data/templates/ubuntu-application/help/tutorial.xml:181(programlisting)
414
"sudo apt-get install quickly-widgets\n"
417
"sudo apt-get install quickly-widgets\n"
419
#: data/templates/ubuntu-application/help/tutorial.xml:184(para)
421
"This will install the api, and everything you need for the api to run. After "
422
"desktopcouch is installed, you can write the code. The code will do the "
426
#: data/templates/ubuntu-application/help/tutorial.xml:187(para)
427
msgid "Import the stuff you'll need from Quickly Widgets and desktopcouch."
430
#: data/templates/ubuntu-application/help/tutorial.xml:190(para)
431
msgid "Get a reference to the couchdb database to save into."
434
#: data/templates/ubuntu-application/help/tutorial.xml:193(para)
435
msgid "Get the title of the document and the text from the user interface."
438
#: data/templates/ubuntu-application/help/tutorial.xml:196(para)
440
"Check if there is already a document with the same title, and if so "
444
#: data/templates/ubuntu-application/help/tutorial.xml:199(para)
445
msgid "If there is not a document already, create one."
448
#: data/templates/ubuntu-application/help/tutorial.xml:202(title)
449
msgid "Import the stuff you'll need from python-desktopcouch-records."
452
#: data/templates/ubuntu-application/help/tutorial.xml:202(para)
454
"<placeholder-1/> Add these import statements along with the other imports to "
455
"the top of the jotty file:"
458
#: data/templates/ubuntu-application/help/tutorial.xml:205(programlisting)
462
"from desktopcouch.records.server import CouchDatabase\n"
463
"from desktopcouch.records.record import Record\n"
466
"from desktopcouch.records.server import CouchDatabase\n"
467
"from desktopcouch.records.record import Record\n"
469
#: data/templates/ubuntu-application/help/tutorial.xml:209(title)
470
msgid "Get a Reference to the Database"
473
#: data/templates/ubuntu-application/help/tutorial.xml:209(para)
475
"<placeholder-1/> Desktopcouch will set up a database for us, or create a new "
476
"one if it's needed. We'll use \"jotty\" for the name of the database. Since "
477
"we want this line to run every time the Jotty Window is created, put it at "
478
"the end of the finish_initializing function:"
481
#: data/templates/ubuntu-application/help/tutorial.xml:211(programlisting)
485
" self.database = CouchDatabase(\"jotty\", create=True)\n"
488
" self.database = CouchDatabase(\"jotty\", create=True)\n"
490
#: data/templates/ubuntu-application/help/tutorial.xml:214(para)
492
"Now that we have an instance-wide reference to the database, we'll add code "
493
"to the save_file function to run whenever the Save command is issued."
496
#: data/templates/ubuntu-application/help/tutorial.xml:215(para)
497
msgid "Here's the code to pull the title out of the title entry:"
500
#: data/templates/ubuntu-application/help/tutorial.xml:218(programlisting)
504
" #get the title for the note\n"
505
" title = self.builder.get_object(\"entry1\").get_text()\n"
508
" #Den Titel der Notiz erhalten\n"
509
" title = self.builder.get_object(\"entry1\").get_text()\n"
511
#: data/templates/ubuntu-application/help/tutorial.xml:222(title)
512
msgid "Here's the code to get pull the text out of the TextView:"
515
#: data/templates/ubuntu-application/help/tutorial.xml:222(para)
517
"<placeholder-1/> In pygtk, TextView widgets have a text buffer that stores "
518
"the text. So you ask the TextView for it's TextBuffer, and then you ask the "
519
"TextBuffer for the text. You use iters to determine from which part of the "
520
"text buffer you want text. Since we want all the text, it's easy to just get "
521
"the start and end iters."
524
#: data/templates/ubuntu-application/help/tutorial.xml:225(programlisting)
529
" buff = self.builder.get_object(\"textview1\").get_buffer()\n"
530
" start_iter = buff.get_start_iter()\n"
531
" end_iter = buff.get_end_iter()\n"
532
" text = buff.get_text(start_iter,end_iter)\n"
535
" #Den String erhalten\n"
536
" buff = self.builder.get_object(\"textview1\").get_buffer()\n"
537
" start_iter = buff.get_start_iter()\n"
538
" end_iter = buff.get_end_iter()\n"
539
" text = buff.get_text(start_iter,end_iter)\n"
541
#: data/templates/ubuntu-application/help/tutorial.xml:232(title)
542
msgid "Saving a document to Couchdb"
545
#: data/templates/ubuntu-application/help/tutorial.xml:232(para)
547
"<placeholder-1/> A record in couch is essentially a python dictionary with "
548
"some extra key/value pairs to make the database work. So we can save the "
549
"document to couch like this:"
552
#: data/templates/ubuntu-application/help/tutorial.xml:235(programlisting)
556
" record_type = \"http://wiki.ubuntu.com/Quickly/JottyDoc\"\n"
557
" new_rec = Record({\"record_type\": record_type,\"title\":title, "
559
" self.database.put(new_rec)\n"
562
" record_type = \"http://wiki.ubuntu.com/Quickly/JottyDoc\"\n"
563
" new_rec = Record({\"record_type\": record_type,\"title\":title, "
565
" self.database.put(new_rec)\n"
567
#: data/templates/ubuntu-application/help/tutorial.xml:240(para)
569
"The \"record_type\" field is not strictly required, but among other things, "
570
"it makes it easy to fetch the documents later. By convention, we use a url "
571
"to specify the record type. This provides a place for other developers to go "
572
"to read about the record type. The description only needs to be human "
573
"readable. Couchdb is not a typed database, so don't expect that the url will "
574
"have any kind of schema definition or anything. You can use whatever url you "
575
"want, and put whatever you want at that URL."
578
#: data/templates/ubuntu-application/help/tutorial.xml:243(title)
579
msgid "Check for a pre-existing note with the same title"
582
#: data/templates/ubuntu-application/help/tutorial.xml:241(para)
584
"<placeholder-1/> Before we just write the new document though, we have to "
585
"take note of the fact that couch will allow you to create as many documents "
586
"as you want with the same title. We probably don't want this, so we we'll "
587
"have to write a little code to check if there is already a document in couch "
588
"with the same title, and if there is, update that document rather than "
592
#: data/templates/ubuntu-application/help/tutorial.xml:247(para)
594
"In CouchDB, you don't do a lot of data processing in the database like you "
595
"would with a relational database. To be most efficient, we could use the "
596
"desktopcouch API to create a view in CouchDB, but it's probably simplest "
597
"just to do the necessary processing on the client for now. To do this, we'll "
598
"use a desktopcouch function to retrieve all of the records of a specified "
602
#: data/templates/ubuntu-application/help/tutorial.xml:249(para)
603
msgid "To find and update documents with a matching title we will:"
606
#: data/templates/ubuntu-application/help/tutorial.xml:252(para) data/templates/ubuntu-application/help/tutorial.xml:321(para)
608
"Retrieve all of the documents with the CouchDatabase.get_records function."
611
#: data/templates/ubuntu-application/help/tutorial.xml:255(para) data/templates/ubuntu-application/help/tutorial.xml:324(para)
612
msgid "Check each of the returned records for a matching title."
615
#: data/templates/ubuntu-application/help/tutorial.xml:258(para)
617
"If there is a match, update the record using the CouchDatabase.update_fields "
618
"function and return."
621
#: data/templates/ubuntu-application/help/tutorial.xml:261(para)
623
"This all may sound very weird, but in code, it's not quite so complicated:"
626
#: data/templates/ubuntu-application/help/tutorial.xml:263(programlisting)
630
" #get all the records\n"
631
" record_type = \"http://wiki.ubuntu.com/Quickly/JottyDoc\"\n"
632
" results = self.database.get_records(record_type = "
633
"record_type,create_view = True)\n"
634
" #update a record that has the same title\n"
635
" for result in results:\n"
636
" document = result.value\n"
637
" if document[\"title\"] == title:\n"
638
" key = document[\"_id\"]\n"
639
" self.database.update_fields(key, {\"text\":text})\n"
644
" #Alle Einträge erhalten\n"
645
" record_type = \"http://wiki.ubuntu.com/Quickly/JottyDoc\"\n"
646
" results = self.database.get_records(record_type = "
647
"record_type,create_view = True)\n"
648
" #Einen Eintrag mit selbem Titel aktualisieren\n"
649
" for result in results:\n"
650
" document = result.value\n"
651
" if document[\"title\"] == title:\n"
652
" key = document[\"_id\"]\n"
653
" self.database.update_fields(key, {\"text\":text})\n"
657
#: data/templates/ubuntu-application/help/tutorial.xml:276(para)
658
msgid "So the whole function should look like this:"
661
#: data/templates/ubuntu-application/help/tutorial.xml:278(programlisting)
665
" def save_file(self, widget, data=None): \n"
666
" #get the title for the note \n"
667
" title = self.builder.get_object(\"entry1\").get_text() \n"
669
" #get the text to save \n"
670
" buff = self.builder.get_object(\"textview1\").get_buffer() \n"
671
" start_iter = buff.get_start_iter() \n"
672
" end_iter = buff.get_end_iter() \n"
673
" text = buff.get_text(start_iter,end_iter) \n"
675
" #get all the records \n"
676
" record_type = \"http://wiki.ubuntu.com/Quickly/JottyDoc\" \n"
677
" results = self.database.get_records(record_type = "
678
"record_type,create_view = True) \n"
680
" #update a record that has the same title \n"
681
" for result in results: \n"
682
" document = result.value \n"
683
" if document[\"title\"] == title: \n"
684
" key = document[\"_id\"]\n"
685
" self.database.update_fields(key, {\"text\":text}) \n"
688
" #if no records had the title, create it \n"
689
" new_rec = Record({\"record_type\":record_type,\"title\":title, "
691
" self.database.put_record(new_rec)\n"
694
" def save_file(self, widget, data=None): \n"
695
" #Den Titel der Notiz erhalten\n"
696
" title = self.builder.get_object(\"entry1\").get_text() \n"
698
" #Den zu speichernden Text erhalten\n"
699
" buff = self.builder.get_object(\"textview1\").get_buffer() \n"
700
" start_iter = buff.get_start_iter() \n"
701
" end_iter = buff.get_end_iter() \n"
702
" text = buff.get_text(start_iter,end_iter) \n"
704
" #Alle Einträge erhalten\n"
705
" record_type = \"http://wiki.ubuntu.com/Quickly/JottyDoc\" \n"
706
" results = self.database.get_records(record_type = "
707
"record_type,create_view = True) \n"
709
" #Einen Eintrag mit selbem Titel aktualisieren\n"
710
" for result in results: \n"
711
" document = result.value \n"
712
" if document[\"title\"] == title: \n"
713
" key = document[\"_id\"]\n"
714
" self.database.update_fields(key, {\"text\":text}) \n"
717
" #Eintrag erstellen, falls keiner mit diesem Titel existierte\n"
718
" new_rec = Record({\"record_type\":record_type,\"title\":title, "
720
" self.database.put_record(new_rec)\n"
722
#: data/templates/ubuntu-application/help/tutorial.xml:306(para)
724
"Couchdb makes it really easy to see if your save function is working. You "
725
"can just point your web browser at it and explore the database:"
728
#: data/templates/ubuntu-application/help/tutorial.xml:307(para)
729
msgid "file:///home/your_user_name/.local/share/desktop-couch/couchdb.html"
731
"file:///home/ihr_benutzername/.local/share/desktop-couch/couchdb.html"
733
#: data/templates/ubuntu-application/help/tutorial.xml:311(para)
735
"If you are redirected to a page that doesn't work, you probably just need to "
736
"clear your browser cache and try again."
739
#: data/templates/ubuntu-application/help/tutorial.xml:312(title)
740
msgid "Implementing Open and New"
743
#: data/templates/ubuntu-application/help/tutorial.xml:312(para)
745
"<placeholder-1/> To open a saved document, the user will type the title of "
746
"the document that they want to open in the text entry, and choose \"Open\" "
747
"from the main menu. If there is no matching document there, it will just "
748
"clear out the text view, ready for input. This is probably not too "
749
"intuitive, so we'll add a dialog box for prompting the user for the title, "
750
"but that's for later in the tutorial. For now, we'll just use the same text "
754
#: data/templates/ubuntu-application/help/tutorial.xml:314(title)
755
msgid "Implementing Open is essentially the reverse of Save:"
758
#: data/templates/ubuntu-application/help/tutorial.xml:314(para)
759
msgid "<placeholder-1/> Follow these steps:"
762
#: data/templates/ubuntu-application/help/tutorial.xml:318(para)
763
msgid "Add the open_file signal to the menu item in Glade."
766
#: data/templates/ubuntu-application/help/tutorial.xml:327(para)
768
"If there is a match, pull out the text and display it in the text view."
771
#: data/templates/ubuntu-application/help/tutorial.xml:330(para)
772
msgid "So the open_file function looks like so:"
775
#: data/templates/ubuntu-application/help/tutorial.xml:332(programlisting)
779
" def open_file(self, widget, data=None):\n"
780
" #get the name of the document to open\n"
781
" title = self.builder.get_object(\"entry1\").get_text()\n"
784
" #get all the records\n"
785
" record_type = \"http://wiki.ubuntu.com/Quickly/JottyDoc\"\n"
786
" results = self.database.get_records(record_type = "
787
"record_type,create_view = True)\n"
789
" #get the text if there is a matching title\n"
790
" for result in results:\n"
791
" document = result.value\n"
792
" if document[\"title\"] == title:\n"
793
" text = document[\"text\"]\n"
795
" #set the UI to display the string\n"
796
" buff = self.builder.get_object(\"textview1\").get_buffer()\n"
797
" buff.set_text(text)\n"
800
#: data/templates/ubuntu-application/help/tutorial.xml:352(title)
801
msgid "Implement New"
804
#: data/templates/ubuntu-application/help/tutorial.xml:352(para)
806
"<placeholder-1/> First, add the new_file signal to the menu item in Glade, "
807
"then add this code to clear out the text:"
810
#: data/templates/ubuntu-application/help/tutorial.xml:355(programlisting)
814
" def new_file(self, widget, data=None):\n"
815
" self.builder.get_object(\"entry1\").set_text(\"Note Title\")\n"
816
" buff = self.builder.get_object(\"textview1\").get_buffer()\n"
817
" buff.set_text(\"\")\n"
820
#: data/templates/ubuntu-application/help/tutorial.xml:361(para)
822
"To make them work, add these functions to the JottyWindow class, and save. "
823
"Then go back and connect the functions to the activate signals for the Open "
824
"and New menu items."
827
#: data/templates/ubuntu-application/help/tutorial.xml:362(ulink)
828
msgid "Complete jotty file"
831
#: data/templates/ubuntu-application/help/tutorial.xml:363(title)
832
msgid "Saving Your Work"
835
#: data/templates/ubuntu-application/help/tutorial.xml:363(para)
837
"<placeholder-1/> When <application>Quickly</application> created your "
838
"application, it automatically added it to Bazaar, a source code versioning "
839
"system. You can use Bazaar to roll back mistake, see code history, compare "
840
"versions, etc... <application>Quickly</application> has a convenience "
841
"function for backing up your work:"
844
#: data/templates/ubuntu-application/help/tutorial.xml:365(programlisting)
848
"<application>Quickly</application> save \"First working version of Jotty\"\n"
851
#: data/templates/ubuntu-application/help/tutorial.xml:368(programlisting)
856
#: data/templates/ubuntu-application/help/tutorial.xml:368(programlisting)
858
msgid "bzr commit -m [your message]"
861
#: data/templates/ubuntu-application/help/tutorial.xml:368(para)
862
msgid "This will call <placeholder-1/> and then <placeholder-2/> for you."
865
#: data/templates/ubuntu-application/help/tutorial.xml:371(title)
866
msgid "Using Dialogs"
869
#: data/templates/ubuntu-application/help/tutorial.xml:372(para)
871
"In part 1, we created an application that can read and write text files, and "
872
"persist them in the couchdb backend. However, the application has a hideous "
873
"usability flaw, in the text box for specifying titles when saving and "
874
"opening files is very confusing. In part 2, we'll fix that by adding a save "
875
"and an open dialog."
878
#: data/templates/ubuntu-application/help/tutorial.xml:374(title)
879
msgid "Creating an Empty Dialog"
882
#: data/templates/ubuntu-application/help/tutorial.xml:374(para)
884
"<placeholder-1/> It's simple to add an empty, but working dialog to your "
885
"project. Simply specify the name of the new dialog, and it will be added "
886
"automatically. Assuming that you are in the jotty project directory:"
889
#: data/templates/ubuntu-application/help/tutorial.xml:376(programlisting)
893
"quickly add dialog save\n"
896
#: data/templates/ubuntu-application/help/tutorial.xml:379(para)
897
msgid "This will add the dialog to your project."
900
#: data/templates/ubuntu-application/help/tutorial.xml:380(title) data/templates/ubuntu-application/help/tutorial.xml:502(title)
901
msgid "Editing the New Dialog"
904
#: data/templates/ubuntu-application/help/tutorial.xml:380(para)
906
"<placeholder-1/> To edit the UI for the dialog, you'll need to load it into "
907
"Glade again. If you already have an instance of glade running, you might "
908
"want to go ahead and close it first, as it may get confusing if you have "
909
"more than one open at a time. After closing glade, simply open it again:"
912
#: data/templates/ubuntu-application/help/tutorial.xml:382(programlisting) data/templates/ubuntu-application/help/tutorial.xml:504(programlisting)
919
#: data/templates/ubuntu-application/help/tutorial.xml:385(para)
921
"Then use the project menu to switch to newly created SaveDialog.ui file."
924
#: data/templates/ubuntu-application/help/tutorial.xml:389(para)
926
"Then add some widgets for the UI. Start with a Vertical Box (VBox) with two "
927
"items. Put a label in the top, and an HBox in the bottom slot. In the HBox, "
928
"add a label and an edit widget, just like you did for JottyWindow in part 1. "
929
"Set the padding and expand properties as well."
932
#: data/templates/ubuntu-application/help/tutorial.xml:393(title)
933
msgid "Code the Dialog"
936
#: data/templates/ubuntu-application/help/tutorial.xml:393(para)
938
"<placeholder-1/> You can use the \"<application>Quickly</application> edit\" "
939
"command to open the SaveDialog.py file. This dialog needs very little "
940
"additional code to work. Essentially, you just need a way to retrieve the "
941
"string specified by the user. We'll add a qiuck accessor method for this:"
944
#: data/templates/ubuntu-application/help/tutorial.xml:396(programlisting)
949
" def title_text(self):\n"
950
" return self.builder.get_object(\"entry1\").get_text()\n"
953
#: data/templates/ubuntu-application/help/tutorial.xml:401(para)
955
"We don't need to write any code for the Ok and Cancel buttons, as they were "
956
"automatically hooked up by <application>Quickly</application> when it "
957
"created the dialog."
960
#: data/templates/ubuntu-application/help/tutorial.xml:402(para)
962
"Before we go on to invoking the dialog, delete HBox from JottyWindow that "
963
"holds the text entry and label, as we won't be needing those."
966
#: data/templates/ubuntu-application/help/tutorial.xml:406(title)
967
msgid "Calling the Save Dialog"
970
#: data/templates/ubuntu-application/help/tutorial.xml:406(para)
972
"<placeholder-1/> To use the dialog in JottyWindow, we need to follow these "
976
#: data/templates/ubuntu-application/help/tutorial.xml:410(para)
977
msgid "Import SaveDialog in JottyWindow"
980
#: data/templates/ubuntu-application/help/tutorial.xml:413(para)
981
msgid "In the save_file function, create an instance of SaveDialog"
984
#: data/templates/ubuntu-application/help/tutorial.xml:416(para) data/templates/ubuntu-application/help/tutorial.xml:590(para)
985
msgid "Run the Dialog"
988
#: data/templates/ubuntu-application/help/tutorial.xml:419(para)
989
msgid "Get the String"
992
#: data/templates/ubuntu-application/help/tutorial.xml:422(para) data/templates/ubuntu-application/help/tutorial.xml:596(para)
993
msgid "Destroy the dialog"
996
#: data/templates/ubuntu-application/help/tutorial.xml:426(title)
997
msgid "Importing the SaveDialog"
1000
#: data/templates/ubuntu-application/help/tutorial.xml:426(para)
1002
"<placeholder-1/> Add the SaveDialog to the list of the imported modules at "
1003
"the top of the bin file of your project, so it looks like this:"
1006
#: data/templates/ubuntu-application/help/tutorial.xml:428(programlisting)
1010
"from jotty import (\n"
1011
" AboutJottyDialog, PreferencesJottyDialog, SaveDialog)\n"
1014
#: data/templates/ubuntu-application/help/tutorial.xml:433(title) data/templates/ubuntu-application/help/tutorial.xml:616(title)
1015
msgid "Create an instance of the dialog and run it"
1018
#: data/templates/ubuntu-application/help/tutorial.xml:433(para)
1020
"<placeholder-1/> When the user chooses Save, we want to open the SaveDialog "
1021
"and collect the title of the note from the user. So we need to modify our "
1022
"save_file function."
1025
#: data/templates/ubuntu-application/help/tutorial.xml:436(para)
1026
msgid "First, create an instance of the SaveDialog like this:"
1029
#: data/templates/ubuntu-application/help/tutorial.xml:437(programlisting)
1033
" saver = SaveDialog.SaveDialog()\n"
1036
#: data/templates/ubuntu-application/help/tutorial.xml:440(para)
1038
"To make the dialog appear, simply use the run() method. However, we want to "
1039
"check the result, so we'll need to store that in a variable. After it runs, "
1040
"we want to collect the string from the user, like this:"
1043
#: data/templates/ubuntu-application/help/tutorial.xml:441(programlisting)
1047
" result = saver.run()\n"
1048
" title = saver.title_text\n"
1051
#: data/templates/ubuntu-application/help/tutorial.xml:445(title)
1052
msgid "Clean up the dialog"
1055
#: data/templates/ubuntu-application/help/tutorial.xml:445(para)
1057
"<placeholder-1/> We need to tell the dialog to not show itself anymore. We "
1058
"could call saver.hide() to make it hide, but since we don't need it hanging "
1059
"around, we'll just destroy it. Before we go on, though, we need to ensure "
1060
"that the user actually wants to save, so if we didn't get the Ok result, we "
1061
"should just return out of the function:"
1064
#: data/templates/ubuntu-application/help/tutorial.xml:448(programlisting)
1068
" saver.destroy()\n"
1069
" if result != gtk.RESPONSE_OK:\n"
1073
#: data/templates/ubuntu-application/help/tutorial.xml:454(para)
1075
"Since we're now getting the title from the dialog instead of the text entry, "
1076
"we should delete the line of the code that sents it from entry1. So except "
1077
"for the addition of the dialog code, the save_file function looks pretty "
1078
"much the same as it did in part 1:"
1081
#: data/templates/ubuntu-application/help/tutorial.xml:457(programlisting)
1085
" def save_file(self, widget, data=None):\n"
1086
" #get the titel from the user\n"
1087
" saver = SaveDialog.SaveDialog()\n"
1088
" result = saver.run()\n"
1089
" title = saver.title_text\n"
1091
" saver.destroy()\n"
1092
" if result != gtk.RESPONSE_OK:\n"
1095
" #get the text to save\n"
1096
" buff = self.builder.get_object(\"textview1\").get_buffer()\n"
1097
" start_iter = buff.get_start_iter()\n"
1098
" end_iter = buff.get_end_iter()\n"
1099
" text = buff.get_text(start_iter,end_iter)\n"
1101
" #get all the records\n"
1102
" record_type = \"http://wiki.ubuntu.com/Quickly/JottyDoc\"\n"
1103
" results = self.database.get_records(record_type = "
1104
"record_type,create_view = True)\n"
1106
" #update a record that has the same title\n"
1107
" for result in results:\n"
1108
" record = result.value\n"
1109
" if record[\"title\"] == title:\n"
1110
" key = result.key\n"
1111
" self.database.update_fields(key, {\"text\":text})\n"
1114
" #if no records had the title, create it \n"
1115
" new_rec = Record({\"record_type\":record_type,\"title\":title, "
1117
" self.database.put_record(new_rec)\n"
1120
#: data/templates/ubuntu-application/help/tutorial.xml:490(para)
1121
msgid "Now when we choose save, we get the SaveDialog instead:"
1124
#: data/templates/ubuntu-application/help/tutorial.xml:495(title)
1125
msgid "Creating a Dialog with a CouchGrid"
1128
#: data/templates/ubuntu-application/help/tutorial.xml:495(para)
1130
"<placeholder-1/> We'll use a similar approach in the Open dialog that we did "
1131
"with Save. However, there is one big difference, we want to provide the user "
1132
"with a list of documents that you could choose to open. We'll use a widget "
1133
"called CouchGrid, which is included in the quickly-widgets package for this."
1136
#: data/templates/ubuntu-application/help/tutorial.xml:498(title)
1137
msgid "Create the Open Dialog"
1140
#: data/templates/ubuntu-application/help/tutorial.xml:499(programlisting)
1144
"quickly add dialog open\n"
1147
#: data/templates/ubuntu-application/help/tutorial.xml:502(para)
1149
"<placeholder-1/> Start out by closing, and then reopening glade again:"
1152
#: data/templates/ubuntu-application/help/tutorial.xml:507(para)
1154
"Start by adding a VBox and a label in the same manner as in the Save Dialog "
1155
"above. Leave an empty space in the VBox. We will use code to put the "
1159
#: data/templates/ubuntu-application/help/tutorial.xml:511(title)
1160
msgid "Coding the Open Dialog"
1163
#: data/templates/ubuntu-application/help/tutorial.xml:512(title)
1164
msgid "Creating and Adding a CouchGrid"
1167
#: data/templates/ubuntu-application/help/tutorial.xml:512(para)
1169
"<placeholder-1/> It just takes a little bit of code to add a CouchGrid to "
1170
"the dialog. We need to:"
1173
#: data/templates/ubuntu-application/help/tutorial.xml:516(para)
1174
msgid "Import the CouchGrid class."
1177
#: data/templates/ubuntu-application/help/tutorial.xml:519(para)
1179
"Create a CouchGrid pointing at the jotty database, and the desired record "
1183
#: data/templates/ubuntu-application/help/tutorial.xml:522(para)
1184
msgid "Add the CouchGrid to the dialog."
1187
#: data/templates/ubuntu-application/help/tutorial.xml:526(title)
1188
msgid "Import the CouchGrid class"
1191
#: data/templates/ubuntu-application/help/tutorial.xml:526(para)
1193
"<placeholder-1/> CouchGrid is part of the quickly.widgets api, so we import "
1197
#: data/templates/ubuntu-application/help/tutorial.xml:528(programlisting)
1201
"from quickly.widgets.couch_grid import CouchGrid\n"
1204
#: data/templates/ubuntu-application/help/tutorial.xml:531(title)
1205
msgid "Create the CouchGrid"
1208
#: data/templates/ubuntu-application/help/tutorial.xml:531(para)
1210
"<placeholder-1/> A CouchGrid needs to know three things, the name of the "
1211
"database, the name of the record type, and the name of the keys to use. "
1212
"\"keys\" is a list of fields that the widget will display, and by default "
1213
"will also use the same text for the heading of any columns. This set up "
1214
"should be done in the OpenDialog's finish_initalizing function. All this is "
1215
"easily done in code like this:"
1218
#: data/templates/ubuntu-application/help/tutorial.xml:535(programlisting)
1222
" database = \"jotty\"\n"
1223
" keys = [\"title\"]\n"
1224
" record_type = \"http://wiki.ubuntu.com/Quickly/JottyDoc\"\n"
1225
" self.couchgrid = CouchGrid(database, "
1226
"record_type=record_type,keys=keys)\n"
1230
#: data/templates/ubuntu-application/help/tutorial.xml:542(title)
1231
msgid "Add the CouchGrid to the Dialog"
1234
#: data/templates/ubuntu-application/help/tutorial.xml:542(para)
1236
"<placeholder-1/> we added the VBox to the dialog, we left an open space at "
1237
"the bottom. We'll use this by \"packing\" the CouchGrid into the VBox. We "
1238
"need to show it as well. So add the following lines to the "
1239
"finish_initializing function as well:"
1242
#: data/templates/ubuntu-application/help/tutorial.xml:546(programlisting)
1246
" self.couchgrid.show()\n"
1247
" self.builder.get_object(\"vbox1\").pack_end(self.couchgrid)\n"
1251
#: data/templates/ubuntu-application/help/tutorial.xml:552(title)
1252
msgid "Create the get_selection function"
1255
#: data/templates/ubuntu-application/help/tutorial.xml:552(para)
1257
"<placeholder-1/> The dialog still needs a bit more code to work. It needs to "
1258
"return the user's selection, if there is one. To do this, we need to ask the "
1259
"CouchGrid what is selected. This is easy using the widgets "
1260
"selected_record_ids function. But the CouchGrid supports multiple selection, "
1261
"so we'll do the following:"
1264
#: data/templates/ubuntu-application/help/tutorial.xml:556(para)
1265
msgid "Use a decorator to define the function as a property accessor."
1268
#: data/templates/ubuntu-application/help/tutorial.xml:559(para)
1269
msgid "Get all the selected record ids."
1272
#: data/templates/ubuntu-application/help/tutorial.xml:562(para)
1273
msgid "If none are selected, return None."
1276
#: data/templates/ubuntu-application/help/tutorial.xml:565(para)
1277
msgid "Pick the first one and return it."
1280
#: data/templates/ubuntu-application/help/tutorial.xml:568(para)
1281
msgid "So the function to add to OpenDialog looks like this:"
1284
#: data/templates/ubuntu-application/help/tutorial.xml:570(programlisting)
1289
" def selected_record_id(self):\n"
1290
" ids = self.couchgrid.selected_record_ids\n"
1291
" if len(ids) < 1:\n"
1298
#: data/templates/ubuntu-application/help/tutorial.xml:580(title)
1299
msgid "Using the Open Dialog"
1302
#: data/templates/ubuntu-application/help/tutorial.xml:580(para)
1304
"<placeholder-1/> Now we want to use the Open Dialog in the JottyWindow "
1305
"open_file function. To use it,we'll follow these steps:"
1308
#: data/templates/ubuntu-application/help/tutorial.xml:584(para)
1309
msgid "Import OpenDialog in JottyWindow"
1312
#: data/templates/ubuntu-application/help/tutorial.xml:587(para)
1313
msgid "In the open_file function, create an instance of OpenDialog"
1316
#: data/templates/ubuntu-application/help/tutorial.xml:593(para)
1317
msgid "Get the id for the selected title."
1320
#: data/templates/ubuntu-application/help/tutorial.xml:599(para)
1321
msgid "Check the response before proceeding"
1324
#: data/templates/ubuntu-application/help/tutorial.xml:602(para) data/templates/ubuntu-application/help/tutorial.xml:634(title)
1325
msgid "Use the id to get the record from CouchDB"
1328
#: data/templates/ubuntu-application/help/tutorial.xml:605(para) data/templates/ubuntu-application/help/tutorial.xml:644(title)
1329
msgid "Update the UI"
1332
#: data/templates/ubuntu-application/help/tutorial.xml:609(title)
1333
msgid "Import OpenDialog"
1336
#: data/templates/ubuntu-application/help/tutorial.xml:609(para)
1338
"<placeholder-1/> Just like the SaveDialog, add the import line to the list "
1342
#: data/templates/ubuntu-application/help/tutorial.xml:611(programlisting)
1346
"from jotty import (\n"
1347
" AboutJottyDialog, PreferencesJottyDialog, SaveDialog, OpenDialog)\n"
1350
#: data/templates/ubuntu-application/help/tutorial.xml:616(para)
1352
"<placeholder-1/> So now we're ready to call the dialog from the "
1353
"JottyWindow's open_file function. Creating the OpenDialog is exactly the "
1354
"same as creating the SaveDialog, except we also want to tell it to load the "
1355
"titles before we run it:"
1358
#: data/templates/ubuntu-application/help/tutorial.xml:619(programlisting)
1361
"opener = OpenDialog.NewODialog()\n"
1362
" result = opener.run()"
1365
#: data/templates/ubuntu-application/help/tutorial.xml:622(title)
1366
msgid "Get the id for the selected title"
1369
#: data/templates/ubuntu-application/help/tutorial.xml:622(para)
1371
"<placeholder-1/> Now use the property that we created to retrieve the title "
1372
"and text from the dialog. Don't forget to check the response type before "
1376
#: data/templates/ubuntu-application/help/tutorial.xml:625(programlisting)
1380
" rec_id = opener.selected_record_id\n"
1382
" #close the dialog, and check whether to proceed\n"
1383
" opener.destroy()\n"
1384
" if result != gtk.RESPONSE_OK:\n"
1388
#: data/templates/ubuntu-application/help/tutorial.xml:634(para)
1390
"<placeholder-1/> If nothing was selected, we'll just return. Otherwise, "
1391
"we'll retrieve the record from CouchDB and pull out the text for the "
1395
#: data/templates/ubuntu-application/help/tutorial.xml:637(programlisting)
1399
" #get the record from CouchDB and extract the text\n"
1400
" if rec_id == None:\n"
1402
" record = self.database.get_record(rec_id)\n"
1403
" text = record[\"text\"]"
1406
#: data/templates/ubuntu-application/help/tutorial.xml:644(para)
1407
msgid "<placeholder-1/> Now just put the text into the texview:"
1410
#: data/templates/ubuntu-application/help/tutorial.xml:647(programlisting)
1414
" #set the UI to display the string\n"
1415
" buff = self.builder.get_object(\"textview1\").get_buffer()\n"
1416
" buff.set_text(text)"
1419
#: data/templates/ubuntu-application/help/tutorial.xml:651(para)
1421
"That's all there is to it. So the whole open_file function looks like this:"
1424
#: data/templates/ubuntu-application/help/tutorial.xml:653(programlisting)
1428
" def open_file(self, widget, data=None):\n"
1429
" #run the open dialog\n"
1430
" opener = OpenDialog.OpenDialog()\n"
1431
" result = opener.run()\n"
1433
" #get the record id from the dialog\n"
1434
" rec_id = opener.selected_record_id\n"
1436
" #close the dialog, and check whether to proceed\n"
1437
" opener.destroy()\n"
1438
" if result != gtk.RESPONSE_OK:\n"
1441
" #get the record from CouchDB and extract the text\n"
1442
" if rec_id == None:\n"
1444
" record = self.database.get_record(rec_id)\n"
1445
" text = record[\"text\"]\n"
1447
" #set the UI to display the string\n"
1448
" buff = self.builder.get_object(\"textview1\").get_buffer()\n"
1449
" buff.set_text(text)\n"
1453
#: data/templates/ubuntu-application/help/tutorial.xml:678(para)
1454
msgid "Now users get a nice open dialog:"
1457
#: data/templates/ubuntu-application/help/tutorial.xml:683(para)
1459
"However, the application is not complete. There are a few things left for "
1463
#: data/templates/ubuntu-application/help/tutorial.xml:686(para)
1465
"Set the title of the JottyWindow to display the note title. Try "
1466
"self.set_text(title)."
1469
#: data/templates/ubuntu-application/help/tutorial.xml:689(para)
1471
"The Save command works more like \"Save As\". The application probably "
1472
"shouldn't pop up a SaveDialog every time you want to save. If it's already "
1473
"been saved, you probably just want to save it, but use a SaveDialog when the "
1474
"user choose Save As, or is saving a document for the first time."
1477
#: data/templates/ubuntu-application/help/tutorial.xml:692(para)
1479
"The OpenDialog should probably return when the user double clicks on an item "
1480
"in the list. Try connecting to the \"select-cursor-row\" signal on the "
1481
"TreeView, and calling self.response(gtk.RESPONSE_OK) in the handler."
1484
#: data/templates/ubuntu-application/help/tutorial.xml:695(para)
1486
"Perhaps the Ok button in the OpenDialog should be disabled if nothing is "
1487
"selected. Try setting the \"sensitivity\" in Glade, and the set_sensitive "
1488
"function for the Ok button."
1491
#: data/templates/ubuntu-application/help/tutorial.xml:698(para)
1493
"It would be more consistent for the Open and Close dialogs to have \"Open\" "
1494
"and \"Close\" for buttons instead of \"Ok\". You can set a different type in "
1495
"the properties window in Glade."
1498
#: data/templates/ubuntu-application/help/tutorial.xml:701(para)
1500
"Loading every document into the open dialog is probably a bit inefficient. "
1501
"Perhaps storing the document id and using that to retrieve the document "
1502
"would be a better implementation."
1505
#: data/templates/ubuntu-application/help/tutorial.xml:707(title)
1509
#: data/templates/ubuntu-application/help/tutorial.xml:708(para)
1511
"In parts 1 and 2, we showed how to create a simple Ubuntu application using "
1512
"<application>Quickly</application>. This section will cover how to package "
1513
"an application so that it is easy for you to share, and easy for other "
1514
"people to install."
1517
#: data/templates/ubuntu-application/help/tutorial.xml:709(title)
1518
msgid "License your Application"
1521
#: data/templates/ubuntu-application/help/tutorial.xml:709(para)
1523
"<placeholder-1/> It's important to license your code so users and other "
1524
"programmers know their rights in terms of redistributing or modifying it. To "
1525
"<application>Quickly</application> grant a GPL license to your code, simply:"
1528
#: data/templates/ubuntu-application/help/tutorial.xml:713(para)
1529
msgid "Specify your name and email address in the Copyright file."
1532
#: data/templates/ubuntu-application/help/tutorial.xml:716(para)
1533
msgid "Run the \"license\" command."
1536
#: data/templates/ubuntu-application/help/tutorial.xml:720(title)
1537
msgid "Specify your name and email"
1540
#: data/templates/ubuntu-application/help/tutorial.xml:720(para)
1542
"<placeholder-1/> When <application>Quickly</application> created your ubuntu "
1543
"application, it added a file named Copyright in the top level of the "
1544
"directory. Open this file in your text editor, and modify the top line so it "
1545
"has your name and email included. Be sure not to modify other lines as it "
1546
"will interfere with the next step. For example, I would change the entire "
1547
"file to look like this:"
1550
#: data/templates/ubuntu-application/help/tutorial.xml:723(programlisting)
1553
"# Copyright (C) 2009 Rick Spencer rick.spencer@canonical.com\n"
1554
"### BEGIN AUTOMATIC LICENSE GENERATION\n"
1555
"### END AUTOMATIC LICENSE GENERATION\n"
1558
#: data/templates/ubuntu-application/help/tutorial.xml:727(title)
1559
msgid "Run the \"License\" Command"
1562
#: data/templates/ubuntu-application/help/tutorial.xml:727(para)
1564
"<placeholder-1/> By default, <application>Quickly</application> will use a "
1565
"GPL 3 license for your project. To use this license, use this command:"
1568
#: data/templates/ubuntu-application/help/tutorial.xml:729(programlisting) data/templates/ubuntu-application/help/tutorial.xml:751(programlisting)
1572
"<application>Quickly</application> license\n"
1575
#: data/templates/ubuntu-application/help/tutorial.xml:732(para)
1577
"This will add the GPL 3 license to all of your code files that you've added "
1578
"to your project using <application>Quickly</application>."
1581
#: data/templates/ubuntu-application/help/tutorial.xml:733(para)
1582
msgid "Keep in mind a couple of things:"
1585
#: data/templates/ubuntu-application/help/tutorial.xml:736(para)
1587
"This is a one way trip. Once you license the project, changes to the license "
1588
"must be done manually."
1591
#: data/templates/ubuntu-application/help/tutorial.xml:739(para)
1593
"If you prefer a GPL 2 license, you can specify that when you issue the "
1597
#: data/templates/ubuntu-application/help/tutorial.xml:740(programlisting)
1601
"<application>Quickly</application> license GPL-2\n"
1604
#: data/templates/ubuntu-application/help/tutorial.xml:745(para)
1606
"<application>Quickly</application> doesn't care what license you use, but "
1607
"only knows natively what files and headers to include for BSD, GPL-2, GPL-3, "
1608
"LGPL-2 and LGPL-3. If you prefer another license, you can simply add "
1609
"whatever you license you like by adding your own license in the Copyright "
1613
#: data/templates/ubuntu-application/help/tutorial.xml:747(programlisting)
1616
"### BEGIN AUTOMATIC LICENSE GENERATION\n"
1617
"# My personal license here\n"
1618
"### END AUTOMATIC LICENSE GENERATION"
1621
#: data/templates/ubuntu-application/help/tutorial.xml:750(para)
1622
msgid "and then run:"
1625
#: data/templates/ubuntu-application/help/tutorial.xml:754(para)
1626
msgid "to license every files."
1629
#: data/templates/ubuntu-application/help/tutorial.xml:757(para)
1631
"If you've added code files or other files to your project manually, you will "
1632
"need to add the license to those files manually or add those tags at the "
1633
"beginning of the file:"
1636
#: data/templates/ubuntu-application/help/tutorial.xml:759(programlisting)
1639
"### BEGIN LICENSE\n"
1643
#: data/templates/ubuntu-application/help/tutorial.xml:764(title)
1644
msgid "Translate Your Application"
1647
#: data/templates/ubuntu-application/help/tutorial.xml:764(para)
1649
"<placeholder-1/> To allow for users from other countries to use your "
1650
"application you may want to translate it. Glade automatically creates a pot "
1651
"file for you but to translate strings in your code you have to:"
1654
#: data/templates/ubuntu-application/help/tutorial.xml:766(programlisting)
1656
msgid "import gettext"
1659
#: data/templates/ubuntu-application/help/tutorial.xml:767(programlisting)
1661
msgid "gettext.gettext(\"What you want translated\")"
1664
#: data/templates/ubuntu-application/help/tutorial.xml:769(title)
1665
msgid "Specify Application Settings"
1668
#: data/templates/ubuntu-application/help/tutorial.xml:769(para)
1670
"<placeholder-1/> You should personalize your application a little before "
1671
"creating the archive. This is very easy to do, as all of the files that you "
1672
"need have already been created, and only need a few lines changed to make "
1673
"them your own. To do this you should:"
1676
#: data/templates/ubuntu-application/help/tutorial.xml:773(para)
1677
msgid "Personalize the Application Icon"
1680
#: data/templates/ubuntu-application/help/tutorial.xml:774(para) data/templates/ubuntu-application/help/tutorial.xml:788(title)
1681
msgid "Edit the Desktop File"
1684
#: data/templates/ubuntu-application/help/tutorial.xml:775(para)
1685
msgid "Edit the setup.py File"
1688
#: data/templates/ubuntu-application/help/tutorial.xml:778(title)
1689
msgid "Personalize your Application Icon"
1692
#: data/templates/ubuntu-application/help/tutorial.xml:778(para)
1694
"<placeholder-1/> When users install your application, Ubuntu will display an "
1695
"icon next to it in the menus. You can create your own icon or edit the file "
1696
"called \"icon.png\" in the media directory (jotty/data/media). Ubuntu comes "
1697
"with a great image editing program called \"Gimp.\" So you can go:"
1700
#: data/templates/ubuntu-application/help/tutorial.xml:780(programlisting)
1704
"gimp data/media/icon.png\n"
1707
#: data/templates/ubuntu-application/help/tutorial.xml:786(para)
1709
"If you don't personalize the icon, it's ok, your app will just have the "
1710
"default icon, such as in the image below."
1713
#: data/templates/ubuntu-application/help/tutorial.xml:788(para)
1715
"<placeholder-1/> By default, <application>Quickly</application> Ubuntu "
1716
"applications are classified as \"utilities\", so they show up under the "
1717
"Accessories menu in Ubuntu. If we wanted to make Jotty show up in another "
1718
"category, we can do this by editing the desktop file. A desktop file is a "
1719
"file that describes your application to a Linux desktop. The file "
1720
"\"jottydesktop.in\" was automatically created in the jotty project "
1721
"directory. To change Jotty from a Utility to an Office application, edit "
1722
"jotty.desktop.in and change this:"
1725
#: data/templates/ubuntu-application/help/tutorial.xml:792(programlisting)
1730
"Comment=Jotty application\n"
1731
"Categories=GNOME;Utility;\n"
1735
"Type=Application\n"
1738
#: data/templates/ubuntu-application/help/tutorial.xml:802(para)
1742
#: data/templates/ubuntu-application/help/tutorial.xml:806(programlisting)
1747
"Comment=Jotty application\n"
1748
"Categories=GNOME;Office;\n"
1755
#: data/templates/ubuntu-application/help/tutorial.xml:814(para)
1757
"There are lots more categories that you can use, all defined by the "
1758
"FreeDesktop spec. You can see the complete list in the <ulink "
1759
"url=\"http://standards.freedesktop.org/menu-spec/latest/apa.html\">menu "
1763
#: data/templates/ubuntu-application/help/tutorial.xml:818(title)
1764
msgid "Edit Setup.py"
1767
#: data/templates/ubuntu-application/help/tutorial.xml:817(para)
1769
"<placeholder-1/> Finally, you should include some information in the "
1770
"setup.py file to tell your users a little about yourself. The setup.py file "
1771
"was created for you, just like the desktop file. Most of of the setup.py "
1772
"file shouldn't be modified, as it is just boiler plate that makes your "
1773
"application work properly after it has been installed. However, there is a "
1774
"section at the bottom of the setup.py file that you should edit to describe "
1775
"yourself and the application."
1778
#: data/templates/ubuntu-application/help/tutorial.xml:821(para)
1779
msgid "So I would change this section:"
1782
#: data/templates/ubuntu-application/help/tutorial.xml:825(programlisting)
1785
"DistUtilsExtra.auto.setup(\n"
1788
" license='GPL v3',\n"
1789
" #author='Your Name',\n"
1790
" #author_email='email@ubuntu.com',\n"
1791
" #description='UI for managing …',\n"
1792
" #long_description='Here a longer description',\n"
1793
" #url='https://launchpad.net/jotty',\n"
1794
" cmdclass={'install': InstallAndUpdateDataDirectory}\n"
1798
#: data/templates/ubuntu-application/help/tutorial.xml:837(para)
1799
msgid "To look like this:"
1802
#: data/templates/ubuntu-application/help/tutorial.xml:841(programlisting)
1805
"DistUtilsExtra.auto.setup(\n"
1808
" license='GPL v3',\n"
1809
" author='Rick Spencer',\n"
1810
" author_email='rick.spencer@canonical.com',\n"
1811
" description='Note taking application',\n"
1812
" long_description='Note taking application that uses CouchDB as the "
1813
"backend to support easy replication across users and computers.',\n"
1814
" #url='https://launchpad.net/jotty',\n"
1815
" cmdclass={'install': InstallAndUpdateDataDirectory}\n"
1819
#: data/templates/ubuntu-application/help/tutorial.xml:852(para)
1821
"Note that the license has already been set up for you. author and "
1822
"author_email are updated each time you connect to Launchpad (with "
1823
"<application>Quickly</application> release or "
1824
"<application>Quickly</application> share) with your Launchpad real name and "
1825
"preferred email adress."
1828
#: data/templates/ubuntu-application/help/tutorial.xml:853(para)
1830
"Notice that Jotty doesn't have a web page yet, so I just left that line "
1831
"commented out. Also, you don't have to increment version number as "
1832
"<application>Quickly</application> share and "
1833
"<application>Quickly</application> release commands will make it for you.."
1836
#: data/templates/ubuntu-application/help/tutorial.xml:857(title)
1837
msgid "Create and Test the Debian Archive"
1840
#: data/templates/ubuntu-application/help/tutorial.xml:857(para)
1842
"<placeholder-1/> After personalizing the project, we are now ready to create "
1843
"the package. This is easily done by issuing the package command:"
1846
#: data/templates/ubuntu-application/help/tutorial.xml:860(programlisting) data/templates/ubuntu-application/help/tutorial.xml:1062(programlisting)
1850
"<application>Quickly</application> package\n"
1853
#: data/templates/ubuntu-application/help/tutorial.xml:863(para)
1855
"This command will take a little while to discover dependencies and create "
1856
"all the required archives, etc... It will also report some errors as we "
1857
"haven't created a PGP key, for instance. None the less, when it is done, the "
1858
"package will be created. Using the file browser, you can see the created "
1859
"package next to the project directory:"
1862
#: data/templates/ubuntu-application/help/tutorial.xml:867(para)
1864
"Right now, the specific file we are interested in is \"jotty_0.1_all.deb\". "
1865
"To test it out, double click on it, to open it in Ubuntu's graphical "
1866
"installer program:"
1869
#: data/templates/ubuntu-application/help/tutorial.xml:871(para)
1871
"Click \"Install Package\" to see how it installs onto your desktop. After "
1872
"chugging for a bit, you'll see that it is installed in the Applications-"
1873
">Office menu. If you customized your icon, you'll see that the menu uses "
1874
"your custom icon as well."
1877
#: data/templates/ubuntu-application/help/tutorial.xml:875(title)
1878
msgid "Now that you have a package"
1881
#: data/templates/ubuntu-application/help/tutorial.xml:875(para)
1883
"<placeholder-1/> Now that you've packaged your application, you can share "
1884
"the .deb file. However, if your users install their application this way, "
1885
"and you update the application, your users will have to find this out and "
1886
"resinstall. This hassle can be avoided in Ubuntu by using Personal Package "
1887
"Archives (or PPAs). Distrubuting your applications in this manner is covered "
1888
"in section 4 (not yet available)."
1891
#: data/templates/ubuntu-application/help/tutorial.xml:879(title)
1893
"<application>Quickly</application>: <application>Quickly</application> "
1897
#: data/templates/ubuntu-application/help/tutorial.xml:880(para)
1899
"The ubuntu-application template template contains the following commands."
1902
#: data/templates/ubuntu-application/help/tutorial.xml:883(xref) data/templates/ubuntu-application/help/tutorial.xml:916(title) data/templates/ubuntu-application/help/tutorial.xml:917(title)
1906
#: data/templates/ubuntu-application/help/tutorial.xml:886(xref) data/templates/ubuntu-application/help/tutorial.xml:943(title)
1910
#: data/templates/ubuntu-application/help/tutorial.xml:889(xref) data/templates/ubuntu-application/help/tutorial.xml:988(title) data/templates/ubuntu-application/help/tutorial.xml:989(title)
1914
#: data/templates/ubuntu-application/help/tutorial.xml:892(xref)
1918
#: data/templates/ubuntu-application/help/tutorial.xml:895(xref) data/templates/ubuntu-application/help/tutorial.xml:1012(title) data/templates/ubuntu-application/help/tutorial.xml:1013(title)
1922
#: data/templates/ubuntu-application/help/tutorial.xml:898(xref) data/templates/ubuntu-application/help/tutorial.xml:1021(title) data/templates/ubuntu-application/help/tutorial.xml:1022(title)
1926
#: data/templates/ubuntu-application/help/tutorial.xml:901(xref) data/templates/ubuntu-application/help/tutorial.xml:1060(title) data/templates/ubuntu-application/help/tutorial.xml:1061(title)
1930
#: data/templates/ubuntu-application/help/tutorial.xml:904(xref) data/templates/ubuntu-application/help/tutorial.xml:1077(title) data/templates/ubuntu-application/help/tutorial.xml:1078(title)
1934
#: data/templates/ubuntu-application/help/tutorial.xml:907(xref) data/templates/ubuntu-application/help/tutorial.xml:1112(title) data/templates/ubuntu-application/help/tutorial.xml:1113(title)
1938
#: data/templates/ubuntu-application/help/tutorial.xml:910(xref) data/templates/ubuntu-application/help/tutorial.xml:1122(title) data/templates/ubuntu-application/help/tutorial.xml:1123(title)
1942
#: data/templates/ubuntu-application/help/tutorial.xml:913(xref) data/templates/ubuntu-application/help/tutorial.xml:1137(title) data/templates/ubuntu-application/help/tutorial.xml:1139(title)
1946
#: data/templates/ubuntu-application/help/tutorial.xml:917(para) data/templates/ubuntu-application/help/tutorial.xml:944(para) data/templates/ubuntu-application/help/tutorial.xml:989(para) data/templates/ubuntu-application/help/tutorial.xml:1000(para) data/templates/ubuntu-application/help/tutorial.xml:1013(para) data/templates/ubuntu-application/help/tutorial.xml:1022(para) data/templates/ubuntu-application/help/tutorial.xml:1061(para) data/templates/ubuntu-application/help/tutorial.xml:1078(para) data/templates/ubuntu-application/help/tutorial.xml:1113(para) data/templates/ubuntu-application/help/tutorial.xml:1123(para) data/templates/ubuntu-application/help/tutorial.xml:1138(para)
1947
msgid "<placeholder-1/> Usage:"
1950
#: data/templates/ubuntu-application/help/tutorial.xml:919(programlisting)
1954
"<application>Quickly</application> create ubuntu-application "
1955
"path/to/project_name"
1958
#: data/templates/ubuntu-application/help/tutorial.xml:921(para)
1960
"where \"project_name\" is one or more words separated by an underscore and "
1961
"path/to can be any existing path."
1964
#: data/templates/ubuntu-application/help/tutorial.xml:924(para)
1966
"This will create and run a new project, including Python code, Glade files, "
1967
"and packaging files to make the project work. After creating the project, "
1971
#: data/templates/ubuntu-application/help/tutorial.xml:930(para)
1972
msgid "Changing your working directory to the new project:"
1975
#: data/templates/ubuntu-application/help/tutorial.xml:932(programlisting)
1977
msgid "cd path/to/project_name"
1980
#: data/templates/ubuntu-application/help/tutorial.xml:934(para)
1981
msgid "Edit the UI with Glade:"
1984
#: data/templates/ubuntu-application/help/tutorial.xml:935(programlisting)
1986
msgid "<application>Quickly</application> design"
1989
#: data/templates/ubuntu-application/help/tutorial.xml:937(para)
1990
msgid "Edit the Python code:"
1993
#: data/templates/ubuntu-application/help/tutorial.xml:938(programlisting) data/templates/ubuntu-application/help/tutorial.xml:967(programlisting)
1995
msgid "<application>Quickly</application> edit"
1998
#: data/templates/ubuntu-application/help/tutorial.xml:944(title)
2002
#: data/templates/ubuntu-application/help/tutorial.xml:946(programlisting)
2004
msgid "<application>Quickly</application> add dialog dialog_name"
2007
#: data/templates/ubuntu-application/help/tutorial.xml:947(para)
2008
msgid "where dialog_name is one or more words seperated with underscore"
2011
#: data/templates/ubuntu-application/help/tutorial.xml:948(para)
2012
msgid "This will create:"
2015
#: data/templates/ubuntu-application/help/tutorial.xml:952(para)
2017
"A subclass of gtk.Dialog called DialogNameDialog in the module "
2018
"DialogNameDialog.py"
2021
#: data/templates/ubuntu-application/help/tutorial.xml:955(para)
2022
msgid "A glade file called DialogNameDialog.ui in the ui directory"
2025
#: data/templates/ubuntu-application/help/tutorial.xml:958(para)
2026
msgid "A catalog file called dialog_name_dialog.xml also in the ui directory"
2029
#: data/templates/ubuntu-application/help/tutorial.xml:961(para)
2030
msgid "To edit the UI for the dialog, run:"
2033
#: data/templates/ubuntu-application/help/tutorial.xml:963(programlisting)
2035
msgid "<application>Quickly</application> design\n"
2038
#: data/templates/ubuntu-application/help/tutorial.xml:965(para)
2039
msgid "To edit the behavior, run:"
2042
#: data/templates/ubuntu-application/help/tutorial.xml:968(para)
2043
msgid "To use the dialog you have to invoke it from another python file:"
2046
#: data/templates/ubuntu-application/help/tutorial.xml:972(programlisting)
2050
"Import the dialog\n"
2051
"import DialogNameDialog\n"
2054
#: data/templates/ubuntu-application/help/tutorial.xml:976(programlisting)
2058
"Create an instance of the dialog\n"
2059
"dialog = DialogNameDialog.NewDialogNameDialog()\n"
2062
#: data/templates/ubuntu-application/help/tutorial.xml:980(programlisting)
2066
"Run the dialog and hide the dialog\n"
2067
"result = dialog.run()\n"
2071
#: data/templates/ubuntu-application/help/tutorial.xml:991(programlisting)
2075
"<application>Quickly</application> edit\n"
2078
#: data/templates/ubuntu-application/help/tutorial.xml:993(para)
2080
"A convenience command to open all of your python files in your project "
2081
"directory in your default editor, ready for editing."
2084
#: data/templates/ubuntu-application/help/tutorial.xml:999(title) data/templates/ubuntu-application/help/tutorial.xml:1000(title)
2088
#: data/templates/ubuntu-application/help/tutorial.xml:1001(programlisting)
2092
"<application>Quickly</application> design\n"
2095
#: data/templates/ubuntu-application/help/tutorial.xml:1003(para)
2097
"Opens Glade UI editor so that you can edit the UI for dialogs and windows in "
2098
"your project. Note that you *must* open Glade in this manner for "
2099
"<application>Quickly</application> to work. If you try to open Glade "
2100
"directly, and the open the UI files, Glade will throw errors and won't open "
2104
#: data/templates/ubuntu-application/help/tutorial.xml:1014(programlisting)
2108
"<application>Quickly</application> help\n"
2111
#: data/templates/ubuntu-application/help/tutorial.xml:1016(para)
2112
msgid "Opens a web browser with the help index."
2115
#: data/templates/ubuntu-application/help/tutorial.xml:1023(programlisting)
2119
"<application>Quickly</application> license <Your_Licence=\n"
2122
#: data/templates/ubuntu-application/help/tutorial.xml:1025(para)
2123
msgid "Adds license to project files. Before using this command, you should:"
2126
#: data/templates/ubuntu-application/help/tutorial.xml:1029(para)
2128
"run <application>Quickly</application> save in case something goes wrong"
2131
#: data/templates/ubuntu-application/help/tutorial.xml:1032(para)
2132
msgid "Edit the file Copyright to include your authorship."
2135
#: data/templates/ubuntu-application/help/tutorial.xml:1034(para)
2137
"If you want to put your own <application>Quickly</application> unsupported "
2138
"Licence, remove and replace the tags ### BEGIN AUTOMATIC LICENCE GENERATION "
2139
"and ### END AUTOMATIC LICENCE GENERATION in it by your own licence."
2142
#: data/templates/ubuntu-application/help/tutorial.xml:1039(programlisting)
2144
msgid "<application>Quickly</application> license"
2147
#: data/templates/ubuntu-application/help/tutorial.xml:1039(programlisting)
2149
msgid "<application>Quickly</application> licence <License="
2152
#: data/templates/ubuntu-application/help/tutorial.xml:1038(para)
2154
"Executes either <placeholder-1/> or <placeholder-2/> where <License= can "
2155
"be either: - GPL-3 (default) - GPL-2"
2158
#: data/templates/ubuntu-application/help/tutorial.xml:1045(para)
2160
"This will modify the Copyright file with the chosen licence (with GPL-3 by "
2161
"default). Updating previous chosen Licence if needed. If you previously "
2162
"removed the tags to add your own licence, it will leave it pristine. If no "
2163
"name is attributed to the Copyright, it will try to retrieve it from "
2164
"Launchpad (in <application>Quickly</application> release or "
2165
"<application>Quickly</application> share command only)"
2168
#: data/templates/ubuntu-application/help/tutorial.xml:1051(para)
2169
msgid "Finally, this will copy the Copyright at the head of every files."
2172
#: data/templates/ubuntu-application/help/tutorial.xml:1053(para)
2174
"Note that if you don't run <application>Quickly</application> licence before "
2175
"calling <application>Quickly</application> release or "
2176
"<application>Quickly</application> share, this one will execute it for you "
2177
"and guess the copyright holder from your launchpad account if you didn't "
2181
#: data/templates/ubuntu-application/help/tutorial.xml:1064(para)
2183
"Creates a debian file (deb) from your project. Before running the package "
2184
"command you can edit the Icon and Category entry of *.desktop.in file, where "
2185
"* is the name of your project."
2188
#: data/templates/ubuntu-application/help/tutorial.xml:1068(para)
2190
"Note that if you didn't run <application>Quickly</application> release, "
2191
"<application>Quickly</application> share or "
2192
"<application>Quickly</application> change-lp-project you may miss the name, "
2193
"email in setup.py. You can edit them if you don't want to use any of these "
2194
"commands afterwards. Those changes are not a mandatory at all for testing "
2198
#: data/templates/ubuntu-application/help/tutorial.xml:1079(programlisting)
2202
"<application>Quickly</application> release\n"
2205
#: data/templates/ubuntu-application/help/tutorial.xml:1081(para)
2207
"Posts a release of your project to a PPA on launchpad so that users can "
2208
"install the application on their system."
2211
#: data/templates/ubuntu-application/help/tutorial.xml:1086(programlisting) data/templates/ubuntu-application/help/tutorial.xml:1089(programlisting)
2213
msgid "<application>Quickly</application> release <release_number="
2216
#: data/templates/ubuntu-application/help/tutorial.xml:1084(para)
2218
"You can also execute: <placeholder-1/> of you don't want to use current "
2219
"release_number. The release_number must be a number."
2222
#: data/templates/ubuntu-application/help/tutorial.xml:1088(para)
2224
"<placeholder-1/> notes about changes where \"notes about changes\" is "
2225
"optional text describing what changes were made since the last save"
2228
#: data/templates/ubuntu-application/help/tutorial.xml:1092(para)
2230
"Before running <application>Quickly</application> release, you should: "
2231
"create your account and a project page on http://launchpad.net. You also "
2232
"have to add a PPA to your launchpad account."
2235
#: data/templates/ubuntu-application/help/tutorial.xml:1096(para)
2237
"Name, email and version setup.py will be automatically changed. (version "
2238
"will be <current_release= and bzr will commit and tagged. Once the "
2239
"release is done, <current_release= will be incremented by 0.1 to be ready "
2243
#: data/templates/ubuntu-application/help/tutorial.xml:1101(para)
2245
"If you previously used <application>Quickly</application> shared "
2246
"<current_release=~publicX will be dropped to release <current_release= "
2247
"version (<current_release=~publicX <current_release=) You can modify "
2248
"the description and long description if you wish."
2251
#: data/templates/ubuntu-application/help/tutorial.xml:1107(programlisting)
2253
msgid "<application>Quickly</application> package"
2256
#: data/templates/ubuntu-application/help/tutorial.xml:1106(para)
2258
"You can run <placeholder-1/> and test your package to make sure it installs "
2259
"as expected. (This is not mandatory)"
2262
#: data/templates/ubuntu-application/help/tutorial.xml:1114(programlisting)
2266
"<application>Quickly</application> run\n"
2269
#: data/templates/ubuntu-application/help/tutorial.xml:1116(para)
2271
"Runs your application. This is the best way to try test it out while you are "
2272
"developing it. It starts up the main project window."
2275
#: data/templates/ubuntu-application/help/tutorial.xml:1124(programlisting)
2279
"<application>Quickly</application> save notes about changes\n"
2282
#: data/templates/ubuntu-application/help/tutorial.xml:1126(para)
2284
"where \"notes about changes\" is optional text describing what changes were "
2285
"made since the last save."
2288
#: data/templates/ubuntu-application/help/tutorial.xml:1133(programlisting)
2293
#: data/templates/ubuntu-application/help/tutorial.xml:1129(para)
2295
"This command commits all changes since the last save to bzr. Note that it "
2296
"does not push changes to any back up location. If you need revert or "
2297
"otherwise use the revision control, use bzr directly: <placeholder-1/>"
2300
#: data/templates/ubuntu-application/help/tutorial.xml:1140(programlisting)
2304
"<application>Quickly</application> share"
2307
#: data/templates/ubuntu-application/help/tutorial.xml:1142(para)
2308
msgid "Updates your PPA with the the latest saved project changes."
2311
#: data/templates/ubuntu-application/help/tutorial.xml:1144(para)
2313
"Before running <application>Quickly</application> release, you should: "
2314
"create your account on http://launchpad.net. You also have to add a PPA to "
2315
"your launchpad account."
2318
#: data/templates/ubuntu-application/help/tutorial.xml:1148(para)
2320
"Name, email and version setup.py will be automatically changed. (version "
2321
"will be <current_release~publicX= where X will be incremented at each "
2322
"<application>Quickly</application> share execution) You can modify the "
2323
"description and long description if you wish."
2326
#: data/templates/ubuntu-application/help/tutorial.xml:1158(title)
2330
#: data/templates/ubuntu-application/help/tutorial.xml:1160(link)
2331
msgid "<placeholder-1/>: <placeholder-2/> Command Reference"
2334
#: data/templates/ubuntu-application/help/tutorial.xml:1163(ulink)
2335
msgid "Blog post on <placeholder-1/>"
2338
#: data/templates/ubuntu-application/help/tutorial.xml:1166(ulink)
2339
msgid "Language: Python Language Reference"
2342
#: data/templates/ubuntu-application/help/tutorial.xml:1169(ulink)
2343
msgid "Core Library: Python 2.6 Library Reference"
2346
#: data/templates/ubuntu-application/help/tutorial.xml:1172(ulink)
2347
msgid "UI Library: PyGtk"
2350
#: data/templates/ubuntu-application/help/tutorial.xml:1175(ulink)
2351
msgid "Database: CouchDB Reference"
2354
#: data/templates/ubuntu-application/help/tutorial.xml:1178(ulink)
2355
msgid "UI Editing: Glade User Documenation"
2358
#: data/templates/ubuntu-application/help/tutorial.xml:1181(ulink)
2359
msgid "Editor: Gedit Help"
2362
#: data/templates/ubuntu-application/help/tutorial.xml:1184(ulink)
2363
msgid "Version Control: Bazaar"
52
#: data/templates/ubuntu-pygame/help/tutorial.xml:32(para)
54
"Use <application>The Quickly Pygame Template</application> to write old "
55
"school arcade games for running on Ubuntu. PyGame is a framework that "
56
"handles sprites, collisons, sounds, and everything you need to make a game. "
57
"You just need to add the game play. The Quickly template creates a starter "
58
"game for you and comes ready for you to turn into your fun game, and then "
59
"easily package and share it with other Ubuntu users."
62
#: data/templates/ubuntu-pygame/help/tutorial.xml:35(para)
64
"The Quickly Pygame Template inherits from the Quickly Application template. "
65
"So you get all the commands that you get from the that template, except "
69
#: data/templates/ubuntu-pygame/help/tutorial.xml:41(title)
70
msgid "Creating and Running Your Game"
73
#: data/templates/ubuntu-pygame/help/tutorial.xml:44(para)
75
"In this tutorial we will start making a top down shooter reminiscent of the "
76
"space arcade shooters of the 1980s."
79
#: data/templates/ubuntu-pygame/help/tutorial.xml:50(para)
81
"We'll do this by creating a default game, editing some of the generated "
82
"code, writing some new code, and adding our images for sprits."
85
#: data/templates/ubuntu-pygame/help/tutorial.xml:53(para)
87
"Creating a default working game couldn't be simpler. First, open a terminal "
88
"window to type commands into. When it's open, type the command:"
91
#: data/templates/ubuntu-pygame/help/tutorial.xml:56(programlisting)
95
"$quickly create ubuntu-pygame shooter\n"
99
#: data/templates/ubuntu-pygame/help/tutorial.xml:60(para)
101
"This will create a shooter sub directory containing a complete directory "
102
"tree and files for an empty python application. The command finishes by "
103
"running the newly created game. The game is played by using the \"s\" and "
104
"\"f\" keys to rotate the guy, the \"j\" key to shoot, and the \"l\" key to "
108
#: data/templates/ubuntu-pygame/help/tutorial.xml:63(para)
110
"You can play the newly created game. Notice that the <application>Quickly "
111
"PyGame Template</application> inferred that the game title is \"Shooter\". "
112
"Also note that there is a guy that you can control with the s,f,j, and l "
113
"keys. There is an enemy and a homing missle. You also get a \"Game Over\" "
114
"screen, scoring, and levels build in for free."
117
#: data/templates/ubuntu-pygame/help/tutorial.xml:66(para)
119
"Close the game by closing the window or using the Esc key. Since the game "
120
"isn't installed into Ubuntu yet, you can't start the game from the "
121
"application menu yet. To start the game, use the terminal to first cd into "
122
"the new subdirectory, and then use \"quickly run\" to start the program."
125
#: data/templates/ubuntu-pygame/help/tutorial.xml:69(programlisting)
134
#: data/templates/ubuntu-pygame/help/tutorial.xml:75(title)
135
msgid "Creating your own Sprites"
138
#: data/templates/ubuntu-pygame/help/tutorial.xml:79(listitem)
140
"Ink Scape is a great and free tool for creating your sprites. It's in the "
141
"Featured Applications section of the Software Center."
144
#: data/templates/ubuntu-pygame/help/tutorial.xml:80(listitem)
146
"If you use Ink Scape, you'll want to export the images as PNGs. But keep the "
147
"Ink Scape files around in case you want to edit the sprites later."
150
#: data/templates/ubuntu-pygame/help/tutorial.xml:81(listitem)
152
"Whatever size you make the sprites, that's the size they will be in the game."
155
#: data/templates/ubuntu-pygame/help/tutorial.xml:82(listitem)
157
"The game will look for sprites in the data/media folder, so make sure you "
161
#: data/templates/ubuntu-pygame/help/tutorial.xml:76(para)
163
"The first think you probably noticed about the game is that the graphics are "
164
"so blah! Let's start by adding our own sprites. We;ll do a compbination of "
165
"replacing sprites with our own images, and also add a new sprite which we'll "
166
"use later. Here's a few things to keep in mind: <placeholder-1/>"
169
#: data/templates/ubuntu-pygame/help/tutorial.xml:85(para)
171
"I made new images for the guy (the sprite the player controls), enemies, "
172
"bullets, and the game background. I also made a new sprite called "
173
"\"enemy_bullet.png\" which we'll add into the game later. <placeholder-1/> "
174
"Just drag your new sprite images into the shooter/data/media and tell it to "
175
"replace the images. Now when you run the game, you'll see your new sprites "
176
"at work. <placeholder-2/> Oops. As you can see, the background image I "
177
"created was for a game of different dimensions. It's for a game that's 400 "
178
"pixels wide by 500 pixels high. In the next section, we'll make the game "
182
#: data/templates/ubuntu-pygame/help/tutorial.xml:98(title)
183
msgid "Changing the Screen Dimensions"
186
#: data/templates/ubuntu-pygame/help/tutorial.xml:99(para)
188
"The first change we'll make is to change the screen dimensions to be "
189
"oriented from top to bottom. We do this by changing a little code. So let's "
190
"fire up the code editor first. Run the edit command to fire up the editor."
193
#: data/templates/ubuntu-pygame/help/tutorial.xml:102(programlisting)
195
msgid "$quickly edit"
198
#: data/templates/ubuntu-pygame/help/tutorial.xml:104(programlisting)
202
"#screen dimensions\n"
203
"screen_width = 400\n"
204
"screen_height = 500\n"
207
#: data/templates/ubuntu-pygame/help/tutorial.xml:103(para)
209
"This command should open your code in Gedit. The screen dimensions are set "
210
"in the file \"shooterconfig.py\". So just go to that file and change the "
211
"width to 400 and the height to 500. <placeholder-1/> Save the file and run "
212
"the game again. Notice that the screen wrapping and centering and everything "
213
"was taken care of for you. That's because you made the change in the "
214
"shooterconfig.py file. This is the right place to add and change variables "
215
"that should be availble throughout the game. We'll be make a few more "
216
"changes here later."
219
#: data/templates/ubuntu-pygame/help/tutorial.xml:114(title)
220
msgid "Programming the Guy"
223
#: data/templates/ubuntu-pygame/help/tutorial.xml:115(para)
225
"For this game, what we want is the guy to move left and right across the "
226
"bottom and not wrap through the screen. Also, we want to make the bullets "
227
"look like they are coming out of the guy's front."
230
#: data/templates/ubuntu-pygame/help/tutorial.xml:121(listitem)
232
"Place the guy at the beginning of each level at the middle and bottom of the "
236
#: data/templates/ubuntu-pygame/help/tutorial.xml:122(listitem)
238
"Add functions to guy.py for moving and stop movig right and left, and remove "
239
"the rotate functions."
242
#: data/templates/ubuntu-pygame/help/tutorial.xml:123(listitem)
244
"Change the keyboard input in the bin/shooter file to call these new "
248
#: data/templates/ubuntu-pygame/help/tutorial.xml:118(para)
249
msgid "To make the guy move just left and right we need to: <placeholder-1/>"
252
#: data/templates/ubuntu-pygame/help/tutorial.xml:128(programlisting)
256
" def init_position(self):\n"
257
" \"\"\"init_position - resets the Guy's position near the\n"
258
" bottom of the screen\n"
261
" sw = shooterconfig.screen_width\n"
262
" sh = shooterconfig.screen_height\n"
265
" self.y = sh - 80\n"
268
#: data/templates/ubuntu-pygame/help/tutorial.xml:143(listitem)
269
msgid "start_moving_left: the user pressed the \"s\" key"
272
#: data/templates/ubuntu-pygame/help/tutorial.xml:144(listitem)
273
msgid "stop_moving_left: the user released the \"s\" key"
276
#: data/templates/ubuntu-pygame/help/tutorial.xml:145(listitem)
277
msgid "start_moving_right: the user pressed the \"f\" key"
280
#: data/templates/ubuntu-pygame/help/tutorial.xml:146(listitem)
281
msgid "stop_moving_right: the user released the \"f\" key"
284
#: data/templates/ubuntu-pygame/help/tutorial.xml:150(listitem)
285
msgid "Create two tracking variables, _moving_left and _moving_right"
288
#: data/templates/ubuntu-pygame/help/tutorial.xml:151(listitem)
290
"Set these tracking variables to True or False in the "
291
"start/stop_moving_left/right functions"
294
#: data/templates/ubuntu-pygame/help/tutorial.xml:152(listitem)
296
"In the guy's update function, change the x coordinates of the guy based on "
300
#: data/templates/ubuntu-pygame/help/tutorial.xml:126(para)
302
"The functionaly that is specific to the player's sprite is in the guy.py "
303
"file. The first thing we will do is work on placing the guy properly. "
304
"Fortunately, the is an existing function that we can modify for this. The "
305
"function init_position is called to each time the guy needs to be placed on "
306
"the screen, like after he gets killed for instance . When created, the guy "
307
"calls the based class function center_on_screen. As you may guess, we will "
308
"want to change this function. so the guys is positionedhalfway down the "
309
"screen, and we want him to start a few pixels from the bottom. Fortunaately "
310
"we know how to get the screen dimensions, so it's easy make the change to "
311
"init_position. <placeholder-1/> Now when you run the game, the guy starts at "
312
"the bottom, which is what we want, but he also rotates when we use the s and "
313
"the d button, which we do not want. So let's change that next by "
314
"implementing four new functions: <placeholder-2/> Here's how we will "
315
"implement these functions: <placeholder-3/>"
318
#: data/templates/ubuntu-pygame/help/tutorial.xml:158(programlisting)
322
" self._moving_left = False\n"
323
" self._moving_right = False\n"
326
#: data/templates/ubuntu-pygame/help/tutorial.xml:164(programlisting)
330
" def start_moving_right(self):\n"
331
" self._moving_left = False\n"
332
" self._moving_right = True\n"
334
" def start_moving_left(self):\n"
335
" self._moving_left = True\n"
336
" self._moving_right = False\n"
338
" def stop_moving_left(self):\n"
339
" self._moving_left = False\n"
341
" def stop_moving_right(self):\n"
342
" self._moving_right = False\n"
346
#: data/templates/ubuntu-pygame/help/tutorial.xml:156(para)
348
"First, add the tracking variables to the Guy.__init__function. Add these "
349
"after the call to BaseSprite.__init__(). <placeholder-1/> Now the functions "
350
"for responding to keys simply set those tracking variables as appropriate. "
351
"So we add these four new functions to guy.py. <placeholder-2/>"
354
#: data/templates/ubuntu-pygame/help/tutorial.xml:181(para)
356
"Now we need change the guy's coordinates based on the tracking variable. "
357
"Every sprite has an update function. This function is called for every "
358
"\"tick\" in the game, and the sprite looks at it's internal data, and "
359
"updates itself appropriately. By default, the guy's rotation is handled by "
360
"BaseSprite, so we can ignore that, especially since we won't be using "
361
"rotation anyway. We're also not using acceleration for the guy, so we can "
362
"delete a bit of code. Funally, we don't want the guy to \"wrap\" though the "
363
"screen, so we whould catch that condition."
366
#: data/templates/ubuntu-pygame/help/tutorial.xml:186(programlisting)
370
" def update(self):\n"
371
" \"\"\"update - Update internal data for a game tick\"\"\" \n"
373
" BaseSprite.update(self)\n"
375
" if self._moving_left:\n"
377
" if self.x < 0:\n"
379
" if self._moving_right:\n"
381
" if self.x + self.rect.width > shooterconfig.screen_width:\n"
382
" self.x = shooterconfig.screen_width - self.rect.width\n"
385
#: data/templates/ubuntu-pygame/help/tutorial.xml:184(para)
387
"Let's start with moving the guy 5 pixels per tick. So we can change the top "
388
"of the update function to look like this: <placeholder-1/>"
391
#: data/templates/ubuntu-pygame/help/tutorial.xml:202(para)
393
"So the guy is ready. He starts in the right place, tracks whether he is "
394
"moving left or right, and updates his position as desired. Now we just need "
395
"to hook him up the keys."
398
#: data/templates/ubuntu-pygame/help/tutorial.xml:205(para)
400
"Keyboard contol is handled in the shoort file in the bin directory. For each "
401
"click of the clock, the controller_tick function is called. Detecting "
402
"keyboard input and directing it as appropriate is handled in this funciton. "
403
"So what we wante to do is find where the f and s key events are handled, and "
404
"call the guy's start/stop_moving_left/right functions there."
407
#: data/templates/ubuntu-pygame/help/tutorial.xml:211(listitem)
408
msgid "Call the start_moving functions instead of rotate functions."
411
#: data/templates/ubuntu-pygame/help/tutorial.xml:212(listitem)
412
msgid "Remove the call to the accelerate function."
415
#: data/templates/ubuntu-pygame/help/tutorial.xml:213(listitem)
416
msgid "Remve the call to the hyperspace function."
419
#: data/templates/ubuntu-pygame/help/tutorial.xml:216(programlisting)
423
" #control the guy\n"
424
" if not game.paused: \n"
425
" if event.key == pygame.K_f:\n"
426
" g.start_moving_right()\n"
427
" if event.key == pygame.K_s:\n"
428
" g.start_moving_left()\n"
429
" if event.key == pygame.K_j:\n"
434
#: data/templates/ubuntu-pygame/help/tutorial.xml:208(para)
436
"Key down events are handled first, in a section commented \"control\" the "
437
"guy. We want to make a few changes here. <placeholder-1/> These last two "
438
"functions aren't needed for our new game. So let's make the changes and this "
439
"part of the controller_tick function will change to this: <placeholder-2/>"
442
#: data/templates/ubuntu-pygame/help/tutorial.xml:230(programlisting)
446
" #key up events, typically stop actions\n"
447
" if event.type == pygame.KEYUP:\n"
448
" if event.key == pygame.K_F11:\n"
449
" pygame.display.toggle_fullscreen() \n"
450
" if event.key == pygame.K_f:\n"
451
" g.stop_moving_right()\n"
452
" if event.key == pygame.K_s:\n"
453
" g.stop_moving_left()\n"
457
#: data/templates/ubuntu-pygame/help/tutorial.xml:228(para)
459
"We'll handle the key up functions similarly. <placeholder-1/><placeholder-2/>"
462
#: data/templates/ubuntu-pygame/help/tutorial.xml:248(listitem)
464
"The bullets accelerate and go way to fast, they'll miss enemies by skipping "
468
#: data/templates/ubuntu-pygame/help/tutorial.xml:249(listitem)
470
"The bullets should go to the top of the screen, and not stop before or wrap "
474
#: data/templates/ubuntu-pygame/help/tutorial.xml:250(listitem)
476
"The bullets should appear to come out of the middle of the guy, instead of "
480
#: data/templates/ubuntu-pygame/help/tutorial.xml:253(programlisting)
484
" self.max_velocity = 20\n"
485
" self.max_ticks = 20\n"
488
#: data/templates/ubuntu-pygame/help/tutorial.xml:258(programlisting)
492
" def update(self):\n"
493
" \"\"\"update - update internal data and position.\n"
494
" Typically called by the game controller each game\n"
499
" BaseSprite.update(self)\n"
501
" if self.y < 1:\n"
503
" if self.y == shooterconfig.screen_height:\n"
507
#: data/templates/ubuntu-pygame/help/tutorial.xml:282(programlisting)
511
" def shoot(self):\n"
512
" \"\"\"shoot - fire a bullet. Adds the bullet to the bullet sprite "
514
" If the maximum number of bullets premitted would be exceeded, \n"
515
" the bullet will not fire. If the guy is exploding, the guy will no\n"
521
" #only allow max numbe of bullets on the screen at a time\n"
522
" if len(self.bullets.sprites()) < self.max_bullets:\n"
523
" center_x = (self.x + self.rect.width / 2) - 3\n"
524
" b = Bullet(center_x,self.y,self.orientation)\n"
525
" self.bullets.add(b)\n"
528
#: data/templates/ubuntu-pygame/help/tutorial.xml:245(para)
530
"Now we've got the guy working the way we want, but we need to make a few "
531
"changes to to how the guy's bullets are working: <placeholder-1/> We'll "
532
"handle the first problem my changing the Bullet class in the bullet.py file. "
533
"The acceleration and speed of bullets in the game is configured in the "
534
"__init__ function of this file. The rate at whcih a bullet accelerates is "
535
"controlled by member variable acceleration_divisor. We won't need to change "
536
"that. However, the maximum speed a bullet will reach is defined ny "
537
"max_velocity, and the lifetme of the bullet is defined by max_ticks. Let's "
538
"make the bullets go slower, but last longer, by changing max_velocity to 20, "
539
"and max_ticks to 20 in the Bullet __init__ funciton. <placeholder-2/> This "
540
"simple change is all that is necessary to control the bullets throughout the "
541
"game. Note that making this change in the Bullet class means all bullets in "
542
"the game, including enemy bullets, will now work this way. So let's quickly "
543
"deal with stopping bullets from wrapping as well. We'll add to the Bullet "
544
"class's update function to see if the bullet is above or below the screen, "
545
"and if so, we'll remove it. So we'll change the to of the update function in "
546
"bullet.py to look like this: <placeholder-3/> Note that a Sprite's kill "
547
"function, removes it from the game immediately, and with no fanfare. "
548
"Finally, we need to adjust the bullet so it comes out from the guys the way "
549
"we want it to. Since this is only related to the way the guy shoots bullets "
550
"and won't have anything to do with enemy bullets, we'll configure how "
551
"bullets emerge in the guy.py file. Let's just tweak the shoot function a "
552
"bit. As you can see in this function, when you create a bullet, you provide "
553
"it x and y coordinates. We'll just calculate at better x coordinate to "
554
"start. We'll find the middle of the width of the guy's image, and offset it "
555
"a bit so the bullet sprite looks like it comes out correctly. "
556
"<progamlisting> center_x = (self.x + self.rect.width / 2) - 3 "
557
"</progamlisting> So we change change the ugy's shoot funciton to look like "
558
"this: <placeholder-4/>"
561
#: data/templates/ubuntu-pygame/help/tutorial.xml:299(para)
563
"<placeholder-1/> Now we have the guy working as desired. Moves back and "
564
"forth across the bottom and shoots bullets the way we want. Next we'll go on "
565
"to changing the way the enemies work."
568
#: data/templates/ubuntu-pygame/help/tutorial.xml:308(title)
569
msgid "Programming Enemies"
572
#: data/templates/ubuntu-pygame/help/tutorial.xml:309(para)
574
"The generated game always adds two enemies for each level, a homing missle "
575
"and a stock \"enemy\". The homing missle does pretty much what's it name "
576
"suggests, homes in on the guy and kills him. The Enemy doesn't do much of "
577
"anything. Just kind of plunks down and waits to get killed. First we're "
578
"going to remove the homing missle from the game, and then we'll customize "
579
"the enemies to be a bit more menancing."
582
#: data/templates/ubuntu-pygame/help/tutorial.xml:314(programlisting)
586
" #TODO: set up enemies here\n"
587
" #You can add more enemies or use different enemies\n"
588
" #depening on the level\n"
589
" for i in xrange(0,game.level + 3):\n"
590
" enemies.add(Enemy())\n"
593
#: data/templates/ubuntu-pygame/help/tutorial.xml:312(para)
595
"The bin/shooter fileset up a SpriteGroup already. It's called \"enemies\" "
596
"and gets populated each time a new level is created. New levels are created "
597
"in the next_level function in the bin/shooter file. The next_level function "
598
"is pretty simple, it increments the game level bu 1, removes any remaining "
599
"emenemities for the SpriteGroup and then repulates the enemies SpriteGroup. "
600
"Let's make a couple of basic chagnnges here. First, we'll change the xrange "
601
"so that it creates more enemies with each level, and second, we'll just "
602
"delete the line that creates the homing missle. Change the next_level "
603
"function to make the last few lines as below. <placeholder-1/> So for the "
604
"first level, there will by for enemies, and each time there is an new level "
605
"created the number of enemies will increase by 1. Aslo, no more homing "
606
"missles. <placeholder-2/>"
609
#: data/templates/ubuntu-pygame/help/tutorial.xml:326(para)
611
"However, there are two things we need to do to enhance the game play with "
612
"our enemies. First, as you can see, they can start quite close to the guy, "
613
"even under. We'll need to fix that. Also, we should put them in motion so "
614
"they are a bit more of a challenge to shoot. We'll do both of the things by "
615
"modifying the Enemy class in the enemy.py file. Specifically in the "
616
"init_postion function."
619
#: data/templates/ubuntu-pygame/help/tutorial.xml:329(para)
621
"If you open the enemy.py file and look for the init_position function, "
622
"you'll see there is a call to the function in __init__ but there is no "
623
"function for it. That's because enemy inherits from BaseSprite, which has a "
624
"default init_position implementation that randomly places it on the screen. "
625
"So we'll simply override the init_position function in the Enemy class in "
629
#: data/templates/ubuntu-pygame/help/tutorial.xml:334(programlisting)
633
" sh = shooterconfig.screen_height\n"
634
" sw = shooterconfig.screen_width\n"
637
#: data/templates/ubuntu-pygame/help/tutorial.xml:339(programlisting)
644
#: data/templates/ubuntu-pygame/help/tutorial.xml:343(programlisting)
648
" self.x = random.randint(20,sw - self.rect.width - 20)\n"
649
" self.y = random.randint(20,sh/2)\n"
652
#: data/templates/ubuntu-pygame/help/tutorial.xml:348(programlisting)
656
" self.velocity_x = random.randint(-30,30)\n"
659
#: data/templates/ubuntu-pygame/help/tutorial.xml:352(programlisting)
663
" def init_position(self):\n"
664
" sh = shooterconfig.screen_height\n"
665
" sw = shooterconfig.screen_width\n"
667
" self.x = random.randint(20,sw - self.rect.width - 20)\n"
668
" self.y = random.randint(20,sh/2)\n"
669
" self.velocity_x = random.randint(-30,30)\n"
672
#: data/templates/ubuntu-pygame/help/tutorial.xml:332(para)
674
"First, to make it a bitter easier to code, grab a reference to the screen "
675
"height and widgth that you configured and keep those in easier to use "
676
"variables. <placeholder-1/> Next, we want to choose random start position "
677
"along the X axis. But we don't want the enemy to start too close to either "
678
"side or it might get stuck in a spot where the guy can't shoot it. To "
679
"generate random integers, use the randome module, so you'll have to add an "
680
"import to the top of the file. <placeholder-2/> We can use the screenwidth "
681
"to and the enemies own width to determine the right most starting position. "
682
"For the Y axis, we want the enemies to be far enough away that they can't "
683
"too easily kill the guy. We'll also make sure they don't get out of reach of "
684
"the guy's bullets. So between 20 and half way down seems about right. "
685
"<placeholder-3/> Finally, let's put each enemy in motion by picking a random "
686
"velocity_x within some reasonable bounds. <placeholder-4/> Notice that one "
687
"in 60 of the enemies won't be moving. That's okay because we added padding "
688
"to keep the enemies from ending up too close to the sides. The full "
689
"init_position function you need to add looks like this: <placeholder-5/> "
690
"When you run the game, you can see that the enemies are moving and are good "
691
"targets to shoot at. But next we'll make the enemies fight back."
694
#: data/templates/ubuntu-pygame/help/tutorial.xml:366(listitem)
695
msgid "Figure out where to place the bullet on the screen"
698
#: data/templates/ubuntu-pygame/help/tutorial.xml:367(listitem)
699
msgid "Configure the bullet's velocity and maximum speed"
702
#: data/templates/ubuntu-pygame/help/tutorial.xml:368(listitem)
703
msgid "Create the bullet object and add it to a SpriteGroup"
706
#: data/templates/ubuntu-pygame/help/tutorial.xml:371(programlisting)
710
"#create the player's guy and some enemies\n"
711
"bullets = pygame.sprite.RenderUpdates()\n"
713
"enemies = pygame.sprite.RenderUpdates()\n"
714
"enemy_bullets = pygame.sprite.RenderUpdates()\n"
717
#: data/templates/ubuntu-pygame/help/tutorial.xml:380(listitem)
719
"Clear out all the sprites in the group when creating a new level or "
720
"resetting a level after the guy dies."
723
#: data/templates/ubuntu-pygame/help/tutorial.xml:381(listitem)
725
"Tell the bullets in the sprite group to update themselves at the right time."
728
#: data/templates/ubuntu-pygame/help/tutorial.xml:382(listitem)
729
msgid "Tell the bullets to draw themselves at the right time."
732
#: data/templates/ubuntu-pygame/help/tutorial.xml:383(listitem)
734
"Pass a reference to the sprite group to each enemy that is created, so it "
735
"can add it's bullets to the group."
738
#: data/templates/ubuntu-pygame/help/tutorial.xml:386(programlisting)
745
#: data/templates/ubuntu-pygame/help/tutorial.xml:390(programlisting)
749
"def update_sprites():\n"
750
" \"\"\"update_sprites - call update() for all sprites\"\"\"\n"
752
" bullets.update()\n"
753
" enemies.update() \n"
754
" enemy_bullets.update()\n"
757
#: data/templates/ubuntu-pygame/help/tutorial.xml:399(programlisting)
762
" enemies.draw(screen)\n"
763
" enemy_bullets.draw(screen)\n"
766
#: data/templates/ubuntu-pygame/help/tutorial.xml:405(programlisting)
770
" def __init__(self,enemy_bullets):\n"
771
" \"\"\"Creates an Enemy \"\"\"\n"
772
" self.enemy_bullets = enemy_bullets\n"
776
#: data/templates/ubuntu-pygame/help/tutorial.xml:412(programlisting)
780
" enemies.add(Enemy(enemy_bullets))\n"
783
#: data/templates/ubuntu-pygame/help/tutorial.xml:416(programlisting)
787
"from bullet import Bullet\n"
790
#: data/templates/ubuntu-pygame/help/tutorial.xml:421(programlisting)
794
" def shoot(self):\n"
796
" b = Bullet(self.x,self.y, 180)\n"
797
" b.max_velocity = 6\n"
798
" b.max_ticks = 50\n"
799
" self.enemy_bullets.add(b)\n"
802
#: data/templates/ubuntu-pygame/help/tutorial.xml:431(programlisting)
806
" if not game.paused:\n"
807
" for e in enemies:\n"
808
" if random.randint(0,20) == 1:\n"
812
#: data/templates/ubuntu-pygame/help/tutorial.xml:441(programlisting)
816
"enemy_bullet_image = image_path + \"enemy_bullet.png\"\n"
819
#: data/templates/ubuntu-pygame/help/tutorial.xml:445(programlisting)
823
" def shoot(self):\n"
825
" img = shooterconfig.enemy_bullet_image\n"
826
" b = Bullet(self.x,self.y, 180, img)\n"
827
" b.max_velocity = 6\n"
828
" b.max_ticks = 50\n"
829
" self.enemy_bullets.add(b)\n"
832
#: data/templates/ubuntu-pygame/help/tutorial.xml:363(para)
834
"Let's add the ability for an enemy to drop a bomb. By default, enemies can't "
835
"do anything like that, so we'll have to add a new function. The function "
836
"will need to do the following things: <placeholder-1/> We should probably "
837
"start with this last part. We'll want to create a special sprite group for "
838
"the bullets to go into. This is primarily so that we can use the "
839
"SpriteGroups collision detection capabilities later. Also it's easier to "
840
"manage updates of sprites when they are in a group. First things first, "
841
"we'll create the sprite group. There's a place in the bin/shooter for "
842
"setting up enemies and such, so create another sprite group there. You "
843
"create a sprite group by calling a function in the pygame.sprite module "
844
"called \"RenderUpdates\". Lookk for the code block below, and notice the new "
845
"line creating the new sprite group by calling RenderUpdates. <placeholder-"
846
"2/> Now that we have the sprite group called enemy_bullets we want to do "
847
"three more things with it for now. <placeholder-3/> So for the first part, "
848
"we'll call the sprite group's empty function in next_level and reset_level "
849
"This function simply removes each sprite in the sprite group from game play. "
850
"Do this as the first thing for each of these function. <placeholder-4/> For "
851
"the second point, we'll add to the function in bin/shooter called "
852
"update_sprites. As you may have guessed, this function is called each tick "
853
"and tells each sprite to update. For sprites in a sprite group, this is "
854
"easy, because the SpriteGroup class includes an update function that calls "
855
"update for each of it's sprites. So just add that to the end of the "
856
"update_sprites function in bin/shooter, so it looks like the listing here: "
857
"<placeholder-5/> The view_tick function is called once per tick as well. "
858
"This funciton updates the view on the screen. We'll add a line of code to "
859
"tell the bullets to draw themselves right under where the enemies draw "
860
"themselves. <placeholder-6/> Finally, we need to pass a reference to each "
861
"enemy as it is created and create a member variable to store that reference. "
862
"So we need to make a change in the enemy.py fil, to add an argument for the "
863
"SpriteGroup in the __init__ function, and also we need to pass the "
864
"SpriteGroup when creating enemies. So change the Enemy class in enemy.py so "
865
"the top of the __init__ function looks like so: <placeholder-7/> And then "
866
"back in the bin/shooter file in the next_level function when creating "
867
"enemies, pass in enemy_bullets. <placeholder-8/> Now we have a functioning "
868
"sprite group and the enemies have a reference to it, we are ready to start "
869
"actually adding some bullets to it. We'll do this by adding a member "
870
"function called \"shoot\" to the enemy. Don't forget to import the Bullet "
871
"class into the enemy.py file. <placeholder-9/> First thing is we'll check "
872
"that the enemy is alive. We don't have to do this, but for this game, we "
873
"don't want it to shoot if it's int the process of exploding. Then we'll just "
874
"create a bullet and add it to the SpriteGroup. The last argument we'll pass "
875
"in is to set the orientatin to 180. Orientation goes clockwise for 360 "
876
"degrees, with zero being directly up, and 180 being directly down. In code, "
877
"it looks like the listing below. <placeholder-10/> So now we just need to "
878
"tell the enemies to shoot. We'll do this back in the bin/shooter file, in "
879
"the\"controller_tick function. After the section where we respond to "
880
"keyboard input, we'll add a few lines to make the enemies shoot. First, "
881
"we'll make sure the game is not paused, not very fair to shoot in a paused "
882
"game, is it? Next we'll loop through the enemies and desider if we should "
883
"call shoot. using our friend random.randint, we'll do this say, one time "
884
"twenty. So if you add this code to the end of the controller_tick function, "
885
"your enemies will start dropping bombs. <placeholder-11/><placeholder-12/> "
886
"So if you run the game, you'll see that the enemies are dropping bulltes "
887
"like bombs. Nice. However, maybe it would be nicer if the sprites for the "
888
"enemy bullets were different than the sprites for the guy's bullets. "
889
"Remember at the beginning of the tutorial we added an image called "
890
"enemy_bullet.png to the data/media directory. Now we'll write a bit of code "
891
"to use that image. First thing, we should add a reference to it in the "
892
"shooterconfig.py file. In this way, the Enemy class will be able to find it. "
893
"Just add the following line along with the other image path setting code in "
894
"shooterconfig.py. <placeholder-13/> So now we need to tell the bullets in "
895
"the Enemy class to use that image. Fortunately the Bullet class takes an "
896
"optional parameter for the name of an image to use. So just modify the shoot "
897
"function in the Enemy class to include the path. <placeholder-14/> Now the "
898
"enemies are dropping bombs with our new image. <placeholder-15/>"
901
#: data/templates/ubuntu-pygame/help/tutorial.xml:459(para)
903
"But of course, you many notice the bombs aren't too menancing. In the next "
904
"chapter we'll add collision detection to make the bombs kill the guy."
907
#: data/templates/ubuntu-pygame/help/tutorial.xml:464(title)
908
msgid "Collision Detection"
911
#: data/templates/ubuntu-pygame/help/tutorial.xml:465(para)
913
"Collision detection is when you check for sprites that are overlapping, and "
914
"run code based on what happened. PyGame makes this very easy by providing "
915
"some functions to check for overlapping sprites for you. As you will see, it "
916
"works for individual sprites as well as sprite groups."
919
#: data/templates/ubuntu-pygame/help/tutorial.xml:470(programlisting)
923
" b = pygame.sprite.spritecollideany(g, enemy_bullets)\n"
929
#: data/templates/ubuntu-pygame/help/tutorial.xml:481(programlisting)
933
" hits_dict = pygame.sprite.groupcollide(bullets, enemy_bullets, True, "
937
#: data/templates/ubuntu-pygame/help/tutorial.xml:468(para)
939
"Ok, so let's start by making the bombs that the enemies drop actually kill "
940
"the guy. To do this, we want to check if the bombs ever collide with the "
941
"guy, and if they do, we'll tell the guy to explode, and then we'll remove "
942
"the bomb from the screen. So the logic is \"tell me if the guy collides with "
943
"any enemy_bullets\". There is a funciton for this called, "
944
"pygame.sprite.spritecollideany, which takes a single sprite and a sprite "
945
"group and returns a reference to any sprite in the sprite group that "
946
"collided with the single sprite. If there were no collisions, than e will be "
947
"None. Otherwise, we'll want to tell the guy to explode and tell the bullet "
948
"to just \"kill\", which will remove it from play. So we can call it like "
949
"this: <placeholder-1/> There is a function in bin/shooter called "
950
"check_collisions which is called once per tick, and is the perfect place to "
951
"add this code. Add it right under the similar test for the guy colliding "
952
"with enemies. Now those bombs can kill the guys. <placeholder-2/> If you "
953
"play for a bit, you may notice that the bullets and the bombs just kind of "
954
"pass by each other. We can ramp up the game play by making the enemy bullets "
955
"destroy the guy's bullets, but not visa versa. So that logic here is, have "
956
"any of the sprites in the bullets sprite group collided with the bullets in "
957
"the enemy bullets sprite group. There is function for this as well, "
958
"pygame.sprite.groupcollide. groupcollide takes two sprite lists and returns "
959
"a dictionary. The keys in the dictionary are any sprites from the first "
960
"group that are involved in a collision, and the values are the sprites from "
961
"the second group that collided with the sprite that for key. It's a bit hard "
962
"to explain, but I bet the code is pretty readable. Add this line to the "
963
"check_collisions function. <placeholder-3/> Now if you run the game, it's a "
964
"bit more challenging as the enemies are a bit more offensive. This code just "
965
"kills the bullets involed in any collisions. Notice that I passed in True "
966
"False at the end of this function. These paramaters determine whether to "
967
"kill sprites form either group involved in the collusion. The True tells the "
968
"function to kill any bullets involved in collisions, so this was simple to "
972
#: data/templates/ubuntu-pygame/help/tutorial.xml:488(title)
973
msgid "Playing Sounds"
976
#: data/templates/ubuntu-pygame/help/tutorial.xml:491(programlisting)
980
"tink_sound = sound_path + \"tink.wav\" \n"
984
#: data/templates/ubuntu-pygame/help/tutorial.xml:495(programlisting)
988
"#set up some objects and models\n"
989
"tink_sound = pygame.mixer.Sound(shooter.shooterconfig.tink_sound) \n"
993
#: data/templates/ubuntu-pygame/help/tutorial.xml:500(programlisting)
997
" hits_dict = pygame.sprite.groupcollide(bullets, enemy_bullets, True, "
999
" if len(hits_dict) > 0:\n"
1000
" tink_sound.play() \n"
1004
#: data/templates/ubuntu-pygame/help/tutorial.xml:506(programlisting)
1008
" self.launch_sound = "
1009
"pygame.mixer.Sound(shooterconfig.guy_shoot_sound)\n"
1010
" self.launch_sound.set_volume(.2)\n"
1011
" self.launch_sound.play() \n"
1015
#: data/templates/ubuntu-pygame/help/tutorial.xml:489(para)
1017
"The game is pretty much done in terms of game play, but I want to make one "
1018
"small enhancement. When the enemy bullets kill one of the guy's bullets, I'd "
1019
"like to play a little sound to signify this. So first, I added a little "
1020
"\"tink\" sound to the data/media directory. After you add your sound, you "
1021
"need to add a reference to it in the shootercongif.py file. <placeholder-1/> "
1022
"Now, I want to add a little code after the collision detection between the "
1023
"bullets to play that sound if they collided. I can't just hop straight to "
1024
"that though, first I have to create a sound object.In pygame you manage "
1025
"sounds with the \"mixer\" module. I don't want to create this object over "
1026
"and over again. So I'll add it to the bin/shooter file where the other "
1027
"objects and such for the game are set up. <placeholder-2/> Now that I've "
1028
"told the mixer module to give me a sound, I can go ahead and check if there "
1029
"were any collisions between bullets, and play my sound. <placeholder-3/> So "
1030
"it seems to be working well, but what if you are finding that one of the "
1031
"sounds is too quiet or too loud? Or perhpas you want a certain sound to be "
1032
"loud sometimes and queit other times, for example to simulate distance. This "
1033
"is easy to do because each sound object has a set_volume function that you "
1034
"can use to set the sound between 0 (for slient) and 1 (for normal volume). "
1035
"The bullet launch sound I used was a bit loud, so in the bullet.py file, "
1036
"I'll adjust the Bullet class to play the sound a bit more quietly. "
1040
#: data/templates/ubuntu-pygame/help/tutorial.xml:514(title)
1044
#: data/templates/ubuntu-pygame/help/tutorial.xml:518(listitem)
1045
msgid "Creating a game using $quickly create ubuntu-pygame"
1048
#: data/templates/ubuntu-pygame/help/tutorial.xml:519(listitem)
1049
msgid "Adding your own sprites to the game"
1052
#: data/templates/ubuntu-pygame/help/tutorial.xml:520(listitem)
1053
msgid "Setting the screen size and other info in the config file"
1056
#: data/templates/ubuntu-pygame/help/tutorial.xml:521(listitem)
1057
msgid "Programming a player's guy to respond to keyboard input and to shoot"
1060
#: data/templates/ubuntu-pygame/help/tutorial.xml:522(listitem)
1061
msgid "Programming enemies to move and shoot"
1064
#: data/templates/ubuntu-pygame/help/tutorial.xml:523(listitem)
1065
msgid "Using collision detection to blow up Sprites"
1068
#: data/templates/ubuntu-pygame/help/tutorial.xml:524(listitem)
1069
msgid "Playing and adjusting sounds"
1072
#: data/templates/ubuntu-pygame/help/tutorial.xml:528(listitem)
1074
"The bullets that the guy shoots and the bombs that the enemies drop make the "
1075
"same sound, it would probably be nicer if they each made a different sounds."
1078
#: data/templates/ubuntu-pygame/help/tutorial.xml:529(listitem)
1080
"The default explosions are crayon drawings, they don't fit in much with the "
1081
"look of the game. Perhaps some new images for the explosion stages would be "
1085
#: data/templates/ubuntu-pygame/help/tutorial.xml:530(listitem)
1087
"There are no power ups! You could create power up classes the derive from "
1088
"BaseSprite to give the guy extra powers, like bigger bullets, more bullets, "
1092
#: data/templates/ubuntu-pygame/help/tutorial.xml:531(listitem)
1094
"More special enemies, for example you could use the HomingMissle class to "
1095
"create harder to kill enemies."
1098
#: data/templates/ubuntu-pygame/help/tutorial.xml:532(listitem)
1100
"There is no high scores list. You could use desktopcouch to store high "
1101
"scores and use the code in view_tick to see how to present the scores."
1104
#: data/templates/ubuntu-pygame/help/tutorial.xml:515(para)
1106
"So now you have a working game! This tutorial introduced the following key "
1107
"concepts for using the Quickly PyGame Template. <placeholder-1/> But there "
1108
"is still a lot to do to have a propper game. For example: <placeholder-2/>"
2366
1111
#. Put one translator per line, in the form of NAME <EMAIL>, YEAR1, YEAR2
2367
#: data/templates/ubuntu-application/help/tutorial.xml:0(None)
1112
#: data/templates/ubuntu-pygame/help/tutorial.xml:0(None)
2368
1113
msgid "translator-credits"
2370
1115
"Launchpad Contributions:\n"
2371
1116
" Didier Roche https://launchpad.net/~didrocks\n"
2372
1117
" Jan-Christoph Borchardt https://launchpad.net/~jancborchardt\n"
2373
1118
" lineak https://launchpad.net/~lineak"
1132
#~ msgid "Getting Started"
1133
#~ msgstr "Erste Schritte"
1135
#~ msgid "<application>Quickly</application> 0.4 User Guide"
1136
#~ msgstr "<application>Quickly</application> 0.4 Anleitung"
1139
#~ msgid "quickly create ubuntu-application jotty"
1140
#~ msgstr "quickly create ubuntu-application jotty"
1142
#~ msgid "Running the Application"
1143
#~ msgstr "Die Anwendung ausführen"
1145
#~ msgid "Creating a <application>Quickly</application> Project"
1146
#~ msgstr "Ein <application>Quickly</application>-Projekt erstellen"
1148
#~ msgid "Testing the Empty Application"
1149
#~ msgstr "Die leere Anwendung testen"
1151
#~ msgid "Edit the User Interface in Glade"
1152
#~ msgstr "Die Oberfläche in Glade bearbeiten"
1164
#~ msgid "Editing an Application"
1165
#~ msgstr "Eine Anwendung bearbeiten"
1168
#~ msgid "quickly design"
1169
#~ msgstr "quickly design"
1171
#~ msgid "Edit the Code in Gedit"
1172
#~ msgstr "Den Quelltext in Gedit bearbeiten"
1185
#~ " def save_file(self, widget, data=None):\n"
1186
#~ " print \"save\"\n"
1190
#~ " def save_file(self, widget, data=None):\n"
1191
#~ " print \"speichern\"\n"
1195
#~ msgid "quickly edit"
1196
#~ msgstr "quickly edit"
1201
#~ "sudo apt-get install quickly-widgets\n"
1204
#~ "sudo apt-get install quickly-widgets\n"
1209
#~ " self.database = CouchDatabase(\"jotty\", create=True)\n"
1212
#~ " self.database = CouchDatabase(\"jotty\", create=True)\n"
1217
#~ "from desktopcouch.records.server import CouchDatabase\n"
1218
#~ "from desktopcouch.records.record import Record\n"
1221
#~ "from desktopcouch.records.server import CouchDatabase\n"
1222
#~ "from desktopcouch.records.record import Record\n"
1227
#~ " #get the title for the note\n"
1228
#~ " title = self.builder.get_object(\"entry1\").get_text()\n"
1231
#~ " #Den Titel der Notiz erhalten\n"
1232
#~ " title = self.builder.get_object(\"entry1\").get_text()\n"
1237
#~ " record_type = \"http://wiki.ubuntu.com/Quickly/JottyDoc\"\n"
1238
#~ " new_rec = Record({\"record_type\": record_type,\"title\":title, "
1239
#~ "\"text\":text})\n"
1240
#~ " self.database.put(new_rec)\n"
1243
#~ " record_type = \"http://wiki.ubuntu.com/Quickly/JottyDoc\"\n"
1244
#~ " new_rec = Record({\"record_type\": record_type,\"title\":title, "
1245
#~ "\"text\":text})\n"
1246
#~ " self.database.put(new_rec)\n"
1251
#~ " #get the string\n"
1252
#~ " buff = self.builder.get_object(\"textview1\").get_buffer()\n"
1253
#~ " start_iter = buff.get_start_iter()\n"
1254
#~ " end_iter = buff.get_end_iter()\n"
1255
#~ " text = buff.get_text(start_iter,end_iter)\n"
1258
#~ " #Den String erhalten\n"
1259
#~ " buff = self.builder.get_object(\"textview1\").get_buffer()\n"
1260
#~ " start_iter = buff.get_start_iter()\n"
1261
#~ " end_iter = buff.get_end_iter()\n"
1262
#~ " text = buff.get_text(start_iter,end_iter)\n"
1267
#~ " def save_file(self, widget, data=None): \n"
1268
#~ " #get the title for the note \n"
1269
#~ " title = self.builder.get_object(\"entry1\").get_text() \n"
1271
#~ " #get the text to save \n"
1272
#~ " buff = self.builder.get_object(\"textview1\").get_buffer() \n"
1273
#~ " start_iter = buff.get_start_iter() \n"
1274
#~ " end_iter = buff.get_end_iter() \n"
1275
#~ " text = buff.get_text(start_iter,end_iter) \n"
1277
#~ " #get all the records \n"
1278
#~ " record_type = \"http://wiki.ubuntu.com/Quickly/JottyDoc\" \n"
1279
#~ " results = self.database.get_records(record_type = "
1280
#~ "record_type,create_view = True) \n"
1282
#~ " #update a record that has the same title \n"
1283
#~ " for result in results: \n"
1284
#~ " document = result.value \n"
1285
#~ " if document[\"title\"] == title: \n"
1286
#~ " key = document[\"_id\"]\n"
1287
#~ " self.database.update_fields(key, {\"text\":text}) \n"
1290
#~ " #if no records had the title, create it \n"
1291
#~ " new_rec = Record({\"record_type\":record_type,\"title\":title, "
1292
#~ "\"text\":text})\n"
1293
#~ " self.database.put_record(new_rec)\n"
1296
#~ " def save_file(self, widget, data=None): \n"
1297
#~ " #Den Titel der Notiz erhalten\n"
1298
#~ " title = self.builder.get_object(\"entry1\").get_text() \n"
1300
#~ " #Den zu speichernden Text erhalten\n"
1301
#~ " buff = self.builder.get_object(\"textview1\").get_buffer() \n"
1302
#~ " start_iter = buff.get_start_iter() \n"
1303
#~ " end_iter = buff.get_end_iter() \n"
1304
#~ " text = buff.get_text(start_iter,end_iter) \n"
1306
#~ " #Alle Einträge erhalten\n"
1307
#~ " record_type = \"http://wiki.ubuntu.com/Quickly/JottyDoc\" \n"
1308
#~ " results = self.database.get_records(record_type = "
1309
#~ "record_type,create_view = True) \n"
1311
#~ " #Einen Eintrag mit selbem Titel aktualisieren\n"
1312
#~ " for result in results: \n"
1313
#~ " document = result.value \n"
1314
#~ " if document[\"title\"] == title: \n"
1315
#~ " key = document[\"_id\"]\n"
1316
#~ " self.database.update_fields(key, {\"text\":text}) \n"
1319
#~ " #Eintrag erstellen, falls keiner mit diesem Titel existierte\n"
1320
#~ " new_rec = Record({\"record_type\":record_type,\"title\":title, "
1321
#~ "\"text\":text})\n"
1322
#~ " self.database.put_record(new_rec)\n"
1324
#~ msgid "file:///home/your_user_name/.local/share/desktop-couch/couchdb.html"
1326
#~ "file:///home/ihr_benutzername/.local/share/desktop-couch/couchdb.html"
1331
#~ " #get all the records\n"
1332
#~ " record_type = \"http://wiki.ubuntu.com/Quickly/JottyDoc\"\n"
1333
#~ " results = self.database.get_records(record_type = "
1334
#~ "record_type,create_view = True)\n"
1335
#~ " #update a record that has the same title\n"
1336
#~ " for result in results:\n"
1337
#~ " document = result.value\n"
1338
#~ " if document[\"title\"] == title:\n"
1339
#~ " key = document[\"_id\"]\n"
1340
#~ " self.database.update_fields(key, {\"text\":text})\n"
1345
#~ " #Alle Einträge erhalten\n"
1346
#~ " record_type = \"http://wiki.ubuntu.com/Quickly/JottyDoc\"\n"
1347
#~ " results = self.database.get_records(record_type = "
1348
#~ "record_type,create_view = True)\n"
1349
#~ " #Einen Eintrag mit selbem Titel aktualisieren\n"
1350
#~ " for result in results:\n"
1351
#~ " document = result.value\n"
1352
#~ " if document[\"title\"] == title:\n"
1353
#~ " key = document[\"_id\"]\n"
1354
#~ " self.database.update_fields(key, {\"text\":text})\n"
1358
#~ msgid "<application>Quickly</application> 0.6.1 User Guide"
1359
#~ msgstr "<application>Quickly</application> 0.6.1 Anleitung"